diff --git a/.changeset/six-dryers-sing.md b/.changeset/six-dryers-sing.md new file mode 100644 index 00000000000..d2d1d36286f --- /dev/null +++ b/.changeset/six-dryers-sing.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Propagate 401 errors when connecting in-app wallet diff --git a/packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts b/packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts index cd88a95651b..52b3bf9e89d 100644 --- a/packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts +++ b/packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts @@ -17,7 +17,7 @@ export async function getUserStatus({ authToken: string; client: ThirdwebClient; ecosystem?: Ecosystem; -}): Promise { +}): Promise { const clientFetch = getClientFetch(client, ecosystem); const response = await clientFetch( `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/accounts`, @@ -32,12 +32,10 @@ export async function getUserStatus({ ); if (!response.ok) { - if (response.status === 401) { - // 401 response indicates there is no user logged in, so we return undefined - return undefined; - } - const result = await response.json(); - throw new Error(`Failed to get user status: ${result.message}`); + const result = await response.text().catch(() => { + return "Unknown error"; + }); + throw new Error(`Failed to get user info: ${result}`); } return (await response.json()) as UserStatus;