@b3dotfun/sdk 0.1.70-alpha.1 → 0.1.70-alpha.10
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,13 +1,36 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { twoFactorClient } from "better-auth/client/plugins";
|
|
3
|
+
import { getB3ApiUrl } from "../app.shared.js";
|
|
4
|
+
export function createB3BetterAuthClient(baseURL) {
|
|
4
5
|
return createAuthClient({
|
|
5
|
-
baseURL,
|
|
6
|
+
baseURL: baseURL ?? getB3ApiUrl(),
|
|
6
7
|
basePath: "/auth",
|
|
7
8
|
fetchOptions: {
|
|
8
9
|
credentials: "include",
|
|
9
10
|
},
|
|
11
|
+
plugins: [twoFactorClient()],
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
|
-
//
|
|
14
|
+
// Lazily-initialized singleton. Recreated when the API URL changes via
|
|
15
|
+
// `resetBetterAuthClient()` (called by B3Provider when `apiUrl` changes).
|
|
16
|
+
let _client = null;
|
|
17
|
+
let _clientUrl = null;
|
|
18
|
+
/** Get the shared BetterAuth client, creating it if needed. */
|
|
19
|
+
export function getBetterAuthClient() {
|
|
20
|
+
const url = getB3ApiUrl();
|
|
21
|
+
if (!_client || _clientUrl !== url) {
|
|
22
|
+
_client = createB3BetterAuthClient(url);
|
|
23
|
+
_clientUrl = url;
|
|
24
|
+
}
|
|
25
|
+
return _client;
|
|
26
|
+
}
|
|
27
|
+
/** Force-recreate the client on next access (e.g. after API URL change). */
|
|
28
|
+
export function resetBetterAuthClient() {
|
|
29
|
+
_client = null;
|
|
30
|
+
_clientUrl = null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `getBetterAuthClient()` instead. This static singleton
|
|
34
|
+
* does not reflect runtime API URL changes via `B3Provider apiUrl` prop.
|
|
35
|
+
*/
|
|
13
36
|
export const betterAuthClient = createB3BetterAuthClient();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const app: import("@b3dotfun/basement-api").ClientApplication;
|
|
2
|
-
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<
|
|
2
|
+
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
|
|
3
3
|
export declare const resetSocket: () => void;
|
|
4
|
-
export declare const authenticateWithB3JWT: (fullToken: string, params?: Record<string, any>) => Promise<
|
|
4
|
+
export declare const authenticateWithB3JWT: (fullToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
|
|
5
5
|
export default app;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MMKV } from "react-native-mmkv";
|
|
2
2
|
export declare const localStoreInstance: MMKV;
|
|
3
3
|
declare const app: import("@b3dotfun/basement-api").ClientApplication;
|
|
4
|
-
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<
|
|
4
|
+
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
|
|
5
5
|
export default app;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientApplication } from "@b3dotfun/b3-api";
|
|
2
2
|
export type ClientType = "socket" | "rest";
|
|
3
|
+
/** Reset all cached clients (called when API URL changes). */
|
|
4
|
+
export declare function resetClients(): void;
|
|
3
5
|
/**
|
|
4
6
|
* Sets the active client type and creates the appropriate client
|
|
5
7
|
*
|
|
@@ -25,20 +27,20 @@ export declare function resetSocket(): void;
|
|
|
25
27
|
/**
|
|
26
28
|
* Authenticates with the current active client
|
|
27
29
|
*/
|
|
28
|
-
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<
|
|
30
|
+
export declare const authenticate: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
|
|
29
31
|
/**
|
|
30
32
|
* Authenticates with a specific client type
|
|
31
33
|
*/
|
|
32
|
-
export declare const authenticateWithClient: (clientType: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<
|
|
34
|
+
export declare const authenticateWithClient: (clientType: ClientType, accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<Record<string, any> | null>;
|
|
33
35
|
/**
|
|
34
36
|
* Authenticates with both clients in parallel (useful for migration scenarios)
|
|
35
37
|
*/
|
|
36
38
|
export declare const authenticateBoth: (accessToken: string, identityToken: string, params?: Record<string, any>) => Promise<{
|
|
37
|
-
socket:
|
|
38
|
-
rest:
|
|
39
|
+
socket: Record<string, any> | null;
|
|
40
|
+
rest: Record<string, any> | null;
|
|
39
41
|
success: boolean;
|
|
40
42
|
}>;
|
|
41
43
|
/**
|
|
42
44
|
* Switches the client type and authenticates
|
|
43
45
|
*/
|
|
44
|
-
export declare function switchClientAndAuth(type: ClientType, access: string, id: string, params?: any): Promise<
|
|
46
|
+
export declare function switchClientAndAuth(type: ClientType, access: string, id: string, params?: any): Promise<Record<string, any> | null>;
|
|
@@ -2,22 +2,26 @@ import { 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.js";
|
|
6
6
|
// Global state to track which client type is active
|
|
7
7
|
let currentClientType = "rest";
|
|
8
8
|
let currentClient = null;
|
|
9
9
|
// Socket client instance
|
|
10
10
|
let socketClient = null;
|
|
11
11
|
let socketInstance = null;
|
|
12
|
+
let socketClientUrl = null;
|
|
12
13
|
// REST client instance
|
|
13
14
|
let restClient = null;
|
|
15
|
+
let restClientUrl = null;
|
|
14
16
|
/**
|
|
15
17
|
* Creates a socket client
|
|
16
18
|
*/
|
|
17
19
|
function createSocketClient() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const url = getB3ApiUrl();
|
|
21
|
+
if (!socketClient || socketClientUrl !== url) {
|
|
22
|
+
socketInstance = io(url, { transports: ["websocket"] });
|
|
20
23
|
socketClient = createClient(socketio(socketInstance), clientOptions);
|
|
24
|
+
socketClientUrl = url;
|
|
21
25
|
}
|
|
22
26
|
return socketClient;
|
|
23
27
|
}
|
|
@@ -33,12 +37,22 @@ function resolveFetch() {
|
|
|
33
37
|
return require("cross-fetch").fetch;
|
|
34
38
|
}
|
|
35
39
|
function createRestClient() {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
const url = getB3ApiUrl();
|
|
41
|
+
if (!restClient || restClientUrl !== url) {
|
|
42
|
+
const connection = rest(url).fetch(resolveFetch());
|
|
38
43
|
restClient = createClient(connection, clientOptions);
|
|
44
|
+
restClientUrl = url;
|
|
39
45
|
}
|
|
40
46
|
return restClient;
|
|
41
47
|
}
|
|
48
|
+
/** Reset all cached clients (called when API URL changes). */
|
|
49
|
+
export function resetClients() {
|
|
50
|
+
socketClient = null;
|
|
51
|
+
socketClientUrl = null;
|
|
52
|
+
restClient = null;
|
|
53
|
+
restClientUrl = null;
|
|
54
|
+
currentClient = null;
|
|
55
|
+
}
|
|
42
56
|
/**
|
|
43
57
|
* Sets the active client type and creates the appropriate client
|
|
44
58
|
*
|
|
@@ -6,13 +6,12 @@ import { validateImageUrl } from "../../../../global-account/react/utils/profile
|
|
|
6
6
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
7
7
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
8
8
|
import { getIpfsUrl } from "../../../../shared/utils/ipfs.js";
|
|
9
|
-
import {
|
|
9
|
+
import { uploadFile as uploadToB3 } from "../../../../shared/utils/upload.js";
|
|
10
10
|
import { Loader2, Upload, X } from "lucide-react";
|
|
11
11
|
import { useCallback, useRef, useState } from "react";
|
|
12
12
|
import Cropper from "react-easy-crop";
|
|
13
13
|
import "react-easy-crop/react-easy-crop.css";
|
|
14
14
|
import { useActiveAccount } from "thirdweb/react";
|
|
15
|
-
import { upload } from "thirdweb/storage";
|
|
16
15
|
import { useModalStore } from "../../stores/index.js";
|
|
17
16
|
import ModalHeader from "../ModalHeader/ModalHeader.js";
|
|
18
17
|
const debug = debugB3React("AvatarEditor");
|
|
@@ -195,18 +194,14 @@ export function AvatarEditor({ onSetAvatar, className }) {
|
|
|
195
194
|
return;
|
|
196
195
|
}
|
|
197
196
|
}
|
|
198
|
-
// Upload
|
|
197
|
+
// Upload file if we have one
|
|
199
198
|
if (fileToUpload) {
|
|
200
|
-
debug("Starting upload
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
client,
|
|
204
|
-
files: [fileToUpload],
|
|
205
|
-
});
|
|
206
|
-
debug("Upload successful", ipfsUrl);
|
|
199
|
+
debug("Starting upload", fileToUpload);
|
|
200
|
+
const avatarUrl = await uploadToB3(fileToUpload);
|
|
201
|
+
debug("Upload successful", avatarUrl);
|
|
207
202
|
// Save avatar URL using profiles service
|
|
208
203
|
const user = await app.service("users").setAvatar({
|
|
209
|
-
avatar:
|
|
204
|
+
avatar: avatarUrl,
|
|
210
205
|
},
|
|
211
206
|
// @ts-expect-error - our typed client is expecting context even though it's set elsewhere
|
|
212
207
|
{});
|
|
@@ -15,10 +15,8 @@ export interface B3ConfigContextType {
|
|
|
15
15
|
stripePublishableKey?: string;
|
|
16
16
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
17
17
|
authStrategy: AuthStrategy;
|
|
18
|
-
/** Override the API base URL for all auth operations (Better Auth client, Feathers JWT exchange). */
|
|
19
|
-
apiUrl?: string;
|
|
20
18
|
}
|
|
21
|
-
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, authStrategy,
|
|
19
|
+
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, authStrategy, }: {
|
|
22
20
|
children: React.ReactNode;
|
|
23
21
|
accountOverride?: Account;
|
|
24
22
|
environment?: "development" | "production";
|
|
@@ -30,7 +28,5 @@ export declare function B3ConfigProvider({ children, accountOverride, environmen
|
|
|
30
28
|
stripePublishableKey?: string;
|
|
31
29
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
30
|
authStrategy?: AuthStrategy;
|
|
33
|
-
/** Override the API base URL for all auth operations (Better Auth client, Feathers JWT exchange). */
|
|
34
|
-
apiUrl?: string;
|
|
35
31
|
}): import("react/jsx-runtime").JSX.Element;
|
|
36
32
|
export declare function useB3Config(): B3ConfigContextType;
|
|
@@ -10,7 +10,7 @@ const DEFAULT_PERMISSIONS = {
|
|
|
10
10
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
11
11
|
};
|
|
12
12
|
const B3ConfigContext = createContext(null);
|
|
13
|
-
export function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, authStrategy = "thirdweb",
|
|
13
|
+
export function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, authStrategy = "thirdweb", }) {
|
|
14
14
|
return (_jsx(B3ConfigContext.Provider, { value: {
|
|
15
15
|
accountOverride,
|
|
16
16
|
environment,
|
|
@@ -22,7 +22,6 @@ export function B3ConfigProvider({ children, accountOverride, environment = "dev
|
|
|
22
22
|
stripePublishableKey,
|
|
23
23
|
createClientReferenceId,
|
|
24
24
|
authStrategy,
|
|
25
|
-
apiUrl,
|
|
26
25
|
}, children: children }));
|
|
27
26
|
}
|
|
28
27
|
export function useB3Config() {
|
|
@@ -10,7 +10,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
10
10
|
/**
|
|
11
11
|
* Main B3Provider component
|
|
12
12
|
*/
|
|
13
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, authStrategy, apiUrl, }: {
|
|
13
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, authStrategy, apiUrl, notificationsApiUrl, }: {
|
|
14
14
|
theme: "light" | "dark";
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
accountOverride?: Account;
|
|
@@ -40,19 +40,14 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
40
40
|
/** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
|
|
41
41
|
authStrategy?: AuthStrategy;
|
|
42
42
|
/**
|
|
43
|
-
* Override the API
|
|
43
|
+
* Override the B3 API URL. When provided, all SDK requests (auth, Feathers,
|
|
44
|
+
* BetterAuth) will use this URL instead of the `NEXT_PUBLIC_B3_API` env var.
|
|
44
45
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* Useful for local development where the frontend runs on localhost:3003 and
|
|
49
|
-
* the b3-api runs on localhost:3031 — keeps the entire OAuth flow local so
|
|
50
|
-
* sessions, cookies, and token exchange all hit the same server.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```tsx
|
|
54
|
-
* <B3Provider apiUrl="http://localhost:3031" ... />
|
|
55
|
-
* ```
|
|
46
|
+
* Useful for local development: pass `http://localhost:3031` to route
|
|
47
|
+
* OAuth callbacks and session checks through your local B3 API.
|
|
48
|
+
* If omitted, defaults to `NEXT_PUBLIC_B3_API` or `https://api.b3.fun`.
|
|
56
49
|
*/
|
|
57
50
|
apiUrl?: string;
|
|
51
|
+
/** Override the notifications worker URL. Defaults to `https://notifications.b3.fun`. */
|
|
52
|
+
notificationsApiUrl?: string;
|
|
58
53
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,20 +5,41 @@ import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
|
5
5
|
import { WalletProvider } from "../../../../wallet/react/index.js";
|
|
6
6
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
7
7
|
import { useEffect, useMemo } from "react";
|
|
8
|
-
import { setClientType } from "../../../client-manager.js";
|
|
8
|
+
import { resetClients, setClientType } from "../../../client-manager.js";
|
|
9
|
+
import { setB3ApiUrl } from "../../../../app.shared.js";
|
|
10
|
+
import { setApiUrl as setNotificationsApiUrl } from "../../../../notifications/services/api.js";
|
|
11
|
+
import { resetBetterAuthClient } from "../../../better-auth-client.js";
|
|
9
12
|
import { StyleRoot } from "../StyleRoot.js";
|
|
10
13
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
|
|
11
14
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
12
15
|
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
13
|
-
import { BetterAuthClientProvider } from "./BetterAuthClientProvider.js";
|
|
14
16
|
import BetterAuthProvider from "./BetterAuthProvider.js";
|
|
15
17
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
18
|
+
const NOTIFICATIONS_URL_BY_ENV = {
|
|
19
|
+
development: "https://dev-notifications.b3.fun",
|
|
20
|
+
production: "https://notifications.b3.fun",
|
|
21
|
+
};
|
|
16
22
|
/**
|
|
17
23
|
* Main B3Provider component
|
|
18
24
|
*/
|
|
19
25
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey,
|
|
20
26
|
// deprecated since v0.0.87
|
|
21
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, authStrategy = "thirdweb", apiUrl, }) {
|
|
27
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, authStrategy = "thirdweb", apiUrl, notificationsApiUrl, }) {
|
|
28
|
+
// Override the B3 API URL when the `apiUrl` prop is provided.
|
|
29
|
+
// Must run before client initialization and auth providers mount.
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setB3ApiUrl(apiUrl ?? null);
|
|
32
|
+
if (apiUrl) {
|
|
33
|
+
resetBetterAuthClient();
|
|
34
|
+
resetClients();
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
setB3ApiUrl(null);
|
|
38
|
+
};
|
|
39
|
+
}, [apiUrl]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setNotificationsApiUrl(notificationsApiUrl ?? NOTIFICATIONS_URL_BY_ENV[environment ?? "production"]);
|
|
42
|
+
}, [notificationsApiUrl, environment]);
|
|
22
43
|
// Initialize Google Analytics on mount
|
|
23
44
|
useEffect(() => {
|
|
24
45
|
loadGA4Script();
|
|
@@ -28,7 +49,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
28
49
|
setClientType(clientType);
|
|
29
50
|
}, [clientType]);
|
|
30
51
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
31
|
-
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children:
|
|
52
|
+
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, authStrategy: authStrategy, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), authStrategy === "better-auth" ? (_jsx(BetterAuthProvider, { partnerId: partnerId })) : (_jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa, defaultEoaProvider: defaultEoaProvider }))] }) }) }) }) }));
|
|
32
53
|
}
|
|
33
54
|
/**
|
|
34
55
|
* Component to connect the toast context to the global toast API
|
|
@@ -4,8 +4,8 @@ import { B3_AUTH_COOKIE_NAME } from "../../../../shared/constants/index.js";
|
|
|
4
4
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
5
5
|
import Cookies from "js-cookie";
|
|
6
6
|
import { useEffect, useRef } from "react";
|
|
7
|
+
import { getBetterAuthClient } from "../../../better-auth-client.js";
|
|
7
8
|
import { useUserQuery } from "../../hooks/useUserQuery.js";
|
|
8
|
-
import { useBetterAuthClient } from "./BetterAuthClientProvider.js";
|
|
9
9
|
const debug = debugB3React("BetterAuthProvider");
|
|
10
10
|
/**
|
|
11
11
|
* Parallel to AuthenticationProvider for Better Auth strategy.
|
|
@@ -20,7 +20,6 @@ const debug = debugB3React("BetterAuthProvider");
|
|
|
20
20
|
* useAuth, SignIn component, etc.) automatically clears the Better Auth session.
|
|
21
21
|
*/
|
|
22
22
|
const BetterAuthProvider = ({ partnerId }) => {
|
|
23
|
-
const betterAuthClient = useBetterAuthClient();
|
|
24
23
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
24
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
26
25
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
@@ -41,7 +40,7 @@ const BetterAuthProvider = ({ partnerId }) => {
|
|
|
41
40
|
app.logout = async () => {
|
|
42
41
|
debug("Patched logout: clearing Better Auth session");
|
|
43
42
|
try {
|
|
44
|
-
await
|
|
43
|
+
await getBetterAuthClient().signOut();
|
|
45
44
|
}
|
|
46
45
|
catch {
|
|
47
46
|
debug("Better Auth signOut failed (non-critical)");
|
|
@@ -52,7 +51,7 @@ const BetterAuthProvider = ({ partnerId }) => {
|
|
|
52
51
|
app.logout = originalLogout;
|
|
53
52
|
hasPatched.current = false;
|
|
54
53
|
};
|
|
55
|
-
}, [
|
|
54
|
+
}, []);
|
|
56
55
|
// Session restore on mount
|
|
57
56
|
useEffect(() => {
|
|
58
57
|
if (hasAttemptedRestore.current)
|
|
@@ -75,9 +74,50 @@ const BetterAuthProvider = ({ partnerId }) => {
|
|
|
75
74
|
catch {
|
|
76
75
|
debug("No existing Feathers JWT");
|
|
77
76
|
}
|
|
78
|
-
// 2. Check for
|
|
77
|
+
// 2. Check for _ba_token in URL (OAuth callback with third-party cookie bypass).
|
|
78
|
+
// When the API and frontend are on different domains, browsers with third-party
|
|
79
|
+
// cookie blocking (Firefox TCP, Safari ITP, Chrome Privacy Sandbox) prevent the
|
|
80
|
+
// better-auth.session_token cookie from being sent on cross-origin requests.
|
|
81
|
+
// The B3 API injects the session token into the redirect URL as _ba_token,
|
|
82
|
+
// allowing direct exchange without relying on cookies.
|
|
83
|
+
const params = new URLSearchParams(window.location.search);
|
|
84
|
+
const baToken = params.get("_ba_token");
|
|
85
|
+
if (baToken) {
|
|
86
|
+
debug("Found _ba_token in URL, exchanging for Feathers JWT");
|
|
87
|
+
// Clean the token from the URL immediately (security)
|
|
88
|
+
params.delete("_ba_token");
|
|
89
|
+
const cleanSearch = params.toString();
|
|
90
|
+
const cleanUrl = window.location.pathname + (cleanSearch ? `?${cleanSearch}` : "") + window.location.hash;
|
|
91
|
+
window.history.replaceState({}, "", cleanUrl);
|
|
92
|
+
try {
|
|
93
|
+
const response = await app.authenticate({
|
|
94
|
+
strategy: "better-auth",
|
|
95
|
+
accessToken: baToken,
|
|
96
|
+
partnerId,
|
|
97
|
+
});
|
|
98
|
+
if (response.accessToken) {
|
|
99
|
+
Cookies.set(B3_AUTH_COOKIE_NAME, response.accessToken, {
|
|
100
|
+
secure: true,
|
|
101
|
+
sameSite: "Lax",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (response.user) {
|
|
105
|
+
setUser(response.user);
|
|
106
|
+
setIsAuthenticated(true);
|
|
107
|
+
setIsConnected(true);
|
|
108
|
+
}
|
|
109
|
+
debug("_ba_token exchanged for Feathers JWT", { userId: response.user?.userId });
|
|
110
|
+
setIsAuthenticating(false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
debug("_ba_token exchange failed", err);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// 3. Check for a Better Auth session via cookie (works when API and frontend
|
|
118
|
+
// share a domain or when cookies aren't partitioned)
|
|
79
119
|
try {
|
|
80
|
-
const session = await
|
|
120
|
+
const session = await getBetterAuthClient().getSession();
|
|
81
121
|
if (session.data?.session?.token) {
|
|
82
122
|
debug("Better Auth session found, exchanging for Feathers JWT", {
|
|
83
123
|
betterAuthUserId: session.data.user?.id,
|
|
@@ -106,11 +146,11 @@ const BetterAuthProvider = ({ partnerId }) => {
|
|
|
106
146
|
catch {
|
|
107
147
|
debug("No Better Auth session to restore");
|
|
108
148
|
}
|
|
109
|
-
//
|
|
149
|
+
// 4. Nothing found — show login UI
|
|
110
150
|
setIsAuthenticating(false);
|
|
111
151
|
};
|
|
112
152
|
restoreSession();
|
|
113
|
-
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId
|
|
153
|
+
}, [setIsAuthenticated, setIsAuthenticating, setIsConnected, setUser, partnerId]);
|
|
114
154
|
return null;
|
|
115
155
|
};
|
|
116
156
|
export default BetterAuthProvider;
|
|
@@ -72,7 +72,7 @@ const SettingsProfileCard = () => {
|
|
|
72
72
|
// Better Auth: register username without wallet signing (DB-only, no ENS)
|
|
73
73
|
// Skip ens_normalize — it rejects underscores/mixed-case that are valid non-ENS usernames
|
|
74
74
|
const sanitizedUsername = editedUsername.trim().toLowerCase();
|
|
75
|
-
// Type assertion needed:
|
|
75
|
+
// Type assertion needed: API now accepts message/hash as optional for Better Auth users
|
|
76
76
|
updatedUser = (await app
|
|
77
77
|
.service("users")
|
|
78
78
|
.registerUsername({ username: sanitizedUsername }, {}));
|
|
@@ -4,7 +4,6 @@ import { LoginStepBetterAuth } from "./steps/LoginStepBetterAuth.js";
|
|
|
4
4
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { useActiveAccount } from "thirdweb/react";
|
|
7
|
-
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
8
7
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep.js";
|
|
9
8
|
import { LoginStepCustom } from "./steps/LoginStepCustom.js";
|
|
10
9
|
const debug = debugB3React("SignInWithB3Flow");
|
|
@@ -251,10 +250,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
251
250
|
}
|
|
252
251
|
else {
|
|
253
252
|
// Custom strategy
|
|
254
|
-
if (strategies
|
|
255
|
-
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
256
|
-
}
|
|
257
|
-
else if (strategies) {
|
|
253
|
+
if (strategies) {
|
|
258
254
|
// Strategies are explicitly provided
|
|
259
255
|
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
260
256
|
}
|
|
@@ -2,10 +2,11 @@ import { Chain } from "thirdweb";
|
|
|
2
2
|
import { SingleStepAuthArgsType, Wallet } from "thirdweb/wallets";
|
|
3
3
|
type WalletType = Wallet["id"];
|
|
4
4
|
type StrategyType = SingleStepAuthArgsType["strategy"];
|
|
5
|
-
|
|
5
|
+
declare const customStrategies: readonly ["basement"];
|
|
6
|
+
type CustomStrategyType = (typeof customStrategies)[number];
|
|
6
7
|
type AllowedStrategies = StrategyType | WalletType | CustomStrategyType | "email";
|
|
7
8
|
type NonWalletStrategyType = Exclude<AllowedStrategies, WalletType>;
|
|
8
|
-
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"
|
|
9
|
+
export declare const allowedStrategies: readonly ["apple", "google", "github", "x", "discord", "email", "guest", "walletConnect", "io.metamask", "com.coinbase.wallet", "basement"];
|
|
9
10
|
export type AllowedStrategy = (typeof allowedStrategies)[number];
|
|
10
11
|
export declare function isWalletType(strategy: AllowedStrategies): strategy is WalletType;
|
|
11
12
|
export declare function isStrategyType(strategy: AllowedStrategies): strategy is NonWalletStrategyType;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createWallet } from "thirdweb/wallets";
|
|
2
|
-
const customStrategies = ["basement"
|
|
3
|
-
// type CustomStrategy = (typeof customStrategies)[number];
|
|
2
|
+
const customStrategies = ["basement"];
|
|
4
3
|
export const allowedStrategies = [
|
|
5
4
|
// Auth strategies
|
|
6
5
|
"apple",
|
|
@@ -15,7 +14,6 @@ export const allowedStrategies = [
|
|
|
15
14
|
"io.metamask",
|
|
16
15
|
"com.coinbase.wallet",
|
|
17
16
|
// Custom strategies
|
|
18
|
-
// TODO: Audit we don't use "privy" directly anymore
|
|
19
17
|
...customStrategies,
|
|
20
18
|
];
|
|
21
19
|
export function isWalletType(strategy) {
|
|
@@ -5,7 +5,6 @@ export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
|
5
5
|
export { useB3 } from "./B3Provider/useB3";
|
|
6
6
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
7
7
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
8
|
-
export { useBetterAuthClient } from "./B3Provider/BetterAuthClientProvider";
|
|
9
8
|
export { StyleRoot } from "./StyleRoot";
|
|
10
9
|
export { BetterAuthResetPassword, type BetterAuthResetPasswordProps } from "./SignInWithB3/BetterAuthResetPassword";
|
|
11
10
|
export { BetterAuthSignIn, type BetterAuthSignInProps } from "./SignInWithB3/BetterAuthSignIn";
|
|
@@ -15,7 +14,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
15
14
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
16
15
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
17
16
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
18
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
19
17
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
20
18
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
21
19
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
@@ -6,7 +6,6 @@ export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper.js
|
|
|
6
6
|
export { useB3 } from "./B3Provider/useB3.js";
|
|
7
7
|
export { useB3Account } from "./B3Provider/useB3Account.js";
|
|
8
8
|
export { useB3Config } from "./B3Provider/useB3Config.js";
|
|
9
|
-
export { useBetterAuthClient } from "./B3Provider/BetterAuthClientProvider.js";
|
|
10
9
|
export { StyleRoot } from "./StyleRoot.js";
|
|
11
10
|
// SignInWithB3 Components
|
|
12
11
|
export { BetterAuthResetPassword } from "./SignInWithB3/BetterAuthResetPassword.js";
|
|
@@ -17,7 +16,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem.js";
|
|
|
17
16
|
export { WalletRow } from "./SignInWithB3/components/WalletRow.js";
|
|
18
17
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3.js";
|
|
19
18
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow.js";
|
|
20
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy.js";
|
|
21
19
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep.js";
|
|
22
20
|
export { getConnectOptionsFromStrategy, isWalletType } from "./SignInWithB3/utils/signInUtils.js";
|
|
23
21
|
// ManageAccount Components
|
|
@@ -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";
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA.js";
|
|
|
17
17
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo.js";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount.js";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted.js";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile.js";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
@@ -6,8 +6,8 @@ import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
|
6
6
|
* This hook provides 1:1 feature parity with useAuthentication.ts
|
|
7
7
|
*/
|
|
8
8
|
export declare function useAuth(): {
|
|
9
|
-
authenticate: (accessToken: string, partnerId: string, strategy?: string) => Promise<
|
|
10
|
-
reAuthenticate: () => Promise<
|
|
9
|
+
authenticate: (accessToken: string, partnerId: string, strategy?: string) => Promise<Record<string, any>>;
|
|
10
|
+
reAuthenticate: () => Promise<Record<string, any>>;
|
|
11
11
|
logout: (callback?: () => void) => Promise<void>;
|
|
12
12
|
isAuthenticated: boolean;
|
|
13
13
|
isReady: boolean;
|
|
@@ -70,6 +70,6 @@ export declare function useAuth(): {
|
|
|
70
70
|
turnkeyOtpId?: string | undefined;
|
|
71
71
|
};
|
|
72
72
|
} | undefined;
|
|
73
|
-
refetchUser: () => Promise<
|
|
73
|
+
refetchUser: () => Promise<Record<string, any>>;
|
|
74
74
|
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
75
75
|
};
|
|
@@ -65,6 +65,6 @@ export declare function useAuthentication(partnerId: string, { skipAutoConnect }
|
|
|
65
65
|
turnkeyOtpId?: string | undefined;
|
|
66
66
|
};
|
|
67
67
|
} | undefined;
|
|
68
|
-
refetchUser: (wallet?: Wallet) => Promise<
|
|
68
|
+
refetchUser: (wallet?: Wallet) => Promise<Record<string, any>>;
|
|
69
69
|
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
70
70
|
};
|
|
@@ -186,7 +186,7 @@ export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
|
186
186
|
localStorage.removeItem("lastAuthProvider");
|
|
187
187
|
localStorage.removeItem("b3-user");
|
|
188
188
|
}
|
|
189
|
-
app.logout();
|
|
189
|
+
await app.logout();
|
|
190
190
|
debug("@@logout:loggedOut");
|
|
191
191
|
setIsAuthenticated(false);
|
|
192
192
|
setIsConnected(false);
|