@b3dotfun/sdk 0.1.69-alpha.8 → 0.1.69-test.0
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/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +43 -23
- 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 +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- 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/B3DynamicModal.js +3 -0
- 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 +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +9 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -9
- 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/ProfileSection.js +15 -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 +12 -29
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- 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 +67 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +163 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +138 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +3 -0
- package/dist/cjs/global-account/react/components/index.js +7 -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 +24 -11
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +157 -0
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -7
- 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/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/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +44 -24
- 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 +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- 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/B3DynamicModal.js +3 -0
- 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 +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -5
- 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/ProfileSection.js +13 -7
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- 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 +64 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +160 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +135 -0
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +3 -0
- package/dist/esm/global-account/react/components/index.js +2 -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 +24 -11
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +149 -0
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -7
- 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/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/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- 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/B3ConfigProvider.d.ts +4 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- 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 +34 -0
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +3 -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/useBetterAuth.d.ts +973 -0
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- 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/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 +14 -6
- package/src/anyspend/constants/rpc.ts +2 -1
- package/src/anyspend/react/components/AnySpendNFT.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +15 -1
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +3 -3
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +45 -27
- 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 +2 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +4 -4
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- 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/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +6 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +14 -20
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +52 -40
- 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/ProfileSection.tsx +29 -11
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- package/src/global-account/react/components/Send/Send.tsx +8 -5
- package/src/global-account/react/components/SignInWithB3/BetterAuthResetPassword.tsx +146 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +426 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -4
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +308 -0
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +5 -1
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +2 -1
- package/src/global-account/react/components/index.ts +3 -0
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +24 -11
- package/src/global-account/react/hooks/useAuthentication.ts +21 -8
- package/src/global-account/react/hooks/useBetterAuth.ts +191 -0
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -7
- 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/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/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
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useSimBalance,
|
|
10
10
|
useUnifiedChainSwitchAndExecute,
|
|
11
11
|
} from "@b3dotfun/sdk/global-account/react";
|
|
12
|
+
import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profileDisplay";
|
|
12
13
|
import { formatDisplayNumber, formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
13
14
|
import invariant from "invariant";
|
|
14
15
|
import { CircleHelp, Clock, Loader2, Send as SendIcon, Wallet } from "lucide-react";
|
|
@@ -32,6 +33,7 @@ type SendStep = "recipient" | "token" | "amount" | "confirm" | "success";
|
|
|
32
33
|
// Component for displaying a recent address with profile data
|
|
33
34
|
function RecentAddressItem({ address, onClick }: { address: string; onClick: () => void }) {
|
|
34
35
|
const { data: profileData } = useProfile({ address });
|
|
36
|
+
const validatedAvatar = validateImageUrl(profileData?.avatar);
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
39
|
<button
|
|
@@ -39,8 +41,8 @@ function RecentAddressItem({ address, onClick }: { address: string; onClick: ()
|
|
|
39
41
|
className="flex items-center gap-2 rounded-xl px-3 py-2 transition-colors hover:bg-[#fafafa]"
|
|
40
42
|
>
|
|
41
43
|
{/* Avatar */}
|
|
42
|
-
{
|
|
43
|
-
<img src={
|
|
44
|
+
{validatedAvatar ? (
|
|
45
|
+
<img src={validatedAvatar} alt={profileData?.name || address} className="h-10 w-10 rounded-full" />
|
|
44
46
|
) : (
|
|
45
47
|
<div className="flex h-10 w-10 items-center justify-center rounded-full border border-[#e4e4e7] bg-[#f4f4f5]">
|
|
46
48
|
<Wallet className="h-5 w-5 text-[#a0a0ab]" />
|
|
@@ -84,6 +86,7 @@ export function Send({ recipientAddress: initialRecipient, onSuccess }: SendModa
|
|
|
84
86
|
const { data: validatedProfileData } = useProfile({
|
|
85
87
|
address: showValidatedResult && recipientAddress && isAddress(recipientAddress) ? recipientAddress : undefined,
|
|
86
88
|
});
|
|
89
|
+
const validatedRecipientAvatar = validateImageUrl(validatedProfileData?.avatar);
|
|
87
90
|
|
|
88
91
|
// Address validation
|
|
89
92
|
const handleRecipientAddressChange = (value: string) => {
|
|
@@ -290,10 +293,10 @@ export function Send({ recipientAddress: initialRecipient, onSuccess }: SendModa
|
|
|
290
293
|
className="dark:bg-b3-background dark:border-b3-line flex items-center gap-2 rounded-xl bg-[#f4f4f5] px-3 py-2 transition-colors hover:bg-[#e4e4e7]"
|
|
291
294
|
>
|
|
292
295
|
{/* Avatar */}
|
|
293
|
-
{
|
|
296
|
+
{validatedRecipientAvatar ? (
|
|
294
297
|
<img
|
|
295
|
-
src={
|
|
296
|
-
alt={validatedProfileData
|
|
298
|
+
src={validatedRecipientAvatar}
|
|
299
|
+
alt={validatedProfileData?.name || recipientAddress}
|
|
297
300
|
className="h-10 w-10 rounded-full"
|
|
298
301
|
/>
|
|
299
302
|
) : (
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Button, Input } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useBetterAuth } from "../../hooks/useBetterAuth";
|
|
5
|
+
|
|
6
|
+
const debug = debugB3React("BetterAuthResetPassword");
|
|
7
|
+
|
|
8
|
+
export interface BetterAuthResetPasswordProps {
|
|
9
|
+
/** The reset token from the URL query param */
|
|
10
|
+
token: string;
|
|
11
|
+
/** Called after password is successfully reset */
|
|
12
|
+
onSuccess?: () => void;
|
|
13
|
+
/** Called on error */
|
|
14
|
+
onError?: (error: Error) => void;
|
|
15
|
+
/** Optional class name */
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Standalone reset password form. Render this on your reset password page.
|
|
21
|
+
* Reads the token from props (extract it from the URL query string).
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const token = new URLSearchParams(window.location.search).get("token");
|
|
26
|
+
* <BetterAuthResetPassword token={token} onSuccess={() => navigate("/login")} />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function BetterAuthResetPassword({ token, onSuccess, onError, className }: BetterAuthResetPasswordProps) {
|
|
30
|
+
const { resetPassword } = useBetterAuth();
|
|
31
|
+
|
|
32
|
+
const [password, setPassword] = useState("");
|
|
33
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
34
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
35
|
+
const [error, setError] = useState<string | null>(null);
|
|
36
|
+
const [success, setSuccess] = useState(false);
|
|
37
|
+
|
|
38
|
+
const handleSubmit = async () => {
|
|
39
|
+
if (!password) {
|
|
40
|
+
setError("Please enter a new password");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (password.length < 8) {
|
|
45
|
+
setError("Password must be at least 8 characters");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (password !== confirmPassword) {
|
|
50
|
+
setError("Passwords do not match");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
setIsLoading(true);
|
|
56
|
+
setError(null);
|
|
57
|
+
await resetPassword(password, token);
|
|
58
|
+
setSuccess(true);
|
|
59
|
+
debug("Password reset successful");
|
|
60
|
+
onSuccess?.();
|
|
61
|
+
} catch (err) {
|
|
62
|
+
const message = err instanceof Error ? err.message : "Password reset failed";
|
|
63
|
+
setError(message);
|
|
64
|
+
debug("Password reset failed", err);
|
|
65
|
+
onError?.(err as Error);
|
|
66
|
+
} finally {
|
|
67
|
+
setPassword("");
|
|
68
|
+
setConfirmPassword("");
|
|
69
|
+
setIsLoading(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (!token) {
|
|
74
|
+
return (
|
|
75
|
+
<div className={`w-full max-w-[400px] px-6 text-center ${className || ""}`}>
|
|
76
|
+
<p className="text-sm text-red-500">Invalid or missing reset token.</p>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
83
|
+
<div className="mb-10 text-center">
|
|
84
|
+
<h1 className="text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100">
|
|
85
|
+
{success ? "Password reset" : "Set new password"}
|
|
86
|
+
</h1>
|
|
87
|
+
<p className="mt-3 text-[15px] text-gray-500 dark:text-gray-400">
|
|
88
|
+
{success ? "Your password has been updated." : "Enter your new password below."}
|
|
89
|
+
</p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
{success ? (
|
|
93
|
+
<div className="space-y-4 text-center">
|
|
94
|
+
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100">
|
|
95
|
+
<svg className="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
96
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
97
|
+
</svg>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
) : (
|
|
101
|
+
<div className="space-y-5">
|
|
102
|
+
<div>
|
|
103
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
104
|
+
New password
|
|
105
|
+
</label>
|
|
106
|
+
<Input
|
|
107
|
+
type="password"
|
|
108
|
+
placeholder="At least 8 characters"
|
|
109
|
+
value={password}
|
|
110
|
+
onChange={e => setPassword(e.target.value)}
|
|
111
|
+
disabled={isLoading}
|
|
112
|
+
className="h-11 px-4 text-[15px]"
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div>
|
|
117
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
118
|
+
Confirm password
|
|
119
|
+
</label>
|
|
120
|
+
<Input
|
|
121
|
+
type="password"
|
|
122
|
+
placeholder="Repeat your password"
|
|
123
|
+
value={confirmPassword}
|
|
124
|
+
onChange={e => setConfirmPassword(e.target.value)}
|
|
125
|
+
disabled={isLoading}
|
|
126
|
+
onKeyDown={e => {
|
|
127
|
+
if (e.key === "Enter") handleSubmit();
|
|
128
|
+
}}
|
|
129
|
+
className="h-11 px-4 text-[15px]"
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{error && <p className="text-sm text-red-500">{error}</p>}
|
|
134
|
+
|
|
135
|
+
<Button
|
|
136
|
+
onClick={handleSubmit}
|
|
137
|
+
disabled={isLoading}
|
|
138
|
+
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"
|
|
139
|
+
>
|
|
140
|
+
{isLoading ? "Resetting..." : "Reset password"}
|
|
141
|
+
</Button>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { Button, Input, 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 { strategyIcons, strategyLabels } from "./utils/signInUtils";
|
|
10
|
+
|
|
11
|
+
const debug = debugB3React("BetterAuthSignIn");
|
|
12
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
13
|
+
|
|
14
|
+
type SocialProviderConfig = { id: BetterAuthSocialProvider; label: string };
|
|
15
|
+
|
|
16
|
+
const DEFAULT_SOCIAL_PROVIDERS: SocialProviderConfig[] = [
|
|
17
|
+
{ id: "google", label: "Google" },
|
|
18
|
+
{ id: "github", label: "GitHub" },
|
|
19
|
+
{ id: "discord", label: "Discord" },
|
|
20
|
+
{ id: "microsoft", label: "Microsoft" },
|
|
21
|
+
{ id: "slack", label: "Slack" },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export interface BetterAuthSignInProps {
|
|
25
|
+
/** Title displayed above the form. Default: "Welcome back" for sign-in, "Create an account" for sign-up */
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Subtitle displayed below the title */
|
|
28
|
+
subtitle?: string;
|
|
29
|
+
/** Which social providers to show. Defaults to all. Pass empty array to hide. */
|
|
30
|
+
socialProviders?: BetterAuthSocialProvider[];
|
|
31
|
+
/** Show email/password form. Default: true */
|
|
32
|
+
showEmail?: boolean;
|
|
33
|
+
/** URL to redirect to after password reset link is clicked. Token is appended as ?token=... */
|
|
34
|
+
passwordResetRedirectTo?: string;
|
|
35
|
+
/** Called after successful authentication */
|
|
36
|
+
onSuccess?: () => void;
|
|
37
|
+
/** Called on authentication error */
|
|
38
|
+
onError?: (error: Error) => void;
|
|
39
|
+
/** Optional class name for the root container */
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Standalone inline sign-in component for Better Auth.
|
|
45
|
+
*
|
|
46
|
+
* Renders directly — no modal, no button wrapper. Designed for full-page
|
|
47
|
+
* sign-in layouts (e.g., B3OS web with branding on the left, form on the right).
|
|
48
|
+
*
|
|
49
|
+
* Usage:
|
|
50
|
+
* ```tsx
|
|
51
|
+
* <BetterAuthSignIn
|
|
52
|
+
* socialProviders={["google", "github"]}
|
|
53
|
+
* onSuccess={() => router.push("/dashboard")}
|
|
54
|
+
* />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function BetterAuthSignIn({
|
|
58
|
+
title,
|
|
59
|
+
subtitle = "Enter your credentials to access your account",
|
|
60
|
+
socialProviders = DEFAULT_SOCIAL_PROVIDERS.map(p => p.id),
|
|
61
|
+
showEmail = true,
|
|
62
|
+
passwordResetRedirectTo,
|
|
63
|
+
onSuccess,
|
|
64
|
+
onError,
|
|
65
|
+
className,
|
|
66
|
+
}: BetterAuthSignInProps) {
|
|
67
|
+
const { signInWithEmail, signUpWithEmail, signInWithSocial, requestPasswordReset } = useBetterAuth();
|
|
68
|
+
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
69
|
+
|
|
70
|
+
const [mode, setMode] = useState<"sign-in" | "sign-up" | "forgot-password">("sign-in");
|
|
71
|
+
const [email, setEmail] = useState("");
|
|
72
|
+
const [password, setPassword] = useState("");
|
|
73
|
+
const [name, setName] = useState("");
|
|
74
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
75
|
+
const [loadingProvider, setLoadingProvider] = useState<string | null>(null);
|
|
76
|
+
const [error, setError] = useState<string | null>(null);
|
|
77
|
+
const [resetEmailSent, setResetEmailSent] = useState(false);
|
|
78
|
+
const [verificationSent, setVerificationSent] = useState(false);
|
|
79
|
+
|
|
80
|
+
const resolvedTitle =
|
|
81
|
+
title ||
|
|
82
|
+
(mode === "forgot-password" ? "Reset password" : mode === "sign-in" ? "Welcome back" : "Create an account");
|
|
83
|
+
|
|
84
|
+
const resolvedSubtitle =
|
|
85
|
+
mode === "forgot-password"
|
|
86
|
+
? "Enter your email and we'll send you a reset link"
|
|
87
|
+
: subtitle || "Enter your credentials to access your account";
|
|
88
|
+
|
|
89
|
+
const handleForgotPassword = async () => {
|
|
90
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
91
|
+
|
|
92
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
93
|
+
setError("Please enter a valid email address");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
setIsLoading(true);
|
|
99
|
+
setError(null);
|
|
100
|
+
await requestPasswordReset(normalizedEmail, passwordResetRedirectTo);
|
|
101
|
+
setResetEmailSent(true);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
const message = err instanceof Error ? err.message : "Failed to send reset email";
|
|
104
|
+
setError(message);
|
|
105
|
+
} finally {
|
|
106
|
+
setIsLoading(false);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const providers: SocialProviderConfig[] = socialProviders
|
|
111
|
+
.map(id => DEFAULT_SOCIAL_PROVIDERS.find(p => p.id === id))
|
|
112
|
+
.filter((p): p is SocialProviderConfig => !!p);
|
|
113
|
+
|
|
114
|
+
if (isAuthenticated) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const handleEmailSubmit = async () => {
|
|
119
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
120
|
+
|
|
121
|
+
if (!EMAIL_REGEX.test(normalizedEmail)) {
|
|
122
|
+
setError("Please enter a valid email address");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!password) {
|
|
127
|
+
setError("Please enter a password");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (mode === "sign-up" && !name.trim()) {
|
|
132
|
+
setError("Please enter your name");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
setIsLoading(true);
|
|
138
|
+
setError(null);
|
|
139
|
+
|
|
140
|
+
if (mode === "sign-up") {
|
|
141
|
+
await signUpWithEmail(normalizedEmail, password, name.trim());
|
|
142
|
+
} else {
|
|
143
|
+
await signInWithEmail(normalizedEmail, password);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
debug("Auth successful");
|
|
147
|
+
onSuccess?.();
|
|
148
|
+
} catch (err) {
|
|
149
|
+
if (err instanceof EmailVerificationRequiredError) {
|
|
150
|
+
setVerificationSent(true);
|
|
151
|
+
setError(null);
|
|
152
|
+
} else {
|
|
153
|
+
const message = err instanceof Error ? err.message : "Authentication failed";
|
|
154
|
+
setError(message);
|
|
155
|
+
onError?.(err as Error);
|
|
156
|
+
}
|
|
157
|
+
debug("Auth failed", err);
|
|
158
|
+
} finally {
|
|
159
|
+
setPassword("");
|
|
160
|
+
setIsLoading(false);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handleSocialSignIn = async (provider: BetterAuthSocialProvider) => {
|
|
165
|
+
try {
|
|
166
|
+
setIsLoading(true);
|
|
167
|
+
setLoadingProvider(provider);
|
|
168
|
+
setError(null);
|
|
169
|
+
await signInWithSocial(provider);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
const message = err instanceof Error ? err.message : `Sign in failed`;
|
|
172
|
+
setError(message);
|
|
173
|
+
onError?.(err as Error);
|
|
174
|
+
setIsLoading(false);
|
|
175
|
+
setLoadingProvider(null);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (verificationSent) {
|
|
180
|
+
return (
|
|
181
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
182
|
+
<div className="flex flex-col items-center gap-6 text-center">
|
|
183
|
+
<div className="flex h-14 w-14 shrink-0 items-center justify-center rounded-full bg-green-100">
|
|
184
|
+
<svg
|
|
185
|
+
className="h-7 w-7 shrink-0 text-green-600"
|
|
186
|
+
fill="none"
|
|
187
|
+
viewBox="0 0 24 24"
|
|
188
|
+
stroke="currentColor"
|
|
189
|
+
width={28}
|
|
190
|
+
height={28}
|
|
191
|
+
>
|
|
192
|
+
<path
|
|
193
|
+
strokeLinecap="round"
|
|
194
|
+
strokeLinejoin="round"
|
|
195
|
+
strokeWidth={2}
|
|
196
|
+
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"
|
|
197
|
+
/>
|
|
198
|
+
</svg>
|
|
199
|
+
</div>
|
|
200
|
+
<h2 className="text-[22px] font-semibold text-gray-900 dark:text-gray-100">Check your email</h2>
|
|
201
|
+
<p className="text-[15px] text-gray-500 dark:text-gray-400">
|
|
202
|
+
We sent a verification link to <span className="font-medium text-gray-700 dark:text-gray-200">{email}</span>
|
|
203
|
+
. Click the link to verify your account, then come back and sign in.
|
|
204
|
+
</p>
|
|
205
|
+
<button
|
|
206
|
+
onClick={() => {
|
|
207
|
+
setVerificationSent(false);
|
|
208
|
+
setMode("sign-in");
|
|
209
|
+
setPassword("");
|
|
210
|
+
}}
|
|
211
|
+
className="text-[14px] font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
212
|
+
>
|
|
213
|
+
Back to sign in
|
|
214
|
+
</button>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
222
|
+
{/* Header */}
|
|
223
|
+
<div className="mb-10 text-center">
|
|
224
|
+
<h1 className="text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100">{resolvedTitle}</h1>
|
|
225
|
+
<p className="mt-3 text-[15px] text-gray-500 dark:text-gray-400">{resolvedSubtitle}</p>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
{/* Forgot password view */}
|
|
229
|
+
{mode === "forgot-password" && (
|
|
230
|
+
<div className="space-y-5">
|
|
231
|
+
{resetEmailSent ? (
|
|
232
|
+
<div className="space-y-4 text-center">
|
|
233
|
+
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100">
|
|
234
|
+
<svg className="h-6 w-6 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
235
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
236
|
+
</svg>
|
|
237
|
+
</div>
|
|
238
|
+
<p className="text-[15px] text-gray-600 dark:text-gray-300">Check your email for a reset link.</p>
|
|
239
|
+
</div>
|
|
240
|
+
) : (
|
|
241
|
+
<>
|
|
242
|
+
<div>
|
|
243
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
244
|
+
Email
|
|
245
|
+
</label>
|
|
246
|
+
<Input
|
|
247
|
+
type="email"
|
|
248
|
+
placeholder="name@company.com"
|
|
249
|
+
value={email}
|
|
250
|
+
onChange={e => setEmail(e.target.value)}
|
|
251
|
+
disabled={isLoading}
|
|
252
|
+
onKeyDown={e => {
|
|
253
|
+
if (e.key === "Enter") handleForgotPassword();
|
|
254
|
+
}}
|
|
255
|
+
className="h-11 px-4 text-[15px]"
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
{error && <p className="text-sm text-red-500">{error}</p>}
|
|
260
|
+
|
|
261
|
+
<Button
|
|
262
|
+
onClick={handleForgotPassword}
|
|
263
|
+
disabled={isLoading}
|
|
264
|
+
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"
|
|
265
|
+
>
|
|
266
|
+
{isLoading ? "Sending..." : "Send reset link"}
|
|
267
|
+
</Button>
|
|
268
|
+
</>
|
|
269
|
+
)}
|
|
270
|
+
|
|
271
|
+
<p className="mt-8 text-center text-[14px] text-gray-500 dark:text-gray-400">
|
|
272
|
+
<button
|
|
273
|
+
onClick={() => {
|
|
274
|
+
setMode("sign-in");
|
|
275
|
+
setError(null);
|
|
276
|
+
setResetEmailSent(false);
|
|
277
|
+
}}
|
|
278
|
+
className="font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
279
|
+
>
|
|
280
|
+
Back to sign in
|
|
281
|
+
</button>
|
|
282
|
+
</p>
|
|
283
|
+
</div>
|
|
284
|
+
)}
|
|
285
|
+
|
|
286
|
+
{/* Email/Password form */}
|
|
287
|
+
{showEmail && mode !== "forgot-password" && (
|
|
288
|
+
<div className="space-y-5">
|
|
289
|
+
{mode === "sign-up" && (
|
|
290
|
+
<div>
|
|
291
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
292
|
+
Name
|
|
293
|
+
</label>
|
|
294
|
+
<Input
|
|
295
|
+
type="text"
|
|
296
|
+
placeholder="Your name"
|
|
297
|
+
value={name}
|
|
298
|
+
onChange={e => setName(e.target.value)}
|
|
299
|
+
disabled={isLoading}
|
|
300
|
+
className="h-11 px-4 text-[15px]"
|
|
301
|
+
/>
|
|
302
|
+
</div>
|
|
303
|
+
)}
|
|
304
|
+
|
|
305
|
+
<div>
|
|
306
|
+
<label className="mb-2 block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
307
|
+
Email
|
|
308
|
+
</label>
|
|
309
|
+
<Input
|
|
310
|
+
type="email"
|
|
311
|
+
placeholder="name@company.com"
|
|
312
|
+
value={email}
|
|
313
|
+
onChange={e => setEmail(e.target.value)}
|
|
314
|
+
disabled={isLoading}
|
|
315
|
+
className="h-11 px-4 text-[15px]"
|
|
316
|
+
/>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
<div>
|
|
320
|
+
<div className="mb-2 flex items-center justify-between">
|
|
321
|
+
<label className="block text-xs font-medium uppercase tracking-wide text-gray-700 dark:text-gray-300">
|
|
322
|
+
Password
|
|
323
|
+
</label>
|
|
324
|
+
{mode === "sign-in" && (
|
|
325
|
+
<button
|
|
326
|
+
type="button"
|
|
327
|
+
onClick={() => {
|
|
328
|
+
setMode("forgot-password");
|
|
329
|
+
setError(null);
|
|
330
|
+
}}
|
|
331
|
+
className="text-xs font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
332
|
+
>
|
|
333
|
+
Forgot password?
|
|
334
|
+
</button>
|
|
335
|
+
)}
|
|
336
|
+
</div>
|
|
337
|
+
<Input
|
|
338
|
+
type="password"
|
|
339
|
+
placeholder="Password"
|
|
340
|
+
value={password}
|
|
341
|
+
onChange={e => setPassword(e.target.value)}
|
|
342
|
+
disabled={isLoading}
|
|
343
|
+
onKeyDown={e => {
|
|
344
|
+
if (e.key === "Enter") handleEmailSubmit();
|
|
345
|
+
}}
|
|
346
|
+
className="h-11 px-4 text-[15px]"
|
|
347
|
+
/>
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
{error && <p className="text-sm text-red-500">{error}</p>}
|
|
351
|
+
|
|
352
|
+
<Button
|
|
353
|
+
onClick={handleEmailSubmit}
|
|
354
|
+
disabled={isLoading}
|
|
355
|
+
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"
|
|
356
|
+
>
|
|
357
|
+
{isLoading ? "Loading..." : mode === "sign-in" ? "Sign in" : "Sign up"}
|
|
358
|
+
</Button>
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
|
|
362
|
+
{/* Social providers */}
|
|
363
|
+
{providers.length > 0 && mode !== "forgot-password" && (
|
|
364
|
+
<>
|
|
365
|
+
{showEmail && (
|
|
366
|
+
<div className="my-8 flex items-center gap-4">
|
|
367
|
+
<div className="h-px flex-1 bg-gray-200 dark:bg-gray-700" />
|
|
368
|
+
<span className="text-xs text-gray-400">Or continue with</span>
|
|
369
|
+
<div className="h-px flex-1 bg-gray-200 dark:bg-gray-700" />
|
|
370
|
+
</div>
|
|
371
|
+
)}
|
|
372
|
+
|
|
373
|
+
<div className="space-y-4">
|
|
374
|
+
{providers.map(provider => {
|
|
375
|
+
const icon = strategyIcons[provider.id];
|
|
376
|
+
const label = strategyLabels[provider.id] || provider.label;
|
|
377
|
+
|
|
378
|
+
const isProviderLoading = loadingProvider === provider.id;
|
|
379
|
+
|
|
380
|
+
return (
|
|
381
|
+
<button
|
|
382
|
+
key={provider.id}
|
|
383
|
+
onClick={() => handleSocialSignIn(provider.id)}
|
|
384
|
+
disabled={isLoading}
|
|
385
|
+
style={{ paddingTop: "12px", paddingBottom: "12px" }}
|
|
386
|
+
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"
|
|
387
|
+
>
|
|
388
|
+
{isProviderLoading ? (
|
|
389
|
+
<svg className="h-5 w-5 animate-spin text-gray-400" viewBox="0 0 24 24" fill="none">
|
|
390
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
391
|
+
<path
|
|
392
|
+
className="opacity-75"
|
|
393
|
+
fill="currentColor"
|
|
394
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
395
|
+
/>
|
|
396
|
+
</svg>
|
|
397
|
+
) : (
|
|
398
|
+
icon && <img src={icon} alt="" className="h-5 w-5" />
|
|
399
|
+
)}
|
|
400
|
+
<span>{isProviderLoading ? "Redirecting..." : label}</span>
|
|
401
|
+
</button>
|
|
402
|
+
);
|
|
403
|
+
})}
|
|
404
|
+
</div>
|
|
405
|
+
</>
|
|
406
|
+
)}
|
|
407
|
+
|
|
408
|
+
{/* Toggle sign-in / sign-up */}
|
|
409
|
+
{showEmail && mode !== "forgot-password" && (
|
|
410
|
+
<p className="mt-8 text-center text-[14px] text-gray-500 dark:text-gray-400">
|
|
411
|
+
{mode === "sign-in" ? "Don't have an account? " : "Already have an account? "}
|
|
412
|
+
<button
|
|
413
|
+
onClick={() => {
|
|
414
|
+
setMode(mode === "sign-in" ? "sign-up" : "sign-in");
|
|
415
|
+
setError(null);
|
|
416
|
+
}}
|
|
417
|
+
disabled={isLoading}
|
|
418
|
+
className="font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400"
|
|
419
|
+
>
|
|
420
|
+
{mode === "sign-in" ? "Sign up" : "Sign in"}
|
|
421
|
+
</button>
|
|
422
|
+
</p>
|
|
423
|
+
)}
|
|
424
|
+
</div>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
useGetAllTWSigners,
|
|
8
8
|
useModalStore,
|
|
9
9
|
} from "@b3dotfun/sdk/global-account/react";
|
|
10
|
+
import { LoginStepBetterAuth } from "./steps/LoginStepBetterAuth";
|
|
10
11
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
11
12
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
13
|
import { useActiveAccount } from "thirdweb/react";
|
|
@@ -34,7 +35,7 @@ export function SignInWithB3Flow({
|
|
|
34
35
|
source = "signInWithB3Button",
|
|
35
36
|
signersEnabled = false,
|
|
36
37
|
}: SignInWithB3ModalProps) {
|
|
37
|
-
const { automaticallySetFirstEoa } = useB3Config();
|
|
38
|
+
const { automaticallySetFirstEoa, authStrategy } = useB3Config();
|
|
38
39
|
// skipAutoConnect: this component intentionally logs out on mount to show a fresh login screen.
|
|
39
40
|
// AuthenticationProvider is the sole owner of useAutoConnect to avoid competing auth cycles.
|
|
40
41
|
const { user, logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
@@ -42,10 +43,13 @@ export function SignInWithB3Flow({
|
|
|
42
43
|
// Tracks whether the pre-login logout has finished.
|
|
43
44
|
// We must not render ConnectEmbed until logout (wallet disconnect) completes,
|
|
44
45
|
// otherwise the wallet state disrupts ConnectEmbed causing a blank modal.
|
|
45
|
-
const [readyToShowLogin, setReadyToShowLogin] = useState(
|
|
46
|
+
const [readyToShowLogin, setReadyToShowLogin] = useState(
|
|
47
|
+
source === "requestPermissions" || authStrategy === "better-auth",
|
|
48
|
+
);
|
|
46
49
|
const hasLoggedOutRef = useRef(false);
|
|
47
50
|
useEffect(() => {
|
|
48
51
|
if (hasLoggedOutRef.current) return;
|
|
52
|
+
if (authStrategy === "better-auth") return;
|
|
49
53
|
if (source !== "requestPermissions") {
|
|
50
54
|
debug("Logging out before login");
|
|
51
55
|
hasLoggedOutRef.current = true;
|
|
@@ -53,7 +57,7 @@ export function SignInWithB3Flow({
|
|
|
53
57
|
setReadyToShowLogin(true);
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
|
-
}, [source, logout]);
|
|
60
|
+
}, [source, logout, authStrategy]);
|
|
57
61
|
|
|
58
62
|
const [step, setStep] = useState<"login" | "permissions" | null>(source === "requestPermissions" ? null : "login");
|
|
59
63
|
const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
|
|
@@ -284,7 +288,12 @@ export function SignInWithB3Flow({
|
|
|
284
288
|
} else if (step === "login") {
|
|
285
289
|
// Show loading spinner while: authenticating, waiting for pre-login logout to finish,
|
|
286
290
|
// or fetching signers.
|
|
287
|
-
if (
|
|
291
|
+
if (authStrategy === "better-auth") {
|
|
292
|
+
// Better Auth manages its own loading/verification states internally.
|
|
293
|
+
// Don't gate on isAuthenticating — it would unmount the component
|
|
294
|
+
// and lose verification state when setIsAuthenticating(false) fires.
|
|
295
|
+
content = <LoginStepBetterAuth onSuccess={() => handleLoginSuccess({} as Account)} onError={onError} />;
|
|
296
|
+
} else if (!readyToShowLogin || isAuthenticating || isFetchingSigners) {
|
|
288
297
|
content = (
|
|
289
298
|
<LoginStepContainer partnerId={partnerId}>
|
|
290
299
|
<div className="my-8 flex min-h-[350px] items-center justify-center">
|