@b3dotfun/sdk 0.1.69-alpha.1 → 0.1.69-alpha.11
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/anyspend/react/components/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +37 -6
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +7 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -6
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +11 -7
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/bsmnt.d.ts +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.js +57 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +96 -15
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +15 -2
- package/dist/cjs/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/cjs/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/cjs/global-account/react/hooks/useAuth.js +26 -15
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +23 -12
- package/dist/cjs/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +0 -17
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -1
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +34 -3
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/StepProgress.js +4 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -7
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +9 -5
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +100 -19
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +14 -1
- package/dist/esm/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/esm/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/esm/global-account/react/hooks/useAuth.js +28 -17
- package/dist/esm/global-account/react/hooks/useAuthentication.js +24 -13
- package/dist/esm/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +0 -16
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/types/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/types/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/package.json +2 -6
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +2 -4
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -0
- package/src/anyspend/react/components/common/OrderStatus.tsx +38 -3
- package/src/anyspend/react/components/common/StepProgress.tsx +15 -5
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -7
- package/src/anyspend/react/hooks/useKycStatus.ts +8 -5
- package/src/app.shared.ts +9 -8
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -2
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +2 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +7 -1
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +207 -54
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +19 -3
- package/src/global-account/react/components/Toast/ToastContext.tsx +39 -7
- package/src/global-account/react/hooks/useAuth.ts +28 -17
- package/src/global-account/react/hooks/useAuthentication.ts +24 -13
- package/src/global-account/react/hooks/useConnect.tsx +2 -2
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -1
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +0 -18
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/shared/utils/session-duration.ts +64 -0
- package/src/types/torph.d.ts +4 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -3,15 +3,17 @@ import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
5
|
type CustomStrategyType = "basement" | "privy";
|
|
6
|
-
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType;
|
|
7
|
-
|
|
6
|
+
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
|
+
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement", "privy"];
|
|
8
9
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
9
10
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
10
|
-
export declare function isStrategyType(strategy: AllowedStrategies): strategy is
|
|
11
|
+
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
11
12
|
export declare function getConnectOptionsFromStrategy(strategy: AllowedStrategy): {
|
|
12
13
|
strategy: StrategyType;
|
|
13
14
|
wallet?: Wallet;
|
|
14
15
|
chain?: Chain;
|
|
15
16
|
};
|
|
16
17
|
export declare const strategyIcons: Record<string, string>;
|
|
18
|
+
export declare const strategyLabels: Record<string, string>;
|
|
17
19
|
export {};
|
|
@@ -5,9 +5,10 @@ export const allowedStrategies = [
|
|
|
5
5
|
// Auth strategies
|
|
6
6
|
"apple",
|
|
7
7
|
"google",
|
|
8
|
+
"github",
|
|
8
9
|
"x",
|
|
9
10
|
"discord",
|
|
10
|
-
|
|
11
|
+
"email",
|
|
11
12
|
"guest",
|
|
12
13
|
// Wallet IDs
|
|
13
14
|
"walletConnect",
|
|
@@ -29,6 +30,9 @@ export function getConnectOptionsFromStrategy(strategy) {
|
|
|
29
30
|
if (!allowedStrategies.includes(strategy)) {
|
|
30
31
|
throw new Error(`Invalid strategy: ${strategy}`);
|
|
31
32
|
}
|
|
33
|
+
if (strategy === "email") {
|
|
34
|
+
throw new Error("Email strategy requires OTP flow and cannot be connected in a single step");
|
|
35
|
+
}
|
|
32
36
|
if (isWalletType(strategy)) {
|
|
33
37
|
return { strategy: "wallet", wallet: createWallet(strategy) };
|
|
34
38
|
}
|
|
@@ -45,6 +49,15 @@ export const strategyIcons = {
|
|
|
45
49
|
guest: "https://cdn.b3.fun/incognito.svg",
|
|
46
50
|
// Add more strategies as needed
|
|
47
51
|
};
|
|
52
|
+
export const strategyLabels = {
|
|
53
|
+
google: "Google",
|
|
54
|
+
x: "X",
|
|
55
|
+
discord: "Discord",
|
|
56
|
+
apple: "Apple",
|
|
57
|
+
guest: "Guest",
|
|
58
|
+
github: "GitHub",
|
|
59
|
+
email: "Email",
|
|
60
|
+
};
|
|
48
61
|
// Test it
|
|
49
62
|
// console.log(getConnectOptionsFromStrategy("io.metamask"));
|
|
50
63
|
// console.log(getConnectOptionsFromStrategy("google"));
|
|
@@ -11,6 +11,9 @@ interface ToastContextType {
|
|
|
11
11
|
addToast: (type: ToastType, message: string, duration?: number) => string;
|
|
12
12
|
removeToast: (id: string) => void;
|
|
13
13
|
clearAll: () => void;
|
|
14
|
+
headerMode: boolean;
|
|
15
|
+
setHeaderMode: (enabled: boolean) => void;
|
|
16
|
+
latestToast: ToastItem | null;
|
|
14
17
|
}
|
|
15
18
|
export declare function ToastProvider({ children }: {
|
|
16
19
|
children: React.ReactNode;
|
|
@@ -4,6 +4,9 @@ const ToastContext = createContext(undefined);
|
|
|
4
4
|
let globalToastCounter = 0;
|
|
5
5
|
export function ToastProvider({ children }) {
|
|
6
6
|
const [toasts, setToasts] = useState([]);
|
|
7
|
+
const [headerMode, setHeaderMode] = useState(false);
|
|
8
|
+
const headerModeRef = useRef(false);
|
|
9
|
+
const [latestToast, setLatestToast] = useState(null);
|
|
7
10
|
const timeoutsRef = useRef(new Map());
|
|
8
11
|
const removeToast = useCallback((id) => {
|
|
9
12
|
setToasts(prev => prev.filter(toast => toast.id !== id));
|
|
@@ -22,12 +25,23 @@ export function ToastProvider({ children }) {
|
|
|
22
25
|
duration,
|
|
23
26
|
createdAt: Date.now(),
|
|
24
27
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (headerModeRef.current) {
|
|
29
|
+
setLatestToast(newToast);
|
|
30
|
+
if (duration > 0) {
|
|
31
|
+
const timeout = setTimeout(() => {
|
|
32
|
+
setLatestToast(null);
|
|
33
|
+
}, duration);
|
|
34
|
+
timeoutsRef.current.set(id, timeout);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
setToasts(prev => [...prev, newToast]);
|
|
39
|
+
if (duration > 0) {
|
|
40
|
+
const timeout = setTimeout(() => {
|
|
41
|
+
removeToast(id);
|
|
42
|
+
}, duration);
|
|
43
|
+
timeoutsRef.current.set(id, timeout);
|
|
44
|
+
}
|
|
31
45
|
}
|
|
32
46
|
return id;
|
|
33
47
|
}, [removeToast]);
|
|
@@ -36,6 +50,15 @@ export function ToastProvider({ children }) {
|
|
|
36
50
|
timeoutsRef.current.clear();
|
|
37
51
|
setToasts([]);
|
|
38
52
|
}, []);
|
|
53
|
+
const setHeaderModeCallback = useCallback((enabled) => {
|
|
54
|
+
setHeaderMode(enabled);
|
|
55
|
+
headerModeRef.current = enabled;
|
|
56
|
+
if (!enabled) {
|
|
57
|
+
setLatestToast(null);
|
|
58
|
+
timeoutsRef.current.forEach(timeout => clearTimeout(timeout));
|
|
59
|
+
timeoutsRef.current.clear();
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
39
62
|
// Cleanup on unmount
|
|
40
63
|
useEffect(() => {
|
|
41
64
|
const timeouts = timeoutsRef.current;
|
|
@@ -44,7 +67,7 @@ export function ToastProvider({ children }) {
|
|
|
44
67
|
timeouts.clear();
|
|
45
68
|
};
|
|
46
69
|
}, []);
|
|
47
|
-
return _jsx(ToastContext.Provider, { value: { toasts, addToast, removeToast, clearAll }, children: children });
|
|
70
|
+
return (_jsx(ToastContext.Provider, { value: { toasts, addToast, removeToast, clearAll, headerMode, setHeaderMode: setHeaderModeCallback, latestToast }, children: children }));
|
|
48
71
|
}
|
|
49
72
|
export function useToastContext() {
|
|
50
73
|
const context = useContext(ToastContext);
|
|
@@ -5,13 +5,13 @@ import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
|
5
5
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getConnectors } from "@wagmi/core";
|
|
8
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
8
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
9
9
|
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
11
11
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
12
12
|
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
13
13
|
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider.js";
|
|
14
|
-
import {
|
|
14
|
+
import { createWagmiConfig } from "../utils/createWagmiConfig.js";
|
|
15
15
|
import { useSearchParam } from "./useSearchParamsSSR.js";
|
|
16
16
|
import { useUserQuery } from "./useUserQuery.js";
|
|
17
17
|
const debug = debugB3React("useAuth");
|
|
@@ -21,7 +21,7 @@ const debug = debugB3React("useAuth");
|
|
|
21
21
|
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
22
22
|
*/
|
|
23
23
|
export function useAuth() {
|
|
24
|
-
const { onConnectCallback } = useContext(LocalSDKContext);
|
|
24
|
+
const { onConnectCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
25
25
|
const { disconnect } = useDisconnect();
|
|
26
26
|
const wallets = useConnectedWallets();
|
|
27
27
|
const activeWallet = useActiveWallet();
|
|
@@ -38,7 +38,7 @@ export function useAuth() {
|
|
|
38
38
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
39
39
|
const referralCode = useSearchParam("referralCode");
|
|
40
40
|
const { partnerId } = useB3Config();
|
|
41
|
-
const wagmiConfig =
|
|
41
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
42
42
|
const { connect } = useConnect();
|
|
43
43
|
const activeWagmiAccount = useAccount();
|
|
44
44
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -63,8 +63,10 @@ export function useAuth() {
|
|
|
63
63
|
}
|
|
64
64
|
// Authenticate with BSMNT
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (!disableBSMNTAuthentication) {
|
|
67
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
68
|
+
debug("BSMNT re-authentication successful", b3Jwt);
|
|
69
|
+
}
|
|
68
70
|
}
|
|
69
71
|
catch (bsmntError) {
|
|
70
72
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
@@ -76,7 +78,7 @@ export function useAuth() {
|
|
|
76
78
|
debug("Re-authentication failed", err);
|
|
77
79
|
throw err;
|
|
78
80
|
}
|
|
79
|
-
}, [setUser]);
|
|
81
|
+
}, [setUser, disableBSMNTAuthentication]);
|
|
80
82
|
const syncWagmi = useCallback(async () => {
|
|
81
83
|
function syncWagmiFunc() {
|
|
82
84
|
const connectors = getConnectors(wagmiConfig);
|
|
@@ -120,9 +122,7 @@ export function useAuth() {
|
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
syncWagmiFunc();
|
|
123
|
-
|
|
124
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
|
-
}, [partnerId, wallets]);
|
|
125
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
126
126
|
useEffect(() => {
|
|
127
127
|
syncWagmi();
|
|
128
128
|
}, [wallets, syncWagmi]);
|
|
@@ -139,9 +139,11 @@ export function useAuth() {
|
|
|
139
139
|
setIsAuthenticated(true);
|
|
140
140
|
setIsAuthenticating(false);
|
|
141
141
|
debug("Re-authenticated successfully", { userAuth });
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
if (!disableBSMNTAuthentication) {
|
|
143
|
+
// Authenticate on BSMNT with B3 JWT
|
|
144
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
145
|
+
debug("@@b3Jwt", b3Jwt);
|
|
146
|
+
}
|
|
145
147
|
return userAuth;
|
|
146
148
|
}
|
|
147
149
|
catch (error) {
|
|
@@ -151,7 +153,14 @@ export function useAuth() {
|
|
|
151
153
|
setIsAuthenticating(false);
|
|
152
154
|
throw new Error("Authentication required. Please authenticate.");
|
|
153
155
|
}
|
|
154
|
-
}, [
|
|
156
|
+
}, [
|
|
157
|
+
reAuthenticate,
|
|
158
|
+
setIsAuthenticated,
|
|
159
|
+
setIsAuthenticating,
|
|
160
|
+
setUser,
|
|
161
|
+
setHasStartedConnecting,
|
|
162
|
+
disableBSMNTAuthentication,
|
|
163
|
+
]);
|
|
155
164
|
/**
|
|
156
165
|
* Authenticate with B3
|
|
157
166
|
*
|
|
@@ -181,8 +190,10 @@ export function useAuth() {
|
|
|
181
190
|
}
|
|
182
191
|
// Step 3: Authenticate with BSMNT for basement integration
|
|
183
192
|
try {
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
if (!disableBSMNTAuthentication) {
|
|
194
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
195
|
+
debug("BSMNT authentication successful", b3Jwt);
|
|
196
|
+
}
|
|
186
197
|
}
|
|
187
198
|
catch (bsmntError) {
|
|
188
199
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
@@ -194,7 +205,7 @@ export function useAuth() {
|
|
|
194
205
|
debug("Authentication failed", err);
|
|
195
206
|
throw err;
|
|
196
207
|
}
|
|
197
|
-
}, [referralCode, setUser]);
|
|
208
|
+
}, [referralCode, setUser, disableBSMNTAuthentication]);
|
|
198
209
|
/**
|
|
199
210
|
* Handle wallet connection
|
|
200
211
|
*/
|
|
@@ -5,7 +5,7 @@ import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
|
5
5
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getConnectors } from "@wagmi/core";
|
|
8
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
8
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
9
9
|
import { useActiveWallet, useAutoConnect, useConnectedWallets, useDisconnect, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
11
11
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
@@ -16,7 +16,7 @@ import { useTWAuth } from "./useTWAuth.js";
|
|
|
16
16
|
import { useUserQuery } from "./useUserQuery.js";
|
|
17
17
|
const debug = debugB3React("useAuthentication");
|
|
18
18
|
export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
19
|
-
const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
|
|
19
|
+
const { onConnectCallback, onLogoutCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
20
20
|
const { disconnect } = useDisconnect();
|
|
21
21
|
const wallets = useConnectedWallets();
|
|
22
22
|
// Keep refs so logout() always disconnects current wallets, not stale closure values.
|
|
@@ -48,7 +48,7 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
48
48
|
const { authenticate } = useTWAuth();
|
|
49
49
|
const { user, setUser } = useUserQuery();
|
|
50
50
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
51
|
-
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
51
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
52
52
|
const { connect } = useConnect();
|
|
53
53
|
const activeWagmiAccount = useAccount();
|
|
54
54
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -99,9 +99,7 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
syncWagmiFunc();
|
|
102
|
-
|
|
103
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
-
}, [partnerId, wallets]);
|
|
102
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
105
103
|
useEffect(() => {
|
|
106
104
|
syncWagmi();
|
|
107
105
|
}, [wallets, syncWagmi]);
|
|
@@ -121,9 +119,11 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
121
119
|
setIsAuthenticated(true);
|
|
122
120
|
setIsAuthenticating(false);
|
|
123
121
|
debug("Re-authenticated successfully", { userAuth });
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
if (!disableBSMNTAuthentication) {
|
|
123
|
+
// Authenticate on BSMNT with B3 JWT
|
|
124
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
125
|
+
debug("@@b3Jwt", b3Jwt);
|
|
126
|
+
}
|
|
127
127
|
return userAuth;
|
|
128
128
|
}
|
|
129
129
|
catch (error) {
|
|
@@ -134,12 +134,23 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
134
134
|
setIsAuthenticated(true);
|
|
135
135
|
setIsAuthenticating(false);
|
|
136
136
|
debug("Fresh authentication successful", { userAuth });
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
if (!disableBSMNTAuthentication) {
|
|
138
|
+
// Authenticate on BSMNT with B3 JWT
|
|
139
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
140
|
+
debug("@@b3Jwt", b3Jwt);
|
|
141
|
+
}
|
|
140
142
|
return userAuth;
|
|
141
143
|
}
|
|
142
|
-
}, [
|
|
144
|
+
}, [
|
|
145
|
+
activeWallet,
|
|
146
|
+
partnerId,
|
|
147
|
+
authenticate,
|
|
148
|
+
setIsAuthenticated,
|
|
149
|
+
setIsAuthenticating,
|
|
150
|
+
setUser,
|
|
151
|
+
setHasStartedConnecting,
|
|
152
|
+
disableBSMNTAuthentication,
|
|
153
|
+
]);
|
|
143
154
|
const logout = useCallback(async (callback) => {
|
|
144
155
|
// Disconnect ecosystem/smart wallets from the connected wallets list.
|
|
145
156
|
// EOA wallets (MetaMask, Coinbase Wallet) are left in the list so they can
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Chain } from "thirdweb";
|
|
2
|
-
import { SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
2
|
+
import { MultiStepAuthArgsType, SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
3
3
|
/**
|
|
4
4
|
* This hook is used to connect to a wallet using the thirdweb client.
|
|
5
5
|
*/
|
|
6
6
|
export declare function useConnect(partnerId: string, chain?: Chain): {
|
|
7
|
-
connect: (strategyOptions?: SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
7
|
+
connect: (strategyOptions?: MultiStepAuthArgsType | SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
};
|
|
@@ -7451,8 +7451,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7451
7451
|
[x: `bool[${string}]`]: undefined;
|
|
7452
7452
|
[x: `bytes[${string}]`]: undefined;
|
|
7453
7453
|
[x: `bytes1[${string}]`]: undefined;
|
|
7454
|
-
[x: `
|
|
7454
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
7455
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
7455
7456
|
[x: `bytes30[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
7456
7458
|
[x: `bytes18[${string}]`]: undefined;
|
|
7457
7459
|
[x: `bytes6[${string}]`]: undefined;
|
|
7458
7460
|
[x: `bytes9[${string}]`]: undefined;
|
|
@@ -7460,12 +7462,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7460
7462
|
[x: `bytes10[${string}]`]: undefined;
|
|
7461
7463
|
[x: `bytes2[${string}]`]: undefined;
|
|
7462
7464
|
[x: `bytes3[${string}]`]: undefined;
|
|
7463
|
-
[x: `
|
|
7464
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
7465
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
7465
7466
|
[x: `bytes11[${string}]`]: undefined;
|
|
7466
7467
|
[x: `bytes12[${string}]`]: undefined;
|
|
7467
7468
|
[x: `bytes13[${string}]`]: undefined;
|
|
7468
|
-
[x: `bytes14[${string}]`]: undefined;
|
|
7469
7469
|
[x: `bytes15[${string}]`]: undefined;
|
|
7470
7470
|
[x: `bytes16[${string}]`]: undefined;
|
|
7471
7471
|
[x: `bytes17[${string}]`]: undefined;
|
|
@@ -7553,8 +7553,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7553
7553
|
bool?: undefined;
|
|
7554
7554
|
bytes?: undefined;
|
|
7555
7555
|
bytes1?: undefined;
|
|
7556
|
-
|
|
7556
|
+
bytes7?: undefined;
|
|
7557
|
+
bytes14?: undefined;
|
|
7557
7558
|
bytes30?: undefined;
|
|
7559
|
+
bytes5?: undefined;
|
|
7558
7560
|
bytes18?: undefined;
|
|
7559
7561
|
bytes6?: undefined;
|
|
7560
7562
|
bytes9?: undefined;
|
|
@@ -7562,12 +7564,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7562
7564
|
bytes10?: undefined;
|
|
7563
7565
|
bytes2?: undefined;
|
|
7564
7566
|
bytes3?: undefined;
|
|
7565
|
-
|
|
7566
|
-
bytes7?: undefined;
|
|
7567
|
+
bytes4?: undefined;
|
|
7567
7568
|
bytes11?: undefined;
|
|
7568
7569
|
bytes12?: undefined;
|
|
7569
7570
|
bytes13?: undefined;
|
|
7570
|
-
bytes14?: undefined;
|
|
7571
7571
|
bytes15?: undefined;
|
|
7572
7572
|
bytes16?: undefined;
|
|
7573
7573
|
bytes17?: undefined;
|
|
@@ -10,7 +10,6 @@ import { useSearchParam } from "./useSearchParamsSSR.js";
|
|
|
10
10
|
* @deprecated Use useAuth() instead
|
|
11
11
|
*/
|
|
12
12
|
export function useTWAuth() {
|
|
13
|
-
console.warn("useTWAuth is deprecated. Please migrate to useAuth() for authentication.");
|
|
14
13
|
const referralCode = useSearchParam("referralCode");
|
|
15
14
|
const authenticate = useCallback(async (wallet, partnerId) => {
|
|
16
15
|
if (!wallet || !wallet?.getAuthToken?.())
|
|
@@ -425,6 +425,15 @@ export interface SendModalProps extends BaseModalProps {
|
|
|
425
425
|
/** Callback function called when send is successful */
|
|
426
426
|
onSuccess?: (txHash?: string) => void;
|
|
427
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Props for the Session Duration modal
|
|
430
|
+
* Allows users to configure how long they stay signed in
|
|
431
|
+
*/
|
|
432
|
+
export interface SessionDurationModalProps extends BaseModalProps {
|
|
433
|
+
type: "sessionDuration";
|
|
434
|
+
partnerId: string;
|
|
435
|
+
chain: Chain;
|
|
436
|
+
}
|
|
428
437
|
/**
|
|
429
438
|
* Props for the Notifications modal
|
|
430
439
|
* Allows users to manage notification settings and channels
|
|
@@ -626,7 +635,7 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
626
635
|
/**
|
|
627
636
|
* Union type of all possible modal content types
|
|
628
637
|
*/
|
|
629
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
638
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | SessionDurationModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
630
639
|
/**
|
|
631
640
|
* State interface for the modal store
|
|
632
641
|
*/
|
|
@@ -25,21 +25,3 @@ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): im
|
|
|
25
25
|
}, {
|
|
26
26
|
"thirdweb:lastChainId": number;
|
|
27
27
|
}>)[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Returns a cached wagmi config for the given partnerId.
|
|
30
|
-
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
31
|
-
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getCachedWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
34
|
-
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
35
|
-
}, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
36
|
-
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
37
|
-
accounts: withCapabilities extends true ? readonly {
|
|
38
|
-
address: `0x${string}`;
|
|
39
|
-
capabilities: Record<string, unknown>;
|
|
40
|
-
}[] : readonly `0x${string}`[];
|
|
41
|
-
chainId: number;
|
|
42
|
-
}>;
|
|
43
|
-
}, {
|
|
44
|
-
"thirdweb:lastChainId": number;
|
|
45
|
-
}>)[]>;
|
|
@@ -27,19 +27,3 @@ export function createWagmiConfig(options) {
|
|
|
27
27
|
connectors: finalConnectors,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
/** Module-level cache — wagmi configs must not be recreated on every render. */
|
|
31
|
-
const wagmiConfigCache = new Map();
|
|
32
|
-
/**
|
|
33
|
-
* Returns a cached wagmi config for the given partnerId.
|
|
34
|
-
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
35
|
-
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
36
|
-
*/
|
|
37
|
-
export function getCachedWagmiConfig(options) {
|
|
38
|
-
const key = options.partnerId;
|
|
39
|
-
let config = wagmiConfigCache.get(key);
|
|
40
|
-
if (!config) {
|
|
41
|
-
config = createWagmiConfig(options);
|
|
42
|
-
wagmiConfigCache.set(key, config);
|
|
43
|
-
}
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const SESSION_DURATION_OPTIONS: readonly [0, 1, 7, 14, 30];
|
|
2
|
+
export type SessionDurationDays = (typeof SESSION_DURATION_OPTIONS)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Read session duration for a specific partner.
|
|
5
|
+
*
|
|
6
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
7
|
+
*
|
|
8
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
9
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
10
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSessionDurationDays(userPreferences?: Record<string, any>, partnerId?: string): SessionDurationDays;
|
|
13
|
+
export declare const SESSION_DURATION_LABELS: Record<SessionDurationDays, string>;
|
|
14
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
15
|
+
export declare function setSessionDurationDays(days: SessionDurationDays, partnerId?: string): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const STORAGE_KEY_PREFIX = "b3-session-duration";
|
|
2
|
+
const DEFAULT_DAYS = 7;
|
|
3
|
+
// 0 = session cookie (expires when browser closes)
|
|
4
|
+
export const SESSION_DURATION_OPTIONS = [0, 1, 7, 14, 30];
|
|
5
|
+
function storageKey(partnerId) {
|
|
6
|
+
return partnerId ? `${STORAGE_KEY_PREFIX}_${partnerId}` : STORAGE_KEY_PREFIX;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Read session duration for a specific partner.
|
|
10
|
+
*
|
|
11
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
12
|
+
*
|
|
13
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
14
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
15
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
16
|
+
*/
|
|
17
|
+
export function getSessionDurationDays(userPreferences, partnerId) {
|
|
18
|
+
if (userPreferences) {
|
|
19
|
+
if (partnerId) {
|
|
20
|
+
const v = userPreferences[partnerId]?.sessionDuration;
|
|
21
|
+
if (SESSION_DURATION_OPTIONS.includes(v))
|
|
22
|
+
return v;
|
|
23
|
+
}
|
|
24
|
+
const v = userPreferences["sessionDuration"];
|
|
25
|
+
if (SESSION_DURATION_OPTIONS.includes(v))
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (partnerId) {
|
|
30
|
+
const stored = localStorage.getItem(storageKey(partnerId));
|
|
31
|
+
if (stored !== null) {
|
|
32
|
+
const parsed = Number(stored);
|
|
33
|
+
if (SESSION_DURATION_OPTIONS.includes(parsed))
|
|
34
|
+
return parsed;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const stored = localStorage.getItem(STORAGE_KEY_PREFIX);
|
|
38
|
+
if (stored !== null) {
|
|
39
|
+
const parsed = Number(stored);
|
|
40
|
+
if (SESSION_DURATION_OPTIONS.includes(parsed))
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// localStorage unavailable (e.g. SSR)
|
|
46
|
+
}
|
|
47
|
+
return DEFAULT_DAYS;
|
|
48
|
+
}
|
|
49
|
+
export const SESSION_DURATION_LABELS = {
|
|
50
|
+
0: "Session only",
|
|
51
|
+
1: "1 day",
|
|
52
|
+
7: "7 days",
|
|
53
|
+
14: "14 days",
|
|
54
|
+
30: "30 days",
|
|
55
|
+
};
|
|
56
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
57
|
+
export function setSessionDurationDays(days, partnerId) {
|
|
58
|
+
try {
|
|
59
|
+
localStorage.setItem(storageKey(partnerId), String(days));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// ignore
|
|
63
|
+
}
|
|
64
|
+
}
|