@b3dotfun/sdk 0.1.70-alpha.1 → 0.1.70-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/chains/b3Chain.js +3 -1
- package/dist/cjs/anyspend/constants/rpc.d.ts +2 -1
- package/dist/cjs/anyspend/constants/rpc.js +4 -2
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +21 -14
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +9 -3
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +13 -3
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/cjs/anyspend/utils/chain.d.ts +39 -1
- package/dist/cjs/anyspend/utils/chain.js +23 -2
- package/dist/cjs/anyspend/utils/token.d.ts +2 -0
- package/dist/cjs/anyspend/utils/token.js +15 -1
- package/dist/cjs/app.shared.d.ts +9 -1
- package/dist/cjs/app.shared.js +19 -0
- package/dist/cjs/global-account/app.native.d.ts +1 -1
- package/dist/cjs/global-account/better-auth-client.d.ts +3314 -36
- package/dist/cjs/global-account/better-auth-client.js +28 -3
- package/dist/cjs/global-account/bsmnt.d.ts +2 -2
- package/dist/cjs/global-account/bsmnt.native.d.ts +1 -1
- package/dist/cjs/global-account/client-manager.d.ts +7 -5
- package/dist/cjs/global-account/client-manager.js +19 -4
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +8 -13
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +24 -3
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +48 -8
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
- package/dist/cjs/global-account/react/components/index.d.ts +0 -2
- package/dist/cjs/global-account/react/components/index.js +3 -7
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +2 -4
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +3 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -1
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1656 -21
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +13 -14
- package/dist/cjs/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +20 -17
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +28 -0
- package/dist/cjs/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
- package/dist/cjs/notifications/services/api.js +1 -0
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +6 -54
- package/dist/cjs/shared/constants/chains/b3Chain.js +5 -41
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -49
- package/dist/cjs/shared/constants/chains/supported.js +8 -36
- package/dist/cjs/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/cjs/shared/utils/chain-transformers.js +38 -37
- package/dist/cjs/shared/utils/thirdweb-insights.js +2 -2
- package/dist/cjs/shared/utils/upload.d.ts +9 -0
- package/dist/cjs/shared/utils/upload.js +34 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +2 -1
- package/dist/esm/anyspend/constants/rpc.js +3 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +21 -14
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +10 -4
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +14 -4
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/esm/anyspend/utils/chain.d.ts +39 -1
- package/dist/esm/anyspend/utils/chain.js +24 -3
- package/dist/esm/anyspend/utils/token.d.ts +2 -0
- package/dist/esm/anyspend/utils/token.js +13 -0
- package/dist/esm/app.shared.d.ts +9 -1
- package/dist/esm/app.shared.js +17 -0
- package/dist/esm/global-account/app.native.d.ts +1 -1
- package/dist/esm/global-account/better-auth-client.d.ts +3314 -36
- package/dist/esm/global-account/better-auth-client.js +27 -4
- package/dist/esm/global-account/bsmnt.d.ts +2 -2
- package/dist/esm/global-account/bsmnt.native.d.ts +1 -1
- package/dist/esm/global-account/client-manager.d.ts +7 -5
- package/dist/esm/global-account/client-manager.js +19 -5
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -5
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +8 -13
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +25 -4
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +48 -8
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +1 -3
- package/dist/esm/global-account/react/components/index.d.ts +0 -2
- package/dist/esm/global-account/react/components/index.js +0 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +3 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -1
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1656 -21
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +13 -14
- package/dist/esm/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +1 -1
- package/dist/esm/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +20 -17
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +28 -0
- package/dist/esm/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
- package/dist/esm/notifications/services/api.js +1 -0
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +6 -54
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -38
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -49
- package/dist/esm/shared/constants/chains/supported.js +7 -35
- package/dist/esm/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/esm/shared/utils/chain-transformers.js +38 -37
- package/dist/esm/shared/utils/thirdweb-insights.js +2 -2
- package/dist/esm/shared/utils/upload.d.ts +9 -0
- package/dist/esm/shared/utils/upload.js +31 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnyspendSignatureMint.d.ts +2 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +3 -1
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/types/anyspend/utils/chain.d.ts +39 -1
- package/dist/types/anyspend/utils/token.d.ts +2 -0
- package/dist/types/app.shared.d.ts +9 -1
- package/dist/types/global-account/app.native.d.ts +1 -1
- package/dist/types/global-account/better-auth-client.d.ts +3314 -36
- package/dist/types/global-account/bsmnt.d.ts +2 -2
- package/dist/types/global-account/bsmnt.native.d.ts +1 -1
- package/dist/types/global-account/client-manager.d.ts +7 -5
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -5
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +8 -13
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/types/global-account/react/components/index.d.ts +0 -2
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useAuth.d.ts +3 -3
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1656 -21
- package/dist/types/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/types/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +28 -0
- package/dist/types/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/types/global-account/types/feature-flags.d.ts +5 -5
- package/dist/types/shared/constants/chains/b3Chain.d.ts +6 -54
- package/dist/types/shared/constants/chains/supported.d.ts +1 -49
- package/dist/types/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/types/shared/utils/upload.d.ts +9 -0
- package/node_modules/@b3/chain-registry/chains.json +1160 -0
- package/node_modules/@b3/chain-registry/package.json +14 -0
- package/node_modules/@b3/chain-registry/src/index.ts +169 -0
- package/node_modules/@b3/chain-registry/tsconfig.json +16 -0
- package/package.json +76 -28
- package/src/anyspend/constants/rpc.ts +3 -2
- package/src/anyspend/react/components/AnySpendBondKit.tsx +2 -0
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +3 -0
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +29 -14
- package/src/anyspend/react/components/AnySpendDeposit.tsx +13 -3
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +3 -0
- package/src/anyspend/react/components/AnySpendWorkflowTrigger.tsx +4 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +3 -0
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +3 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +4 -0
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +97 -79
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +13 -13
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +4 -4
- package/src/anyspend/types/api_req_res.ts +10 -5
- package/src/anyspend/utils/chain.ts +26 -1
- package/src/anyspend/utils/token.ts +14 -0
- package/src/app.shared.ts +21 -1
- package/src/global-account/app.native.ts +5 -1
- package/src/global-account/better-auth-client.ts +30 -4
- package/src/global-account/bsmnt.native.ts +5 -1
- package/src/global-account/bsmnt.ts +9 -2
- package/src/global-account/client-manager.ts +41 -9
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +6 -11
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +0 -6
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +49 -32
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +53 -8
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -4
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +2 -4
- package/src/global-account/react/components/index.ts +0 -2
- package/src/global-account/react/components/ui/button.tsx +1 -2
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAuth.ts +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +2 -2
- package/src/global-account/react/hooks/useBetterAuth.ts +14 -15
- package/src/global-account/react/hooks/useClient.ts +11 -2
- package/src/global-account/react/hooks/useNativeBalance.tsx +1 -1
- package/src/global-account/react/hooks/useSiwe.native.tsx +1 -1
- package/src/global-account/react/hooks/useSiwe.tsx +1 -1
- package/src/global-account/react/hooks/useTWAuth.tsx +1 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +22 -20
- package/src/global-account/react/stores/useModalStore.ts +28 -0
- package/src/global-account/types/b3-api.types.ts +5 -1
- package/src/notifications/services/api.ts +1 -0
- package/src/shared/constants/chains/b3Chain.ts +4 -43
- package/src/shared/constants/chains/supported.ts +9 -48
- package/src/shared/utils/chain-transformers.ts +41 -39
- package/src/shared/utils/thirdweb-insights.ts +2 -2
- package/src/shared/utils/upload.ts +48 -0
- package/src/styles/index.css +27 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +0 -17
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthClientProvider.js +0 -31
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -46
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -70
- package/dist/cjs/global-account/types/chain-networks.d.ts +0 -44
- package/dist/cjs/global-account/types/chain-networks.js +0 -48
- package/dist/cjs/shared/generated/chain-networks.json +0 -684
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +0 -17
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthClientProvider.js +0 -27
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -43
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -67
- package/dist/esm/global-account/types/chain-networks.d.ts +0 -44
- package/dist/esm/global-account/types/chain-networks.js +0 -45
- package/dist/esm/shared/generated/chain-networks.json +0 -684
- package/dist/types/global-account/react/components/B3Provider/BetterAuthClientProvider.d.ts +0 -17
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/types/global-account/types/chain-networks.d.ts +0 -44
- package/src/global-account/react/components/B3Provider/BetterAuthClientProvider.tsx +0 -40
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +0 -63
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +0 -79
- package/src/global-account/types/chain-networks.ts +0 -54
- package/src/shared/generated/chain-networks.json +0 -684
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/client";
|
|
2
|
-
import {
|
|
2
|
+
import { twoFactorClient } from "better-auth/client/plugins";
|
|
3
|
+
import { getB3ApiUrl } from "../app.shared";
|
|
3
4
|
|
|
4
5
|
export type B3BetterAuthClient = ReturnType<typeof createB3BetterAuthClient>;
|
|
5
6
|
|
|
6
|
-
export function createB3BetterAuthClient(baseURL
|
|
7
|
+
export function createB3BetterAuthClient(baseURL?: string) {
|
|
7
8
|
return createAuthClient({
|
|
8
|
-
baseURL,
|
|
9
|
+
baseURL: baseURL ?? getB3ApiUrl(),
|
|
9
10
|
basePath: "/auth",
|
|
10
11
|
fetchOptions: {
|
|
11
12
|
credentials: "include",
|
|
12
13
|
},
|
|
14
|
+
plugins: [twoFactorClient()],
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
//
|
|
18
|
+
// Lazily-initialized singleton. Recreated when the API URL changes via
|
|
19
|
+
// `resetBetterAuthClient()` (called by B3Provider when `apiUrl` changes).
|
|
20
|
+
let _client: B3BetterAuthClient | null = null;
|
|
21
|
+
let _clientUrl: string | null = null;
|
|
22
|
+
|
|
23
|
+
/** Get the shared BetterAuth client, creating it if needed. */
|
|
24
|
+
export function getBetterAuthClient(): B3BetterAuthClient {
|
|
25
|
+
const url = getB3ApiUrl();
|
|
26
|
+
if (!_client || _clientUrl !== url) {
|
|
27
|
+
_client = createB3BetterAuthClient(url);
|
|
28
|
+
_clientUrl = url;
|
|
29
|
+
}
|
|
30
|
+
return _client;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Force-recreate the client on next access (e.g. after API URL change). */
|
|
34
|
+
export function resetBetterAuthClient(): void {
|
|
35
|
+
_client = null;
|
|
36
|
+
_clientUrl = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `getBetterAuthClient()` instead. This static singleton
|
|
41
|
+
* does not reflect runtime API URL changes via `B3Provider apiUrl` prop.
|
|
42
|
+
*/
|
|
17
43
|
export const betterAuthClient = createB3BetterAuthClient();
|
|
@@ -80,7 +80,11 @@ const app = createClient(socketio(socket), {
|
|
|
80
80
|
storageKey: BSMNT_AUTH_COOKIE_NAME,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
export const authenticate = async (
|
|
83
|
+
export const authenticate = async (
|
|
84
|
+
accessToken: string,
|
|
85
|
+
identityToken: string,
|
|
86
|
+
params?: Record<string, any>,
|
|
87
|
+
): Promise<Record<string, any> | null> => {
|
|
84
88
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
85
89
|
|
|
86
90
|
// Do not authenticate if there is no token
|
|
@@ -42,7 +42,11 @@ const app = createClient(socketio(socket), {
|
|
|
42
42
|
storageKey: BSMNT_AUTH_COOKIE_NAME,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
export const authenticate = async (
|
|
45
|
+
export const authenticate = async (
|
|
46
|
+
accessToken: string,
|
|
47
|
+
identityToken: string,
|
|
48
|
+
params?: Record<string, any>,
|
|
49
|
+
): Promise<Record<string, any> | null> => {
|
|
46
50
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
47
51
|
|
|
48
52
|
// Do not authenticate if there is no token
|
|
@@ -73,7 +77,10 @@ export const resetSocket = () => {
|
|
|
73
77
|
// reset the socket connection
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
export const authenticateWithB3JWT = async (
|
|
80
|
+
export const authenticateWithB3JWT = async (
|
|
81
|
+
fullToken: string,
|
|
82
|
+
params?: Record<string, any>,
|
|
83
|
+
): Promise<Record<string, any> | null> => {
|
|
77
84
|
// Do not authenticate if there is no token
|
|
78
85
|
if (!fullToken) {
|
|
79
86
|
console.log("No token found, not authenticating");
|
|
@@ -2,7 +2,7 @@ import { ClientApplication, createClient } from "@b3dotfun/b3-api";
|
|
|
2
2
|
import rest from "@feathersjs/rest-client";
|
|
3
3
|
import socketio from "@feathersjs/socketio-client";
|
|
4
4
|
import io from "socket.io-client";
|
|
5
|
-
import { authenticate as authenticateB3,
|
|
5
|
+
import { authenticate as authenticateB3, getB3ApiUrl, clientOptions } from "../app.shared";
|
|
6
6
|
|
|
7
7
|
export type ClientType = "socket" | "rest";
|
|
8
8
|
|
|
@@ -13,17 +13,21 @@ let currentClient: ClientApplication | null = null;
|
|
|
13
13
|
// Socket client instance
|
|
14
14
|
let socketClient: ClientApplication | null = null;
|
|
15
15
|
let socketInstance: any = null;
|
|
16
|
+
let socketClientUrl: string | null = null;
|
|
16
17
|
|
|
17
18
|
// REST client instance
|
|
18
19
|
let restClient: ClientApplication | null = null;
|
|
20
|
+
let restClientUrl: string | null = null;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Creates a socket client
|
|
22
24
|
*/
|
|
23
25
|
function createSocketClient(): ClientApplication {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
const url = getB3ApiUrl();
|
|
27
|
+
if (!socketClient || socketClientUrl !== url) {
|
|
28
|
+
socketInstance = io(url, { transports: ["websocket"] });
|
|
26
29
|
socketClient = createClient(socketio(socketInstance), clientOptions);
|
|
30
|
+
socketClientUrl = url;
|
|
27
31
|
}
|
|
28
32
|
return socketClient;
|
|
29
33
|
}
|
|
@@ -40,13 +44,24 @@ function resolveFetch(): typeof fetch {
|
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
function createRestClient(): ClientApplication {
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
const url = getB3ApiUrl();
|
|
48
|
+
if (!restClient || restClientUrl !== url) {
|
|
49
|
+
const connection = rest(url).fetch(resolveFetch());
|
|
45
50
|
restClient = createClient(connection, clientOptions);
|
|
51
|
+
restClientUrl = url;
|
|
46
52
|
}
|
|
47
53
|
return restClient;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
/** Reset all cached clients (called when API URL changes). */
|
|
57
|
+
export function resetClients(): void {
|
|
58
|
+
socketClient = null;
|
|
59
|
+
socketClientUrl = null;
|
|
60
|
+
restClient = null;
|
|
61
|
+
restClientUrl = null;
|
|
62
|
+
currentClient = null;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
/**
|
|
51
66
|
* Sets the active client type and creates the appropriate client
|
|
52
67
|
*
|
|
@@ -99,7 +114,11 @@ export function resetSocket(): void {
|
|
|
99
114
|
/**
|
|
100
115
|
* Authenticates with the current active client
|
|
101
116
|
*/
|
|
102
|
-
export const authenticate = async (
|
|
117
|
+
export const authenticate = async (
|
|
118
|
+
accessToken: string,
|
|
119
|
+
identityToken: string,
|
|
120
|
+
params?: Record<string, any>,
|
|
121
|
+
): Promise<Record<string, any> | null> => {
|
|
103
122
|
return authenticateB3(getClient(), accessToken, identityToken, params);
|
|
104
123
|
};
|
|
105
124
|
|
|
@@ -111,7 +130,7 @@ export const authenticateWithClient = async (
|
|
|
111
130
|
accessToken: string,
|
|
112
131
|
identityToken: string,
|
|
113
132
|
params?: Record<string, any>,
|
|
114
|
-
) => {
|
|
133
|
+
): Promise<Record<string, any> | null> => {
|
|
115
134
|
const client = getClientByType(clientType);
|
|
116
135
|
return authenticateB3(client, accessToken, identityToken, params);
|
|
117
136
|
};
|
|
@@ -119,7 +138,15 @@ export const authenticateWithClient = async (
|
|
|
119
138
|
/**
|
|
120
139
|
* Authenticates with both clients in parallel (useful for migration scenarios)
|
|
121
140
|
*/
|
|
122
|
-
export const authenticateBoth = async (
|
|
141
|
+
export const authenticateBoth = async (
|
|
142
|
+
accessToken: string,
|
|
143
|
+
identityToken: string,
|
|
144
|
+
params?: Record<string, any>,
|
|
145
|
+
): Promise<{
|
|
146
|
+
socket: Record<string, any> | null;
|
|
147
|
+
rest: Record<string, any> | null;
|
|
148
|
+
success: boolean;
|
|
149
|
+
}> => {
|
|
123
150
|
const [socketResult, restResult] = await Promise.allSettled([
|
|
124
151
|
authenticateWithClient("socket", accessToken, identityToken, params),
|
|
125
152
|
authenticateWithClient("rest", accessToken, identityToken, params),
|
|
@@ -135,7 +162,12 @@ export const authenticateBoth = async (accessToken: string, identityToken: strin
|
|
|
135
162
|
/**
|
|
136
163
|
* Switches the client type and authenticates
|
|
137
164
|
*/
|
|
138
|
-
export async function switchClientAndAuth(
|
|
165
|
+
export async function switchClientAndAuth(
|
|
166
|
+
type: ClientType,
|
|
167
|
+
access: string,
|
|
168
|
+
id: string,
|
|
169
|
+
params?: any,
|
|
170
|
+
): Promise<Record<string, any> | null> {
|
|
139
171
|
setClientType(type);
|
|
140
172
|
return authenticateWithClient(type, access, id, params);
|
|
141
173
|
}
|
|
@@ -13,7 +13,7 @@ import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profi
|
|
|
13
13
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
14
14
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
15
15
|
import { getIpfsUrl } from "@b3dotfun/sdk/shared/utils/ipfs";
|
|
16
|
-
import {
|
|
16
|
+
import { uploadFile as uploadToB3 } from "@b3dotfun/sdk/shared/utils/upload";
|
|
17
17
|
import { Loader2, Upload, X } from "lucide-react";
|
|
18
18
|
import { useCallback, useRef, useState } from "react";
|
|
19
19
|
import type { Area } from "react-easy-crop";
|
|
@@ -21,7 +21,6 @@ import Cropper from "react-easy-crop";
|
|
|
21
21
|
import "react-easy-crop/react-easy-crop.css";
|
|
22
22
|
|
|
23
23
|
import { useActiveAccount } from "thirdweb/react";
|
|
24
|
-
import { upload } from "thirdweb/storage";
|
|
25
24
|
import { useModalStore } from "../../stores";
|
|
26
25
|
import ModalHeader from "../ModalHeader/ModalHeader";
|
|
27
26
|
|
|
@@ -243,22 +242,18 @@ export function AvatarEditor({ onSetAvatar, className }: AvatarEditorProps) {
|
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
// Upload
|
|
245
|
+
// Upload file if we have one
|
|
247
246
|
if (fileToUpload) {
|
|
248
|
-
debug("Starting upload
|
|
247
|
+
debug("Starting upload", fileToUpload);
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
const ipfsUrl = await upload({
|
|
252
|
-
client,
|
|
253
|
-
files: [fileToUpload],
|
|
254
|
-
});
|
|
249
|
+
const avatarUrl = await uploadToB3(fileToUpload);
|
|
255
250
|
|
|
256
|
-
debug("Upload successful",
|
|
251
|
+
debug("Upload successful", avatarUrl);
|
|
257
252
|
|
|
258
253
|
// Save avatar URL using profiles service
|
|
259
254
|
const user = await app.service("users").setAvatar(
|
|
260
255
|
{
|
|
261
|
-
avatar:
|
|
256
|
+
avatar: avatarUrl,
|
|
262
257
|
},
|
|
263
258
|
// @ts-expect-error - our typed client is expecting context even though it's set elsewhere
|
|
264
259
|
{},
|
|
@@ -28,8 +28,6 @@ export interface B3ConfigContextType {
|
|
|
28
28
|
stripePublishableKey?: string;
|
|
29
29
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
30
30
|
authStrategy: AuthStrategy;
|
|
31
|
-
/** Override the API base URL for all auth operations (Better Auth client, Feathers JWT exchange). */
|
|
32
|
-
apiUrl?: string;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
const B3ConfigContext = createContext<B3ConfigContextType | null>(null);
|
|
@@ -46,7 +44,6 @@ export function B3ConfigProvider({
|
|
|
46
44
|
stripePublishableKey,
|
|
47
45
|
createClientReferenceId,
|
|
48
46
|
authStrategy = "thirdweb",
|
|
49
|
-
apiUrl,
|
|
50
47
|
}: {
|
|
51
48
|
children: React.ReactNode;
|
|
52
49
|
accountOverride?: Account;
|
|
@@ -59,8 +56,6 @@ export function B3ConfigProvider({
|
|
|
59
56
|
stripePublishableKey?: string;
|
|
60
57
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
61
58
|
authStrategy?: AuthStrategy;
|
|
62
|
-
/** Override the API base URL for all auth operations (Better Auth client, Feathers JWT exchange). */
|
|
63
|
-
apiUrl?: string;
|
|
64
59
|
}) {
|
|
65
60
|
return (
|
|
66
61
|
<B3ConfigContext.Provider
|
|
@@ -75,7 +70,6 @@ export function B3ConfigProvider({
|
|
|
75
70
|
stripePublishableKey,
|
|
76
71
|
createClientReferenceId,
|
|
77
72
|
authStrategy,
|
|
78
|
-
apiUrl,
|
|
79
73
|
}}
|
|
80
74
|
>
|
|
81
75
|
{children}
|
|
@@ -11,15 +11,22 @@ import { QueryClient } from "@tanstack/react-query";
|
|
|
11
11
|
import { useEffect, useMemo } from "react";
|
|
12
12
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
13
13
|
import { CreateConnectorFn } from "wagmi";
|
|
14
|
-
import { ClientType, setClientType } from "../../../client-manager";
|
|
14
|
+
import { ClientType, resetClients, setClientType } from "../../../client-manager";
|
|
15
|
+
import { setB3ApiUrl } from "../../../../app.shared";
|
|
16
|
+
import { setApiUrl as setNotificationsApiUrl } from "../../../../notifications/services/api";
|
|
17
|
+
import { resetBetterAuthClient } from "../../../better-auth-client";
|
|
15
18
|
import { StyleRoot } from "../StyleRoot";
|
|
16
19
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
|
|
17
20
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
18
21
|
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
19
|
-
import { BetterAuthClientProvider } from "./BetterAuthClientProvider";
|
|
20
22
|
import BetterAuthProvider from "./BetterAuthProvider";
|
|
21
23
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
22
24
|
|
|
25
|
+
const NOTIFICATIONS_URL_BY_ENV = {
|
|
26
|
+
development: "https://dev-notifications.b3.fun",
|
|
27
|
+
production: "https://notifications.b3.fun",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
23
30
|
/**
|
|
24
31
|
* Main B3Provider component
|
|
25
32
|
*/
|
|
@@ -47,6 +54,7 @@ export function B3Provider({
|
|
|
47
54
|
queryClient,
|
|
48
55
|
authStrategy = "thirdweb",
|
|
49
56
|
apiUrl,
|
|
57
|
+
notificationsApiUrl,
|
|
50
58
|
}: {
|
|
51
59
|
theme: "light" | "dark";
|
|
52
60
|
children: React.ReactNode;
|
|
@@ -77,22 +85,34 @@ export function B3Provider({
|
|
|
77
85
|
/** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
|
|
78
86
|
authStrategy?: AuthStrategy;
|
|
79
87
|
/**
|
|
80
|
-
* Override the API
|
|
81
|
-
*
|
|
82
|
-
* When set, the Better Auth client (signIn, signUp, signOut, getSession) will
|
|
83
|
-
* target this URL instead of the default `B3_API_URL` / `NEXT_PUBLIC_B3_API`.
|
|
88
|
+
* Override the B3 API URL. When provided, all SDK requests (auth, Feathers,
|
|
89
|
+
* BetterAuth) will use this URL instead of the `NEXT_PUBLIC_B3_API` env var.
|
|
84
90
|
*
|
|
85
|
-
* Useful for local development
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```tsx
|
|
91
|
-
* <B3Provider apiUrl="http://localhost:3031" ... />
|
|
92
|
-
* ```
|
|
91
|
+
* Useful for local development: pass `http://localhost:3031` to route
|
|
92
|
+
* OAuth callbacks and session checks through your local B3 API.
|
|
93
|
+
* If omitted, defaults to `NEXT_PUBLIC_B3_API` or `https://api.b3.fun`.
|
|
93
94
|
*/
|
|
94
95
|
apiUrl?: string;
|
|
96
|
+
/** Override the notifications worker URL. Defaults to `https://notifications.b3.fun`. */
|
|
97
|
+
notificationsApiUrl?: string;
|
|
95
98
|
}) {
|
|
99
|
+
// Override the B3 API URL when the `apiUrl` prop is provided.
|
|
100
|
+
// Must run before client initialization and auth providers mount.
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
setB3ApiUrl(apiUrl ?? null);
|
|
103
|
+
if (apiUrl) {
|
|
104
|
+
resetBetterAuthClient();
|
|
105
|
+
resetClients();
|
|
106
|
+
}
|
|
107
|
+
return () => {
|
|
108
|
+
setB3ApiUrl(null);
|
|
109
|
+
};
|
|
110
|
+
}, [apiUrl]);
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
setNotificationsApiUrl(notificationsApiUrl ?? NOTIFICATIONS_URL_BY_ENV[environment ?? "production"]);
|
|
114
|
+
}, [notificationsApiUrl, environment]);
|
|
115
|
+
|
|
96
116
|
// Initialize Google Analytics on mount
|
|
97
117
|
useEffect(() => {
|
|
98
118
|
loadGA4Script();
|
|
@@ -128,25 +148,22 @@ export function B3Provider({
|
|
|
128
148
|
createClientReferenceId={createClientReferenceId}
|
|
129
149
|
defaultPermissions={defaultPermissions}
|
|
130
150
|
authStrategy={authStrategy}
|
|
131
|
-
apiUrl={apiUrl}
|
|
132
151
|
>
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
)}
|
|
149
|
-
</BetterAuthClientProvider>
|
|
152
|
+
<ToastContextConnector />
|
|
153
|
+
<RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
|
|
154
|
+
{children}
|
|
155
|
+
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
156
|
+
<StyleRoot id="b3-root" />
|
|
157
|
+
</RelayKitProviderWrapper>
|
|
158
|
+
{authStrategy === "better-auth" ? (
|
|
159
|
+
<BetterAuthProvider partnerId={partnerId} />
|
|
160
|
+
) : (
|
|
161
|
+
<AuthenticationProvider
|
|
162
|
+
partnerId={partnerId}
|
|
163
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
164
|
+
defaultEoaProvider={defaultEoaProvider}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
150
167
|
</B3ConfigProvider>
|
|
151
168
|
</LocalSDKProvider>
|
|
152
169
|
</ToastProvider>
|
|
@@ -4,8 +4,8 @@ import { B3_AUTH_COOKIE_NAME } from "@b3dotfun/sdk/shared/constants";
|
|
|
4
4
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
5
5
|
import Cookies from "js-cookie";
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
7
|
+
import { getBetterAuthClient } from "../../../better-auth-client";
|
|
7
8
|
import { useUserQuery } from "../../hooks/useUserQuery";
|
|
8
|
-
import { useBetterAuthClient } from "./BetterAuthClientProvider";
|
|
9
9
|
|
|
10
10
|
const debug = debugB3React("BetterAuthProvider");
|
|
11
11
|
|
|
@@ -22,7 +22,6 @@ const debug = debugB3React("BetterAuthProvider");
|
|
|
22
22
|
* useAuth, SignIn component, etc.) automatically clears the Better Auth session.
|
|
23
23
|
*/
|
|
24
24
|
const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
25
|
-
const betterAuthClient = useBetterAuthClient();
|
|
26
25
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
27
26
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
28
27
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
@@ -44,7 +43,7 @@ const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
|
44
43
|
(app as any).logout = async () => {
|
|
45
44
|
debug("Patched logout: clearing Better Auth session");
|
|
46
45
|
try {
|
|
47
|
-
await
|
|
46
|
+
await getBetterAuthClient().signOut();
|
|
48
47
|
} catch {
|
|
49
48
|
debug("Better Auth signOut failed (non-critical)");
|
|
50
49
|
}
|
|
@@ -55,7 +54,7 @@ const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
|
55
54
|
(app as any).logout = originalLogout;
|
|
56
55
|
hasPatched.current = false;
|
|
57
56
|
};
|
|
58
|
-
}, [
|
|
57
|
+
}, []);
|
|
59
58
|
|
|
60
59
|
// Session restore on mount
|
|
61
60
|
useEffect(() => {
|
|
@@ -80,9 +79,55 @@ const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
|
80
79
|
debug("No existing Feathers JWT");
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
// 2. Check for
|
|
82
|
+
// 2. Check for _ba_token in URL (OAuth callback with third-party cookie bypass).
|
|
83
|
+
// When the API and frontend are on different domains, browsers with third-party
|
|
84
|
+
// cookie blocking (Firefox TCP, Safari ITP, Chrome Privacy Sandbox) prevent the
|
|
85
|
+
// better-auth.session_token cookie from being sent on cross-origin requests.
|
|
86
|
+
// The B3 API injects the session token into the redirect URL as _ba_token,
|
|
87
|
+
// allowing direct exchange without relying on cookies.
|
|
88
|
+
const params = new URLSearchParams(window.location.search);
|
|
89
|
+
const baToken = params.get("_ba_token");
|
|
90
|
+
if (baToken) {
|
|
91
|
+
debug("Found _ba_token in URL, exchanging for Feathers JWT");
|
|
92
|
+
|
|
93
|
+
// Clean the token from the URL immediately (security)
|
|
94
|
+
params.delete("_ba_token");
|
|
95
|
+
const cleanSearch = params.toString();
|
|
96
|
+
const cleanUrl = window.location.pathname + (cleanSearch ? `?${cleanSearch}` : "") + window.location.hash;
|
|
97
|
+
window.history.replaceState({}, "", cleanUrl);
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const response = await app.authenticate({
|
|
101
|
+
strategy: "better-auth",
|
|
102
|
+
accessToken: baToken,
|
|
103
|
+
partnerId,
|
|
104
|
+
} as any);
|
|
105
|
+
|
|
106
|
+
if (response.accessToken) {
|
|
107
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, response.accessToken, {
|
|
108
|
+
secure: true,
|
|
109
|
+
sameSite: "Lax",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (response.user) {
|
|
114
|
+
setUser(response.user);
|
|
115
|
+
setIsAuthenticated(true);
|
|
116
|
+
setIsConnected(true);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
debug("_ba_token exchanged for Feathers JWT", { userId: response.user?.userId });
|
|
120
|
+
setIsAuthenticating(false);
|
|
121
|
+
return;
|
|
122
|
+
} catch (err) {
|
|
123
|
+
debug("_ba_token exchange failed", err);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 3. Check for a Better Auth session via cookie (works when API and frontend
|
|
128
|
+
// share a domain or when cookies aren't partitioned)
|
|
84
129
|
try {
|
|
85
|
-
const session = await
|
|
130
|
+
const session = await getBetterAuthClient().getSession();
|
|
86
131
|
if (session.data?.session?.token) {
|
|
87
132
|
debug("Better Auth session found, exchanging for Feathers JWT", {
|
|
88
133
|
betterAuthUserId: session.data.user?.id,
|
|
@@ -115,12 +160,12 @@ const BetterAuthProvider = ({ partnerId }: { partnerId: string }) => {
|
|
|
115
160
|
debug("No Better Auth session to restore");
|
|
116
161
|
}
|
|
117
162
|
|
|
118
|
-
//
|
|
163
|
+
// 4. Nothing found — show login UI
|
|
119
164
|
setIsAuthenticating(false);
|
|
120
165
|
};
|
|
121
166
|
|
|
122
167
|
restoreSession();
|
|
123
|
-
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId
|
|
168
|
+
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId]);
|
|
124
169
|
|
|
125
170
|
return null;
|
|
126
171
|
};
|
|
@@ -84,7 +84,7 @@ const SettingsProfileCard = () => {
|
|
|
84
84
|
// Better Auth: register username without wallet signing (DB-only, no ENS)
|
|
85
85
|
// Skip ens_normalize — it rejects underscores/mixed-case that are valid non-ENS usernames
|
|
86
86
|
const sanitizedUsername = editedUsername.trim().toLowerCase();
|
|
87
|
-
// Type assertion needed:
|
|
87
|
+
// Type assertion needed: API now accepts message/hash as optional for Better Auth users
|
|
88
88
|
updatedUser = (await app
|
|
89
89
|
.service("users")
|
|
90
90
|
.registerUsername({ username: sanitizedUsername } as any, {} as any)) as unknown as Users;
|
|
@@ -12,7 +12,6 @@ import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
|
12
12
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
13
13
|
import { useActiveAccount } from "thirdweb/react";
|
|
14
14
|
import { Account } from "thirdweb/wallets";
|
|
15
|
-
import { SignInWithB3Privy } from "./SignInWithB3Privy";
|
|
16
15
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep";
|
|
17
16
|
import { LoginStepCustom } from "./steps/LoginStepCustom";
|
|
18
17
|
|
|
@@ -310,9 +309,7 @@ export function SignInWithB3Flow({
|
|
|
310
309
|
);
|
|
311
310
|
} else {
|
|
312
311
|
// Custom strategy
|
|
313
|
-
if (strategies
|
|
314
|
-
content = <SignInWithB3Privy onSuccess={handleLoginSuccess} chain={chain} />;
|
|
315
|
-
} else if (strategies) {
|
|
312
|
+
if (strategies) {
|
|
316
313
|
// Strategies are explicitly provided
|
|
317
314
|
content = (
|
|
318
315
|
<LoginStepCustom
|
|
@@ -3,12 +3,11 @@ import { createWallet, SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
|
3
3
|
|
|
4
4
|
type WalletType = Wallet["id"];
|
|
5
5
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
6
|
-
|
|
6
|
+
const customStrategies = ["basement"] as const;
|
|
7
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
7
8
|
|
|
8
9
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
9
10
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
10
|
-
const customStrategies = ["basement", "privy"] as const;
|
|
11
|
-
// type CustomStrategy = (typeof customStrategies)[number];
|
|
12
11
|
|
|
13
12
|
export const allowedStrategies = [
|
|
14
13
|
// Auth strategies
|
|
@@ -26,7 +25,6 @@ export const allowedStrategies = [
|
|
|
26
25
|
"com.coinbase.wallet",
|
|
27
26
|
|
|
28
27
|
// Custom strategies
|
|
29
|
-
// TODO: Audit we don't use "privy" directly anymore
|
|
30
28
|
...customStrategies,
|
|
31
29
|
] as const;
|
|
32
30
|
|
|
@@ -7,7 +7,6 @@ export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
|
7
7
|
export { useB3 } from "./B3Provider/useB3";
|
|
8
8
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
9
9
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
10
|
-
export { useBetterAuthClient } from "./B3Provider/BetterAuthClientProvider";
|
|
11
10
|
export { StyleRoot } from "./StyleRoot";
|
|
12
11
|
|
|
13
12
|
// SignInWithB3 Components
|
|
@@ -23,7 +22,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
23
22
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
24
23
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
25
24
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
26
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
27
25
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
28
26
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
29
27
|
|
|
@@ -32,8 +32,7 @@ const buttonVariants = cva(
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
export interface ButtonProps
|
|
35
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
36
|
-
VariantProps<typeof buttonVariants> {
|
|
35
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
37
36
|
asChild?: boolean;
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -62,7 +62,7 @@ export function useAuth() {
|
|
|
62
62
|
* Re-authenticate using existing session
|
|
63
63
|
* Also updates user state and authenticates with BSMNT
|
|
64
64
|
*/
|
|
65
|
-
const reAuthenticate = useCallback(async () => {
|
|
65
|
+
const reAuthenticate = useCallback(async (): Promise<Record<string, any>> => {
|
|
66
66
|
debug("Re-authenticating...");
|
|
67
67
|
try {
|
|
68
68
|
const response = await app.reAuthenticate();
|
|
@@ -191,7 +191,7 @@ export function useAuth() {
|
|
|
191
191
|
* 3. Authenticates with BSMNT for basement integration
|
|
192
192
|
*/
|
|
193
193
|
const authenticate = useCallback(
|
|
194
|
-
async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt") => {
|
|
194
|
+
async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt"): Promise<Record<string, any>> => {
|
|
195
195
|
if (!accessToken) {
|
|
196
196
|
throw new Error("Access token is required");
|
|
197
197
|
}
|
|
@@ -120,7 +120,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
120
120
|
}, [wallets, syncWagmi]);
|
|
121
121
|
|
|
122
122
|
const authenticateUser = useCallback(
|
|
123
|
-
async (wallet?: Wallet) => {
|
|
123
|
+
async (wallet?: Wallet): Promise<Record<string, any>> => {
|
|
124
124
|
setHasStartedConnecting(true);
|
|
125
125
|
|
|
126
126
|
if (!wallet) {
|
|
@@ -216,7 +216,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
216
216
|
localStorage.removeItem("b3-user");
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
app.logout();
|
|
219
|
+
await app.logout();
|
|
220
220
|
debug("@@logout:loggedOut");
|
|
221
221
|
|
|
222
222
|
setIsAuthenticated(false);
|