@b3dotfun/sdk 0.0.34-alpha.1 → 0.0.34-alpha.3
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/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +20 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -1
- package/dist/esm/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -0
- package/dist/types/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +1 -6
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +3 -3
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +5 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +3 -0
- package/src/global-account/react/hooks/useAuthentication.ts +24 -1
- package/src/global-account/react/stores/useAuthStore.ts +8 -0
- package/src/styles/index.css +5 -2
|
@@ -4,7 +4,7 @@ import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
|
4
4
|
import { b3MainnetThirdWeb } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
5
5
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
|
-
import { useEffect } from "react";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
8
|
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect } from "thirdweb/react";
|
|
9
9
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
10
10
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
@@ -27,6 +27,11 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
27
27
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
28
28
|
const isConnecting = useAuthStore(state => state.isConnecting);
|
|
29
29
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
30
|
+
const useAutoConnectLoadingPrevious = useRef(false);
|
|
31
|
+
const setIsAuthenticatingV2 = useAuthStore(state => state.setIsAuthenticatingV2);
|
|
32
|
+
const isAuthenticatingV2 = useAuthStore(state => state.isAuthenticatingV2);
|
|
33
|
+
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
34
|
+
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
30
35
|
const { connect } = useConnect(partnerId, b3MainnetThirdWeb);
|
|
31
36
|
|
|
32
37
|
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
@@ -37,11 +42,15 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
37
42
|
client,
|
|
38
43
|
wallets: [wallet],
|
|
39
44
|
onConnect: async wallet => {
|
|
45
|
+
setHasStartedConnecting(true);
|
|
46
|
+
|
|
40
47
|
try {
|
|
41
48
|
setIsConnected(true);
|
|
42
49
|
if (!loginWithSiwe) {
|
|
43
50
|
debug("Skipping SIWE login", { loginWithSiwe });
|
|
44
51
|
setIsAuthenticated(true);
|
|
52
|
+
|
|
53
|
+
setIsAuthenticatingV2(false);
|
|
45
54
|
return;
|
|
46
55
|
}
|
|
47
56
|
debug("setIsAuthenticating:true:4");
|
|
@@ -56,6 +65,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
56
65
|
const userAuth = await app.reAuthenticate();
|
|
57
66
|
setUser(userAuth.user);
|
|
58
67
|
setIsAuthenticated(true);
|
|
68
|
+
setIsAuthenticatingV2(false);
|
|
59
69
|
debug("Re-authenticated successfully", { userAuth });
|
|
60
70
|
} catch (error) {
|
|
61
71
|
// If re-authentication fails, try fresh authentication
|
|
@@ -63,6 +73,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
63
73
|
const userAuth = await authenticate(account, partnerId);
|
|
64
74
|
setUser(userAuth.user);
|
|
65
75
|
setIsAuthenticated(true);
|
|
76
|
+
setIsAuthenticatingV2(false);
|
|
66
77
|
debug("Fresh authentication successful", { userAuth });
|
|
67
78
|
}
|
|
68
79
|
} catch (error) {
|
|
@@ -71,9 +82,20 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
71
82
|
debug("setIsAuthenticating:false:4");
|
|
72
83
|
setUser();
|
|
73
84
|
}
|
|
85
|
+
setIsAuthenticatingV2(false);
|
|
74
86
|
},
|
|
75
87
|
});
|
|
76
88
|
|
|
89
|
+
/**
|
|
90
|
+
* useAutoConnectLoading starts as false
|
|
91
|
+
*/
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
94
|
+
setIsAuthenticatingV2(false);
|
|
95
|
+
}
|
|
96
|
+
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
97
|
+
}, [useAutoConnectLoading]);
|
|
98
|
+
|
|
77
99
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
78
100
|
useEffect(() => {
|
|
79
101
|
if (useAutoConnectLoading) {
|
|
@@ -137,5 +159,6 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
137
159
|
wallet,
|
|
138
160
|
preAuthenticate,
|
|
139
161
|
connect,
|
|
162
|
+
isAuthenticatingV2,
|
|
140
163
|
};
|
|
141
164
|
}
|
|
@@ -27,6 +27,10 @@ interface AuthState {
|
|
|
27
27
|
onError?: (error: Error) => void;
|
|
28
28
|
}) => void;
|
|
29
29
|
reset: () => void;
|
|
30
|
+
isAuthenticatingV2: boolean;
|
|
31
|
+
setIsAuthenticatingV2: (isAuthenticating: boolean) => void;
|
|
32
|
+
hasStartedConnecting: boolean;
|
|
33
|
+
setHasStartedConnecting: (hasStartedConnecting: boolean) => void;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export const useAuthStore = create<AuthState>(set => ({
|
|
@@ -69,4 +73,8 @@ export const useAuthStore = create<AuthState>(set => ({
|
|
|
69
73
|
onSuccess: undefined,
|
|
70
74
|
onError: undefined,
|
|
71
75
|
}),
|
|
76
|
+
isAuthenticatingV2: true,
|
|
77
|
+
setIsAuthenticatingV2: isAuthenticating => set({ isAuthenticatingV2: isAuthenticating }),
|
|
78
|
+
hasStartedConnecting: false,
|
|
79
|
+
setHasStartedConnecting: hasStartedConnecting => set({ hasStartedConnecting }),
|
|
72
80
|
}));
|
package/src/styles/index.css
CHANGED
|
@@ -343,8 +343,7 @@ Dark version
|
|
|
343
343
|
@apply bg-b3-react-background;
|
|
344
344
|
}
|
|
345
345
|
.b3-modal .css-1m9ejup,
|
|
346
|
-
.b3-modal .css-1cv2836
|
|
347
|
-
.b3-modal .css-1d4s0we img[width="24"] {
|
|
346
|
+
.b3-modal .css-1cv2836 {
|
|
348
347
|
display: none !important;
|
|
349
348
|
}
|
|
350
349
|
|
|
@@ -386,6 +385,10 @@ Dark version
|
|
|
386
385
|
}
|
|
387
386
|
|
|
388
387
|
.b3-login-step {
|
|
388
|
+
& > div > div > div > div > div > div > div > img {
|
|
389
|
+
display: none;
|
|
390
|
+
}
|
|
391
|
+
|
|
389
392
|
/* Input fields styling */
|
|
390
393
|
& input {
|
|
391
394
|
color: hsl(var(--b3-react-foreground)) !important;
|