Skip to content

Commit 1894888

Browse files
gregfromstlclaude
andcommitted
fix: auto-login on autoconnect of IAW in all cases
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5b07c95 commit 1894888

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

.changeset/little-cities-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Auto-login on autoconnect of IAW in all cases

packages/thirdweb/src/wallets/connection/autoConnectCore.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
AuthArgsType,
99
AuthStoredTokenWithCookieReturnType,
1010
} from "../in-app/core/authentication/types.js";
11+
import { isInAppSigner } from "../in-app/core/wallet/is-in-app-signer.js";
1112
import { getUrlToken } from "../in-app/web/lib/get-url-token.js";
1213
import type { Wallet } from "../interfaces/wallet.js";
1314
import {
@@ -92,9 +93,9 @@ const _autoConnectCore = async ({
9293
clientId: props.client.clientId,
9394
ecosystem: isEcosystemWallet(wallet)
9495
? {
95-
id: wallet.id,
96-
partnerId: wallet.getConfig()?.partnerId,
97-
}
96+
id: wallet.id,
97+
partnerId: wallet.getConfig()?.partnerId,
98+
}
9899
: undefined,
99100
});
100101
await clientStorage.saveAuthCookie(urlToken.authCookie);
@@ -150,9 +151,9 @@ const _autoConnectCore = async ({
150151
const connectedWallet = await (connectOverride
151152
? connectOverride(activeWallet)
152153
: manager.connect(activeWallet, {
153-
client: props.client,
154-
accountAbstraction: props.accountAbstraction,
155-
}));
154+
client: props.client,
155+
accountAbstraction: props.accountAbstraction,
156+
}));
156157
if (connectedWallet) {
157158
autoConnected = true;
158159
try {
@@ -192,7 +193,20 @@ const _autoConnectCore = async ({
192193
}
193194

194195
// Auto-login with SIWE
195-
if (urlToken && activeWallet && props.siweAuth?.requiresAuth) {
196+
const isIAW =
197+
activeWallet &&
198+
isInAppSigner({
199+
wallet: activeWallet,
200+
connectedWallets: activeWallet
201+
? [activeWallet, ...otherWallets]
202+
: otherWallets,
203+
});
204+
if (
205+
isIAW &&
206+
props.siweAuth?.requiresAuth &&
207+
!props.siweAuth?.isLoggedIn &&
208+
!props.siweAuth?.isLoggingIn
209+
) {
196210
await props.siweAuth?.doLogin();
197211
}
198212
manager.isAutoConnecting.setValue(false);

packages/thirdweb/src/wallets/connection/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,7 @@ export type AutoConnectProps = {
125125
siweAuth?: {
126126
requiresAuth: boolean;
127127
doLogin: () => Promise<void>;
128+
isLoggedIn: boolean | undefined;
129+
isLoggingIn: boolean | undefined;
128130
};
129131
};

0 commit comments

Comments
 (0)