@b3dotfun/sdk 0.1.69-alpha.2 → 0.1.69-alpha.20
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/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- 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/CheckoutPaymentPanel.js +2 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +43 -23
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -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/B3DynamicModal.js +5 -2
- 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 -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/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/components/AuthButton.js +10 -1
- 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/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/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 +26 -15
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +23 -12
- 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/useConnect.d.ts +2 -2
- 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 -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/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/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.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/CheckoutPaymentPanel.js +2 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +44 -24
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- 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/B3DynamicModal.js +5 -2
- 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 +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/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/components/AuthButton.js +11 -2
- 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/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/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 +28 -17
- package/dist/esm/global-account/react/hooks/useAuthentication.js +24 -13
- 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/useConnect.d.ts +2 -2
- 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 -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/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/checkout/CheckoutSuccess.d.ts +2 -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/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/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/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/useConnect.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +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/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/AnySpendNFT.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +15 -1
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +2 -4
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +45 -27
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- 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/B3DynamicModal.tsx +5 -2
- 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 +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/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +308 -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/index.ts +3 -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/useBetterAuth.ts +191 -0
- package/src/global-account/react/hooks/useConnect.tsx +2 -2
- package/src/global-account/react/stores/useModalStore.ts +11 -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/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
package/src/app.shared.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { ClientApplication } from "@b3dotfun/b3-api";
|
|
|
2
2
|
import { AuthenticationClient } from "@feathersjs/authentication-client";
|
|
3
3
|
import Cookies from "js-cookie";
|
|
4
4
|
import { B3_AUTH_COOKIE_NAME } from "./shared/constants";
|
|
5
|
+
import { getSessionDurationDays } from "./shared/utils/session-duration";
|
|
5
6
|
|
|
6
7
|
export const B3_API_URL =
|
|
7
8
|
process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
|
|
8
9
|
|
|
9
|
-
const DEV_USER_GROUP = 4;
|
|
10
|
-
|
|
11
10
|
export const authenticate = async (
|
|
12
11
|
app: ClientApplication,
|
|
13
12
|
accessToken: string,
|
|
@@ -33,12 +32,14 @@ export const authenticate = async (
|
|
|
33
32
|
},
|
|
34
33
|
);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
const token = Cookies.get(B3_AUTH_COOKIE_NAME);
|
|
36
|
+
if (token) {
|
|
37
|
+
const days = getSessionDurationDays(response?.user?.preferences, params?.partnerId);
|
|
38
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, token, {
|
|
39
|
+
...(days > 0 ? { expires: days } : {}),
|
|
40
|
+
secure: true,
|
|
41
|
+
sameSite: "Lax",
|
|
42
|
+
});
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
return response;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/client";
|
|
2
|
+
import { B3_API_URL } from "../app.shared";
|
|
3
|
+
|
|
4
|
+
export type B3BetterAuthClient = ReturnType<typeof createB3BetterAuthClient>;
|
|
5
|
+
|
|
6
|
+
export function createB3BetterAuthClient(baseURL: string = B3_API_URL) {
|
|
7
|
+
return createAuthClient({
|
|
8
|
+
baseURL,
|
|
9
|
+
basePath: "/auth",
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
credentials: "include",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Default singleton for standard usage
|
|
17
|
+
export const betterAuthClient = createB3BetterAuthClient();
|
|
@@ -73,12 +73,6 @@ export const resetSocket = () => {
|
|
|
73
73
|
// reset the socket connection
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export function extractAvatarIdFromUrl(url: string): string | null {
|
|
77
|
-
const regex = /https:\/\/models\.readyplayer\.me\/([a-f0-9]{24})\.[a-zA-Z0-9]+/;
|
|
78
|
-
const match = url.match(regex);
|
|
79
|
-
return match ? match[1] : null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
export const authenticateWithB3JWT = async (fullToken: string, params?: Record<string, any>) => {
|
|
83
77
|
// Do not authenticate if there is no token
|
|
84
78
|
if (!fullToken) {
|
|
@@ -27,6 +27,7 @@ import { LinkAccount } from "./LinkAccount/LinkAccount";
|
|
|
27
27
|
import { LinkNewAccount } from "./LinkAccount/LinkNewAccount";
|
|
28
28
|
import { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
29
29
|
import NotificationsContent from "./ManageAccount/NotificationsContent";
|
|
30
|
+
import SessionDurationContent from "./ManageAccount/SessionDurationContent";
|
|
30
31
|
import { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
31
32
|
import { Send } from "./Send/Send";
|
|
32
33
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
@@ -43,7 +44,7 @@ export function B3DynamicModal() {
|
|
|
43
44
|
const navigateBack = useModalStore(state => state.navigateBack);
|
|
44
45
|
const { theme } = useB3Config();
|
|
45
46
|
const isMobile = useIsMobile();
|
|
46
|
-
const { toasts, removeToast } = useToastContext();
|
|
47
|
+
const { toasts, removeToast, headerMode } = useToastContext();
|
|
47
48
|
|
|
48
49
|
// Define arrays for different modal type groups
|
|
49
50
|
const fullWidthTypes = [
|
|
@@ -172,6 +173,8 @@ export function B3DynamicModal() {
|
|
|
172
173
|
return <Send {...contentType} />;
|
|
173
174
|
case "notifications":
|
|
174
175
|
return <NotificationsContent {...contentType} />;
|
|
176
|
+
case "sessionDuration":
|
|
177
|
+
return <SessionDurationContent partnerId={contentType.partnerId} />;
|
|
175
178
|
// Add other modal types here
|
|
176
179
|
default:
|
|
177
180
|
return null;
|
|
@@ -247,7 +250,7 @@ export function B3DynamicModal() {
|
|
|
247
250
|
|
|
248
251
|
{/* Toast Container - Part of modal-inner-content layer */}
|
|
249
252
|
<AnimatePresence>
|
|
250
|
-
{toasts.length > 0 && (
|
|
253
|
+
{!headerMode && toasts.length > 0 && (
|
|
251
254
|
<motion.div
|
|
252
255
|
initial={{ height: 0 }}
|
|
253
256
|
animate={{ height: "auto" }}
|
|
@@ -15,6 +15,8 @@ const DEFAULT_PERMISSIONS: PermissionsConfig = {
|
|
|
15
15
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export type AuthStrategy = "thirdweb" | "better-auth";
|
|
19
|
+
|
|
18
20
|
export interface B3ConfigContextType {
|
|
19
21
|
accountOverride?: Account;
|
|
20
22
|
automaticallySetFirstEoa: boolean;
|
|
@@ -25,6 +27,7 @@ export interface B3ConfigContextType {
|
|
|
25
27
|
partnerId: string;
|
|
26
28
|
stripePublishableKey?: string;
|
|
27
29
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
30
|
+
authStrategy: AuthStrategy;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const B3ConfigContext = createContext<B3ConfigContextType | null>(null);
|
|
@@ -40,6 +43,7 @@ export function B3ConfigProvider({
|
|
|
40
43
|
partnerId,
|
|
41
44
|
stripePublishableKey,
|
|
42
45
|
createClientReferenceId,
|
|
46
|
+
authStrategy = "thirdweb",
|
|
43
47
|
}: {
|
|
44
48
|
children: React.ReactNode;
|
|
45
49
|
accountOverride?: Account;
|
|
@@ -51,6 +55,7 @@ export function B3ConfigProvider({
|
|
|
51
55
|
partnerId: string;
|
|
52
56
|
stripePublishableKey?: string;
|
|
53
57
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
58
|
+
authStrategy?: AuthStrategy;
|
|
54
59
|
}) {
|
|
55
60
|
return (
|
|
56
61
|
<B3ConfigContext.Provider
|
|
@@ -64,6 +69,7 @@ export function B3ConfigProvider({
|
|
|
64
69
|
partnerId,
|
|
65
70
|
stripePublishableKey,
|
|
66
71
|
createClientReferenceId,
|
|
72
|
+
authStrategy,
|
|
67
73
|
}}
|
|
68
74
|
>
|
|
69
75
|
{children}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
|
-
import {
|
|
2
|
+
import { WalletProvider } from "@b3dotfun/sdk/wallet/react";
|
|
3
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
4
4
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
5
|
|
|
6
6
|
import { ClientType } from "../../../client-manager";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useMemo } from "react";
|
|
9
9
|
import { createWagmiConfig } from "../../utils/createWagmiConfig";
|
|
10
10
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
11
11
|
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
12
12
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
13
13
|
|
|
14
|
-
// Create queryClient instance
|
|
15
|
-
const queryClient = new QueryClient();
|
|
16
|
-
|
|
17
14
|
/**
|
|
18
15
|
* Main B3Provider component
|
|
19
16
|
*/
|
|
@@ -82,23 +79,21 @@ export function InnerProvider({
|
|
|
82
79
|
partnerId: string;
|
|
83
80
|
rpcUrls?: Record<number, string>;
|
|
84
81
|
}) {
|
|
85
|
-
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
|
|
82
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls }), [partnerId, rpcUrls]);
|
|
86
83
|
|
|
87
84
|
return (
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</QueryClientProvider>
|
|
102
|
-
</WagmiProvider>
|
|
85
|
+
<WalletProvider wagmiConfig={wagmiConfig}>
|
|
86
|
+
<B3ConfigProvider
|
|
87
|
+
accountOverride={accountOverride}
|
|
88
|
+
environment={environment}
|
|
89
|
+
automaticallySetFirstEoa={false}
|
|
90
|
+
theme={theme}
|
|
91
|
+
clientType={clientType}
|
|
92
|
+
partnerId={partnerId}
|
|
93
|
+
defaultPermissions={defaultPermissions}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</B3ConfigProvider>
|
|
97
|
+
</WalletProvider>
|
|
103
98
|
);
|
|
104
99
|
}
|
|
@@ -3,23 +3,22 @@ import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspen
|
|
|
3
3
|
import { RelayKitProviderWrapper, TooltipProvider } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { createWagmiConfig } from "@b3dotfun/sdk/global-account/react/utils/createWagmiConfig";
|
|
5
5
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
6
|
+
import type { AuthStrategy } from "./B3ConfigProvider";
|
|
6
7
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
8
|
+
import { WalletProvider } from "@b3dotfun/sdk/wallet/react";
|
|
7
9
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
8
|
-
import { QueryClient
|
|
10
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
9
11
|
import { useEffect, useMemo } from "react";
|
|
10
|
-
import { ThirdwebProvider } from "thirdweb/react";
|
|
11
12
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
12
|
-
import { CreateConnectorFn
|
|
13
|
+
import { CreateConnectorFn } from "wagmi";
|
|
13
14
|
import { ClientType, setClientType } from "../../../client-manager";
|
|
14
15
|
import { StyleRoot } from "../StyleRoot";
|
|
15
16
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
|
|
16
17
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
17
18
|
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
19
|
+
import BetterAuthProvider from "./BetterAuthProvider";
|
|
18
20
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
19
21
|
|
|
20
|
-
// Create queryClient instance
|
|
21
|
-
const queryClient = new QueryClient();
|
|
22
|
-
|
|
23
22
|
/**
|
|
24
23
|
* Main B3Provider component
|
|
25
24
|
*/
|
|
@@ -43,6 +42,9 @@ export function B3Provider({
|
|
|
43
42
|
overrideDefaultConnectors = false,
|
|
44
43
|
createClientReferenceId,
|
|
45
44
|
defaultPermissions,
|
|
45
|
+
disableBSMNTAuthentication = false,
|
|
46
|
+
queryClient,
|
|
47
|
+
authStrategy = "thirdweb",
|
|
46
48
|
}: {
|
|
47
49
|
theme: "light" | "dark";
|
|
48
50
|
children: React.ReactNode;
|
|
@@ -67,6 +69,11 @@ export function B3Provider({
|
|
|
67
69
|
overrideDefaultConnectors?: boolean;
|
|
68
70
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
69
71
|
defaultPermissions?: PermissionsConfig;
|
|
72
|
+
disableBSMNTAuthentication?: boolean;
|
|
73
|
+
/** Provide your own QueryClient for React Query. If omitted, WalletProvider creates one internally. */
|
|
74
|
+
queryClient?: QueryClient;
|
|
75
|
+
/** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
|
|
76
|
+
authStrategy?: AuthStrategy;
|
|
70
77
|
}) {
|
|
71
78
|
// Initialize Google Analytics on mount
|
|
72
79
|
useEffect(() => {
|
|
@@ -84,41 +91,46 @@ export function B3Provider({
|
|
|
84
91
|
);
|
|
85
92
|
|
|
86
93
|
return (
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
<WalletProvider wagmiConfig={wagmiConfig} queryClient={queryClient}>
|
|
95
|
+
<TooltipProvider>
|
|
96
|
+
<ToastProvider>
|
|
97
|
+
<LocalSDKProvider
|
|
98
|
+
onConnectCallback={onConnect}
|
|
99
|
+
onLogoutCallback={onLogout}
|
|
100
|
+
disableBSMNTAuthentication={disableBSMNTAuthentication}
|
|
101
|
+
>
|
|
102
|
+
<B3ConfigProvider
|
|
103
|
+
accountOverride={accountOverride}
|
|
104
|
+
environment={environment}
|
|
105
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
106
|
+
theme={theme}
|
|
107
|
+
clientType={clientType}
|
|
108
|
+
partnerId={partnerId}
|
|
109
|
+
stripePublishableKey={stripePublishableKey}
|
|
110
|
+
createClientReferenceId={createClientReferenceId}
|
|
111
|
+
defaultPermissions={defaultPermissions}
|
|
112
|
+
authStrategy={authStrategy}
|
|
113
|
+
>
|
|
114
|
+
<ToastContextConnector />
|
|
115
|
+
<RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
|
|
116
|
+
{children}
|
|
117
|
+
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
118
|
+
<StyleRoot id="b3-root" />
|
|
119
|
+
</RelayKitProviderWrapper>
|
|
120
|
+
{authStrategy === "better-auth" ? (
|
|
121
|
+
<BetterAuthProvider partnerId={partnerId} />
|
|
122
|
+
) : (
|
|
123
|
+
<AuthenticationProvider
|
|
99
124
|
partnerId={partnerId}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</RelayKitProviderWrapper>
|
|
110
|
-
<AuthenticationProvider
|
|
111
|
-
partnerId={partnerId}
|
|
112
|
-
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
113
|
-
defaultEoaProvider={defaultEoaProvider}
|
|
114
|
-
/>
|
|
115
|
-
</B3ConfigProvider>
|
|
116
|
-
</LocalSDKProvider>
|
|
117
|
-
</ToastProvider>
|
|
118
|
-
</TooltipProvider>
|
|
119
|
-
</QueryClientProvider>
|
|
120
|
-
</WagmiProvider>
|
|
121
|
-
</ThirdwebProvider>
|
|
125
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
126
|
+
defaultEoaProvider={defaultEoaProvider}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
</B3ConfigProvider>
|
|
130
|
+
</LocalSDKProvider>
|
|
131
|
+
</ToastProvider>
|
|
132
|
+
</TooltipProvider>
|
|
133
|
+
</WalletProvider>
|
|
122
134
|
);
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
+
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { B3_AUTH_COOKIE_NAME } from "@b3dotfun/sdk/shared/constants";
|
|
4
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
5
|
+
import Cookies from "js-cookie";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { betterAuthClient } from "../../../better-auth-client";
|
|
8
|
+
import { useUserQuery } from "../../hooks/useUserQuery";
|
|
9
|
+
|
|
10
|
+
const debug = debugB3React("BetterAuthProvider");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parallel to AuthenticationProvider for Better Auth strategy.
|
|
14
|
+
*
|
|
15
|
+
* Manages the isAuthenticating lifecycle for Better Auth:
|
|
16
|
+
* 1. On mount, try to restore an existing Feathers JWT (from a previous login)
|
|
17
|
+
* 2. If no Feathers JWT, check for a Better Auth session (e.g. after OAuth redirect)
|
|
18
|
+
* and exchange it for a Feathers JWT
|
|
19
|
+
* 3. If neither exists, set isAuthenticating: false so the login UI renders
|
|
20
|
+
*
|
|
21
|
+
* Also patches app.logout() so any code path that calls it (useAuthentication,
|
|
22
|
+
* useAuth, SignIn component, etc.) automatically clears the Better Auth session.
|
|
23
|
+
*/
|
|
24
|
+
const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
25
|
+
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
26
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
27
|
+
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
28
|
+
const { setUser } = useUserQuery();
|
|
29
|
+
const hasAttemptedRestore = useRef(false);
|
|
30
|
+
const hasPatched = useRef(false);
|
|
31
|
+
|
|
32
|
+
// Patch app.logout() to also clear the Better Auth session.
|
|
33
|
+
// This ensures any existing logout path (useAuthentication, useAuth, SignIn
|
|
34
|
+
// dropdown, etc.) clears both the Feathers JWT and the Better Auth session.
|
|
35
|
+
// Patch app.logout() to also clear the Better Auth session.
|
|
36
|
+
// Only handles Better Auth signOut — state cleanup (isAuthenticated, isConnected,
|
|
37
|
+
// setUser, localStorage) is handled by useAuthentication/useAuth's own logout.
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (hasPatched.current) return;
|
|
40
|
+
hasPatched.current = true;
|
|
41
|
+
|
|
42
|
+
const originalLogout = app.logout.bind(app);
|
|
43
|
+
(app as any).logout = async () => {
|
|
44
|
+
debug("Patched logout: clearing Better Auth session");
|
|
45
|
+
try {
|
|
46
|
+
await betterAuthClient.signOut();
|
|
47
|
+
} catch {
|
|
48
|
+
debug("Better Auth signOut failed (non-critical)");
|
|
49
|
+
}
|
|
50
|
+
return originalLogout();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
(app as any).logout = originalLogout;
|
|
55
|
+
hasPatched.current = false;
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
// Session restore on mount
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (hasAttemptedRestore.current) return;
|
|
62
|
+
hasAttemptedRestore.current = true;
|
|
63
|
+
|
|
64
|
+
const restoreSession = async () => {
|
|
65
|
+
debug("Attempting session restore");
|
|
66
|
+
|
|
67
|
+
// 1. Try existing Feathers JWT first (fastest — no network call to Better Auth)
|
|
68
|
+
try {
|
|
69
|
+
const response = await app.reAuthenticate();
|
|
70
|
+
if (response?.user) {
|
|
71
|
+
debug("Feathers JWT restored", { userId: response.user.userId });
|
|
72
|
+
setUser(response.user);
|
|
73
|
+
setIsAuthenticated(true);
|
|
74
|
+
setIsConnected(true);
|
|
75
|
+
setIsAuthenticating(false);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
debug("No existing Feathers JWT");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 2. Check for a Better Auth session (e.g. after OAuth redirect sets a cookie)
|
|
83
|
+
try {
|
|
84
|
+
const session = await betterAuthClient.getSession();
|
|
85
|
+
if (session.data?.session?.token) {
|
|
86
|
+
debug("Better Auth session found, exchanging for Feathers JWT", {
|
|
87
|
+
betterAuthUserId: session.data.user?.id,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const response = await app.authenticate({
|
|
91
|
+
strategy: "better-auth",
|
|
92
|
+
accessToken: session.data.session.token,
|
|
93
|
+
partnerId,
|
|
94
|
+
} as any);
|
|
95
|
+
|
|
96
|
+
if (response.accessToken) {
|
|
97
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, response.accessToken, {
|
|
98
|
+
secure: true,
|
|
99
|
+
sameSite: "Lax",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (response.user) {
|
|
104
|
+
setUser(response.user);
|
|
105
|
+
setIsAuthenticated(true);
|
|
106
|
+
setIsConnected(true);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
debug("OAuth session exchanged for Feathers JWT", { userId: response.user?.userId });
|
|
110
|
+
setIsAuthenticating(false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
debug("No Better Auth session to restore");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 3. Nothing found — show login UI
|
|
118
|
+
setIsAuthenticating(false);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
restoreSession();
|
|
122
|
+
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId]);
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default BetterAuthProvider;
|
|
@@ -8,11 +8,13 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
8
8
|
export interface LocalSDKContextType {
|
|
9
9
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
10
10
|
onLogoutCallback?: () => void | Promise<void>;
|
|
11
|
+
disableBSMNTAuthentication?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const LocalSDKContext = createContext<LocalSDKContextType>({
|
|
14
15
|
onConnectCallback: undefined,
|
|
15
16
|
onLogoutCallback: undefined,
|
|
17
|
+
disableBSMNTAuthentication: false,
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -22,16 +24,19 @@ export function LocalSDKProvider({
|
|
|
22
24
|
children,
|
|
23
25
|
onConnectCallback,
|
|
24
26
|
onLogoutCallback,
|
|
27
|
+
disableBSMNTAuthentication,
|
|
25
28
|
}: {
|
|
26
29
|
children: React.ReactNode;
|
|
27
30
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
28
31
|
onLogoutCallback?: () => void | Promise<void>;
|
|
32
|
+
disableBSMNTAuthentication?: boolean;
|
|
29
33
|
}) {
|
|
30
34
|
return (
|
|
31
35
|
<LocalSDKContext.Provider
|
|
32
36
|
value={{
|
|
33
37
|
onConnectCallback,
|
|
34
38
|
onLogoutCallback,
|
|
39
|
+
disableBSMNTAuthentication,
|
|
35
40
|
}}
|
|
36
41
|
>
|
|
37
42
|
{children}
|
|
@@ -22,6 +22,8 @@ interface IPFSMediaRendererProps {
|
|
|
22
22
|
controls?: boolean;
|
|
23
23
|
/** Style object */
|
|
24
24
|
style?: React.CSSProperties;
|
|
25
|
+
/** Callback when media fails to load */
|
|
26
|
+
onError?: () => void;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
@@ -51,6 +53,7 @@ export function IPFSMediaRenderer({
|
|
|
51
53
|
height,
|
|
52
54
|
controls,
|
|
53
55
|
style,
|
|
56
|
+
onError,
|
|
54
57
|
}: IPFSMediaRendererProps) {
|
|
55
58
|
// If no source, render fallback
|
|
56
59
|
if (!src) {
|
|
@@ -67,16 +70,20 @@ export function IPFSMediaRenderer({
|
|
|
67
70
|
// This avoids Thirdweb's default cloudflare-ipfs.com which can be unreliable
|
|
68
71
|
const resolvedSrc = src.startsWith("ipfs://") ? getIpfsUrl(src) : src;
|
|
69
72
|
|
|
73
|
+
// Wrap in a span with onErrorCapture to catch img/video load errors from
|
|
74
|
+
// MediaRenderer, which doesn't expose an onError prop itself.
|
|
70
75
|
return (
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
<span onErrorCapture={onError} className="contents">
|
|
77
|
+
<MediaRenderer
|
|
78
|
+
src={resolvedSrc}
|
|
79
|
+
client={client}
|
|
80
|
+
alt={alt}
|
|
81
|
+
className={className}
|
|
82
|
+
width={width ? width.toString() : undefined}
|
|
83
|
+
height={height ? height.toString() : undefined}
|
|
84
|
+
controls={controls}
|
|
85
|
+
style={style}
|
|
86
|
+
/>
|
|
87
|
+
</span>
|
|
81
88
|
);
|
|
82
89
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Button, toast, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profileDisplay";
|
|
2
3
|
import { truncateAddress } from "@b3dotfun/sdk/shared/utils/truncateAddress";
|
|
3
4
|
import { Copy, Loader2, UnlinkIcon } from "lucide-react";
|
|
4
5
|
|
|
@@ -55,7 +56,7 @@ const LinkedAccountItem = ({
|
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
const displayImageUrl = profileData?.avatar || profile.imageUrl;
|
|
59
|
+
const displayImageUrl = validateImageUrl(profileData?.avatar) || validateImageUrl(profile.imageUrl);
|
|
59
60
|
const displayName = profileData?.name || displayTitle;
|
|
60
61
|
|
|
61
62
|
return (
|
|
@@ -5,14 +5,18 @@ import {
|
|
|
5
5
|
useSimBalance,
|
|
6
6
|
useUser,
|
|
7
7
|
} from "@b3dotfun/sdk/global-account/react";
|
|
8
|
+
import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profileDisplay";
|
|
8
9
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
9
10
|
import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
11
|
+
import Avatar from "boring-avatars";
|
|
10
12
|
import { Pencil } from "lucide-react";
|
|
11
|
-
import { useMemo } from "react";
|
|
13
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
12
14
|
import { useActiveAccount } from "thirdweb/react";
|
|
13
15
|
import { useFirstEOA } from "../../hooks/useFirstEOA";
|
|
14
16
|
import { IPFSMediaRenderer } from "../IPFSMediaRenderer/IPFSMediaRenderer";
|
|
15
17
|
|
|
18
|
+
const AVATAR_COLORS = ["#3368ef", "#272727", "#6366f1", "#06b6d4", "#eeb0d9", "#ba3fbf", "#ff777b", "#dfbb53"];
|
|
19
|
+
|
|
16
20
|
const ProfileSection = () => {
|
|
17
21
|
const account = useActiveAccount();
|
|
18
22
|
const { address: eoaAddress } = useFirstEOA();
|
|
@@ -27,8 +31,9 @@ const ProfileSection = () => {
|
|
|
27
31
|
const navigateBack = useModalStore(state => state.navigateBack);
|
|
28
32
|
|
|
29
33
|
const { data: simBalance } = useSimBalance(smartWalletAddress);
|
|
34
|
+
const [imgError, setImgError] = useState(false);
|
|
35
|
+
const handleImgError = useCallback(() => setImgError(true), []);
|
|
30
36
|
|
|
31
|
-
// Calculate total balance in USD
|
|
32
37
|
const totalBalanceUsd = useMemo(() => {
|
|
33
38
|
if (!simBalance?.balances) return 0;
|
|
34
39
|
return simBalance.balances.reduce((sum, token) => sum + (token.value_usd || 0), 0);
|
|
@@ -39,27 +44,40 @@ const ProfileSection = () => {
|
|
|
39
44
|
setB3ModalContentType({
|
|
40
45
|
type: "avatarEditor",
|
|
41
46
|
onSuccess: () => {
|
|
42
|
-
// navigate back on success
|
|
43
47
|
navigateBack();
|
|
44
48
|
},
|
|
45
49
|
});
|
|
46
50
|
};
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
const avatarSrc = useMemo(
|
|
53
|
+
() => validateImageUrl(user?.avatar) || validateImageUrl(profile?.avatar),
|
|
54
|
+
[user?.avatar, profile?.avatar],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Reset error state when avatar source changes (e.g. user uploads a new avatar)
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setImgError(false);
|
|
60
|
+
}, [avatarSrc]);
|
|
50
61
|
|
|
51
|
-
// Get current username - prioritize user.username, fallback to profile data
|
|
52
62
|
const currentUsername = user?.username || profile?.displayName || formatUsername(profile?.name || "");
|
|
63
|
+
const avatarSeed = eoaAddress || account?.address || smartWalletAddress || currentUsername || "user";
|
|
53
64
|
|
|
54
65
|
return (
|
|
55
66
|
<div className="flex items-center justify-between px-5 py-6">
|
|
56
67
|
<div className="global-account-profile flex items-center gap-4">
|
|
57
68
|
<div className="global-account-profile-avatar relative">
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
<div className="border-b3-line border-1 bg-b3-primary-wash size-14 overflow-hidden rounded-full border">
|
|
70
|
+
{avatarSrc && !imgError ? (
|
|
71
|
+
<IPFSMediaRenderer
|
|
72
|
+
src={avatarSrc}
|
|
73
|
+
alt="Profile Avatar"
|
|
74
|
+
className="h-full w-full object-cover"
|
|
75
|
+
onError={handleImgError}
|
|
76
|
+
/>
|
|
77
|
+
) : (
|
|
78
|
+
<Avatar name={avatarSeed} variant="beam" size={56} colors={AVATAR_COLORS} />
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
63
81
|
|
|
64
82
|
<button
|
|
65
83
|
onClick={handleEditAvatar}
|