diff --git a/.changeset/little-cities-help.md b/.changeset/little-cities-help.md new file mode 100644 index 00000000000..0f051bc26fd --- /dev/null +++ b/.changeset/little-cities-help.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Auto-login on autoconnect of IAW in all cases diff --git a/packages/thirdweb/src/wallets/connection/autoConnectCore.ts b/packages/thirdweb/src/wallets/connection/autoConnectCore.ts index 0dbac362b27..11f68a34da1 100644 --- a/packages/thirdweb/src/wallets/connection/autoConnectCore.ts +++ b/packages/thirdweb/src/wallets/connection/autoConnectCore.ts @@ -8,6 +8,7 @@ import type { AuthArgsType, AuthStoredTokenWithCookieReturnType, } from "../in-app/core/authentication/types.js"; +import { isInAppSigner } from "../in-app/core/wallet/is-in-app-signer.js"; import { getUrlToken } from "../in-app/web/lib/get-url-token.js"; import type { Wallet } from "../interfaces/wallet.js"; import { @@ -192,7 +193,20 @@ const _autoConnectCore = async ({ } // Auto-login with SIWE - if (urlToken && activeWallet && props.siweAuth?.requiresAuth) { + const isIAW = + activeWallet && + isInAppSigner({ + wallet: activeWallet, + connectedWallets: activeWallet + ? [activeWallet, ...otherWallets] + : otherWallets, + }); + if ( + isIAW && + props.siweAuth?.requiresAuth && + !props.siweAuth?.isLoggedIn && + !props.siweAuth?.isLoggingIn + ) { await props.siweAuth?.doLogin(); } manager.isAutoConnecting.setValue(false); diff --git a/packages/thirdweb/src/wallets/connection/types.ts b/packages/thirdweb/src/wallets/connection/types.ts index 2af5015ad68..159600cd13c 100644 --- a/packages/thirdweb/src/wallets/connection/types.ts +++ b/packages/thirdweb/src/wallets/connection/types.ts @@ -125,5 +125,7 @@ export type AutoConnectProps = { siweAuth?: { requiresAuth: boolean; doLogin: () => Promise; + isLoggedIn: boolean | undefined; + isLoggingIn: boolean | undefined; }; };