From 6b6ee2fe9ff5d48819b666bff3a406dab72409fe Mon Sep 17 00:00:00 2001 From: bernd2022 <104787072+bernd2022@users.noreply.github.com> Date: Tue, 3 Mar 2026 10:24:08 +0100 Subject: [PATCH] fix: add public key requirement for ICP CLI login (#977) * fix: add public key requirement for ICP CLI login ICP signature verification requires the public key to derive and validate the principal. Without it, the API rejects the login with "Public key is required for ICP signature verification". Add Blockchain.INTERNET_COMPUTER to the requiresKey list alongside Cardano and Arweave. * fix: pass key parameter through URL-based login Add key to AppParams and forward it to createSession in handleParamSession so that URL-based login works for blockchains that require a public key (Cardano, Arweave, ICP). * add key parameter --- src/components/home/wallet/connect-cli.tsx | 2 +- src/contexts/app-handling.context.tsx | 4 ++++ src/contexts/wallet.context.tsx | 2 +- src/index-widget.tsx | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/home/wallet/connect-cli.tsx b/src/components/home/wallet/connect-cli.tsx index 63f7a239e..4f32b342d 100644 --- a/src/components/home/wallet/connect-cli.tsx +++ b/src/components/home/wallet/connect-cli.tsx @@ -130,7 +130,7 @@ function Content({ wallet, isConnecting, connect, error, form, onSwitch, rootRef const [signMessage, setSignMessage] = useState(); const [isLoading, setIsLoading] = useState(false); - const requiresKey = [Blockchain.CARDANO, Blockchain.ARWEAVE].includes(blockchain); + const requiresKey = [Blockchain.CARDANO, Blockchain.ARWEAVE, Blockchain.INTERNET_COMPUTER].includes(blockchain); const hasKey = !requiresKey || key; useEffect(() => { diff --git a/src/contexts/app-handling.context.tsx b/src/contexts/app-handling.context.tsx index 65d7cffee..68b704173 100644 --- a/src/contexts/app-handling.context.tsx +++ b/src/contexts/app-handling.context.tsx @@ -18,6 +18,7 @@ const urlParamsToRemove = [ 'lang', 'address', 'signature', + 'key', 'mail', 'account-type', 'first-name', @@ -67,6 +68,7 @@ export interface AppParams { lang?: string; address?: string; signature?: string; + key?: string; mail?: string; accountType?: string; firstName?: string; @@ -244,6 +246,7 @@ export function AppHandlingContextProvider(props: AppHandlingContextProps): JSX. delete copy.address; delete copy.signature; + delete copy.key; delete copy.session; delete copy.autoStart; @@ -308,6 +311,7 @@ export function AppHandlingContextProvider(props: AppHandlingContextProps): JSX. lang: getParameter(query, 'lang'), address: getParameter(query, 'address'), signature: getParameter(query, 'signature'), + key: getParameter(query, 'key'), mail: getParameter(query, 'mail'), accountType: getParameter(query, 'account-type'), firstName: getParameter(query, 'first-name'), diff --git a/src/contexts/wallet.context.tsx b/src/contexts/wallet.context.tsx index ab2fc350a..1558b8e05 100644 --- a/src/contexts/wallet.context.tsx +++ b/src/contexts/wallet.context.tsx @@ -225,7 +225,7 @@ export function WalletContextProvider(props: WalletContextProps): JSX.Element { // Set credentials BEFORE async call to prevent race conditions (React StrictMode double-render) lastAppliedCredentials.current = { address: appParams.address, signature: appParams.signature }; - await createSession(appParams.address, appParams.signature); + await createSession(appParams.address, appParams.signature, appParams.key); return true; } else if (appParams.session && Utils.isJwt(appParams.session)) { // Skip if same session was already applied diff --git a/src/index-widget.tsx b/src/index-widget.tsx index 9df5cea07..5e3795d8c 100644 --- a/src/index-widget.tsx +++ b/src/index-widget.tsx @@ -11,6 +11,7 @@ const props: { [k in keyof WidgetParams]: 'string' | 'number' | 'boolean' | 'fun lang: 'string', address: 'string', signature: 'string', + key: 'string', mail: 'string', accountType: 'string', firstName: 'string',