@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 {};
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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
|
-
}>)[]>;
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.1.69-alpha.
|
|
3
|
+
"version": "0.1.69-alpha.11",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -338,6 +338,7 @@
|
|
|
338
338
|
"socket.io-client": "4.7.5",
|
|
339
339
|
"sonner": "1.7.4",
|
|
340
340
|
"tailwind-merge": "2.6.0",
|
|
341
|
+
"torph": "^0.0.9",
|
|
341
342
|
"typescript": "5.8.2",
|
|
342
343
|
"vaul": "^1.1.2",
|
|
343
344
|
"zustand": "4.5.6"
|
|
@@ -387,8 +388,6 @@
|
|
|
387
388
|
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
|
|
388
389
|
"@privy-io/react-auth": "^2.8.0",
|
|
389
390
|
"@react-three/postprocessing": "2.16.6",
|
|
390
|
-
"@readyplayerme/react-avatar-creator": "0.5.0",
|
|
391
|
-
"@readyplayerme/visage": "6.10.0",
|
|
392
391
|
"@tanstack/react-query": "5.55.0",
|
|
393
392
|
"@wagmi/core": "2.20.3",
|
|
394
393
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -403,9 +402,6 @@
|
|
|
403
402
|
"@react-three/postprocessing": {
|
|
404
403
|
"optional": true
|
|
405
404
|
},
|
|
406
|
-
"@readyplayerme/visage": {
|
|
407
|
-
"optional": true
|
|
408
|
-
},
|
|
409
405
|
"react-native-mmkv": {
|
|
410
406
|
"optional": true
|
|
411
407
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "@b3dotfun/sdk/anyspend";
|
|
1
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
4
|
GlareCardRounded,
|
|
@@ -474,7 +474,7 @@ export function AnySpendStakeB3({
|
|
|
474
474
|
>
|
|
475
475
|
<div className="mb-6">
|
|
476
476
|
<a
|
|
477
|
-
href={
|
|
477
|
+
href={getExplorerTxUrl(base.id, stakingTxHash)}
|
|
478
478
|
target="_blank"
|
|
479
479
|
rel="noopener noreferrer"
|
|
480
480
|
className="text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "@b3dotfun/sdk/anyspend";
|
|
1
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
@@ -492,7 +492,7 @@ export function AnySpendStakeB3ExactIn({
|
|
|
492
492
|
>
|
|
493
493
|
<div className="mb-6">
|
|
494
494
|
<a
|
|
495
|
-
href={
|
|
495
|
+
href={getExplorerTxUrl(base.id, stakingTxHash)}
|
|
496
496
|
target="_blank"
|
|
497
497
|
rel="noopener noreferrer"
|
|
498
498
|
className="text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors"
|
|
@@ -186,14 +186,12 @@ export function CheckoutPaymentPanel({
|
|
|
186
186
|
const accordionButtonClass = (active: boolean) =>
|
|
187
187
|
cn(
|
|
188
188
|
"anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors",
|
|
189
|
-
active
|
|
190
|
-
? "bg-white dark:bg-neutral-900"
|
|
191
|
-
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800",
|
|
189
|
+
!active && "hover:bg-gray-50 dark:hover:bg-neutral-800",
|
|
192
190
|
classes?.paymentMethodButton,
|
|
193
191
|
);
|
|
194
192
|
|
|
195
193
|
const expandedPanelClass = cn(
|
|
196
|
-
"anyspend-payment-method-panel border-t border-gray-100
|
|
194
|
+
"anyspend-payment-method-panel border-t border-gray-100 px-4 py-4 dark:border-neutral-800",
|
|
197
195
|
);
|
|
198
196
|
|
|
199
197
|
return (
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { getExplorerTxUrl } from "@b3dotfun/sdk/anyspend";
|
|
4
|
+
import { b3 } from "viem/chains";
|
|
3
5
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
6
|
import { ExternalLink } from "lucide-react";
|
|
5
7
|
import { motion } from "motion/react";
|
|
@@ -9,13 +11,21 @@ import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
|
9
11
|
|
|
10
12
|
interface CheckoutSuccessProps {
|
|
11
13
|
txHash?: string;
|
|
14
|
+
dstChainId?: number;
|
|
12
15
|
orderId?: string;
|
|
13
16
|
returnUrl?: string;
|
|
14
17
|
returnLabel?: string;
|
|
15
18
|
classes?: AnySpendCheckoutClasses;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
export function CheckoutSuccess({
|
|
21
|
+
export function CheckoutSuccess({
|
|
22
|
+
txHash,
|
|
23
|
+
dstChainId,
|
|
24
|
+
orderId,
|
|
25
|
+
returnUrl,
|
|
26
|
+
returnLabel,
|
|
27
|
+
classes,
|
|
28
|
+
}: CheckoutSuccessProps) {
|
|
19
29
|
const { content, slots } = useAnySpendCustomization();
|
|
20
30
|
|
|
21
31
|
if (slots.successScreen) {
|
|
@@ -29,7 +39,7 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
29
39
|
: "Your payment has been processed successfully.",
|
|
30
40
|
txHash,
|
|
31
41
|
orderId,
|
|
32
|
-
explorerUrl: txHash ?
|
|
42
|
+
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ?? b3.id, txHash) : undefined,
|
|
33
43
|
onDone: () => {
|
|
34
44
|
if (returnUrl) window.location.href = returnUrl;
|
|
35
45
|
},
|
|
@@ -69,7 +79,7 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
69
79
|
initial={{ opacity: 0 }}
|
|
70
80
|
animate={{ opacity: 1 }}
|
|
71
81
|
transition={{ duration: 0.3, delay: 0.5, ease: "easeOut" }}
|
|
72
|
-
href={
|
|
82
|
+
href={getExplorerTxUrl(dstChainId ?? b3.id, txHash)}
|
|
73
83
|
target="_blank"
|
|
74
84
|
rel="noopener noreferrer"
|
|
75
85
|
className="anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400"
|
|
@@ -10,14 +10,20 @@ import { USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
|
|
|
10
10
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
11
11
|
import { formatUnits } from "@b3dotfun/sdk/shared/utils/number";
|
|
12
12
|
import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
ShinyButton,
|
|
15
|
+
TextShimmer,
|
|
16
|
+
useAccountWallet,
|
|
17
|
+
useB3Config,
|
|
18
|
+
useModalStore,
|
|
19
|
+
useTokenData,
|
|
20
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
14
21
|
import { thirdwebB3Chain } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
15
22
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
16
23
|
import type { PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
|
|
17
24
|
import { Loader2, Lock, Wallet } from "lucide-react";
|
|
18
25
|
import { AnimatePresence, motion } from "motion/react";
|
|
19
26
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
-
import { useAccount } from "wagmi";
|
|
21
27
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
22
28
|
import { KycGate } from "./KycGate";
|
|
23
29
|
|
|
@@ -58,7 +64,7 @@ export function FiatCheckoutPanel({
|
|
|
58
64
|
const onErrorRef = useRef(onError);
|
|
59
65
|
onErrorRef.current = onError;
|
|
60
66
|
|
|
61
|
-
const { address } =
|
|
67
|
+
const { address } = useAccountWallet();
|
|
62
68
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
63
69
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
64
70
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ShinyButton,
|
|
6
|
+
TextShimmer,
|
|
7
|
+
useAccountWallet,
|
|
8
|
+
useB3Config,
|
|
9
|
+
useModalStore,
|
|
10
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
5
11
|
import { thirdwebB3Chain } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
6
12
|
import { Loader2, ShieldCheck, AlertTriangle, Clock, Wallet } from "lucide-react";
|
|
7
13
|
import { AnimatePresence, motion } from "motion/react";
|
|
8
14
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
|
-
import { useAccount } from "wagmi";
|
|
10
15
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
11
16
|
import { useCreateKycInquiry, useKycStatus, useVerifyKyc, useWalletAuthHeaders } from "../../hooks/useKycStatus";
|
|
12
17
|
|
|
@@ -20,7 +25,7 @@ interface KycGateProps {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export function KycGate({ themeColor, classes, enabled = false, onStatusResolved }: KycGateProps) {
|
|
23
|
-
const { address } =
|
|
28
|
+
const { address } = useAccountWallet();
|
|
24
29
|
const { partnerId } = useB3Config();
|
|
25
30
|
// Gate the status fetch behind explicit user consent so the wallet
|
|
26
31
|
// signature prompt doesn't fire automatically on tab open.
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
useB3Config,
|
|
25
25
|
useModalStore,
|
|
26
26
|
useProfile,
|
|
27
|
+
useToastContext,
|
|
27
28
|
useUnifiedChainSwitchAndExecute,
|
|
28
29
|
} from "@b3dotfun/sdk/global-account/react";
|
|
29
30
|
import { useRouter, useSearchParams } from "@b3dotfun/sdk/shared/react/hooks";
|
|
@@ -231,6 +232,13 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
231
232
|
const router = useRouter();
|
|
232
233
|
const searchParams = useSearchParams();
|
|
233
234
|
|
|
235
|
+
const { setHeaderMode } = useToastContext();
|
|
236
|
+
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
setHeaderMode(true);
|
|
239
|
+
return () => setHeaderMode(false);
|
|
240
|
+
}, [setHeaderMode]);
|
|
241
|
+
|
|
234
242
|
// Get theme from B3Provider context
|
|
235
243
|
const { theme } = useB3Config();
|
|
236
244
|
const colorMode = theme || "light";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getStatusDisplay } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
3
|
import { useSearchParams } from "@b3dotfun/sdk/shared/react";
|
|
4
|
-
import { Clock, Loader2, RotateCcw, X } from "lucide-react";
|
|
4
|
+
import { AlertCircle, AlertTriangle, CheckCircle, Clock, Info, Loader2, RotateCcw, X } from "lucide-react";
|
|
5
|
+
import { useToastContext } from "@b3dotfun/sdk/global-account/react";
|
|
6
|
+
import type { ToastType } from "@b3dotfun/sdk/global-account/react";
|
|
5
7
|
import React, { memo, useEffect, useRef } from "react";
|
|
6
8
|
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext";
|
|
7
9
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark";
|
|
@@ -15,6 +17,20 @@ function getStepIndex(status: string): number {
|
|
|
15
17
|
return -1;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
function getToastIcon(type: ToastType): React.ReactNode {
|
|
21
|
+
const iconClass = "h-5 w-5";
|
|
22
|
+
switch (type) {
|
|
23
|
+
case "success":
|
|
24
|
+
return <CheckCircle className={`${iconClass} text-green-500`} />;
|
|
25
|
+
case "error":
|
|
26
|
+
return <AlertCircle className={`${iconClass} text-red-500`} />;
|
|
27
|
+
case "info":
|
|
28
|
+
return <Info className={`${iconClass} text-blue-500`} />;
|
|
29
|
+
case "warning":
|
|
30
|
+
return <AlertTriangle className={`${iconClass} text-amber-500`} />;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
export const OrderStatus = memo(function OrderStatus({
|
|
19
35
|
order,
|
|
20
36
|
selectedCryptoPaymentMethod,
|
|
@@ -56,9 +72,28 @@ export const OrderStatus = memo(function OrderStatus({
|
|
|
56
72
|
if (content.processingDescription) description = content.processingDescription;
|
|
57
73
|
}
|
|
58
74
|
|
|
75
|
+
const { latestToast } = useToastContext();
|
|
76
|
+
|
|
77
|
+
// Override subtitle with toast notification when present (title stays unchanged)
|
|
78
|
+
let notificationIcon: React.ReactNode = undefined;
|
|
79
|
+
if (latestToast && currentStepIndex >= 0) {
|
|
80
|
+
description = latestToast.message;
|
|
81
|
+
notificationIcon = getToastIcon(latestToast.type);
|
|
82
|
+
}
|
|
83
|
+
|
|
59
84
|
const paymentSteps: Step[] = [
|
|
60
|
-
{
|
|
61
|
-
|
|
85
|
+
{
|
|
86
|
+
id: 1,
|
|
87
|
+
title: text,
|
|
88
|
+
description: typeof description === "string" ? description : defaultDescription || "",
|
|
89
|
+
icon: notificationIcon,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 2,
|
|
93
|
+
title: text,
|
|
94
|
+
description: typeof description === "string" ? description : defaultDescription || "",
|
|
95
|
+
icon: notificationIcon,
|
|
96
|
+
},
|
|
62
97
|
];
|
|
63
98
|
|
|
64
99
|
if (currentStepIndex === 0) {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { motion } from "framer-motion";
|
|
5
|
+
import { TextMorph } from "torph/react";
|
|
4
6
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark";
|
|
5
7
|
|
|
6
8
|
export interface Step {
|
|
7
9
|
id: string | number;
|
|
8
10
|
title: string;
|
|
9
11
|
description?: string;
|
|
12
|
+
icon?: React.ReactNode;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
export interface StepProgressProps {
|
|
@@ -32,8 +35,8 @@ export function StepProgress({
|
|
|
32
35
|
{/* Step Progress Indicator */}
|
|
33
36
|
<div className="flex items-center gap-2">
|
|
34
37
|
{steps.map((_, index) => (
|
|
35
|
-
|
|
36
|
-
<div
|
|
38
|
+
<React.Fragment key={index}>
|
|
39
|
+
<div className="flex items-center">
|
|
37
40
|
{index < currentStepIndex ? (
|
|
38
41
|
// Completed step - checkmark replaces the whole circle
|
|
39
42
|
<motion.div
|
|
@@ -71,7 +74,7 @@ export function StepProgress({
|
|
|
71
74
|
))}
|
|
72
75
|
</div>
|
|
73
76
|
)}
|
|
74
|
-
|
|
77
|
+
</React.Fragment>
|
|
75
78
|
))}
|
|
76
79
|
</div>
|
|
77
80
|
|
|
@@ -83,8 +86,15 @@ export function StepProgress({
|
|
|
83
86
|
transition={{ delay: 0.3 }}
|
|
84
87
|
className="text-center"
|
|
85
88
|
>
|
|
86
|
-
<h2 className="text-as-primary text-xl font-semibold">
|
|
87
|
-
|
|
89
|
+
<h2 className="text-as-primary text-xl font-semibold">
|
|
90
|
+
<TextMorph>{currentStep.title}</TextMorph>
|
|
91
|
+
</h2>
|
|
92
|
+
{currentStep.description && (
|
|
93
|
+
<p className="text-as-tertiary mt-1 flex items-center justify-center gap-1.5 text-sm">
|
|
94
|
+
{currentStep.icon}
|
|
95
|
+
<TextMorph>{currentStep.description}</TextMorph>
|
|
96
|
+
</p>
|
|
97
|
+
)}
|
|
88
98
|
</motion.div>
|
|
89
99
|
)}
|
|
90
100
|
</div>
|
|
@@ -11,9 +11,8 @@ import { useMemo } from "react";
|
|
|
11
11
|
|
|
12
12
|
import { parseUnits } from "viem";
|
|
13
13
|
import { base } from "viem/chains";
|
|
14
|
-
import { useAccount } from "wagmi";
|
|
15
14
|
import { CreateOrderParams } from "./useAnyspendCreateOrder";
|
|
16
|
-
import { getCachedWalletHeaders } from "./useKycStatus";
|
|
15
|
+
import { getCachedWalletHeaders, useWalletAuthHeaders } from "./useKycStatus";
|
|
17
16
|
import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId";
|
|
18
17
|
|
|
19
18
|
export type OnrampOptions = {
|
|
@@ -42,7 +41,7 @@ export type UseAnyspendCreateOnrampOrderProps = {
|
|
|
42
41
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
|
|
43
42
|
// Get B3 context values
|
|
44
43
|
const { partnerId } = useB3Config();
|
|
45
|
-
const { address } =
|
|
44
|
+
const { address, getHeaders: getWalletAuthHeaders } = useWalletAuthHeaders();
|
|
46
45
|
|
|
47
46
|
// Get validated client reference ID from B3 context
|
|
48
47
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
@@ -86,12 +85,11 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
|
|
|
86
85
|
|
|
87
86
|
// For card payments, include wallet auth headers so the backend can verify
|
|
88
87
|
// KYC by the signing wallet address (may differ from the B3 JWT address).
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
// KycGate pre-caches the headers in the "Continue to Verify" user-gesture.
|
|
88
|
+
// First try cached headers (from KycGate), then sign on-the-fly.
|
|
89
|
+
// The user is already clicking "Continue"/"Pay" so signing here is acceptable.
|
|
92
90
|
let kycWalletHeaders: Record<string, string> | undefined;
|
|
93
91
|
if (onramp.vendor === "stripe-web2" && address) {
|
|
94
|
-
kycWalletHeaders = getCachedWalletHeaders(address);
|
|
92
|
+
kycWalletHeaders = getCachedWalletHeaders(address) || (await getWalletAuthHeaders());
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
return await anyspendService.createOrder({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { ANYSPEND_MAINNET_BASE_URL } from "@b3dotfun/sdk/anyspend/constants";
|
|
4
|
+
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
4
5
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
6
|
import { useCallback } from "react";
|
|
6
|
-
import { useAccount, useSignMessage } from "wagmi";
|
|
7
7
|
|
|
8
8
|
export interface KycStatusResponse {
|
|
9
9
|
kycRequired: boolean;
|
|
@@ -46,14 +46,17 @@ export function getCachedWalletHeaders(address: string): Record<string, string>
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Returns a function that builds the wallet-signature auth headers.
|
|
49
|
+
* Uses useAccountWallet (thirdweb) instead of wagmi so signing works
|
|
50
|
+
* for all wallet types (social login, EOA, smart wallet, etc.).
|
|
49
51
|
* Caches signatures for 4 minutes (server allows 5-minute window).
|
|
50
52
|
*/
|
|
51
53
|
export function useWalletAuthHeaders() {
|
|
52
|
-
const { address } =
|
|
53
|
-
const
|
|
54
|
+
const { address, wallet } = useAccountWallet();
|
|
55
|
+
const signMessage = wallet.signMessage;
|
|
54
56
|
|
|
55
57
|
const getHeaders = useCallback(async (): Promise<Record<string, string>> => {
|
|
56
58
|
if (!address) throw new Error("No wallet connected");
|
|
59
|
+
if (!signMessage) throw new Error("Wallet does not support message signing");
|
|
57
60
|
const walletAddress = address.toLowerCase();
|
|
58
61
|
|
|
59
62
|
const cached = headerCache.get(walletAddress);
|
|
@@ -61,7 +64,7 @@ export function useWalletAuthHeaders() {
|
|
|
61
64
|
|
|
62
65
|
const timestamp = Math.floor(Date.now() / 1000);
|
|
63
66
|
const message = buildWalletAuthMessage(walletAddress, timestamp);
|
|
64
|
-
const signature = await
|
|
67
|
+
const signature = await signMessage({ message });
|
|
65
68
|
|
|
66
69
|
const headers = {
|
|
67
70
|
"X-Wallet-Address": walletAddress,
|
|
@@ -71,7 +74,7 @@ export function useWalletAuthHeaders() {
|
|
|
71
74
|
// Cache for 4 minutes so repeated fetches don't re-prompt the user
|
|
72
75
|
headerCache.set(walletAddress, { headers, expiresAt: Date.now() + 4 * 60 * 1000 });
|
|
73
76
|
return headers;
|
|
74
|
-
}, [address,
|
|
77
|
+
}, [address, signMessage]);
|
|
75
78
|
|
|
76
79
|
return { address, getHeaders };
|
|
77
80
|
}
|
package/src/app.shared.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { ClientApplication } from "@b3dotfun/b3-api";
|
|
|
2
2
|
import { AuthenticationClient } from "@feathersjs/authentication-client";
|
|
3
3
|
import Cookies from "js-cookie";
|
|
4
4
|
import { B3_AUTH_COOKIE_NAME } from "./shared/constants";
|
|
5
|
+
import { getSessionDurationDays } from "./shared/utils/session-duration";
|
|
5
6
|
|
|
6
7
|
export const B3_API_URL =
|
|
7
8
|
process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
|
|
8
9
|
|
|
9
|
-
const DEV_USER_GROUP = 4;
|
|
10
|
-
|
|
11
10
|
export const authenticate = async (
|
|
12
11
|
app: ClientApplication,
|
|
13
12
|
accessToken: string,
|
|
@@ -33,12 +32,14 @@ export const authenticate = async (
|
|
|
33
32
|
},
|
|
34
33
|
);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
const token = Cookies.get(B3_AUTH_COOKIE_NAME);
|
|
36
|
+
if (token) {
|
|
37
|
+
const days = getSessionDurationDays(response?.user?.preferences, params?.partnerId);
|
|
38
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, token, {
|
|
39
|
+
...(days > 0 ? { expires: days } : {}),
|
|
40
|
+
secure: true,
|
|
41
|
+
sameSite: "Lax",
|
|
42
|
+
});
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
return response;
|
|
@@ -73,12 +73,6 @@ export const resetSocket = () => {
|
|
|
73
73
|
// reset the socket connection
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export function extractAvatarIdFromUrl(url: string): string | null {
|
|
77
|
-
const regex = /https:\/\/models\.readyplayer\.me\/([a-f0-9]{24})\.[a-zA-Z0-9]+/;
|
|
78
|
-
const match = url.match(regex);
|
|
79
|
-
return match ? match[1] : null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
export const authenticateWithB3JWT = async (fullToken: string, params?: Record<string, any>) => {
|
|
83
77
|
// Do not authenticate if there is no token
|
|
84
78
|
if (!fullToken) {
|