Skip to content

Fix: Auto-signin to autoconnect for all cases #7011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-cities-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Auto-login on autoconnect of IAW in all cases
16 changes: 15 additions & 1 deletion packages/thirdweb/src/wallets/connection/autoConnectCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 {
Expand Down Expand Up @@ -192,7 +193,20 @@
}

// Auto-login with SIWE
if (urlToken && activeWallet && props.siweAuth?.requiresAuth) {
const isIAW =
activeWallet &&
isInAppSigner({
wallet: activeWallet,
connectedWallets: activeWallet
? [activeWallet, ...otherWallets]
: otherWallets,

Check warning on line 202 in packages/thirdweb/src/wallets/connection/autoConnectCore.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L202 was not covered by tests
});
if (
isIAW &&
props.siweAuth?.requiresAuth &&
!props.siweAuth?.isLoggedIn &&
!props.siweAuth?.isLoggingIn

Check warning on line 208 in packages/thirdweb/src/wallets/connection/autoConnectCore.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L208 was not covered by tests
) {
await props.siweAuth?.doLogin();
}
manager.isAutoConnecting.setValue(false);
Expand Down
2 changes: 2 additions & 0 deletions packages/thirdweb/src/wallets/connection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,7 @@ export type AutoConnectProps = {
siweAuth?: {
requiresAuth: boolean;
doLogin: () => Promise<void>;
isLoggedIn: boolean | undefined;
isLoggingIn: boolean | undefined;
};
};
Loading