@b3dotfun/sdk 0.1.69 → 0.1.70-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/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/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- 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/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +21 -14
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +12 -6
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- 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.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +3 -3
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +3 -3
- 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/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- 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.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +15 -7
- 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 +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +11 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +10 -13
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -8
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +120 -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 +5 -0
- package/dist/cjs/global-account/react/components/index.js +12 -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 +158 -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 +42 -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/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- 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/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +21 -14
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +13 -7
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- 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.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +4 -4
- 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/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +15 -6
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- 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.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +16 -8
- 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 +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +11 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +5 -8
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +4 -6
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +115 -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 +5 -0
- package/dist/esm/global-account/react/components/index.js +5 -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 +150 -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 +42 -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/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- 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/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.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/CheckoutPaymentPanel.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 +4 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +11 -2
- 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 +5 -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 +42 -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/AnySpendBondKit.tsx +2 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +3 -0
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +6 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +12 -2
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +29 -14
- package/src/anyspend/react/components/AnySpendDeposit.tsx +51 -34
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +3 -0
- package/src/anyspend/react/components/AnySpendNFT.tsx +6 -2
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +5 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +5 -2
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +4 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +3 -0
- package/src/anyspend/react/components/AnySpendWorkflowTrigger.tsx +4 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +3 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +3 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +29 -5
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- 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 +99 -83
- 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 +6 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +16 -21
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +56 -37
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +127 -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 +11 -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 +192 -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 +43 -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
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { Button, Input, Loading, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
EmailVerificationRequiredError,
|
|
6
|
+
type BetterAuthSocialProvider,
|
|
7
|
+
useBetterAuth,
|
|
8
|
+
} from "../../hooks/useBetterAuth";
|
|
9
|
+
import { PasswordInput } from "./components/PasswordInput";
|
|
10
|
+
import { strategyIcons, strategyLabels } from "./utils/signInUtils";
|
|
11
|
+
|
|
12
|
+
const debug = debugB3React("BetterAuthSignIn");
|
|
13
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
14
|
+
|
|
15
|
+
type SocialProviderConfig = { id: BetterAuthSocialProvider; label: string };
|
|
16
|
+
|
|
17
|
+
const DEFAULT_SOCIAL_PROVIDERS: SocialProviderConfig[] = [
|
|
18
|
+
{ id: "google", label: "Google" },
|
|
19
|
+
{ id: "github", label: "GitHub" },
|
|
20
|
+
{ id: "discord", label: "Discord" },
|
|
21
|
+
{ id: "microsoft", label: "Microsoft" },
|
|
22
|
+
{ id: "slack", label: "Slack" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export interface BetterAuthSignInProps {
|
|
26
|
+
/** Title displayed above the form. Default: "Welcome back" for sign-in, "Create an account" for sign-up */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** Subtitle displayed below the title */
|
|
29
|
+
subtitle?: string;
|
|
30
|
+
/** Which social providers to show. Defaults to all. Pass empty array to hide. */
|
|
31
|
+
socialProviders?: BetterAuthSocialProvider[];
|
|
32
|
+
/** Show email/password form. Default: true */
|
|
33
|
+
showEmail?: boolean;
|
|
34
|
+
/** URL to redirect to after password reset link is clicked. Token is appended as ?token=... */
|
|
35
|
+
passwordResetRedirectTo?: string;
|
|
36
|
+
/**
|
|
37
|
+
* URL Better Auth redirects to after server-side email verification. Render
|
|
38
|
+
* `BetterAuthVerifyEmail` at this route so the user gets a confirmation page.
|
|
39
|
+
*/
|
|
40
|
+
verifyEmailRedirectTo?: string;
|
|
41
|
+
/** Called after successful authentication */
|
|
42
|
+
onSuccess?: () => void;
|
|
43
|
+
/** Called on authentication error */
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
/** Optional class name for the root container */
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Standalone inline sign-in component for Better Auth.
|
|
51
|
+
*
|
|
52
|
+
* Renders directly — no modal, no button wrapper. Designed for full-page
|
|
53
|
+
* sign-in layouts (e.g., B3OS web with branding on the left, form on the right).
|
|
54
|
+
*
|
|
55
|
+
* Usage:
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <BetterAuthSignIn
|
|
58
|
+
* socialProviders={["google", "github"]}
|
|
59
|
+
* onSuccess={() => router.push("/dashboard")}
|
|
60
|
+
* />
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function BetterAuthSignIn({
|
|
64
|
+
title,
|
|
65
|
+
subtitle = "Enter your credentials to access your account",
|
|
66
|
+
socialProviders = DEFAULT_SOCIAL_PROVIDERS.map(p => p.id),
|
|
67
|
+
showEmail = true,
|
|
68
|
+
passwordResetRedirectTo,
|
|
69
|
+
verifyEmailRedirectTo,
|
|
70
|
+
onSuccess,
|
|
71
|
+
onError,
|
|
72
|
+
className,
|
|
73
|
+
}: BetterAuthSignInProps) {
|
|
74
|
+
const { signInWithEmail, signUpWithEmail, signInWithSocial, requestPasswordReset } = useBetterAuth();
|
|
75
|
+
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
76
|
+
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
77
|
+
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
78
|
+
|
|
79
|
+
const [mode, setMode] = useState<"sign-in" | "sign-up" | "forgot-password">("sign-in");
|
|
80
|
+
const [email, setEmail] = useState("");
|
|
81
|
+
const [password, setPassword] = useState("");
|
|
82
|
+
const [name, setName] = useState("");
|
|
83
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
84
|
+
const [loadingProvider, setLoadingProvider] = useState<string | null>(null);
|
|
85
|
+
const [error, setError] = useState<string | null>(null);
|
|
86
|
+
const [resetEmailSent, setResetEmailSent] = useState(false);
|
|
87
|
+
const [verificationSent, setVerificationSent] = useState(false);
|
|
88
|
+
|
|
89
|
+
const resolvedTitle =
|
|
90
|
+
title ||
|
|
91
|
+
(mode === "forgot-password" ? "Reset password" : mode === "sign-in" ? "Welcome back" : "Create an account");
|
|
92
|
+
|
|
93
|
+
const resolvedSubtitle =
|
|
94
|
+
mode === "forgot-password"
|
|
95
|
+
? resetEmailSent
|
|
96
|
+
? "We've sent a password reset link to your email"
|
|
97
|
+
: "Enter your email and we'll send you a reset link"
|
|
98
|
+
: subtitle || "Enter your credentials to access your account";
|
|
99
|
+
|
|
100
|
+
const handleForgotPassword = async () => {
|
|
101
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
102
|
+
|
|
103
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
104
|
+
setError("Please enter a valid email address");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
setIsLoading(true);
|
|
110
|
+
setError(null);
|
|
111
|
+
await requestPasswordReset(normalizedEmail, passwordResetRedirectTo);
|
|
112
|
+
setResetEmailSent(true);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
const message = err instanceof Error ? err.message : "Failed to send reset email";
|
|
115
|
+
setError(message);
|
|
116
|
+
} finally {
|
|
117
|
+
setIsLoading(false);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const providers: SocialProviderConfig[] = socialProviders
|
|
122
|
+
.map(id => DEFAULT_SOCIAL_PROVIDERS.find(p => p.id === id))
|
|
123
|
+
.filter((p): p is SocialProviderConfig => !!p);
|
|
124
|
+
|
|
125
|
+
// Show loading during session restore (before any user interaction) to prevent
|
|
126
|
+
// the login form from flashing briefly after OAuth redirect.
|
|
127
|
+
if (isAuthenticating && !hasStartedConnecting) {
|
|
128
|
+
return (
|
|
129
|
+
<div className={`flex w-full max-w-[400px] items-center justify-center px-6 py-20 ${className || ""}`}>
|
|
130
|
+
<Loading variant="primary" size="lg" />
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (isAuthenticated) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const handleEmailSubmit = async () => {
|
|
140
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
141
|
+
|
|
142
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
143
|
+
setError("Please enter a valid email address");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (!password) {
|
|
148
|
+
setError("Please enter a password");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (mode === "sign-up" && !name.trim()) {
|
|
153
|
+
setError("Please enter your name");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
setIsLoading(true);
|
|
159
|
+
setError(null);
|
|
160
|
+
|
|
161
|
+
if (mode === "sign-up") {
|
|
162
|
+
await signUpWithEmail(normalizedEmail, password, name.trim(), verifyEmailRedirectTo);
|
|
163
|
+
} else {
|
|
164
|
+
await signInWithEmail(normalizedEmail, password);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
debug("Auth successful");
|
|
168
|
+
onSuccess?.();
|
|
169
|
+
} catch (err) {
|
|
170
|
+
if (err instanceof EmailVerificationRequiredError) {
|
|
171
|
+
setVerificationSent(true);
|
|
172
|
+
setError(null);
|
|
173
|
+
} else {
|
|
174
|
+
const message = err instanceof Error ? err.message : "Authentication failed";
|
|
175
|
+
setError(message);
|
|
176
|
+
onError?.(err as Error);
|
|
177
|
+
}
|
|
178
|
+
debug("Auth failed", err);
|
|
179
|
+
} finally {
|
|
180
|
+
setPassword("");
|
|
181
|
+
setIsLoading(false);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const handleSocialSignIn = async (provider: BetterAuthSocialProvider) => {
|
|
186
|
+
try {
|
|
187
|
+
setIsLoading(true);
|
|
188
|
+
setLoadingProvider(provider);
|
|
189
|
+
setError(null);
|
|
190
|
+
await signInWithSocial(provider);
|
|
191
|
+
} catch (err) {
|
|
192
|
+
const message = err instanceof Error ? err.message : `Sign in failed`;
|
|
193
|
+
setError(message);
|
|
194
|
+
onError?.(err as Error);
|
|
195
|
+
setIsLoading(false);
|
|
196
|
+
setLoadingProvider(null);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
if (verificationSent) {
|
|
201
|
+
return (
|
|
202
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
203
|
+
<div className="flex flex-col items-center gap-6 text-center">
|
|
204
|
+
<div className="flex h-14 w-14 shrink-0 items-center justify-center rounded-full bg-green-100">
|
|
205
|
+
<svg
|
|
206
|
+
className="h-7 w-7 shrink-0 text-green-600"
|
|
207
|
+
fill="none"
|
|
208
|
+
viewBox="0 0 24 24"
|
|
209
|
+
stroke="currentColor"
|
|
210
|
+
width={28}
|
|
211
|
+
height={28}
|
|
212
|
+
>
|
|
213
|
+
<path
|
|
214
|
+
strokeLinecap="round"
|
|
215
|
+
strokeLinejoin="round"
|
|
216
|
+
strokeWidth={2}
|
|
217
|
+
d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
|
|
218
|
+
/>
|
|
219
|
+
</svg>
|
|
220
|
+
</div>
|
|
221
|
+
<h2 className="text-[22px] font-semibold text-gray-900 dark:text-gray-100">Check your email</h2>
|
|
222
|
+
<p className="text-[15px] text-gray-500 dark:text-gray-400">
|
|
223
|
+
We sent a verification link to <span className="font-medium text-gray-700 dark:text-gray-200">{email}</span>
|
|
224
|
+
. Click the link to verify your account, then come back and sign in.
|
|
225
|
+
</p>
|
|
226
|
+
<button
|
|
227
|
+
onClick={() => {
|
|
228
|
+
setVerificationSent(false);
|
|
229
|
+
setMode("sign-in");
|
|
230
|
+
setPassword("");
|
|
231
|
+
}}
|
|
232
|
+
className="text-[14px] font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
233
|
+
>
|
|
234
|
+
Back to sign in
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
243
|
+
{/* Header */}
|
|
244
|
+
<div className="mb-10 text-center">
|
|
245
|
+
<h1 className="text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100">{resolvedTitle}</h1>
|
|
246
|
+
<p className="mt-3 text-[15px] text-gray-500 dark:text-gray-400">{resolvedSubtitle}</p>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
{/* Forgot password view */}
|
|
250
|
+
{mode === "forgot-password" && (
|
|
251
|
+
<div className="space-y-5">
|
|
252
|
+
{resetEmailSent ? (
|
|
253
|
+
<div className="space-y-4 text-center">
|
|
254
|
+
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100">
|
|
255
|
+
<svg className="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
256
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
257
|
+
</svg>
|
|
258
|
+
</div>
|
|
259
|
+
<p className="text-[15px] text-gray-600 dark:text-gray-300">Check your email for a reset link.</p>
|
|
260
|
+
</div>
|
|
261
|
+
) : (
|
|
262
|
+
<>
|
|
263
|
+
<div>
|
|
264
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
265
|
+
Email
|
|
266
|
+
</label>
|
|
267
|
+
<Input
|
|
268
|
+
type="email"
|
|
269
|
+
placeholder="name@company.com"
|
|
270
|
+
value={email}
|
|
271
|
+
onChange={e => setEmail(e.target.value)}
|
|
272
|
+
disabled={isLoading}
|
|
273
|
+
onKeyDown={e => {
|
|
274
|
+
if (e.key === "Enter") handleForgotPassword();
|
|
275
|
+
}}
|
|
276
|
+
className="h-11 px-4 text-[15px]"
|
|
277
|
+
/>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
{error && <p className="text-sm text-red-500">{error}</p>}
|
|
281
|
+
|
|
282
|
+
<Button
|
|
283
|
+
onClick={handleForgotPassword}
|
|
284
|
+
disabled={isLoading}
|
|
285
|
+
className="h-11 w-full bg-gray-900 text-[15px] font-medium text-white hover:bg-gray-800 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100"
|
|
286
|
+
>
|
|
287
|
+
{isLoading ? "Sending..." : "Send reset link"}
|
|
288
|
+
</Button>
|
|
289
|
+
</>
|
|
290
|
+
)}
|
|
291
|
+
|
|
292
|
+
<p className="mt-8 text-center text-[14px] text-gray-500 dark:text-gray-400">
|
|
293
|
+
<button
|
|
294
|
+
onClick={() => {
|
|
295
|
+
setMode("sign-in");
|
|
296
|
+
setError(null);
|
|
297
|
+
setResetEmailSent(false);
|
|
298
|
+
}}
|
|
299
|
+
className="font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
300
|
+
>
|
|
301
|
+
Back to sign in
|
|
302
|
+
</button>
|
|
303
|
+
</p>
|
|
304
|
+
</div>
|
|
305
|
+
)}
|
|
306
|
+
|
|
307
|
+
{/* Email/Password form */}
|
|
308
|
+
{showEmail && mode !== "forgot-password" && (
|
|
309
|
+
<div className="space-y-5">
|
|
310
|
+
{mode === "sign-up" && (
|
|
311
|
+
<div>
|
|
312
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
313
|
+
Name
|
|
314
|
+
</label>
|
|
315
|
+
<Input
|
|
316
|
+
type="text"
|
|
317
|
+
placeholder="Your name"
|
|
318
|
+
value={name}
|
|
319
|
+
onChange={e => setName(e.target.value)}
|
|
320
|
+
disabled={isLoading}
|
|
321
|
+
className="h-11 px-4 text-[15px]"
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
)}
|
|
325
|
+
|
|
326
|
+
<div>
|
|
327
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
328
|
+
Email
|
|
329
|
+
</label>
|
|
330
|
+
<Input
|
|
331
|
+
type="email"
|
|
332
|
+
placeholder="name@company.com"
|
|
333
|
+
value={email}
|
|
334
|
+
onChange={e => setEmail(e.target.value)}
|
|
335
|
+
disabled={isLoading}
|
|
336
|
+
className="h-11 px-4 text-[15px]"
|
|
337
|
+
/>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<div>
|
|
341
|
+
<div className="mb-2 flex items-center justify-between">
|
|
342
|
+
<label className="block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
343
|
+
Password
|
|
344
|
+
</label>
|
|
345
|
+
{mode === "sign-in" && (
|
|
346
|
+
<button
|
|
347
|
+
type="button"
|
|
348
|
+
onClick={() => {
|
|
349
|
+
setMode("forgot-password");
|
|
350
|
+
setError(null);
|
|
351
|
+
}}
|
|
352
|
+
className="text-xs font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
353
|
+
>
|
|
354
|
+
Forgot password?
|
|
355
|
+
</button>
|
|
356
|
+
)}
|
|
357
|
+
</div>
|
|
358
|
+
<PasswordInput
|
|
359
|
+
key={mode}
|
|
360
|
+
value={password}
|
|
361
|
+
onChange={e => setPassword(e.target.value)}
|
|
362
|
+
disabled={isLoading}
|
|
363
|
+
onKeyDown={e => {
|
|
364
|
+
if (e.key === "Enter") handleEmailSubmit();
|
|
365
|
+
}}
|
|
366
|
+
className="h-11 px-4 pr-11 text-[15px]"
|
|
367
|
+
/>
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
{error && <p className="text-sm text-red-500">{error}</p>}
|
|
371
|
+
|
|
372
|
+
<Button
|
|
373
|
+
onClick={handleEmailSubmit}
|
|
374
|
+
disabled={isLoading}
|
|
375
|
+
className="h-11 w-full bg-gray-900 text-[15px] font-medium text-white hover:bg-gray-800 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100"
|
|
376
|
+
>
|
|
377
|
+
{isLoading ? "Loading..." : mode === "sign-in" ? "Sign in" : "Sign up"}
|
|
378
|
+
</Button>
|
|
379
|
+
</div>
|
|
380
|
+
)}
|
|
381
|
+
|
|
382
|
+
{/* Social providers */}
|
|
383
|
+
{providers.length > 0 && mode !== "forgot-password" && (
|
|
384
|
+
<>
|
|
385
|
+
{showEmail && (
|
|
386
|
+
<div className="my-8 flex items-center gap-4">
|
|
387
|
+
<div className="h-px flex-1 bg-gray-200 dark:bg-gray-700" />
|
|
388
|
+
<span className="text-xs text-gray-400">Or continue with</span>
|
|
389
|
+
<div className="h-px flex-1 bg-gray-200 dark:bg-gray-700" />
|
|
390
|
+
</div>
|
|
391
|
+
)}
|
|
392
|
+
|
|
393
|
+
<div className="space-y-4">
|
|
394
|
+
{providers.map(provider => {
|
|
395
|
+
const icon = strategyIcons[provider.id];
|
|
396
|
+
const label = strategyLabels[provider.id] || provider.label;
|
|
397
|
+
|
|
398
|
+
const isProviderLoading = loadingProvider === provider.id;
|
|
399
|
+
|
|
400
|
+
return (
|
|
401
|
+
<button
|
|
402
|
+
key={provider.id}
|
|
403
|
+
onClick={() => handleSocialSignIn(provider.id)}
|
|
404
|
+
disabled={isLoading}
|
|
405
|
+
style={{ paddingTop: "12px", paddingBottom: "12px" }}
|
|
406
|
+
className="flex w-full items-center justify-center gap-3 rounded-lg border border-gray-200 bg-white px-4 text-[14px] font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700"
|
|
407
|
+
>
|
|
408
|
+
{isProviderLoading ? (
|
|
409
|
+
<svg className="h-5 w-5 animate-spin text-gray-400" viewBox="0 0 24 24" fill="none">
|
|
410
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
411
|
+
<path
|
|
412
|
+
className="opacity-75"
|
|
413
|
+
fill="currentColor"
|
|
414
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
415
|
+
/>
|
|
416
|
+
</svg>
|
|
417
|
+
) : (
|
|
418
|
+
icon && <img src={icon} alt="" className="h-5 w-5" />
|
|
419
|
+
)}
|
|
420
|
+
<span>{isProviderLoading ? "Redirecting..." : label}</span>
|
|
421
|
+
</button>
|
|
422
|
+
);
|
|
423
|
+
})}
|
|
424
|
+
</div>
|
|
425
|
+
</>
|
|
426
|
+
)}
|
|
427
|
+
|
|
428
|
+
{/* Toggle sign-in / sign-up */}
|
|
429
|
+
{showEmail && mode !== "forgot-password" && (
|
|
430
|
+
<p className="mt-8 text-center text-[14px] text-gray-500 dark:text-gray-400">
|
|
431
|
+
{mode === "sign-in" ? "Don't have an account? " : "Already have an account? "}
|
|
432
|
+
<button
|
|
433
|
+
onClick={() => {
|
|
434
|
+
setMode(mode === "sign-in" ? "sign-up" : "sign-in");
|
|
435
|
+
setError(null);
|
|
436
|
+
}}
|
|
437
|
+
disabled={isLoading}
|
|
438
|
+
className="font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
439
|
+
>
|
|
440
|
+
{mode === "sign-in" ? "Sign up" : "Sign in"}
|
|
441
|
+
</button>
|
|
442
|
+
</p>
|
|
443
|
+
)}
|
|
444
|
+
</div>
|
|
445
|
+
);
|
|
446
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Button } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
|
|
4
|
+
const debug = debugB3React("BetterAuthVerifyEmail");
|
|
5
|
+
|
|
6
|
+
export type BetterAuthVerifyEmailState = "success" | "expired" | "invalid" | "already-verified" | "error";
|
|
7
|
+
|
|
8
|
+
export interface BetterAuthVerifyEmailProps {
|
|
9
|
+
/**
|
|
10
|
+
* Error code from the callback URL's `?error=` query param. Pass `null` /
|
|
11
|
+
* `undefined` when the user landed here cleanly (successful verification).
|
|
12
|
+
* Better Auth appends this param when server-side verification fails.
|
|
13
|
+
*/
|
|
14
|
+
errorCode?: string | null;
|
|
15
|
+
/** Called when the user clicks the "Go to sign in" button. */
|
|
16
|
+
onGoToSignIn?: () => void;
|
|
17
|
+
/** Fallback href used when `onGoToSignIn` is not provided. Defaults to "/login". */
|
|
18
|
+
signInHref?: string;
|
|
19
|
+
/** Optional override for the success headline. */
|
|
20
|
+
successTitle?: string;
|
|
21
|
+
/** Optional override for the success body text. */
|
|
22
|
+
successMessage?: string;
|
|
23
|
+
/** Optional class name for the root container. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function classifyError(code: string | null | undefined): BetterAuthVerifyEmailState {
|
|
28
|
+
if (!code) return "success";
|
|
29
|
+
const normalized = code.toLowerCase();
|
|
30
|
+
|
|
31
|
+
// Exact matches for Better Auth's documented verification error codes.
|
|
32
|
+
if (normalized === "expired_token") return "expired";
|
|
33
|
+
if (normalized === "invalid_token") return "invalid";
|
|
34
|
+
if (normalized === "already_verified" || normalized === "email_already_verified") return "already-verified";
|
|
35
|
+
|
|
36
|
+
// Loose fallbacks for close variants. Order matters — check "already" before
|
|
37
|
+
// "verified" so `email_already_verified` maps to already-verified, not invalid.
|
|
38
|
+
if (normalized.includes("expired")) return "expired";
|
|
39
|
+
if (normalized.includes("already")) return "already-verified";
|
|
40
|
+
if (normalized.includes("invalid")) return "invalid";
|
|
41
|
+
return "error";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const COPY: Record<BetterAuthVerifyEmailState, { title: string; message: string }> = {
|
|
45
|
+
success: {
|
|
46
|
+
title: "Email verified",
|
|
47
|
+
message: "Your email is confirmed. You can now sign in to your account.",
|
|
48
|
+
},
|
|
49
|
+
expired: {
|
|
50
|
+
title: "Link expired",
|
|
51
|
+
message: "This verification link has expired. Request a new one from the sign-in page.",
|
|
52
|
+
},
|
|
53
|
+
invalid: {
|
|
54
|
+
title: "Invalid link",
|
|
55
|
+
message: "This verification link is invalid or has already been used. Try signing in or request a new link.",
|
|
56
|
+
},
|
|
57
|
+
"already-verified": {
|
|
58
|
+
title: "Already verified",
|
|
59
|
+
message: "Your email was already confirmed. You can sign in now.",
|
|
60
|
+
},
|
|
61
|
+
error: {
|
|
62
|
+
title: "Verification failed",
|
|
63
|
+
message: "We couldn't verify your email. Request a new link from the sign-in page.",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Standalone email-verification confirmation page. Render on the route you
|
|
69
|
+
* set as `callbackURL` when calling `betterAuthClient.sendVerificationEmail`
|
|
70
|
+
* (or the `verifyCallbackURL` arg on `useBetterAuth().signUpWithEmail`).
|
|
71
|
+
*
|
|
72
|
+
* Better Auth verifies the token server-side before redirecting here. This
|
|
73
|
+
* component only displays the outcome based on the `?error=` query param.
|
|
74
|
+
*
|
|
75
|
+
* Usage:
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const error = new URLSearchParams(window.location.search).get("error");
|
|
78
|
+
* <BetterAuthVerifyEmail
|
|
79
|
+
* errorCode={error}
|
|
80
|
+
* onGoToSignIn={() => router.push("/login")}
|
|
81
|
+
* />
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function BetterAuthVerifyEmail({
|
|
85
|
+
errorCode,
|
|
86
|
+
onGoToSignIn,
|
|
87
|
+
signInHref = "/login",
|
|
88
|
+
successTitle,
|
|
89
|
+
successMessage,
|
|
90
|
+
className,
|
|
91
|
+
}: BetterAuthVerifyEmailProps) {
|
|
92
|
+
const state = classifyError(errorCode);
|
|
93
|
+
const isSuccess = state === "success" || state === "already-verified";
|
|
94
|
+
const copy = COPY[state];
|
|
95
|
+
const title = isSuccess && successTitle ? successTitle : copy.title;
|
|
96
|
+
const message = isSuccess && successMessage ? successMessage : copy.message;
|
|
97
|
+
|
|
98
|
+
debug("Rendering verify-email state", { state, errorCode });
|
|
99
|
+
|
|
100
|
+
const handleClick = () => {
|
|
101
|
+
if (onGoToSignIn) {
|
|
102
|
+
onGoToSignIn();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (typeof window !== "undefined") {
|
|
106
|
+
window.location.href = signInHref;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
112
|
+
<div className="space-y-6 text-center">
|
|
113
|
+
<div
|
|
114
|
+
className={`mx-auto flex h-12 w-12 items-center justify-center rounded-full ${
|
|
115
|
+
isSuccess ? "bg-green-100" : "bg-red-100"
|
|
116
|
+
}`}
|
|
117
|
+
>
|
|
118
|
+
{isSuccess ? (
|
|
119
|
+
<svg
|
|
120
|
+
className="h-6 w-6 text-green-600"
|
|
121
|
+
fill="none"
|
|
122
|
+
viewBox="0 0 24 24"
|
|
123
|
+
stroke="currentColor"
|
|
124
|
+
aria-hidden="true"
|
|
125
|
+
>
|
|
126
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
127
|
+
</svg>
|
|
128
|
+
) : (
|
|
129
|
+
<svg
|
|
130
|
+
className="h-6 w-6 text-red-600"
|
|
131
|
+
fill="none"
|
|
132
|
+
viewBox="0 0 24 24"
|
|
133
|
+
stroke="currentColor"
|
|
134
|
+
aria-hidden="true"
|
|
135
|
+
>
|
|
136
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
137
|
+
</svg>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div>
|
|
142
|
+
<h1 className="text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100">{title}</h1>
|
|
143
|
+
<p className="mt-3 text-[15px] text-gray-500 dark:text-gray-400">{message}</p>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<Button
|
|
147
|
+
onClick={handleClick}
|
|
148
|
+
className="h-11 w-full bg-gray-900 text-[15px] font-medium text-white hover:bg-gray-800 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100"
|
|
149
|
+
>
|
|
150
|
+
{isSuccess ? "Go to sign in" : "Back to sign in"}
|
|
151
|
+
</Button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|