@b3dotfun/sdk 0.1.69 → 0.1.70-alpha.1
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/constants/rpc.d.ts +1 -1
- package/dist/cjs/anyspend/constants/rpc.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +12 -4
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +7 -3
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +4 -4
- 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/AnySpendStakeUpside.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/cjs/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/cjs/anyspend/react/components/checkout/CartSummary.js +13 -11
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutCartPanel.js +5 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutFormPanel.js +2 -2
- 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/CryptoPayPanel.js +43 -23
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/DiscountCodeInput.js +3 -6
- 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/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/cjs/anyspend/react/components/checkout/PriceSkeleton.js +9 -0
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/ShippingSelector.js +3 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +10 -9
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- 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/components/common/TransferCryptoDetails.js +2 -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/anyspend/utils/chain.js +8 -7
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/better-auth-client.d.ts +1883 -0
- package/dist/cjs/global-account/better-auth-client.js +17 -0
- 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/AvatarEditor/AvatarEditor.js +3 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +27 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +11 -13
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -8
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +17 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthClientProvider.js +31 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +121 -0
- 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/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/cjs/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +4 -2
- package/dist/cjs/global-account/react/components/ManageAccount/Header.js +36 -4
- package/dist/cjs/global-account/react/components/ManageAccount/HomeContent.js +4 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +6 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +17 -6
- 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 +14 -29
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +27 -16
- package/dist/cjs/global-account/react/components/Send/Send.js +5 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +68 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +39 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +173 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +85 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +14 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +14 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/components/PasswordInput.d.ts +10 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/components/PasswordInput.js +10 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +8 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +141 -0
- 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 +20 -3
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- 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/components/UserAvatar/UserAvatar.d.ts +18 -0
- package/dist/cjs/global-account/react/components/UserAvatar/UserAvatar.js +27 -0
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +6 -0
- package/dist/cjs/global-account/react/components/index.js +14 -3
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +5 -2
- 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/useAutoSelectWallet.d.ts +6 -3
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.js +31 -3
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +159 -0
- 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 +14 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -24
- 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/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/cjs/shared/constants/chains/b3Chain.js +4 -4
- package/dist/cjs/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/cjs/shared/constants/chains/b3Viem.js +19 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -1
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/cjs/shared/generated/chain-networks.json +2 -2
- package/dist/cjs/shared/utils/chains.d.ts +1 -1
- package/dist/cjs/shared/utils/chains.js +2 -2
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +1 -1
- package/dist/esm/anyspend/constants/rpc.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +12 -4
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +7 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +4 -4
- 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/AnySpendStakeUpside.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/esm/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/esm/anyspend/react/components/checkout/CartSummary.js +13 -11
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutCartPanel.js +5 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutFormPanel.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/CryptoPayPanel.js +44 -24
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/DiscountCodeInput.js +3 -6
- 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/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/esm/anyspend/react/components/checkout/PriceSkeleton.js +6 -0
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/ShippingSelector.js +3 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -8
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -3
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- 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/components/common/TransferCryptoDetails.js +2 -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/anyspend/utils/chain.js +10 -9
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/better-auth-client.d.ts +1883 -0
- package/dist/esm/global-account/better-auth-client.js +13 -0
- 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/AvatarEditor/AvatarEditor.js +3 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +3 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +27 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +6 -8
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +4 -6
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +17 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthClientProvider.js +27 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +116 -0
- 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/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +5 -3
- package/dist/esm/global-account/react/components/ManageAccount/Header.js +37 -5
- package/dist/esm/global-account/react/components/ManageAccount/HomeContent.js +4 -1
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +7 -1
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +16 -8
- 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 +16 -31
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +27 -16
- package/dist/esm/global-account/react/components/Send/Send.js +5 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +65 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +39 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +170 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +82 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +15 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +14 -5
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/components/PasswordInput.d.ts +10 -0
- package/dist/esm/global-account/react/components/SignInWithB3/components/PasswordInput.js +7 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +8 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +138 -0
- 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 +19 -2
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -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/components/UserAvatar/UserAvatar.d.ts +18 -0
- package/dist/esm/global-account/react/components/UserAvatar/UserAvatar.js +21 -0
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +6 -0
- package/dist/esm/global-account/react/components/index.js +6 -0
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- 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/useAutoSelectWallet.d.ts +6 -3
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.js +33 -5
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +151 -0
- 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 +14 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -23
- 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/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -4
- package/dist/esm/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/esm/shared/constants/chains/b3Viem.js +16 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -1
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/esm/shared/generated/chain-networks.json +2 -2
- package/dist/esm/shared/utils/chains.d.ts +1 -1
- package/dist/esm/shared/utils/chains.js +2 -2
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CartItemRow.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/CartSummary.d.ts +6 -4
- package/dist/types/anyspend/react/components/checkout/CheckoutCartPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutFormPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/DiscountCodeInput.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/PriceSkeleton.d.ts +5 -0
- package/dist/types/anyspend/react/components/checkout/ShippingSelector.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- 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/better-auth-client.d.ts +1883 -0
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +8 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +27 -2
- package/dist/types/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +17 -0
- package/dist/types/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.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/BetterAuthResetPassword.d.ts +21 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +39 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/components/PasswordInput.d.ts +10 -0
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +8 -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/components/UserAvatar/UserAvatar.d.ts +18 -0
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +6 -0
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useAutoSelectWallet.d.ts +6 -3
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +973 -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 +14 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -31
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/types/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/types/shared/constants/chains/supported.d.ts +1 -1
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/dist/types/shared/utils/chains.d.ts +1 -1
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +15 -6
- package/src/anyspend/constants/rpc.ts +2 -1
- package/src/anyspend/react/components/AnySpend.tsx +24 -12
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +6 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +12 -2
- package/src/anyspend/react/components/AnySpendDeposit.tsx +38 -31
- package/src/anyspend/react/components/AnySpendNFT.tsx +6 -2
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +4 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +25 -5
- package/src/anyspend/react/components/checkout/CartItemRow.tsx +2 -1
- package/src/anyspend/react/components/checkout/CartSummary.tsx +24 -20
- package/src/anyspend/react/components/checkout/CheckoutCartPanel.tsx +12 -3
- package/src/anyspend/react/components/checkout/CheckoutFormPanel.tsx +5 -0
- 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/CryptoPayPanel.tsx +45 -27
- package/src/anyspend/react/components/checkout/DiscountCodeInput.tsx +15 -5
- 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/checkout/PriceSkeleton.tsx +19 -0
- package/src/anyspend/react/components/checkout/ShippingSelector.tsx +5 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +10 -8
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +10 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +4 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +38 -3
- package/src/anyspend/react/components/common/StepProgress.tsx +15 -5
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -7
- package/src/anyspend/react/hooks/useKycStatus.ts +8 -5
- package/src/anyspend/utils/chain.ts +9 -9
- package/src/app.shared.ts +9 -8
- package/src/global-account/better-auth-client.ts +17 -0
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +3 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -2
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +4 -0
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +12 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +16 -21
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +78 -38
- package/src/global-account/react/components/B3Provider/BetterAuthClientProvider.tsx +40 -0
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +128 -0
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +17 -10
- package/src/global-account/react/components/LinkAccount/LinkedAccountItem.tsx +2 -1
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +18 -14
- package/src/global-account/react/components/ManageAccount/Header.tsx +71 -4
- package/src/global-account/react/components/ManageAccount/HomeContent.tsx +25 -19
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +13 -0
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +40 -15
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +35 -54
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +31 -22
- package/src/global-account/react/components/Send/Send.tsx +8 -5
- package/src/global-account/react/components/SignInWithB3/BetterAuthResetPassword.tsx +145 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +446 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.tsx +155 -0
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +42 -13
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +20 -4
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/components/PasswordInput.tsx +62 -0
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +315 -0
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +207 -54
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +24 -4
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +2 -1
- package/src/global-account/react/components/Toast/ToastContext.tsx +39 -7
- package/src/global-account/react/components/UserAvatar/UserAvatar.tsx +45 -0
- package/src/global-account/react/components/index.ts +12 -0
- package/src/global-account/react/hooks/index.ts +1 -0
- 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/useAutoSelectWallet.ts +40 -6
- package/src/global-account/react/hooks/useBetterAuth.ts +193 -0
- 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 +15 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -25
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/global-account/react/utils/profileDisplay.ts +21 -19
- package/src/shared/constants/chains/b3Chain.ts +5 -5
- package/src/shared/constants/chains/b3Viem.ts +18 -0
- package/src/shared/constants/index.ts +2 -0
- package/src/shared/generated/chain-networks.json +2 -2
- package/src/shared/utils/chains.ts +3 -2
- package/src/shared/utils/session-duration.ts +64 -0
- package/src/types/torph.d.ts +4 -0
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -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
|
@@ -6,7 +6,7 @@ import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
7
|
import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
8
8
|
import { getConnectors } from "@wagmi/core";
|
|
9
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
9
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import {
|
|
11
11
|
useActiveWallet,
|
|
12
12
|
useAutoConnect,
|
|
@@ -18,7 +18,7 @@ import { Wallet, ecosystemWallet } from "thirdweb/wallets";
|
|
|
18
18
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
19
19
|
import { useAccount, useConnect, useSwitchAccount } from "wagmi";
|
|
20
20
|
import { LocalSDKContext } from "../components/B3Provider/LocalSDKProvider";
|
|
21
|
-
import {
|
|
21
|
+
import { createWagmiConfig } from "../utils/createWagmiConfig";
|
|
22
22
|
import { useSearchParam } from "./useSearchParamsSSR";
|
|
23
23
|
import { useUserQuery } from "./useUserQuery";
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ const debug = debugB3React("useAuth");
|
|
|
30
30
|
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
31
31
|
*/
|
|
32
32
|
export function useAuth() {
|
|
33
|
-
const { onConnectCallback } = useContext(LocalSDKContext);
|
|
33
|
+
const { onConnectCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
34
34
|
const { disconnect } = useDisconnect();
|
|
35
35
|
const wallets = useConnectedWallets();
|
|
36
36
|
const activeWallet = useActiveWallet();
|
|
@@ -47,7 +47,7 @@ export function useAuth() {
|
|
|
47
47
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
48
48
|
const referralCode = useSearchParam("referralCode");
|
|
49
49
|
const { partnerId } = useB3Config();
|
|
50
|
-
const wagmiConfig =
|
|
50
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
51
51
|
const { connect } = useConnect();
|
|
52
52
|
const activeWagmiAccount = useAccount();
|
|
53
53
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -76,8 +76,10 @@ export function useAuth() {
|
|
|
76
76
|
|
|
77
77
|
// Authenticate with BSMNT
|
|
78
78
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (!disableBSMNTAuthentication) {
|
|
80
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
81
|
+
debug("BSMNT re-authentication successful", b3Jwt);
|
|
82
|
+
}
|
|
81
83
|
} catch (bsmntError) {
|
|
82
84
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
83
85
|
debug("BSMNT re-authentication failed (non-critical)", bsmntError);
|
|
@@ -88,7 +90,7 @@ export function useAuth() {
|
|
|
88
90
|
debug("Re-authentication failed", err);
|
|
89
91
|
throw err;
|
|
90
92
|
}
|
|
91
|
-
}, [setUser]);
|
|
93
|
+
}, [setUser, disableBSMNTAuthentication]);
|
|
92
94
|
|
|
93
95
|
const syncWagmi = useCallback(async () => {
|
|
94
96
|
function syncWagmiFunc() {
|
|
@@ -136,9 +138,7 @@ export function useAuth() {
|
|
|
136
138
|
});
|
|
137
139
|
}
|
|
138
140
|
syncWagmiFunc();
|
|
139
|
-
|
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
}, [partnerId, wallets]);
|
|
141
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
142
142
|
|
|
143
143
|
useEffect(() => {
|
|
144
144
|
syncWagmi();
|
|
@@ -159,9 +159,11 @@ export function useAuth() {
|
|
|
159
159
|
setIsAuthenticating(false);
|
|
160
160
|
debug("Re-authenticated successfully", { userAuth });
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
if (!disableBSMNTAuthentication) {
|
|
163
|
+
// Authenticate on BSMNT with B3 JWT
|
|
164
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
165
|
+
debug("@@b3Jwt", b3Jwt);
|
|
166
|
+
}
|
|
165
167
|
|
|
166
168
|
return userAuth;
|
|
167
169
|
} catch (error) {
|
|
@@ -171,7 +173,14 @@ export function useAuth() {
|
|
|
171
173
|
setIsAuthenticating(false);
|
|
172
174
|
throw new Error("Authentication required. Please authenticate.");
|
|
173
175
|
}
|
|
174
|
-
}, [
|
|
176
|
+
}, [
|
|
177
|
+
reAuthenticate,
|
|
178
|
+
setIsAuthenticated,
|
|
179
|
+
setIsAuthenticating,
|
|
180
|
+
setUser,
|
|
181
|
+
setHasStartedConnecting,
|
|
182
|
+
disableBSMNTAuthentication,
|
|
183
|
+
]);
|
|
175
184
|
|
|
176
185
|
/**
|
|
177
186
|
* Authenticate with B3
|
|
@@ -208,8 +217,10 @@ export function useAuth() {
|
|
|
208
217
|
|
|
209
218
|
// Step 3: Authenticate with BSMNT for basement integration
|
|
210
219
|
try {
|
|
211
|
-
|
|
212
|
-
|
|
220
|
+
if (!disableBSMNTAuthentication) {
|
|
221
|
+
const b3Jwt = await authenticateWithB3JWT(response.accessToken);
|
|
222
|
+
debug("BSMNT authentication successful", b3Jwt);
|
|
223
|
+
}
|
|
213
224
|
} catch (bsmntError) {
|
|
214
225
|
// BSMNT authentication failure shouldn't block the main auth flow
|
|
215
226
|
debug("BSMNT authentication failed (non-critical)", bsmntError);
|
|
@@ -221,7 +232,7 @@ export function useAuth() {
|
|
|
221
232
|
throw err;
|
|
222
233
|
}
|
|
223
234
|
},
|
|
224
|
-
[referralCode, setUser],
|
|
235
|
+
[referralCode, setUser, disableBSMNTAuthentication],
|
|
225
236
|
);
|
|
226
237
|
|
|
227
238
|
/**
|
|
@@ -6,7 +6,7 @@ import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
7
|
import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
8
8
|
import { getConnectors } from "@wagmi/core";
|
|
9
|
-
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
9
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import {
|
|
11
11
|
useActiveWallet,
|
|
12
12
|
useAutoConnect,
|
|
@@ -25,7 +25,7 @@ import { useUserQuery } from "./useUserQuery";
|
|
|
25
25
|
const debug = debugB3React("useAuthentication");
|
|
26
26
|
|
|
27
27
|
export function useAuthentication(partnerId: string, { skipAutoConnect = false }: { skipAutoConnect?: boolean } = {}) {
|
|
28
|
-
const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
|
|
28
|
+
const { onConnectCallback, onLogoutCallback, disableBSMNTAuthentication } = useContext(LocalSDKContext);
|
|
29
29
|
const { disconnect } = useDisconnect();
|
|
30
30
|
const wallets = useConnectedWallets();
|
|
31
31
|
// Keep refs so logout() always disconnects current wallets, not stale closure values.
|
|
@@ -57,7 +57,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
57
57
|
const { authenticate } = useTWAuth();
|
|
58
58
|
const { user, setUser } = useUserQuery();
|
|
59
59
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
60
|
-
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
60
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId }), [partnerId]);
|
|
61
61
|
const { connect } = useConnect();
|
|
62
62
|
const activeWagmiAccount = useAccount();
|
|
63
63
|
const { switchAccount } = useSwitchAccount();
|
|
@@ -113,9 +113,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
syncWagmiFunc();
|
|
116
|
-
|
|
117
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
-
}, [partnerId, wallets]);
|
|
116
|
+
}, [wagmiConfig, wallets, connect, switchAccount]);
|
|
119
117
|
|
|
120
118
|
useEffect(() => {
|
|
121
119
|
syncWagmi();
|
|
@@ -142,9 +140,11 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
142
140
|
setIsAuthenticating(false);
|
|
143
141
|
debug("Re-authenticated successfully", { userAuth });
|
|
144
142
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
if (!disableBSMNTAuthentication) {
|
|
144
|
+
// Authenticate on BSMNT with B3 JWT
|
|
145
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
146
|
+
debug("@@b3Jwt", b3Jwt);
|
|
147
|
+
}
|
|
148
148
|
|
|
149
149
|
return userAuth;
|
|
150
150
|
} catch (error) {
|
|
@@ -156,14 +156,25 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
156
156
|
setIsAuthenticating(false);
|
|
157
157
|
debug("Fresh authentication successful", { userAuth });
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
if (!disableBSMNTAuthentication) {
|
|
160
|
+
// Authenticate on BSMNT with B3 JWT
|
|
161
|
+
const b3Jwt = await authenticateWithB3JWT(userAuth.accessToken);
|
|
162
|
+
debug("@@b3Jwt", b3Jwt);
|
|
163
|
+
}
|
|
162
164
|
|
|
163
165
|
return userAuth;
|
|
164
166
|
}
|
|
165
167
|
},
|
|
166
|
-
[
|
|
168
|
+
[
|
|
169
|
+
activeWallet,
|
|
170
|
+
partnerId,
|
|
171
|
+
authenticate,
|
|
172
|
+
setIsAuthenticated,
|
|
173
|
+
setIsAuthenticating,
|
|
174
|
+
setUser,
|
|
175
|
+
setHasStartedConnecting,
|
|
176
|
+
disableBSMNTAuthentication,
|
|
177
|
+
],
|
|
167
178
|
);
|
|
168
179
|
|
|
169
180
|
const logout = useCallback(
|
|
@@ -1,19 +1,53 @@
|
|
|
1
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
1
2
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
2
|
-
import { useCallback, useEffect } from "react";
|
|
3
|
-
import { getLastAuthProvider, useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
4
|
-
import { Wallet } from "thirdweb/wallets";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { getLastAuthProvider, useAddConnectedWallet, useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
5
|
+
import { EIP1193, Wallet } from "thirdweb/wallets";
|
|
5
6
|
import { useAuthStore } from "../stores";
|
|
6
7
|
|
|
7
8
|
const debug = debugB3React("useAutoSelectWallet");
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Hook to automatically
|
|
11
|
-
*
|
|
11
|
+
* Hook to automatically connect a default EOA provider (if given) and
|
|
12
|
+
* select the first EOA wallet when user is authenticated.
|
|
13
|
+
* Only auto-selects if the last auth was via wallet or no previous auth provider.
|
|
12
14
|
*/
|
|
13
|
-
export function useAutoSelectWallet({
|
|
15
|
+
export function useAutoSelectWallet({
|
|
16
|
+
enabled,
|
|
17
|
+
defaultEoaProvider,
|
|
18
|
+
}: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
defaultEoaProvider?: EIP1193.EIP1193Provider;
|
|
21
|
+
}) {
|
|
14
22
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
15
23
|
const wallets = useConnectedWallets();
|
|
16
24
|
const setActiveWallet = useSetActiveWallet();
|
|
25
|
+
const addConnectedWallet = useAddConnectedWallet();
|
|
26
|
+
const hasConnectedProvider = useRef(false);
|
|
27
|
+
|
|
28
|
+
// Auto-connect the default EOA provider (e.g. Farcaster frame wallet) on mount.
|
|
29
|
+
// Uses useAddConnectedWallet instead of useConnect so the wallet is added to
|
|
30
|
+
// connectedWallets WITHOUT becoming the active wallet. This prevents
|
|
31
|
+
// useAuthentication's logout/onTimeout from disconnecting it (logout only
|
|
32
|
+
// disconnects ecosystem wallets and the active wallet).
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!defaultEoaProvider || hasConnectedProvider.current) return;
|
|
35
|
+
hasConnectedProvider.current = true;
|
|
36
|
+
|
|
37
|
+
const connectDefaultProvider = async () => {
|
|
38
|
+
try {
|
|
39
|
+
const wallet = EIP1193.fromProvider({ provider: defaultEoaProvider });
|
|
40
|
+
await wallet.connect({ client });
|
|
41
|
+
addConnectedWallet(wallet);
|
|
42
|
+
debug("Auto-connected default EOA provider", wallet.id);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
debug("Failed to auto-connect default EOA provider", error);
|
|
45
|
+
hasConnectedProvider.current = false;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
connectDefaultProvider();
|
|
50
|
+
}, [defaultEoaProvider, addConnectedWallet]);
|
|
17
51
|
|
|
18
52
|
const setWallet = useCallback(
|
|
19
53
|
(wallet: Wallet) => {
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
+
import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
import { useBetterAuthClient } from "../components/B3Provider/BetterAuthClientProvider";
|
|
6
|
+
import { useUserQuery } from "./useUserQuery";
|
|
7
|
+
|
|
8
|
+
const debug = debugB3React("useBetterAuth");
|
|
9
|
+
|
|
10
|
+
export type BetterAuthSocialProvider = "google" | "discord" | "apple" | "github" | "slack" | "microsoft";
|
|
11
|
+
|
|
12
|
+
/** Thrown when email verification is required before the user can sign in. */
|
|
13
|
+
export class EmailVerificationRequiredError extends Error {
|
|
14
|
+
constructor(message = "Check your email to verify your account before signing in.") {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "EmailVerificationRequiredError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hook for authentication via Better Auth (email/password + social providers).
|
|
22
|
+
*
|
|
23
|
+
* Follows the same pattern as Thirdweb auth:
|
|
24
|
+
* 1. Better Auth sign-in returns a session token
|
|
25
|
+
* 2. Token is passed as accessToken to app.authenticate({ strategy: "better-auth" })
|
|
26
|
+
* 3. BetterAuthStrategy verifies the token and issues a Feathers JWT
|
|
27
|
+
*/
|
|
28
|
+
export function useBetterAuth() {
|
|
29
|
+
const { partnerId } = useB3Config();
|
|
30
|
+
const betterAuthClient = useBetterAuthClient();
|
|
31
|
+
const { setUser } = useUserQuery();
|
|
32
|
+
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
33
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
34
|
+
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
35
|
+
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
36
|
+
|
|
37
|
+
const exchangeForFeathersJWT = useCallback(
|
|
38
|
+
async (sessionToken: string) => {
|
|
39
|
+
debug("Exchanging Better Auth token for Feathers JWT");
|
|
40
|
+
|
|
41
|
+
const response = await app.authenticate({
|
|
42
|
+
strategy: "better-auth",
|
|
43
|
+
accessToken: sessionToken,
|
|
44
|
+
partnerId,
|
|
45
|
+
} as any);
|
|
46
|
+
|
|
47
|
+
if (!response.user) {
|
|
48
|
+
throw new Error("No user returned from authentication");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setUser(response.user);
|
|
52
|
+
setIsAuthenticated(true);
|
|
53
|
+
setIsConnected(true);
|
|
54
|
+
setIsAuthenticating(false);
|
|
55
|
+
|
|
56
|
+
debug("Feathers JWT exchange successful", { userId: response.user?.userId });
|
|
57
|
+
return response;
|
|
58
|
+
},
|
|
59
|
+
[partnerId, setUser, setIsAuthenticated, setIsConnected, setIsAuthenticating],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const signInWithEmail = useCallback(
|
|
63
|
+
async (email: string, password: string) => {
|
|
64
|
+
debug("Signing in with email", { email });
|
|
65
|
+
setHasStartedConnecting(true);
|
|
66
|
+
setIsAuthenticating(true);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const result = await betterAuthClient.signIn.email({ email, password });
|
|
70
|
+
|
|
71
|
+
if (result.error) {
|
|
72
|
+
throw new Error(result.error.message || "Sign in failed");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const token = result.data?.token;
|
|
76
|
+
if (!token) {
|
|
77
|
+
throw new Error("No session token returned from sign in");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return await exchangeForFeathersJWT(token);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
setIsAuthenticating(false);
|
|
83
|
+
debug("Sign in failed", error);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[exchangeForFeathersJWT, setIsAuthenticating, setHasStartedConnecting, betterAuthClient],
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const signUpWithEmail = useCallback(
|
|
91
|
+
async (email: string, password: string, name: string, verifyCallbackURL?: string) => {
|
|
92
|
+
debug("Signing up with email", { email, name });
|
|
93
|
+
setHasStartedConnecting(true);
|
|
94
|
+
setIsAuthenticating(true);
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const result = await betterAuthClient.signUp.email({ email, password, name });
|
|
98
|
+
|
|
99
|
+
if (result.error) {
|
|
100
|
+
throw new Error(result.error.message || "Sign up failed");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const token = result.data?.token;
|
|
104
|
+
if (!token) {
|
|
105
|
+
// requireEmailVerification is enabled — send verification email with
|
|
106
|
+
// a callbackURL Better Auth redirects to after server-side verify.
|
|
107
|
+
// Pass verifyCallbackURL to land on a dedicated confirmation page.
|
|
108
|
+
await betterAuthClient.sendVerificationEmail({
|
|
109
|
+
email,
|
|
110
|
+
callbackURL: verifyCallbackURL || `${window.location.origin}?authStrategy=better-auth`,
|
|
111
|
+
});
|
|
112
|
+
throw new EmailVerificationRequiredError();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return await exchangeForFeathersJWT(token);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
setIsAuthenticating(false);
|
|
118
|
+
debug("Sign up failed", error);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[exchangeForFeathersJWT, setIsAuthenticating, setHasStartedConnecting, betterAuthClient],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const signInWithSocial = useCallback(
|
|
126
|
+
async (provider: BetterAuthSocialProvider) => {
|
|
127
|
+
debug("Signing in with social provider", { provider });
|
|
128
|
+
setHasStartedConnecting(true);
|
|
129
|
+
setIsAuthenticating(true);
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const result = await betterAuthClient.signIn.social({
|
|
133
|
+
provider,
|
|
134
|
+
callbackURL: window.location.href,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (result.error) {
|
|
138
|
+
throw new Error(result.error.message || `${provider} sign in failed`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Social auth redirects to provider — JWT exchange happens on callback
|
|
142
|
+
// via BetterAuthProvider session restore
|
|
143
|
+
} catch (error) {
|
|
144
|
+
setIsAuthenticating(false);
|
|
145
|
+
debug("Social sign in failed", error);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
[setIsAuthenticating, setHasStartedConnecting, betterAuthClient],
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const requestPasswordReset = useCallback(async (email: string, redirectTo?: string) => {
|
|
153
|
+
debug("Requesting password reset", { email });
|
|
154
|
+
|
|
155
|
+
const result = await betterAuthClient.requestPasswordReset({
|
|
156
|
+
email,
|
|
157
|
+
redirectTo,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
if (result.error) {
|
|
161
|
+
throw new Error(result.error.message || "Password reset request failed");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
debug("Password reset email sent");
|
|
165
|
+
return result;
|
|
166
|
+
}, [betterAuthClient]);
|
|
167
|
+
|
|
168
|
+
const resetPassword = useCallback(async (newPassword: string, token: string) => {
|
|
169
|
+
debug("Resetting password");
|
|
170
|
+
|
|
171
|
+
const result = await betterAuthClient.resetPassword({
|
|
172
|
+
newPassword,
|
|
173
|
+
token,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (result.error) {
|
|
177
|
+
throw new Error(result.error.message || "Password reset failed");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
debug("Password reset successful");
|
|
181
|
+
return result;
|
|
182
|
+
}, [betterAuthClient]);
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
signInWithEmail,
|
|
186
|
+
signUpWithEmail,
|
|
187
|
+
signInWithSocial,
|
|
188
|
+
requestPasswordReset,
|
|
189
|
+
resetPassword,
|
|
190
|
+
exchangeForFeathersJWT,
|
|
191
|
+
betterAuthClient,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
@@ -4,7 +4,7 @@ import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
|
4
4
|
import { useCallback, useState } from "react";
|
|
5
5
|
import { Chain } from "thirdweb";
|
|
6
6
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
7
|
-
import { ecosystemWallet, SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
7
|
+
import { ecosystemWallet, MultiStepAuthArgsType, SingleStepAuthArgsType } from "thirdweb/wallets";
|
|
8
8
|
const debug = debugB3React("useConnect");
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -23,7 +23,7 @@ export function useConnect(partnerId: string, chain?: Chain) {
|
|
|
23
23
|
* It is used to connect to a wallet using the thirdweb client.
|
|
24
24
|
*/
|
|
25
25
|
const connectTw = useCallback(
|
|
26
|
-
async (strategyOptions?: SingleStepAuthArgsType) => {
|
|
26
|
+
async (strategyOptions?: MultiStepAuthArgsType | SingleStepAuthArgsType) => {
|
|
27
27
|
setIsLoading(true);
|
|
28
28
|
return await connect(async () => {
|
|
29
29
|
if (!strategyOptions) throw new Error("Strategy options are required");
|
|
@@ -12,7 +12,6 @@ import { useSearchParam } from "./useSearchParamsSSR";
|
|
|
12
12
|
* @deprecated Use useAuth() instead
|
|
13
13
|
*/
|
|
14
14
|
export function useTWAuth() {
|
|
15
|
-
console.warn("useTWAuth is deprecated. Please migrate to useAuth() for authentication.");
|
|
16
15
|
const referralCode = useSearchParam("referralCode");
|
|
17
16
|
|
|
18
17
|
const authenticate = useCallback(
|
|
@@ -44,6 +44,8 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
44
44
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
45
45
|
/** Whether to show the signers enabled modal */
|
|
46
46
|
signersEnabled?: boolean;
|
|
47
|
+
/** URL Better Auth redirects to after server-side email verification. */
|
|
48
|
+
verifyEmailRedirectTo?: string;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
/**
|
|
@@ -451,6 +453,16 @@ export interface SendModalProps extends BaseModalProps {
|
|
|
451
453
|
onSuccess?: (txHash?: string) => void;
|
|
452
454
|
}
|
|
453
455
|
|
|
456
|
+
/**
|
|
457
|
+
* Props for the Session Duration modal
|
|
458
|
+
* Allows users to configure how long they stay signed in
|
|
459
|
+
*/
|
|
460
|
+
export interface SessionDurationModalProps extends BaseModalProps {
|
|
461
|
+
type: "sessionDuration";
|
|
462
|
+
partnerId: string;
|
|
463
|
+
chain: Chain;
|
|
464
|
+
}
|
|
465
|
+
|
|
454
466
|
/**
|
|
455
467
|
* Props for the Notifications modal
|
|
456
468
|
* Allows users to manage notification settings and channels
|
|
@@ -625,6 +637,8 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
625
637
|
actionLabel?: string;
|
|
626
638
|
/** Whether to show chain selection step. Defaults to true if sourceTokenChainId is not provided */
|
|
627
639
|
showChainSelection?: boolean;
|
|
640
|
+
/** Whether to show the "Fund with Fiat" option in the deposit options list. Defaults to true */
|
|
641
|
+
showFiatOption?: boolean;
|
|
628
642
|
/** Minimum pool size for filtering tokens (default: 1,000,000) */
|
|
629
643
|
minPoolSize?: number;
|
|
630
644
|
/** Custom title for chain selection step */
|
|
@@ -677,6 +691,7 @@ export type ModalContentType =
|
|
|
677
691
|
| DepositModalProps
|
|
678
692
|
| SendModalProps
|
|
679
693
|
| NotificationsModalProps
|
|
694
|
+
| SessionDurationModalProps
|
|
680
695
|
| AnySpendCollectorClubPurchaseProps
|
|
681
696
|
| AnySpendDepositModalProps
|
|
682
697
|
| AnySpendWorkflowTriggerModalProps
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { createWalletConfig } from "@b3dotfun/sdk/wallet/utils/createWalletConfig";
|
|
1
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
2
|
-
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
3
3
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
4
4
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
5
|
-
import {
|
|
6
|
-
import { createConfig, type CreateConnectorFn } from "wagmi";
|
|
5
|
+
import type { CreateConnectorFn } from "wagmi";
|
|
7
6
|
|
|
8
7
|
export interface CreateWagmiConfigOptions {
|
|
9
8
|
partnerId: string;
|
|
@@ -13,7 +12,8 @@ export interface CreateWagmiConfigOptions {
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* Creates a wagmi config with
|
|
15
|
+
* Creates a wagmi config with the B3 ecosystem wallet connector.
|
|
16
|
+
* Delegates to createWalletConfig and adds the ecosystem connector on top.
|
|
17
17
|
* @param options.partnerId - Partner ID for the ecosystem wallet
|
|
18
18
|
* @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
19
19
|
* @param options.connectors - Additional connectors to include
|
|
@@ -32,27 +32,8 @@ export function createWagmiConfig(options: CreateWagmiConfigOptions) {
|
|
|
32
32
|
|
|
33
33
|
const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
|
|
34
34
|
|
|
35
|
-
return
|
|
36
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
37
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
|
|
35
|
+
return createWalletConfig({
|
|
38
36
|
connectors: finalConnectors,
|
|
37
|
+
rpcUrls,
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
/** Module-level cache — wagmi configs must not be recreated on every render. */
|
|
43
|
-
const wagmiConfigCache = new Map<string, ReturnType<typeof createWagmiConfig>>();
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Returns a cached wagmi config for the given partnerId.
|
|
47
|
-
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
48
|
-
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
49
|
-
*/
|
|
50
|
-
export function getCachedWagmiConfig(options: CreateWagmiConfigOptions) {
|
|
51
|
-
const key = options.partnerId;
|
|
52
|
-
let config = wagmiConfigCache.get(key);
|
|
53
|
-
if (!config) {
|
|
54
|
-
config = createWagmiConfig(options);
|
|
55
|
-
wagmiConfigCache.set(key, config);
|
|
56
|
-
}
|
|
57
|
-
return config;
|
|
58
|
-
}
|
|
@@ -3,6 +3,21 @@ import { type Profile } from "thirdweb/wallets";
|
|
|
3
3
|
|
|
4
4
|
const debug = debugB3React("profileDisplay");
|
|
5
5
|
|
|
6
|
+
const ALLOWED_IPFS_GATEWAYS = [
|
|
7
|
+
"ipfs.io",
|
|
8
|
+
"gateway.pinata.cloud",
|
|
9
|
+
"cloudflare-ipfs.com",
|
|
10
|
+
"dweb.link",
|
|
11
|
+
"nftstorage.link",
|
|
12
|
+
"w3s.link",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const BLOCKED_HOSTNAMES = ["models.readyplayer.me", "readyplayer.me"];
|
|
16
|
+
|
|
17
|
+
function isHostnameInList(hostname: string, list: string[]): boolean {
|
|
18
|
+
return list.some(entry => hostname === entry || hostname.endsWith(`.${entry}`));
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
/**
|
|
7
22
|
* Validates that an image URL uses an allowed schema
|
|
8
23
|
* @param url - The URL to validate
|
|
@@ -31,30 +46,17 @@ export function validateImageUrl(url: string | null | undefined): string | null
|
|
|
31
46
|
return null;
|
|
32
47
|
}
|
|
33
48
|
|
|
34
|
-
// Whitelist of allowed IPFS gateway hostnames
|
|
35
|
-
const allowedIpfsGateways = [
|
|
36
|
-
"ipfs.io",
|
|
37
|
-
"gateway.pinata.cloud",
|
|
38
|
-
"cloudflare-ipfs.com",
|
|
39
|
-
"dweb.link",
|
|
40
|
-
"nftstorage.link",
|
|
41
|
-
"w3s.link",
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
// Check if hostname matches allowed IPFS gateways
|
|
45
49
|
const hostname = parsedUrl.hostname.toLowerCase();
|
|
46
|
-
const isAllowedIpfsGateway = allowedIpfsGateways.some(gateway => {
|
|
47
|
-
// Exact match or subdomain of the gateway
|
|
48
|
-
return hostname === gateway || hostname.endsWith(`.${gateway}`);
|
|
49
|
-
});
|
|
50
50
|
|
|
51
|
-
if (
|
|
51
|
+
if (isHostnameInList(hostname, ALLOWED_IPFS_GATEWAYS)) {
|
|
52
52
|
return url;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (isHostnameInList(hostname, BLOCKED_HOSTNAMES)) {
|
|
56
|
+
debug("Rejected deprecated avatar service:", hostname, url);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
58
60
|
return url;
|
|
59
61
|
} catch (error) {
|
|
60
62
|
// Invalid URL format
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ChainNetworks } from "@b3dotfun/sdk/global-account/types/chain-networks";
|
|
1
2
|
import { defineChain as defineThirdwebChain, Chain as ThirdwebChain } from "thirdweb";
|
|
2
3
|
import { Chain, defineChain } from "viem";
|
|
3
|
-
import { ChainNetworks } from "@b3dotfun/sdk/global-account/types/chain-networks";
|
|
4
4
|
|
|
5
5
|
export const nullAddress = "0x0000000000000000000000000000000000000000";
|
|
6
6
|
|
|
@@ -58,11 +58,11 @@ export const b3Testnet: Chain = defineChain({
|
|
|
58
58
|
export const b3Mainnet = defineChain({
|
|
59
59
|
id: 8333,
|
|
60
60
|
name: "B3",
|
|
61
|
-
rpc: "https://
|
|
61
|
+
rpc: "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2",
|
|
62
62
|
rpcUrls: {
|
|
63
63
|
default: {
|
|
64
|
-
http: ["https://
|
|
65
|
-
ws: ["wss://
|
|
64
|
+
http: ["https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"],
|
|
65
|
+
ws: ["wss://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"],
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
icon: {
|
|
@@ -133,7 +133,7 @@ export const thirdwebB3Testnet: ThirdwebChain = defineThirdwebChain({
|
|
|
133
133
|
export const thirdwebB3Mainnet: ThirdwebChain = defineThirdwebChain({
|
|
134
134
|
id: 8333,
|
|
135
135
|
name: "B3",
|
|
136
|
-
rpc: "https://
|
|
136
|
+
rpc: "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2/",
|
|
137
137
|
icon: {
|
|
138
138
|
url: "https://cdn.b3.fun/b3_logo.svg",
|
|
139
139
|
width: 32,
|