@b3dotfun/sdk 0.1.2-test.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +11 -4
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -5
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -3
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +4 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -3
- package/package.json +1 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +8 -1
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +6 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
- package/src/global-account/react/stores/useModalStore.ts +0 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
3
|
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
4
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
@@ -8,7 +9,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
8
9
|
/**
|
|
9
10
|
* Main B3Provider component
|
|
10
11
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, onTurnkeyConnect, }: {
|
|
12
13
|
theme: "light" | "dark";
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
accountOverride?: Account;
|
|
@@ -31,4 +32,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
31
32
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
33
|
enableTurnkey?: boolean;
|
|
33
34
|
defaultPermissions?: PermissionsConfig;
|
|
35
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
34
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
26
26
|
*/
|
|
27
27
|
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
28
28
|
// deprecated since v0.0.87
|
|
29
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
|
|
29
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, onTurnkeyConnect, }) {
|
|
30
30
|
// Initialize Google Analytics on mount
|
|
31
31
|
(0, react_2.useEffect)(() => {
|
|
32
32
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -36,7 +36,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
36
36
|
(0, client_manager_1.setClientType)(clientType);
|
|
37
37
|
}, [clientType]);
|
|
38
38
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
39
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] }), (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, onTurnkeyConnect: onTurnkeyConnect, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] }), (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { Wallet } from "thirdweb/wallets";
|
|
2
3
|
/**
|
|
3
4
|
* Local SDK Context for internal SDK state (like authentication callbacks)
|
|
@@ -6,13 +7,15 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
6
7
|
export interface LocalSDKContextType {
|
|
7
8
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
8
9
|
onLogoutCallback?: () => void | Promise<void>;
|
|
10
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
9
11
|
}
|
|
10
12
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
11
13
|
/**
|
|
12
14
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
13
15
|
*/
|
|
14
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
16
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, onTurnkeyConnect, }: {
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
17
19
|
onLogoutCallback?: () => void | Promise<void>;
|
|
20
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,13 +7,15 @@ const react_1 = require("react");
|
|
|
7
7
|
exports.LocalSDKContext = (0, react_1.createContext)({
|
|
8
8
|
onConnectCallback: undefined,
|
|
9
9
|
onLogoutCallback: undefined,
|
|
10
|
+
onTurnkeyConnect: undefined,
|
|
10
11
|
});
|
|
11
12
|
/**
|
|
12
13
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
13
14
|
*/
|
|
14
|
-
function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }) {
|
|
15
|
+
function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, onTurnkeyConnect, }) {
|
|
15
16
|
return ((0, jsx_runtime_1.jsx)(exports.LocalSDKContext.Provider, { value: {
|
|
16
17
|
onConnectCallback,
|
|
17
18
|
onLogoutCallback,
|
|
19
|
+
onTurnkeyConnect,
|
|
18
20
|
}, children: children }));
|
|
19
21
|
}
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "../../../../global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled,
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -6,6 +6,7 @@ const react_1 = require("../../../../global-account/react");
|
|
|
6
6
|
const debug_1 = require("../../../../shared/utils/debug");
|
|
7
7
|
const react_2 = require("react");
|
|
8
8
|
const react_3 = require("thirdweb/react");
|
|
9
|
+
const LocalSDKProvider_1 = require("../B3Provider/LocalSDKProvider");
|
|
9
10
|
const TurnkeyAuthModal_1 = require("../TurnkeyAuthModal");
|
|
10
11
|
const SignInWithB3Privy_1 = require("./SignInWithB3Privy");
|
|
11
12
|
const LoginStep_1 = require("./steps/LoginStep");
|
|
@@ -16,9 +17,10 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
16
17
|
* Component that manages the authentication flow for Sign In With B3
|
|
17
18
|
* Handles different login providers, authentication steps, and session key management
|
|
18
19
|
*/
|
|
19
|
-
function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false,
|
|
20
|
+
function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
20
21
|
const { automaticallySetFirstEoa, enableTurnkey } = (0, react_1.useB3Config)();
|
|
21
22
|
const { user, refetchUser, logout } = (0, react_1.useAuthentication)(partnerId);
|
|
23
|
+
const { onTurnkeyConnect } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
|
|
22
24
|
// FIXME Logout before login to ensure a clean state
|
|
23
25
|
const hasLoggedOutRef = (0, react_2.useRef)(false);
|
|
24
26
|
(0, react_2.useEffect)(() => {
|
|
@@ -135,11 +137,14 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
135
137
|
]);
|
|
136
138
|
// Define handleTurnkeySuccess before the useEffect that uses it
|
|
137
139
|
const handleTurnkeySuccess = (0, react_2.useCallback)(async (user) => {
|
|
138
|
-
debug("Turnkey authentication successful - setting completed flag", { user });
|
|
140
|
+
debug("Turnkey authentication successful - setting completed flag", { user, onTurnkeyConnect });
|
|
141
|
+
// Call the onTurnkeyConnect callback
|
|
142
|
+
onTurnkeyConnect?.(user);
|
|
139
143
|
// Set completed flag FIRST before any async operations
|
|
140
144
|
setTurnkeyAuthCompleted(true);
|
|
141
145
|
// Refetch user to update the user state with Turnkey ID
|
|
142
146
|
debug("Refetching user after Turnkey success...");
|
|
147
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
143
148
|
await refetchUser();
|
|
144
149
|
debug("User refetched successfully");
|
|
145
150
|
// Set authentication and connection state so UI updates properly
|
|
@@ -163,6 +168,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
163
168
|
});
|
|
164
169
|
// The useEffect will re-run with updated user data to complete the sign-in process
|
|
165
170
|
}, [
|
|
171
|
+
onTurnkeyConnect,
|
|
166
172
|
refetchUser,
|
|
167
173
|
strategies,
|
|
168
174
|
onLoginSuccess,
|
|
@@ -338,8 +344,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
338
344
|
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)(TurnkeyAuthModal_1.TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
339
345
|
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
340
346
|
setTurnkeyAuthCompleted(true);
|
|
341
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
342
|
-
await refetchUser();
|
|
343
347
|
// User is now authenticated via Turnkey
|
|
344
348
|
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
345
349
|
// Wallet connection is optional and can happen later for signing transactions
|
|
@@ -350,6 +354,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
350
354
|
onLoginSuccess?.({});
|
|
351
355
|
// Call the onTurnkeyConnect callback
|
|
352
356
|
onTurnkeyConnect?.(authenticatedUser);
|
|
357
|
+
// After Turnkey auth, refetch user to get the full user object
|
|
358
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
359
|
+
await refetchUser();
|
|
353
360
|
}, onClose: () => {
|
|
354
361
|
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
355
362
|
setTurnkeyAuthCompleted(true);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { components } from "../../../anyspend/types/api";
|
|
3
2
|
import { GenerateSigMintResponse } from "../../../anyspend/types/signatureMint";
|
|
4
3
|
import { AllowedStrategy } from "../../../global-account/react";
|
|
@@ -41,8 +40,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
41
40
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
42
41
|
/** Whether to show the signers enabled modal */
|
|
43
42
|
signersEnabled?: boolean;
|
|
44
|
-
/** Callback for turnkey auth */
|
|
45
|
-
onTurnkeyConnect?: (user: Users) => void;
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Props for the Turnkey Authentication modal
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
3
|
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
4
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
@@ -8,7 +9,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
8
9
|
/**
|
|
9
10
|
* Main B3Provider component
|
|
10
11
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, onTurnkeyConnect, }: {
|
|
12
13
|
theme: "light" | "dark";
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
accountOverride?: Account;
|
|
@@ -31,4 +32,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
31
32
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
33
|
enableTurnkey?: boolean;
|
|
33
34
|
defaultPermissions?: PermissionsConfig;
|
|
35
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
34
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ const queryClient = new QueryClient();
|
|
|
20
20
|
*/
|
|
21
21
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
22
22
|
// deprecated since v0.0.87
|
|
23
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
|
|
23
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, onTurnkeyConnect, }) {
|
|
24
24
|
// Initialize Google Analytics on mount
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
loadGA4Script();
|
|
@@ -30,7 +30,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
30
30
|
setClientType(clientType);
|
|
31
31
|
}, [clientType]);
|
|
32
32
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
33
|
-
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
|
|
33
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, onTurnkeyConnect: onTurnkeyConnect, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, defaultPermissions: defaultPermissions, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { Wallet } from "thirdweb/wallets";
|
|
2
3
|
/**
|
|
3
4
|
* Local SDK Context for internal SDK state (like authentication callbacks)
|
|
@@ -6,13 +7,15 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
6
7
|
export interface LocalSDKContextType {
|
|
7
8
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
8
9
|
onLogoutCallback?: () => void | Promise<void>;
|
|
10
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
9
11
|
}
|
|
10
12
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
11
13
|
/**
|
|
12
14
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
13
15
|
*/
|
|
14
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
16
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, onTurnkeyConnect, }: {
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
17
19
|
onLogoutCallback?: () => void | Promise<void>;
|
|
20
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,13 +3,15 @@ import { createContext } from "react";
|
|
|
3
3
|
export const LocalSDKContext = createContext({
|
|
4
4
|
onConnectCallback: undefined,
|
|
5
5
|
onLogoutCallback: undefined,
|
|
6
|
+
onTurnkeyConnect: undefined,
|
|
6
7
|
});
|
|
7
8
|
/**
|
|
8
9
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
9
10
|
*/
|
|
10
|
-
export function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }) {
|
|
11
|
+
export function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, onTurnkeyConnect, }) {
|
|
11
12
|
return (_jsx(LocalSDKContext.Provider, { value: {
|
|
12
13
|
onConnectCallback,
|
|
13
14
|
onLogoutCallback,
|
|
15
|
+
onTurnkeyConnect,
|
|
14
16
|
}, children: children }));
|
|
15
17
|
}
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "../../../../global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled,
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Loading, useAuthentication, useAuthStore, useB3Config, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
6
|
+
import { LocalSDKContext } from "../B3Provider/LocalSDKProvider.js";
|
|
6
7
|
import { TurnkeyAuthModal } from "../TurnkeyAuthModal.js";
|
|
7
8
|
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
8
9
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep.js";
|
|
@@ -13,9 +14,10 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
13
14
|
* Component that manages the authentication flow for Sign In With B3
|
|
14
15
|
* Handles different login providers, authentication steps, and session key management
|
|
15
16
|
*/
|
|
16
|
-
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false,
|
|
17
|
+
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
17
18
|
const { automaticallySetFirstEoa, enableTurnkey } = useB3Config();
|
|
18
19
|
const { user, refetchUser, logout } = useAuthentication(partnerId);
|
|
20
|
+
const { onTurnkeyConnect } = useContext(LocalSDKContext);
|
|
19
21
|
// FIXME Logout before login to ensure a clean state
|
|
20
22
|
const hasLoggedOutRef = useRef(false);
|
|
21
23
|
useEffect(() => {
|
|
@@ -132,11 +134,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
132
134
|
]);
|
|
133
135
|
// Define handleTurnkeySuccess before the useEffect that uses it
|
|
134
136
|
const handleTurnkeySuccess = useCallback(async (user) => {
|
|
135
|
-
debug("Turnkey authentication successful - setting completed flag", { user });
|
|
137
|
+
debug("Turnkey authentication successful - setting completed flag", { user, onTurnkeyConnect });
|
|
138
|
+
// Call the onTurnkeyConnect callback
|
|
139
|
+
onTurnkeyConnect?.(user);
|
|
136
140
|
// Set completed flag FIRST before any async operations
|
|
137
141
|
setTurnkeyAuthCompleted(true);
|
|
138
142
|
// Refetch user to update the user state with Turnkey ID
|
|
139
143
|
debug("Refetching user after Turnkey success...");
|
|
144
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
140
145
|
await refetchUser();
|
|
141
146
|
debug("User refetched successfully");
|
|
142
147
|
// Set authentication and connection state so UI updates properly
|
|
@@ -160,6 +165,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
160
165
|
});
|
|
161
166
|
// The useEffect will re-run with updated user data to complete the sign-in process
|
|
162
167
|
}, [
|
|
168
|
+
onTurnkeyConnect,
|
|
163
169
|
refetchUser,
|
|
164
170
|
strategies,
|
|
165
171
|
onLoginSuccess,
|
|
@@ -335,8 +341,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
335
341
|
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
336
342
|
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
337
343
|
setTurnkeyAuthCompleted(true);
|
|
338
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
339
|
-
await refetchUser();
|
|
340
344
|
// User is now authenticated via Turnkey
|
|
341
345
|
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
342
346
|
// Wallet connection is optional and can happen later for signing transactions
|
|
@@ -347,6 +351,9 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
347
351
|
onLoginSuccess?.({});
|
|
348
352
|
// Call the onTurnkeyConnect callback
|
|
349
353
|
onTurnkeyConnect?.(authenticatedUser);
|
|
354
|
+
// After Turnkey auth, refetch user to get the full user object
|
|
355
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
356
|
+
await refetchUser();
|
|
350
357
|
}, onClose: () => {
|
|
351
358
|
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
352
359
|
setTurnkeyAuthCompleted(true);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { components } from "../../../anyspend/types/api";
|
|
3
2
|
import { GenerateSigMintResponse } from "../../../anyspend/types/signatureMint";
|
|
4
3
|
import { AllowedStrategy } from "../../../global-account/react";
|
|
@@ -41,8 +40,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
41
40
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
42
41
|
/** Whether to show the signers enabled modal */
|
|
43
42
|
signersEnabled?: boolean;
|
|
44
|
-
/** Callback for turnkey auth */
|
|
45
|
-
onTurnkeyConnect?: (user: Users) => void;
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Props for the Turnkey Authentication modal
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
3
|
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
4
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
@@ -8,7 +9,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
8
9
|
/**
|
|
9
10
|
* Main B3Provider component
|
|
10
11
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, onTurnkeyConnect, }: {
|
|
12
13
|
theme: "light" | "dark";
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
accountOverride?: Account;
|
|
@@ -31,4 +32,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
31
32
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
33
|
enableTurnkey?: boolean;
|
|
33
34
|
defaultPermissions?: PermissionsConfig;
|
|
35
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
34
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { Wallet } from "thirdweb/wallets";
|
|
2
3
|
/**
|
|
3
4
|
* Local SDK Context for internal SDK state (like authentication callbacks)
|
|
@@ -6,13 +7,15 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
6
7
|
export interface LocalSDKContextType {
|
|
7
8
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
8
9
|
onLogoutCallback?: () => void | Promise<void>;
|
|
10
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
9
11
|
}
|
|
10
12
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
11
13
|
/**
|
|
12
14
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
13
15
|
*/
|
|
14
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
16
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, onTurnkeyConnect, }: {
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
17
19
|
onLogoutCallback?: () => void | Promise<void>;
|
|
20
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
18
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "@b3dotfun/sdk/global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled,
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
2
|
import { GenerateSigMintResponse } from "@b3dotfun/sdk/anyspend/types/signatureMint";
|
|
4
3
|
import { AllowedStrategy } from "@b3dotfun/sdk/global-account/react";
|
|
@@ -41,8 +40,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
41
40
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
42
41
|
/** Whether to show the signers enabled modal */
|
|
43
42
|
signersEnabled?: boolean;
|
|
44
|
-
/** Callback for turnkey auth */
|
|
45
|
-
onTurnkeyConnect?: (user: Users) => void;
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Props for the Turnkey Authentication modal
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
3
|
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
4
|
import { RelayKitProviderWrapper, TooltipProvider } from "@b3dotfun/sdk/global-account/react";
|
|
@@ -43,6 +44,7 @@ export function B3Provider({
|
|
|
43
44
|
createClientReferenceId,
|
|
44
45
|
enableTurnkey = false,
|
|
45
46
|
defaultPermissions,
|
|
47
|
+
onTurnkeyConnect,
|
|
46
48
|
}: {
|
|
47
49
|
theme: "light" | "dark";
|
|
48
50
|
children: React.ReactNode;
|
|
@@ -66,6 +68,7 @@ export function B3Provider({
|
|
|
66
68
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
67
69
|
enableTurnkey?: boolean;
|
|
68
70
|
defaultPermissions?: PermissionsConfig;
|
|
71
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
69
72
|
}) {
|
|
70
73
|
// Initialize Google Analytics on mount
|
|
71
74
|
useEffect(() => {
|
|
@@ -88,7 +91,11 @@ export function B3Provider({
|
|
|
88
91
|
<QueryClientProvider client={queryClient}>
|
|
89
92
|
<TooltipProvider>
|
|
90
93
|
<ToastProvider>
|
|
91
|
-
<LocalSDKProvider
|
|
94
|
+
<LocalSDKProvider
|
|
95
|
+
onConnectCallback={onConnect}
|
|
96
|
+
onLogoutCallback={onLogout}
|
|
97
|
+
onTurnkeyConnect={onTurnkeyConnect}
|
|
98
|
+
>
|
|
92
99
|
<B3ConfigProvider
|
|
93
100
|
accountOverride={accountOverride}
|
|
94
101
|
environment={environment}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { createContext } from "react";
|
|
2
3
|
import { Wallet } from "thirdweb/wallets";
|
|
3
4
|
|
|
@@ -8,11 +9,13 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
8
9
|
export interface LocalSDKContextType {
|
|
9
10
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
10
11
|
onLogoutCallback?: () => void | Promise<void>;
|
|
12
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export const LocalSDKContext = createContext<LocalSDKContextType>({
|
|
14
16
|
onConnectCallback: undefined,
|
|
15
17
|
onLogoutCallback: undefined,
|
|
18
|
+
onTurnkeyConnect: undefined,
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
/**
|
|
@@ -22,16 +25,19 @@ export function LocalSDKProvider({
|
|
|
22
25
|
children,
|
|
23
26
|
onConnectCallback,
|
|
24
27
|
onLogoutCallback,
|
|
28
|
+
onTurnkeyConnect,
|
|
25
29
|
}: {
|
|
26
30
|
children: React.ReactNode;
|
|
27
31
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
28
32
|
onLogoutCallback?: () => void | Promise<void>;
|
|
33
|
+
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
29
34
|
}) {
|
|
30
35
|
return (
|
|
31
36
|
<LocalSDKContext.Provider
|
|
32
37
|
value={{
|
|
33
38
|
onConnectCallback,
|
|
34
39
|
onLogoutCallback,
|
|
40
|
+
onTurnkeyConnect,
|
|
35
41
|
}}
|
|
36
42
|
>
|
|
37
43
|
{children}
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
useModalStore,
|
|
10
10
|
} from "@b3dotfun/sdk/global-account/react";
|
|
11
11
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
12
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
|
+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
13
13
|
import { useActiveAccount } from "thirdweb/react";
|
|
14
14
|
import { Account } from "thirdweb/wallets";
|
|
15
|
+
import { LocalSDKContext } from "../B3Provider/LocalSDKProvider";
|
|
15
16
|
import { TurnkeyAuthModal } from "../TurnkeyAuthModal";
|
|
16
17
|
import { SignInWithB3Privy } from "./SignInWithB3Privy";
|
|
17
18
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep";
|
|
@@ -35,10 +36,10 @@ export function SignInWithB3Flow({
|
|
|
35
36
|
closeAfterLogin = false,
|
|
36
37
|
source = "signInWithB3Button",
|
|
37
38
|
signersEnabled = false,
|
|
38
|
-
onTurnkeyConnect,
|
|
39
39
|
}: SignInWithB3ModalProps) {
|
|
40
40
|
const { automaticallySetFirstEoa, enableTurnkey } = useB3Config();
|
|
41
41
|
const { user, refetchUser, logout } = useAuthentication(partnerId);
|
|
42
|
+
const { onTurnkeyConnect } = useContext(LocalSDKContext);
|
|
42
43
|
|
|
43
44
|
// FIXME Logout before login to ensure a clean state
|
|
44
45
|
const hasLoggedOutRef = useRef(false);
|
|
@@ -165,13 +166,17 @@ export function SignInWithB3Flow({
|
|
|
165
166
|
// Define handleTurnkeySuccess before the useEffect that uses it
|
|
166
167
|
const handleTurnkeySuccess = useCallback(
|
|
167
168
|
async (user: any) => {
|
|
168
|
-
debug("Turnkey authentication successful - setting completed flag", { user });
|
|
169
|
+
debug("Turnkey authentication successful - setting completed flag", { user, onTurnkeyConnect });
|
|
170
|
+
|
|
171
|
+
// Call the onTurnkeyConnect callback
|
|
172
|
+
onTurnkeyConnect?.(user);
|
|
169
173
|
|
|
170
174
|
// Set completed flag FIRST before any async operations
|
|
171
175
|
setTurnkeyAuthCompleted(true);
|
|
172
176
|
|
|
173
177
|
// Refetch user to update the user state with Turnkey ID
|
|
174
178
|
debug("Refetching user after Turnkey success...");
|
|
179
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
175
180
|
await refetchUser();
|
|
176
181
|
debug("User refetched successfully");
|
|
177
182
|
|
|
@@ -198,6 +203,7 @@ export function SignInWithB3Flow({
|
|
|
198
203
|
// The useEffect will re-run with updated user data to complete the sign-in process
|
|
199
204
|
},
|
|
200
205
|
[
|
|
206
|
+
onTurnkeyConnect,
|
|
201
207
|
refetchUser,
|
|
202
208
|
strategies,
|
|
203
209
|
onLoginSuccess,
|
|
@@ -400,8 +406,6 @@ export function SignInWithB3Flow({
|
|
|
400
406
|
onSuccess={async (authenticatedUser: Users) => {
|
|
401
407
|
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
402
408
|
setTurnkeyAuthCompleted(true);
|
|
403
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
404
|
-
await refetchUser();
|
|
405
409
|
// User is now authenticated via Turnkey
|
|
406
410
|
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
407
411
|
// Wallet connection is optional and can happen later for signing transactions
|
|
@@ -412,6 +416,10 @@ export function SignInWithB3Flow({
|
|
|
412
416
|
onLoginSuccess?.({} as Account);
|
|
413
417
|
// Call the onTurnkeyConnect callback
|
|
414
418
|
onTurnkeyConnect?.(authenticatedUser);
|
|
419
|
+
|
|
420
|
+
// After Turnkey auth, refetch user to get the full user object
|
|
421
|
+
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
422
|
+
await refetchUser();
|
|
415
423
|
}}
|
|
416
424
|
onClose={() => {
|
|
417
425
|
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
2
|
import { GenerateSigMintResponse } from "@b3dotfun/sdk/anyspend/types/signatureMint";
|
|
4
3
|
import { AllowedStrategy } from "@b3dotfun/sdk/global-account/react";
|
|
@@ -44,8 +43,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
44
43
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
45
44
|
/** Whether to show the signers enabled modal */
|
|
46
45
|
signersEnabled?: boolean;
|
|
47
|
-
/** Callback for turnkey auth */
|
|
48
|
-
onTurnkeyConnect?: (user: Users) => void;
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
/**
|