@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/platform/client.d.ts +35 -0
- package/dist/cjs/anyspend/platform/client.js +158 -0
- package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
- package/dist/cjs/anyspend/platform/errors.js +77 -0
- package/dist/cjs/anyspend/platform/index.d.ts +87 -0
- package/dist/cjs/anyspend/platform/index.js +85 -0
- package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
- package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
- package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/events.js +16 -0
- package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
- package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
- package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/cjs/anyspend/platform/resources/products.js +31 -0
- package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
- package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
- package/dist/cjs/anyspend/platform/types.d.ts +478 -0
- package/dist/cjs/anyspend/platform/types.js +5 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
- package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +127 -16
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- 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 +5 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
- package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
- package/dist/cjs/anyspend/services/anyspend.js +3 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
- package/dist/esm/anyspend/platform/client.d.ts +35 -0
- package/dist/esm/anyspend/platform/client.js +153 -0
- package/dist/esm/anyspend/platform/errors.d.ts +38 -0
- package/dist/esm/anyspend/platform/errors.js +67 -0
- package/dist/esm/anyspend/platform/index.d.ts +87 -0
- package/dist/esm/anyspend/platform/index.js +75 -0
- package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
- package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/esm/anyspend/platform/resources/customers.js +30 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
- package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/events.js +12 -0
- package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
- package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/organization.js +11 -0
- package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
- package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/esm/anyspend/platform/resources/products.js +27 -0
- package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
- package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
- package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
- package/dist/esm/anyspend/platform/types.d.ts +478 -0
- package/dist/esm/anyspend/platform/types.js +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
- package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +128 -17
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- 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 +5 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
- package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/index.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
- package/dist/esm/anyspend/services/anyspend.js +3 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/platform/client.d.ts +35 -0
- package/dist/types/anyspend/platform/errors.d.ts +38 -0
- package/dist/types/anyspend/platform/index.d.ts +87 -0
- package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/types/anyspend/platform/types.d.ts +478 -0
- package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/types/anyspend/services/anyspend.d.ts +4 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/package.json +7 -1
- package/src/anyspend/docs/checkout-sessions.md +20 -3
- package/src/anyspend/platform/client.ts +198 -0
- package/src/anyspend/platform/errors.ts +92 -0
- package/src/anyspend/platform/index.ts +129 -0
- package/src/anyspend/platform/resources/analytics.ts +10 -0
- package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
- package/src/anyspend/platform/resources/customers.ts +54 -0
- package/src/anyspend/platform/resources/discount-codes.ts +63 -0
- package/src/anyspend/platform/resources/events.ts +22 -0
- package/src/anyspend/platform/resources/notifications.ts +37 -0
- package/src/anyspend/platform/resources/organization.ts +24 -0
- package/src/anyspend/platform/resources/payment-links.ts +74 -0
- package/src/anyspend/platform/resources/products.ts +59 -0
- package/src/anyspend/platform/resources/transactions.ts +33 -0
- package/src/anyspend/platform/resources/webhooks.ts +47 -0
- package/src/anyspend/platform/resources/widgets.ts +63 -0
- package/src/anyspend/platform/types.ts +532 -0
- package/src/anyspend/platform/utils/idempotency.ts +15 -0
- package/src/anyspend/platform/utils/pagination.ts +32 -0
- package/src/anyspend/react/components/AnySpend.tsx +152 -18
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
- package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
- package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
- package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
- package/src/anyspend/services/anyspend.ts +7 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
- package/src/global-account/react/hooks/useAuth.ts +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +92 -27
- package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
- package/src/global-account/react/stores/useModalStore.ts +6 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
|
@@ -15,11 +15,26 @@ import { createWagmiConfig } from "../utils/createWagmiConfig.js";
|
|
|
15
15
|
import { useTWAuth } from "./useTWAuth.js";
|
|
16
16
|
import { useUserQuery } from "./useUserQuery.js";
|
|
17
17
|
const debug = debugB3React("useAuthentication");
|
|
18
|
-
export function useAuthentication(partnerId) {
|
|
18
|
+
export function useAuthentication(partnerId, { skipAutoConnect = false } = {}) {
|
|
19
19
|
const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
|
|
20
20
|
const { disconnect } = useDisconnect();
|
|
21
21
|
const wallets = useConnectedWallets();
|
|
22
|
+
// Keep refs so logout() always disconnects current wallets, not stale closure values.
|
|
23
|
+
// autoConnectCore captures onConnect (and thus logout) from the first render before wallets
|
|
24
|
+
// are populated — without these refs, logout() would capture wallets=[] and disconnect nothing.
|
|
25
|
+
const walletsRef = useRef(wallets);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
walletsRef.current = wallets;
|
|
28
|
+
}, [wallets]);
|
|
22
29
|
const activeWallet = useActiveWallet();
|
|
30
|
+
// Track the active wallet by ref so logout() can disconnect the exact reference
|
|
31
|
+
// stored in thirdweb's activeWalletStore. walletsRef.current (from useConnectedWallets)
|
|
32
|
+
// may hold a different object reference than what thirdweb considers "active",
|
|
33
|
+
// causing the identity check in onWalletDisconnect to fail silently.
|
|
34
|
+
const activeWalletRef = useRef(activeWallet);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
activeWalletRef.current = activeWallet;
|
|
37
|
+
}, [activeWallet]);
|
|
23
38
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
24
39
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
40
|
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
@@ -126,21 +141,37 @@ export function useAuthentication(partnerId) {
|
|
|
126
141
|
}
|
|
127
142
|
}, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
128
143
|
const logout = useCallback(async (callback) => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
// Disconnect ecosystem/smart wallets from the connected wallets list.
|
|
145
|
+
// EOA wallets (MetaMask, Coinbase Wallet) are left in the list so they can
|
|
146
|
+
// auto-reconnect on next login without requiring a new approval popup.
|
|
147
|
+
// Use walletsRef.current (not the stale closure value) so we always get current wallets —
|
|
148
|
+
// autoConnectCore captures logout from the first render when wallets is still [].
|
|
149
|
+
walletsRef.current.forEach(wallet => {
|
|
150
|
+
debug("@@logout:wallet", wallet.id);
|
|
151
|
+
if (wallet.id.startsWith("ecosystem.") || wallet.id === "smart") {
|
|
152
|
+
disconnect(wallet);
|
|
153
|
+
}
|
|
138
154
|
});
|
|
139
|
-
//
|
|
140
|
-
//
|
|
155
|
+
// Unconditionally disconnect the active wallet to clear thirdweb's activeAccountStore.
|
|
156
|
+
// This is separate from the loop above: even if the active wallet is an EOA (e.g.
|
|
157
|
+
// Coinbase Wallet), we must disconnect it so activeAccount becomes undefined.
|
|
158
|
+
// Without this, ConnectEmbed renders show=false (blank modal) because it checks
|
|
159
|
+
// show = !activeAccount. Note: thirdweb's disconnect() is idempotent — calling it
|
|
160
|
+
// on an already-disconnected wallet (from the loop above) is a no-op.
|
|
161
|
+
// We use the exact reference from activeWalletRef because thirdweb's
|
|
162
|
+
// onWalletDisconnect uses strict identity (===) to decide whether to clear
|
|
163
|
+
// activeAccountStore.
|
|
164
|
+
// Tradeoff: EOA wallets (MetaMask, Coinbase Wallet) will be removed from
|
|
165
|
+
// connectedWallets and require a new approval popup on next login.
|
|
166
|
+
// This is acceptable because a working login form is more critical than
|
|
167
|
+
// skipping one wallet approval step.
|
|
168
|
+
if (activeWalletRef.current) {
|
|
169
|
+
debug("@@logout:disconnecting active wallet", activeWalletRef.current.id);
|
|
170
|
+
disconnect(activeWalletRef.current);
|
|
171
|
+
}
|
|
172
|
+
// Clear user-specific storage (auth tokens, cached user data).
|
|
173
|
+
// Thirdweb's wallet connection state is managed separately via disconnect() above.
|
|
141
174
|
if (typeof localStorage !== "undefined") {
|
|
142
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
143
|
-
localStorage.removeItem("wagmi.store");
|
|
144
175
|
localStorage.removeItem("lastAuthProvider");
|
|
145
176
|
localStorage.removeItem("b3-user");
|
|
146
177
|
}
|
|
@@ -148,33 +179,62 @@ export function useAuthentication(partnerId) {
|
|
|
148
179
|
debug("@@logout:loggedOut");
|
|
149
180
|
setIsAuthenticated(false);
|
|
150
181
|
setIsConnected(false);
|
|
182
|
+
// Reset isAuthenticating so any in-flight page-load auto-connect that set it true
|
|
183
|
+
// does not keep the login modal spinner stuck after logout() is called.
|
|
184
|
+
setIsAuthenticating(false);
|
|
151
185
|
setUser();
|
|
152
186
|
callback?.();
|
|
153
187
|
if (onLogoutCallback) {
|
|
154
188
|
await onLogoutCallback();
|
|
155
189
|
}
|
|
156
|
-
},
|
|
190
|
+
},
|
|
191
|
+
// wallets intentionally omitted — we use walletsRef.current so this callback stays stable
|
|
192
|
+
// and always operates on current wallets even when captured in stale closures.
|
|
193
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
194
|
+
[disconnect, setIsAuthenticated, setIsAuthenticating, setUser, setIsConnected, onLogoutCallback]);
|
|
157
195
|
const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
158
196
|
debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
197
|
+
const connectedEcosystemWallet = allConnectedWallets.find(w => w.id.startsWith("ecosystem."));
|
|
159
198
|
try {
|
|
160
|
-
|
|
161
|
-
if (!wallet) {
|
|
199
|
+
if (!connectedEcosystemWallet) {
|
|
162
200
|
throw new Error("No smart wallet found during auto-connect");
|
|
163
201
|
}
|
|
164
|
-
debug("@@useAuthentication:onConnect", { wallet });
|
|
202
|
+
debug("@@useAuthentication:onConnect", { wallet: connectedEcosystemWallet });
|
|
165
203
|
setHasStartedConnecting(true);
|
|
166
204
|
setIsConnected(true);
|
|
167
205
|
setIsAuthenticating(true);
|
|
168
|
-
await setActiveWallet(
|
|
169
|
-
const userAuth = await authenticateUser(
|
|
206
|
+
await setActiveWallet(connectedEcosystemWallet);
|
|
207
|
+
const userAuth = await authenticateUser(connectedEcosystemWallet);
|
|
170
208
|
if (userAuth && onConnectCallback) {
|
|
171
|
-
await onConnectCallback(
|
|
209
|
+
await onConnectCallback(connectedEcosystemWallet, userAuth.accessToken);
|
|
172
210
|
}
|
|
173
211
|
}
|
|
174
212
|
catch (error) {
|
|
175
213
|
debug("@@useAuthentication:onConnect:failed", { error });
|
|
176
214
|
setIsAuthenticated(false);
|
|
177
215
|
setUser(undefined);
|
|
216
|
+
// Directly disconnect the ecosystem wallet we set active above.
|
|
217
|
+
// We can't rely on logout()'s activeWalletRef here because it's updated
|
|
218
|
+
// via useEffect (deferred until after paint), but this callback may run
|
|
219
|
+
// entirely within a single React commit cycle — before the ref updates.
|
|
220
|
+
// Note: logout() below may also call disconnect() on the same wallet via
|
|
221
|
+
// activeWalletRef — thirdweb's disconnect() is idempotent so this is safe.
|
|
222
|
+
if (connectedEcosystemWallet) {
|
|
223
|
+
debug("@@useAuthentication:onConnect:disconnecting ecosystem wallet", connectedEcosystemWallet.id);
|
|
224
|
+
disconnect(connectedEcosystemWallet);
|
|
225
|
+
}
|
|
226
|
+
// Also disconnect the wallet that autoConnectCore set as active.
|
|
227
|
+
// When only a non-ecosystem wallet (e.g. MetaMask) auto-reconnects,
|
|
228
|
+
// connectedEcosystemWallet is undefined, so the block above is skipped.
|
|
229
|
+
// But autoConnectCore already set this wallet as thirdweb's activeWallet,
|
|
230
|
+
// leaving activeAccount set. ConnectEmbed checks show = !activeAccount,
|
|
231
|
+
// so if we don't clear it, the login form renders blank.
|
|
232
|
+
// Uses object identity (===) which is safe because thirdweb returns
|
|
233
|
+
// stable references for connected wallet instances.
|
|
234
|
+
if (_walleAutoConnectedWith && _walleAutoConnectedWith !== connectedEcosystemWallet) {
|
|
235
|
+
debug("@@useAuthentication:onConnect:disconnecting auto-connected wallet", _walleAutoConnectedWith.id);
|
|
236
|
+
disconnect(_walleAutoConnectedWith);
|
|
237
|
+
}
|
|
178
238
|
await logout();
|
|
179
239
|
}
|
|
180
240
|
finally {
|
|
@@ -189,6 +249,7 @@ export function useAuthentication(partnerId) {
|
|
|
189
249
|
isAuthenticated,
|
|
190
250
|
isAuthenticating,
|
|
191
251
|
isConnected,
|
|
252
|
+
disconnect,
|
|
192
253
|
setHasStartedConnecting,
|
|
193
254
|
setIsConnected,
|
|
194
255
|
setIsAuthenticating,
|
|
@@ -201,23 +262,32 @@ export function useAuthentication(partnerId) {
|
|
|
201
262
|
]);
|
|
202
263
|
const { isLoading: useAutoConnectLoading } = useAutoConnect({
|
|
203
264
|
client,
|
|
204
|
-
|
|
265
|
+
// When skipAutoConnect is true (e.g. LoginStepContent, SignInWithB3Flow), pass an empty
|
|
266
|
+
// wallets array so useAutoConnect completes immediately without firing onConnect.
|
|
267
|
+
// Only AuthenticationProvider (the primary instance) should own auto-connect.
|
|
268
|
+
wallets: skipAutoConnect ? [] : [wallet],
|
|
205
269
|
onConnect,
|
|
206
270
|
onTimeout: () => {
|
|
271
|
+
if (skipAutoConnect)
|
|
272
|
+
return;
|
|
207
273
|
logout().catch(error => {
|
|
208
274
|
debug("@@useAuthentication:logout on timeout failed", { error });
|
|
209
275
|
});
|
|
210
276
|
},
|
|
211
277
|
});
|
|
212
278
|
/**
|
|
213
|
-
* useAutoConnectLoading starts as false
|
|
279
|
+
* useAutoConnectLoading starts as false.
|
|
280
|
+
* Only the primary (non-skip) instance manages isAuthenticating via this effect
|
|
281
|
+
* to avoid race conditions when multiple useAuthentication instances are mounted.
|
|
214
282
|
*/
|
|
215
283
|
useEffect(() => {
|
|
284
|
+
if (skipAutoConnect)
|
|
285
|
+
return;
|
|
216
286
|
if (!useAutoConnectLoading && useAutoConnectLoadingPrevious.current && !hasStartedConnecting) {
|
|
217
287
|
setIsAuthenticating(false);
|
|
218
288
|
}
|
|
219
289
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
220
|
-
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
290
|
+
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating, skipAutoConnect]);
|
|
221
291
|
const isReady = isAuthenticated && !isAuthenticating;
|
|
222
292
|
return {
|
|
223
293
|
logout,
|
|
@@ -62,7 +62,8 @@ export function useGetAllTWSigners({ chain, accountAddress, queryOptions }) {
|
|
|
62
62
|
});
|
|
63
63
|
return result;
|
|
64
64
|
},
|
|
65
|
-
enabled
|
|
65
|
+
// Respect queryOptions.enabled if explicitly set (e.g. signersEnabled=false from SignInWithB3Flow)
|
|
66
|
+
enabled: queryOptions?.enabled !== false && Boolean(chain && accountAddress),
|
|
66
67
|
refetchOnMount: true,
|
|
67
68
|
refetchOnWindowFocus: true,
|
|
68
69
|
refetchOnReconnect: true,
|
|
@@ -657,6 +657,10 @@ interface ModalState {
|
|
|
657
657
|
setLinkingState: (isLinking: boolean, method?: string | null) => void;
|
|
658
658
|
/** Function to update closable property of current content without adding to history */
|
|
659
659
|
setClosable: (closable: boolean) => void;
|
|
660
|
+
/** Whether a third-party iframe (e.g. Persona KYC) is currently active over the modal */
|
|
661
|
+
personaActive: boolean;
|
|
662
|
+
/** Function to mark a third-party iframe as active/inactive */
|
|
663
|
+
setPersonaActive: (active: boolean) => void;
|
|
660
664
|
}
|
|
661
665
|
/**
|
|
662
666
|
* Zustand store for managing modal state
|
|
@@ -36,4 +36,6 @@ export const useModalStore = create(set => ({
|
|
|
36
36
|
setClosable: (closable) => set(state => ({
|
|
37
37
|
contentType: state.contentType ? { ...state.contentType, closable } : null,
|
|
38
38
|
})),
|
|
39
|
+
personaActive: false,
|
|
40
|
+
setPersonaActive: (active) => set({ personaActive: active }),
|
|
39
41
|
}));
|
|
@@ -25,3 +25,21 @@ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): im
|
|
|
25
25
|
}, {
|
|
26
26
|
"thirdweb:lastChainId": number;
|
|
27
27
|
}>)[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a cached wagmi config for the given partnerId.
|
|
30
|
+
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
31
|
+
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCachedWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
34
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
35
|
+
}, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
36
|
+
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
37
|
+
accounts: withCapabilities extends true ? readonly {
|
|
38
|
+
address: `0x${string}`;
|
|
39
|
+
capabilities: Record<string, unknown>;
|
|
40
|
+
}[] : readonly `0x${string}`[];
|
|
41
|
+
chainId: number;
|
|
42
|
+
}>;
|
|
43
|
+
}, {
|
|
44
|
+
"thirdweb:lastChainId": number;
|
|
45
|
+
}>)[]>;
|
|
@@ -27,3 +27,19 @@ export function createWagmiConfig(options) {
|
|
|
27
27
|
connectors: finalConnectors,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
/** Module-level cache — wagmi configs must not be recreated on every render. */
|
|
31
|
+
const wagmiConfigCache = new Map();
|
|
32
|
+
/**
|
|
33
|
+
* Returns a cached wagmi config for the given partnerId.
|
|
34
|
+
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
35
|
+
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
36
|
+
*/
|
|
37
|
+
export function getCachedWagmiConfig(options) {
|
|
38
|
+
const key = options.partnerId;
|
|
39
|
+
let config = wagmiConfigCache.get(key);
|
|
40
|
+
if (!config) {
|
|
41
|
+
config = createWagmiConfig(options);
|
|
42
|
+
wagmiConfigCache.set(key, config);
|
|
43
|
+
}
|
|
44
|
+
return config;
|
|
45
|
+
}
|