@swype-org/react-sdk 0.1.226 → 0.1.228

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/index.js CHANGED
@@ -1932,9 +1932,7 @@ function deriveSourceTypeAndId(state) {
1932
1932
  return { sourceType: "accountId", sourceId: "" };
1933
1933
  }
1934
1934
  function createInitialState(config) {
1935
- const isReturningUser = config.activeCredentialId != null;
1936
1935
  return {
1937
- step: isReturningUser ? "login" : "wallet-picker",
1938
1936
  error: null,
1939
1937
  providers: [],
1940
1938
  accounts: [],
@@ -1950,6 +1948,7 @@ function createInitialState(config) {
1950
1948
  registeringPasskey: false,
1951
1949
  verifyingPasskeyPopup: false,
1952
1950
  passkeyPopupNeeded: config.passkeyPopupNeeded,
1951
+ passkeyConfigLoaded: false,
1953
1952
  activeCredentialId: config.activeCredentialId,
1954
1953
  knownCredentialIds: [],
1955
1954
  verificationTarget: null,
@@ -1957,12 +1956,13 @@ function createInitialState(config) {
1957
1956
  mobileFlow: false,
1958
1957
  deeplinkUri: null,
1959
1958
  increasingLimit: false,
1960
- previousStep: null,
1961
1959
  isGuestFlow: false,
1962
1960
  guestTransferId: null,
1963
1961
  guestSessionToken: null,
1964
1962
  guestPreauthAccountId: null,
1965
- activePublicKey: null
1963
+ activePublicKey: null,
1964
+ userIntent: null,
1965
+ loginRequested: false
1966
1966
  };
1967
1967
  }
1968
1968
  function paymentReducer(state, action) {
@@ -1973,20 +1973,20 @@ function paymentReducer(state, action) {
1973
1973
  ...state,
1974
1974
  verificationTarget: action.target,
1975
1975
  error: null,
1976
- step: "otp-verify"
1976
+ loginRequested: false
1977
1977
  };
1978
1978
  case "BACK_TO_LOGIN":
1979
1979
  return {
1980
1980
  ...state,
1981
1981
  verificationTarget: null,
1982
- error: null,
1983
- step: "login"
1982
+ error: null
1984
1983
  };
1985
1984
  // ── Passkey ──────────────────────────────────────────────────
1986
1985
  case "PASSKEY_CONFIG_LOADED":
1987
1986
  return {
1988
1987
  ...state,
1989
1988
  knownCredentialIds: action.knownIds,
1989
+ passkeyConfigLoaded: true,
1990
1990
  oneTapLimit: action.oneTapLimit ?? state.oneTapLimit
1991
1991
  };
1992
1992
  case "PASSKEY_ACTIVATED":
@@ -2020,9 +2020,6 @@ function paymentReducer(state, action) {
2020
2020
  next.mobileFlow = false;
2021
2021
  next.deeplinkUri = null;
2022
2022
  }
2023
- if (action.resolvedStep !== void 0) {
2024
- next.step = action.resolvedStep;
2025
- }
2026
2023
  return next;
2027
2024
  }
2028
2025
  case "DATA_LOAD_END":
@@ -2046,7 +2043,8 @@ function paymentReducer(state, action) {
2046
2043
  selectedProviderId: action.providerId,
2047
2044
  selectedAccountId: null,
2048
2045
  selectedWalletId: null,
2049
- selectedTokenSymbol: null
2046
+ selectedTokenSymbol: null,
2047
+ userIntent: null
2050
2048
  };
2051
2049
  case "SELECT_ACCOUNT":
2052
2050
  return {
@@ -2054,24 +2052,24 @@ function paymentReducer(state, action) {
2054
2052
  selectedAccountId: action.accountId,
2055
2053
  selectedWalletId: action.walletId,
2056
2054
  selectedTokenSymbol: null,
2057
- step: "deposit"
2055
+ userIntent: null
2058
2056
  };
2059
2057
  case "SELECT_TOKEN":
2060
2058
  return {
2061
2059
  ...state,
2062
2060
  selectedWalletId: action.walletId,
2063
2061
  selectedTokenSymbol: action.tokenSymbol,
2064
- step: "deposit"
2062
+ userIntent: null
2065
2063
  };
2066
2064
  // ── Transfer lifecycle ───────────────────────────────────────
2067
2065
  case "PAY_STARTED":
2068
2066
  return {
2069
2067
  ...state,
2070
- step: action.isSetupRedirect ? "open-wallet" : "processing",
2071
2068
  error: null,
2072
2069
  creatingTransfer: true,
2073
2070
  deeplinkUri: null,
2074
- mobileFlow: false
2071
+ mobileFlow: false,
2072
+ userIntent: null
2075
2073
  };
2076
2074
  case "PAY_ENDED":
2077
2075
  return { ...state, creatingTransfer: false };
@@ -2079,7 +2077,7 @@ function paymentReducer(state, action) {
2079
2077
  return {
2080
2078
  ...state,
2081
2079
  error: action.error,
2082
- step: action.fallbackStep
2080
+ creatingTransfer: false
2083
2081
  };
2084
2082
  case "TRANSFER_CREATED":
2085
2083
  return { ...state, transfer: action.transfer };
@@ -2089,7 +2087,6 @@ function paymentReducer(state, action) {
2089
2087
  return {
2090
2088
  ...state,
2091
2089
  transfer: action.transfer,
2092
- step: "success",
2093
2090
  mobileFlow: false,
2094
2091
  deeplinkUri: null
2095
2092
  };
@@ -2098,17 +2095,20 @@ function paymentReducer(state, action) {
2098
2095
  ...state,
2099
2096
  transfer: action.transfer,
2100
2097
  error: action.error,
2101
- step: "success",
2102
2098
  mobileFlow: false,
2103
2099
  deeplinkUri: null
2104
2100
  };
2105
2101
  case "PROCESSING_TIMEOUT":
2106
- return { ...state, error: action.error, step: "deposit" };
2102
+ return {
2103
+ ...state,
2104
+ error: action.error,
2105
+ transfer: null,
2106
+ creatingTransfer: false
2107
+ };
2107
2108
  case "CONFIRM_SIGN_SUCCESS":
2108
2109
  return {
2109
2110
  ...state,
2110
2111
  transfer: action.transfer,
2111
- step: "processing",
2112
2112
  mobileFlow: false,
2113
2113
  deeplinkUri: null
2114
2114
  };
@@ -2117,8 +2117,7 @@ function paymentReducer(state, action) {
2117
2117
  return {
2118
2118
  ...state,
2119
2119
  mobileFlow: true,
2120
- deeplinkUri: action.deeplinkUri,
2121
- step: "open-wallet"
2120
+ deeplinkUri: action.deeplinkUri
2122
2121
  };
2123
2122
  case "MOBILE_SETUP_COMPLETE":
2124
2123
  return {
@@ -2126,8 +2125,7 @@ function paymentReducer(state, action) {
2126
2125
  transfer: action.transfer ?? state.transfer,
2127
2126
  error: null,
2128
2127
  mobileFlow: false,
2129
- deeplinkUri: null,
2130
- step: "deposit"
2128
+ deeplinkUri: null
2131
2129
  };
2132
2130
  case "MOBILE_SIGN_READY":
2133
2131
  return {
@@ -2135,8 +2133,7 @@ function paymentReducer(state, action) {
2135
2133
  transfer: action.transfer,
2136
2134
  error: null,
2137
2135
  mobileFlow: false,
2138
- deeplinkUri: null,
2139
- step: "confirm-sign"
2136
+ deeplinkUri: null
2140
2137
  };
2141
2138
  case "CLEAR_MOBILE_STATE":
2142
2139
  return { ...state, mobileFlow: false, deeplinkUri: null };
@@ -2146,8 +2143,7 @@ function paymentReducer(state, action) {
2146
2143
  mobileFlow: true,
2147
2144
  deeplinkUri: action.deeplinkUri,
2148
2145
  selectedProviderId: action.providerId ?? state.selectedProviderId,
2149
- error: action.error ?? null,
2150
- step: "open-wallet"
2146
+ error: action.error ?? null
2151
2147
  };
2152
2148
  case "MOBILE_RESUME_SUCCESS":
2153
2149
  return {
@@ -2155,8 +2151,7 @@ function paymentReducer(state, action) {
2155
2151
  transfer: action.transfer,
2156
2152
  error: null,
2157
2153
  mobileFlow: false,
2158
- deeplinkUri: null,
2159
- step: "success"
2154
+ deeplinkUri: null
2160
2155
  };
2161
2156
  case "MOBILE_RESUME_FAILED":
2162
2157
  return {
@@ -2164,8 +2159,7 @@ function paymentReducer(state, action) {
2164
2159
  transfer: action.transfer,
2165
2160
  error: "Transfer failed.",
2166
2161
  mobileFlow: false,
2167
- deeplinkUri: null,
2168
- step: "success"
2162
+ deeplinkUri: null
2169
2163
  };
2170
2164
  case "MOBILE_RESUME_PROCESSING":
2171
2165
  return {
@@ -2173,8 +2167,7 @@ function paymentReducer(state, action) {
2173
2167
  transfer: action.transfer,
2174
2168
  error: null,
2175
2169
  mobileFlow: false,
2176
- deeplinkUri: null,
2177
- step: "processing"
2170
+ deeplinkUri: null
2178
2171
  };
2179
2172
  // ── Increase limit ───────────────────────────────────────────
2180
2173
  case "SET_INCREASING_LIMIT":
@@ -2196,14 +2189,12 @@ function paymentReducer(state, action) {
2196
2189
  guestSessionToken: action.guestSessionToken,
2197
2190
  selectedAccountId: null,
2198
2191
  selectedWalletId: null,
2199
- selectedTokenSymbol: null,
2200
- step: "token-picker"
2192
+ selectedTokenSymbol: null
2201
2193
  };
2202
2194
  case "GUEST_TRANSFER_COMPLETED":
2203
2195
  return {
2204
2196
  ...state,
2205
2197
  transfer: action.transfer,
2206
- step: "success",
2207
2198
  mobileFlow: false,
2208
2199
  deeplinkUri: null,
2209
2200
  isGuestFlow: true,
@@ -2212,27 +2203,32 @@ function paymentReducer(state, action) {
2212
2203
  case "GUEST_PREAUTH_DETECTED":
2213
2204
  return {
2214
2205
  ...state,
2215
- guestPreauthAccountId: action.accountId,
2216
- step: "login"
2206
+ guestPreauthAccountId: action.accountId
2217
2207
  };
2218
2208
  case "ACCOUNT_OWNER_SET":
2219
2209
  return {
2220
2210
  ...state,
2221
2211
  guestPreauthAccountId: null,
2222
2212
  activePublicKey: null,
2223
- step: "deposit",
2224
2213
  error: null
2225
2214
  };
2226
- // ── Navigation & error ───────────────────────────────────────
2227
- case "NAVIGATE":
2228
- return { ...state, step: action.step, previousStep: state.step, error: null };
2215
+ // ── User intent & error ──────────────────────────────────────
2216
+ case "SET_USER_INTENT":
2217
+ return { ...state, userIntent: action.intent };
2218
+ case "REQUEST_LOGIN":
2219
+ return {
2220
+ ...state,
2221
+ loginRequested: true,
2222
+ transfer: null,
2223
+ isGuestFlow: false,
2224
+ creatingTransfer: false
2225
+ };
2229
2226
  case "SET_ERROR":
2230
2227
  return { ...state, error: action.error };
2231
2228
  // ── Lifecycle ────────────────────────────────────────────────
2232
2229
  case "NEW_PAYMENT":
2233
2230
  return {
2234
2231
  ...state,
2235
- step: state.isGuestFlow ? "wallet-picker" : "deposit",
2236
2232
  transfer: null,
2237
2233
  error: null,
2238
2234
  amount: action.depositAmount != null ? action.depositAmount.toString() : "",
@@ -2245,7 +2241,9 @@ function paymentReducer(state, action) {
2245
2241
  guestTransferId: null,
2246
2242
  guestSessionToken: null,
2247
2243
  guestPreauthAccountId: null,
2248
- activePublicKey: null
2244
+ activePublicKey: null,
2245
+ userIntent: null,
2246
+ loginRequested: false
2249
2247
  };
2250
2248
  case "LOGOUT":
2251
2249
  return {
@@ -2313,6 +2311,87 @@ function isMobileUserAgent(userAgent) {
2313
2311
  function shouldUseWalletConnector(options) {
2314
2312
  return options.useWalletConnector ?? !isMobileUserAgent(options.userAgent);
2315
2313
  }
2314
+
2315
+ // src/resolveScreen.ts
2316
+ function hasActiveWallet(accounts) {
2317
+ return accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
2318
+ }
2319
+ function isTransferTerminal(transfer) {
2320
+ return transfer?.status === "COMPLETED" || transfer?.status === "FAILED";
2321
+ }
2322
+ function isTransferInFlight(transfer) {
2323
+ if (!transfer) return false;
2324
+ return ["CREATED", "SENDING", "SENT"].includes(transfer.status);
2325
+ }
2326
+ function isSetupTransfer(transfer) {
2327
+ if (!transfer) return false;
2328
+ return transfer.sources?.some(
2329
+ (s) => s.wallets && Array.isArray(s.wallets) && s.wallets.length === 0
2330
+ ) ?? false;
2331
+ }
2332
+ function resolveScreen(state) {
2333
+ if (!state.privyReady) {
2334
+ return "loading";
2335
+ }
2336
+ if (state.authenticated && !state.activeCredentialId && !state.passkeyConfigLoaded) {
2337
+ return "loading";
2338
+ }
2339
+ if (!state.authenticated && !state.verificationTarget && !state.isGuestFlow && (state.isReturningUser || state.guestPreauthRedirect || state.loginRequested)) {
2340
+ return "login";
2341
+ }
2342
+ if (!state.authenticated && state.verificationTarget != null) {
2343
+ return "otp-verify";
2344
+ }
2345
+ if (state.authenticated && !state.activeCredentialId && state.passkeyConfigLoaded && (state.knownCredentialIds.length === 0 || !state.passkeyPopupNeeded)) {
2346
+ return "create-passkey";
2347
+ }
2348
+ if (state.authenticated && !state.activeCredentialId && state.passkeyConfigLoaded && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded) {
2349
+ return "verify-passkey";
2350
+ }
2351
+ if (isTransferTerminal(state.transfer)) {
2352
+ return "success";
2353
+ }
2354
+ if (state.creatingTransfer || state.transfer != null && isTransferInFlight(state.transfer)) {
2355
+ return "processing";
2356
+ }
2357
+ if (state.transfer?.status === "AUTHORIZED" && !state.isDesktop && !isSetupTransfer(state.transfer)) {
2358
+ return "confirm-sign";
2359
+ }
2360
+ if (state.pendingSelectSource != null) {
2361
+ return state.isDesktop ? "setup" : "select-source";
2362
+ }
2363
+ if (state.pendingOneTapSetup != null && !state.oneTapLimitAlreadySaved) {
2364
+ return "setup";
2365
+ }
2366
+ if (state.mobileFlow || state.inlineAuthorizationExecuting) {
2367
+ return state.isDesktop ? "setup-status" : "open-wallet";
2368
+ }
2369
+ if (state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestSettingSender) {
2370
+ return "guest-token-picker";
2371
+ }
2372
+ if (state.activeCredentialId && !hasActiveWallet(state.accounts) && !state.mobileFlow || !state.authenticated && !state.isReturningUser && !state.isGuestFlow) {
2373
+ return "wallet-picker";
2374
+ }
2375
+ if (state.loadingData && state.activeCredentialId != null && hasActiveWallet(state.accounts)) {
2376
+ return "loading";
2377
+ }
2378
+ if (state.userIntent === "pick-token" && state.selectedAccount != null) {
2379
+ return "token-picker";
2380
+ }
2381
+ if (state.userIntent === "configure-one-tap") {
2382
+ return "setup";
2383
+ }
2384
+ if (state.userIntent === "switch-wallet") {
2385
+ return "wallet-picker";
2386
+ }
2387
+ if (state.activeCredentialId != null && hasActiveWallet(state.accounts) && !state.loadingData) {
2388
+ return "deposit";
2389
+ }
2390
+ if (state.isGuestFlow) {
2391
+ return "wallet-picker";
2392
+ }
2393
+ return "wallet-picker";
2394
+ }
2316
2395
  var MUTED = "#7fa4b0";
2317
2396
  var LOGO_SIZE = 48;
2318
2397
  function BlinkLoadingScreen() {
@@ -5780,7 +5859,7 @@ var emptyStyle = (color) => ({
5780
5859
  padding: "32px 0",
5781
5860
  lineHeight: 1.5
5782
5861
  });
5783
- var LINK_STEPS = /* @__PURE__ */ new Set([
5862
+ var LINK_SCREENS = /* @__PURE__ */ new Set([
5784
5863
  "create-passkey",
5785
5864
  "verify-passkey",
5786
5865
  "wallet-picker",
@@ -5789,27 +5868,57 @@ var LINK_STEPS = /* @__PURE__ */ new Set([
5789
5868
  "setup",
5790
5869
  "confirm-sign"
5791
5870
  ]);
5792
- var DEPOSIT_STEPS = /* @__PURE__ */ new Set([
5871
+ var DEPOSIT_SCREENS = /* @__PURE__ */ new Set([
5793
5872
  "deposit",
5794
- "low-balance",
5795
5873
  "processing",
5796
5874
  "success"
5797
5875
  ]);
5798
- function getFlowPhase(step, previousStep) {
5799
- if (LINK_STEPS.has(step)) return "link";
5800
- if (DEPOSIT_STEPS.has(step)) return "deposit";
5801
- if (step === "token-picker" || step === "select-source") {
5802
- return previousStep === "setup" ? "link" : "deposit";
5876
+ function getFlowPhase(screen, userIntent) {
5877
+ if (LINK_SCREENS.has(screen)) return "link";
5878
+ if (DEPOSIT_SCREENS.has(screen)) return "deposit";
5879
+ if (screen === "token-picker" || screen === "select-source" || screen === "guest-token-picker") {
5880
+ return userIntent === "configure-one-tap" ? "link" : "deposit";
5803
5881
  }
5804
5882
  return null;
5805
5883
  }
5806
5884
  function StepRenderer(props) {
5807
- const phase = getFlowPhase(props.state.step, props.state.previousStep);
5808
- return /* @__PURE__ */ jsx(FlowPhaseProvider, { phase, children: /* @__PURE__ */ jsx(StepRendererContent, { ...props }) });
5885
+ const isDesktop = shouldUseWalletConnector({
5886
+ userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5887
+ });
5888
+ const isReturningUser = props.state.activeCredentialId != null || typeof window !== "undefined" && window.localStorage.getItem("blink_active_credential") != null;
5889
+ const screenState = {
5890
+ privyReady: props.ready,
5891
+ authenticated: props.authenticated,
5892
+ verificationTarget: props.state.verificationTarget,
5893
+ activeCredentialId: props.state.activeCredentialId,
5894
+ knownCredentialIds: props.state.knownCredentialIds,
5895
+ passkeyConfigLoaded: props.state.passkeyConfigLoaded,
5896
+ passkeyPopupNeeded: props.state.passkeyPopupNeeded,
5897
+ accounts: props.state.accounts,
5898
+ isGuestFlow: props.state.isGuestFlow,
5899
+ selectedProviderId: props.state.selectedProviderId,
5900
+ mobileFlow: props.state.mobileFlow,
5901
+ inlineAuthorizationExecuting: props.inlineAuthorizationExecuting,
5902
+ creatingTransfer: props.state.creatingTransfer,
5903
+ transfer: props.state.transfer,
5904
+ pendingSelectSource: props.pendingSelectSource,
5905
+ pendingOneTapSetup: props.pendingOneTapSetup,
5906
+ oneTapLimitAlreadySaved: props.oneTapLimitAlreadySaved,
5907
+ loadingData: props.state.loadingData,
5908
+ isDesktop,
5909
+ isReturningUser,
5910
+ guestPreauthRedirect: props.state.guestPreauthAccountId != null,
5911
+ loginRequested: props.state.loginRequested,
5912
+ userIntent: props.state.userIntent,
5913
+ selectedAccount: props.selectedAccount,
5914
+ guestSettingSender: props.guestSettingSender
5915
+ };
5916
+ const screen = resolveScreen(screenState);
5917
+ const phase = getFlowPhase(screen, props.state.userIntent);
5918
+ return /* @__PURE__ */ jsx(FlowPhaseProvider, { phase, children: /* @__PURE__ */ jsx(StepRendererContent, { ...props, screen, isDesktop }) });
5809
5919
  }
5810
5920
  function StepRendererContent({
5811
5921
  state,
5812
- ready,
5813
5922
  authenticated,
5814
5923
  activeOtpStatus,
5815
5924
  pollingTransfer,
@@ -5839,204 +5948,204 @@ function StepRendererContent({
5839
5948
  onBack,
5840
5949
  onDismiss,
5841
5950
  depositAmount,
5842
- handlers
5951
+ handlers,
5952
+ screen,
5953
+ isDesktop
5843
5954
  }) {
5844
- const { step } = state;
5845
5955
  const selectedWallet = selectedAccount?.wallets.find((w) => w.id === state.selectedWalletId);
5846
5956
  const selectedSourceLabel = selectedSource && selectedWallet ? `${selectedSource.token.symbol} on ${selectedWallet.chain.name}` : void 0;
5847
- if (!ready) {
5848
- return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
5849
- }
5850
- if (step === "login") {
5851
- if (authenticated) {
5957
+ switch (screen) {
5958
+ case "loading":
5852
5959
  return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
5960
+ case "login":
5961
+ return /* @__PURE__ */ jsx(
5962
+ LoginScreen,
5963
+ {
5964
+ authInput,
5965
+ onAuthInputChange: handlers.onSetAuthInput,
5966
+ onSubmit: handlers.onSendLoginCode,
5967
+ sending: activeOtpStatus === "sending-code",
5968
+ error: state.error,
5969
+ onBack,
5970
+ merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
5971
+ }
5972
+ );
5973
+ case "otp-verify":
5974
+ return /* @__PURE__ */ jsx(
5975
+ OtpVerifyScreen,
5976
+ {
5977
+ maskedIdentifier: state.verificationTarget ? maskAuthIdentifier(state.verificationTarget) : "",
5978
+ otpCode,
5979
+ onOtpChange: (code) => {
5980
+ handlers.onSetOtpCode(code);
5981
+ },
5982
+ onVerify: handlers.onVerifyLoginCode,
5983
+ onResend: handlers.onResendLoginCode,
5984
+ onBack: handlers.onBackFromOtp,
5985
+ verifying: activeOtpStatus === "submitting-code" || authenticated,
5986
+ error: state.error
5987
+ }
5988
+ );
5989
+ case "create-passkey":
5990
+ return /* @__PURE__ */ jsx(
5991
+ PasskeyScreen,
5992
+ {
5993
+ onCreatePasskey: handlers.onRegisterPasskey,
5994
+ onBack: handlers.onLogout,
5995
+ onLogout: handlers.onLogout,
5996
+ creating: state.registeringPasskey,
5997
+ error: state.error,
5998
+ popupFallback: state.passkeyPopupNeeded,
5999
+ onCreatePasskeyViaPopup: handlers.onCreatePasskeyViaPopup
6000
+ }
6001
+ );
6002
+ case "verify-passkey":
6003
+ return /* @__PURE__ */ jsx(
6004
+ PasskeyScreen,
6005
+ {
6006
+ onCreatePasskey: handlers.onRegisterPasskey,
6007
+ onBack: handlers.onLogout,
6008
+ onLogout: handlers.onLogout,
6009
+ creating: state.verifyingPasskeyPopup,
6010
+ error: state.error,
6011
+ popupFallback: true,
6012
+ onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
6013
+ }
6014
+ );
6015
+ case "wallet-picker": {
6016
+ const isEntryPoint = !state.isGuestFlow && !authenticated;
6017
+ return /* @__PURE__ */ jsx(
6018
+ WalletPickerScreen,
6019
+ {
6020
+ providers: state.providers,
6021
+ pendingConnections,
6022
+ loading: state.creatingTransfer,
6023
+ useDeeplink: !isDesktop,
6024
+ onPrepareProvider: handlers.onPrepareProvider,
6025
+ onSelectProvider: handlers.onSelectProvider,
6026
+ onContinueConnection: handlers.onContinueConnection,
6027
+ onBack: isEntryPoint ? onBack : () => handlers.onSetUserIntent(null),
6028
+ onLogout: authenticated ? handlers.onLogout : void 0,
6029
+ onLogin: handlers.onLogin,
6030
+ showLoginOption: isEntryPoint
6031
+ }
6032
+ );
5853
6033
  }
5854
- return /* @__PURE__ */ jsx(
5855
- LoginScreen,
5856
- {
5857
- authInput,
5858
- onAuthInputChange: handlers.onSetAuthInput,
5859
- onSubmit: handlers.onSendLoginCode,
5860
- sending: activeOtpStatus === "sending-code",
5861
- error: state.error,
5862
- onBack,
5863
- merchantInitials: merchantName ? merchantName.slice(0, 2).toUpperCase() : void 0
5864
- }
5865
- );
5866
- }
5867
- if (step === "otp-verify") {
5868
- return /* @__PURE__ */ jsx(
5869
- OtpVerifyScreen,
5870
- {
5871
- maskedIdentifier: state.verificationTarget ? maskAuthIdentifier(state.verificationTarget) : "",
5872
- otpCode,
5873
- onOtpChange: (code) => {
5874
- handlers.onSetOtpCode(code);
5875
- },
5876
- onVerify: handlers.onVerifyLoginCode,
5877
- onResend: handlers.onResendLoginCode,
5878
- onBack: handlers.onBackFromOtp,
5879
- verifying: activeOtpStatus === "submitting-code" || authenticated,
5880
- error: state.error
5881
- }
5882
- );
5883
- }
5884
- if (step === "create-passkey") {
5885
- return /* @__PURE__ */ jsx(
5886
- PasskeyScreen,
5887
- {
5888
- onCreatePasskey: handlers.onRegisterPasskey,
5889
- onBack: handlers.onLogout,
5890
- onLogout: handlers.onLogout,
5891
- creating: state.registeringPasskey,
5892
- error: state.error,
5893
- popupFallback: state.passkeyPopupNeeded,
5894
- onCreatePasskeyViaPopup: handlers.onCreatePasskeyViaPopup
5895
- }
5896
- );
5897
- }
5898
- if (step === "verify-passkey") {
5899
- return /* @__PURE__ */ jsx(
5900
- PasskeyScreen,
5901
- {
5902
- onCreatePasskey: handlers.onRegisterPasskey,
5903
- onBack: handlers.onLogout,
5904
- onLogout: handlers.onLogout,
5905
- creating: state.verifyingPasskeyPopup,
5906
- error: state.error,
5907
- popupFallback: true,
5908
- onCreatePasskeyViaPopup: handlers.onVerifyPasskeyViaPopup
5909
- }
5910
- );
5911
- }
5912
- if (step === "wallet-picker") {
5913
- if (state.isGuestFlow && state.selectedProviderId && state.activeCredentialId) {
5914
- return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
6034
+ case "open-wallet": {
6035
+ const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
6036
+ return /* @__PURE__ */ jsx(
6037
+ OpenWalletScreen,
6038
+ {
6039
+ walletName: providerName,
6040
+ deeplinkUri: state.deeplinkUri ?? "",
6041
+ loading: !isDesktop ? state.creatingTransfer || !state.deeplinkUri : state.creatingTransfer,
6042
+ useDeeplink: !isDesktop,
6043
+ error: state.error || (!isDesktop ? pollingError : authExecutorError),
6044
+ onRetryStatus: !isDesktop ? handlers.onRetryMobileStatus : void 0,
6045
+ onBack: !isDesktop ? handlers.onBackFromOpenWallet : void 0,
6046
+ onLogout: handlers.onLogout
6047
+ }
6048
+ );
5915
6049
  }
5916
- const isEntryPoint = !state.isGuestFlow && !authenticated;
5917
- return /* @__PURE__ */ jsx(
5918
- WalletPickerScreen,
5919
- {
5920
- providers: state.providers,
5921
- pendingConnections,
5922
- loading: state.creatingTransfer,
5923
- useDeeplink: !shouldUseWalletConnector({
5924
- userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5925
- }),
5926
- onPrepareProvider: handlers.onPrepareProvider,
5927
- onSelectProvider: handlers.onSelectProvider,
5928
- onContinueConnection: handlers.onContinueConnection,
5929
- onBack: isEntryPoint ? onBack : () => handlers.onNavigate(state.activeCredentialId ? "deposit" : "create-passkey"),
5930
- onLogout: authenticated ? handlers.onLogout : void 0,
5931
- onLogin: handlers.onLogin,
5932
- showLoginOption: isEntryPoint
5933
- }
5934
- );
5935
- }
5936
- if (step === "open-wallet") {
5937
- const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
5938
- const useDeeplink = !shouldUseWalletConnector({
5939
- userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5940
- });
5941
- return /* @__PURE__ */ jsx(
5942
- OpenWalletScreen,
5943
- {
5944
- walletName: providerName,
5945
- deeplinkUri: state.deeplinkUri ?? "",
5946
- loading: useDeeplink ? state.creatingTransfer || !state.deeplinkUri : state.creatingTransfer,
5947
- useDeeplink,
5948
- error: state.error || (useDeeplink ? pollingError : authExecutorError),
5949
- onRetryStatus: useDeeplink ? handlers.onRetryMobileStatus : void 0,
5950
- onBack: useDeeplink ? () => handlers.onNavigate("wallet-picker") : void 0,
5951
- onLogout: handlers.onLogout
5952
- }
5953
- );
5954
- }
5955
- if (step === "setup-status") {
5956
- return /* @__PURE__ */ jsx(
5957
- SetupStatusScreen,
5958
- {
5959
- complete: false,
5960
- limit: state.oneTapLimit,
5961
- tokensApproved: 0,
5962
- merchantName,
5963
- onContinue: () => handlers.onNavigate("setup"),
5964
- onLogout: handlers.onLogout,
5965
- error: state.error || authExecutorError
5966
- }
5967
- );
5968
- }
5969
- if (step === "setup") {
5970
- const selectSourceTokenCount = selectSourceChoices.reduce(
5971
- (sum, chain) => sum + chain.tokens.length,
5972
- 0
5973
- );
5974
- const effectiveTokenCount = tokenCount > 0 ? tokenCount : selectSourceTokenCount;
5975
- const effectiveSourceLabel = selectedSourceLabel ?? (selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : void 0);
5976
- return /* @__PURE__ */ jsx(
5977
- SetupScreen,
5978
- {
5979
- availableBalance: selectedSource ? selectedSource.balance.available.amount : selectSourceAvailableBalance > 0 ? selectSourceAvailableBalance : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
5980
- tokenCount: effectiveTokenCount,
5981
- sourceName,
5982
- onSetupOneTap: handlers.onSetupOneTap,
5983
- onBack: () => handlers.onNavigate("deposit"),
5984
- onLogout: handlers.onLogout,
5985
- onAdvanced: handlers.onSelectToken,
5986
- selectedSourceLabel: effectiveSourceLabel,
5987
- loading: savingOneTapLimit,
5988
- error: state.error,
5989
- selectedTokenSymbol: selectedSource?.token.symbol ?? selectSourceTokenSymbol
5990
- }
5991
- );
5992
- }
5993
- if (step === "confirm-sign") {
5994
- const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
5995
- return /* @__PURE__ */ jsx(
5996
- ConfirmSignScreen,
5997
- {
5998
- walletName: providerName,
5999
- signing: transferSigningSigning,
6000
- error: state.error || transferSigningError,
6001
- onSign: handlers.onConfirmSign,
6002
- onLogout: handlers.onLogout
6003
- }
6004
- );
6005
- }
6006
- if (step === "deposit") {
6007
- if (state.loadingData) {
6008
- return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
6050
+ case "setup-status":
6051
+ return /* @__PURE__ */ jsx(
6052
+ SetupStatusScreen,
6053
+ {
6054
+ complete: false,
6055
+ limit: state.oneTapLimit,
6056
+ tokensApproved: 0,
6057
+ merchantName,
6058
+ onContinue: () => handlers.onSetUserIntent("configure-one-tap"),
6059
+ onLogout: handlers.onLogout,
6060
+ error: state.error || authExecutorError
6061
+ }
6062
+ );
6063
+ case "setup": {
6064
+ const selectSourceTokenCount = selectSourceChoices.reduce(
6065
+ (sum, chain) => sum + chain.tokens.length,
6066
+ 0
6067
+ );
6068
+ const effectiveTokenCount = tokenCount > 0 ? tokenCount : selectSourceTokenCount;
6069
+ const effectiveSourceLabel = selectedSourceLabel ?? (selectSourceChainName && selectSourceTokenSymbol ? `${selectSourceTokenSymbol} on ${selectSourceChainName}` : void 0);
6070
+ return /* @__PURE__ */ jsx(
6071
+ SetupScreen,
6072
+ {
6073
+ availableBalance: selectedSource ? selectedSource.balance.available.amount : selectSourceAvailableBalance > 0 ? selectSourceAvailableBalance : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
6074
+ tokenCount: effectiveTokenCount,
6075
+ sourceName,
6076
+ onSetupOneTap: handlers.onSetupOneTap,
6077
+ onBack: () => handlers.onSetUserIntent(null),
6078
+ onLogout: handlers.onLogout,
6079
+ onAdvanced: handlers.onSelectToken,
6080
+ selectedSourceLabel: effectiveSourceLabel,
6081
+ loading: savingOneTapLimit,
6082
+ error: state.error,
6083
+ selectedTokenSymbol: selectedSource?.token.symbol ?? selectSourceTokenSymbol
6084
+ }
6085
+ );
6009
6086
  }
6010
- const parsedAmt = depositAmount != null ? depositAmount : 5;
6011
- return /* @__PURE__ */ jsx(
6012
- DepositScreen,
6013
- {
6014
- merchantName,
6015
- availableBalance: selectedSource ? selectedSource.balance.available.amount : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
6016
- remainingLimit: selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null,
6017
- tokenCount,
6018
- initialAmount: parsedAmt,
6019
- processing: state.creatingTransfer,
6020
- error: state.error,
6021
- onDeposit: handlers.onPay,
6022
- onSwitchWallet: () => handlers.onNavigate("wallet-picker"),
6023
- onBack: onBack ?? (() => handlers.onLogout()),
6024
- onLogout: handlers.onLogout,
6025
- onIncreaseLimit: handlers.onIncreaseLimit,
6026
- increasingLimit: state.increasingLimit,
6027
- accounts: depositEligibleAccounts,
6028
- selectedAccountId: state.selectedAccountId,
6029
- onSelectAccount: handlers.onSelectAccount,
6030
- onAuthorizeAccount: handlers.onContinueConnection,
6031
- onAddProvider: () => handlers.onNavigate("wallet-picker"),
6032
- onSelectToken: handlers.onSelectToken,
6033
- selectedSourceLabel,
6034
- selectedTokenSymbol: selectedSource?.token.symbol
6087
+ case "confirm-sign": {
6088
+ const providerName = state.providers.find((p) => p.id === state.selectedProviderId)?.name ?? null;
6089
+ return /* @__PURE__ */ jsx(
6090
+ ConfirmSignScreen,
6091
+ {
6092
+ walletName: providerName,
6093
+ signing: transferSigningSigning,
6094
+ error: state.error || transferSigningError,
6095
+ onSign: handlers.onConfirmSign,
6096
+ onLogout: handlers.onLogout
6097
+ }
6098
+ );
6099
+ }
6100
+ case "deposit": {
6101
+ const parsedAmt = depositAmount != null ? depositAmount : 5;
6102
+ return /* @__PURE__ */ jsx(
6103
+ DepositScreen,
6104
+ {
6105
+ merchantName,
6106
+ availableBalance: selectedSource ? selectedSource.balance.available.amount : selectedAccount ? selectedAccount.wallets.reduce((sum, w) => sum + w.balance.available.amount, 0) : maxSourceBalance,
6107
+ remainingLimit: selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null,
6108
+ tokenCount,
6109
+ initialAmount: parsedAmt,
6110
+ processing: state.creatingTransfer,
6111
+ error: state.error,
6112
+ onDeposit: handlers.onPay,
6113
+ onSwitchWallet: () => handlers.onSetUserIntent("switch-wallet"),
6114
+ onBack: onBack ?? (() => handlers.onLogout()),
6115
+ onLogout: handlers.onLogout,
6116
+ onIncreaseLimit: handlers.onIncreaseLimit,
6117
+ increasingLimit: state.increasingLimit,
6118
+ accounts: depositEligibleAccounts,
6119
+ selectedAccountId: state.selectedAccountId,
6120
+ onSelectAccount: handlers.onSelectAccount,
6121
+ onAuthorizeAccount: handlers.onContinueConnection,
6122
+ onAddProvider: () => handlers.onSetUserIntent("switch-wallet"),
6123
+ onSelectToken: handlers.onSelectToken,
6124
+ selectedSourceLabel,
6125
+ selectedTokenSymbol: selectedSource?.token.symbol
6126
+ }
6127
+ );
6128
+ }
6129
+ case "token-picker": {
6130
+ if (!selectedAccount) {
6131
+ return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
6035
6132
  }
6036
- );
6037
- }
6038
- if (step === "token-picker") {
6039
- if (state.isGuestFlow) {
6133
+ return /* @__PURE__ */ jsx(
6134
+ TokenPickerScreen,
6135
+ {
6136
+ account: selectedAccount,
6137
+ chains: state.chains,
6138
+ onSelectAuthorized: handlers.onSelectAuthorizedToken,
6139
+ onAuthorizeToken: handlers.onAuthorizeToken,
6140
+ onBack: () => handlers.onSetUserIntent(null),
6141
+ onLogout: handlers.onLogout,
6142
+ depositAmount: depositAmount ?? void 0,
6143
+ selectedTokenSymbol: selectedSource?.token.symbol,
6144
+ selectedWalletId: state.selectedWalletId ?? void 0
6145
+ }
6146
+ );
6147
+ }
6148
+ case "guest-token-picker":
6040
6149
  return /* @__PURE__ */ jsx(
6041
6150
  GuestTokenPickerScreen,
6042
6151
  {
@@ -6046,107 +6155,60 @@ function StepRendererContent({
6046
6155
  depositAmount: depositAmount ?? void 0,
6047
6156
  error: state.error,
6048
6157
  onSelect: handlers.onSelectGuestToken,
6049
- onBack: () => handlers.onNavigate("wallet-picker")
6158
+ onBack: () => handlers.onSetUserIntent(null)
6159
+ }
6160
+ );
6161
+ case "processing": {
6162
+ const polledStatus = pollingTransfer?.status;
6163
+ const transferPhase = state.creatingTransfer ? "creating" : polledStatus === "SENDING" || polledStatus === "SENT" ? "sent" : "verifying";
6164
+ return /* @__PURE__ */ jsx(
6165
+ TransferStatusScreen,
6166
+ {
6167
+ phase: transferPhase,
6168
+ error: state.error || authExecutorError || transferSigningError || pollingError,
6169
+ onLogout: handlers.onLogout
6050
6170
  }
6051
6171
  );
6052
6172
  }
6053
- if (!selectedAccount) {
6054
- return /* @__PURE__ */ jsx(BlinkLoadingScreen, {});
6173
+ case "select-source":
6174
+ return /* @__PURE__ */ jsx(
6175
+ SelectSourceScreen,
6176
+ {
6177
+ choices: selectSourceChoices,
6178
+ selectedChainName: selectSourceChainName,
6179
+ selectedTokenSymbol: selectSourceTokenSymbol,
6180
+ recommended: selectSourceRecommended,
6181
+ onChainChange: handlers.onSelectSourceChainChange,
6182
+ onTokenChange: handlers.onSetSelectSourceTokenSymbol,
6183
+ onConfirm: handlers.onConfirmSelectSource,
6184
+ onLogout: handlers.onLogout
6185
+ }
6186
+ );
6187
+ case "success": {
6188
+ const succeeded = state.transfer?.status === "COMPLETED";
6189
+ const displayAmount = state.transfer?.amount?.amount ?? 0;
6190
+ const displayCurrency = state.transfer?.amount?.currency ?? "USD";
6191
+ return /* @__PURE__ */ jsx(
6192
+ SuccessScreen,
6193
+ {
6194
+ amount: displayAmount,
6195
+ currency: displayCurrency,
6196
+ succeeded,
6197
+ error: state.error,
6198
+ merchantName,
6199
+ sourceName,
6200
+ remainingLimit: succeeded ? (() => {
6201
+ const limit = selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null;
6202
+ if (limit == null) return null;
6203
+ return limit > displayAmount ? limit - displayAmount : 0;
6204
+ })() : void 0,
6205
+ onDone: onDismiss ?? handlers.onNewPayment,
6206
+ onLogout: handlers.onLogout,
6207
+ onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0
6208
+ }
6209
+ );
6055
6210
  }
6056
- return /* @__PURE__ */ jsx(
6057
- TokenPickerScreen,
6058
- {
6059
- account: selectedAccount,
6060
- chains: state.chains,
6061
- onSelectAuthorized: handlers.onSelectAuthorizedToken,
6062
- onAuthorizeToken: handlers.onAuthorizeToken,
6063
- onBack: () => handlers.onNavigate(state.previousStep === "setup" ? "setup" : "deposit"),
6064
- onLogout: handlers.onLogout,
6065
- depositAmount: depositAmount ?? void 0,
6066
- selectedTokenSymbol: selectedSource?.token.symbol,
6067
- selectedWalletId: state.selectedWalletId
6068
- }
6069
- );
6070
- }
6071
- if (step === "processing") {
6072
- const polledStatus = pollingTransfer?.status;
6073
- const transferPhase = state.creatingTransfer ? "creating" : polledStatus === "SENDING" || polledStatus === "SENT" ? "sent" : "verifying";
6074
- return /* @__PURE__ */ jsx(
6075
- TransferStatusScreen,
6076
- {
6077
- phase: transferPhase,
6078
- error: state.error || authExecutorError || transferSigningError || pollingError,
6079
- onLogout: handlers.onLogout
6080
- }
6081
- );
6082
- }
6083
- if (step === "select-source") {
6084
- const cameFromSetup = state.previousStep === "setup";
6085
- return /* @__PURE__ */ jsx(
6086
- SelectSourceScreen,
6087
- {
6088
- choices: selectSourceChoices,
6089
- selectedChainName: selectSourceChainName,
6090
- selectedTokenSymbol: selectSourceTokenSymbol,
6091
- recommended: selectSourceRecommended,
6092
- onChainChange: handlers.onSelectSourceChainChange,
6093
- onTokenChange: handlers.onSetSelectSourceTokenSymbol,
6094
- onConfirm: cameFromSetup ? () => handlers.onNavigate("setup") : handlers.onConfirmSelectSource,
6095
- onBack: cameFromSetup ? () => handlers.onNavigate("setup") : void 0,
6096
- onLogout: handlers.onLogout
6097
- }
6098
- );
6099
- }
6100
- if (step === "success") {
6101
- const succeeded = state.transfer?.status === "COMPLETED";
6102
- const displayAmount = state.transfer?.amount?.amount ?? 0;
6103
- const displayCurrency = state.transfer?.amount?.currency ?? "USD";
6104
- return /* @__PURE__ */ jsx(
6105
- SuccessScreen,
6106
- {
6107
- amount: displayAmount,
6108
- currency: displayCurrency,
6109
- succeeded,
6110
- error: state.error,
6111
- merchantName,
6112
- sourceName,
6113
- remainingLimit: succeeded ? (() => {
6114
- const limit = selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null;
6115
- if (limit == null) return null;
6116
- return limit > displayAmount ? limit - displayAmount : 0;
6117
- })() : void 0,
6118
- onDone: onDismiss ?? handlers.onNewPayment,
6119
- onLogout: handlers.onLogout,
6120
- onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0
6121
- }
6122
- );
6123
- }
6124
- if (step === "low-balance") {
6125
- return /* @__PURE__ */ jsx(
6126
- DepositScreen,
6127
- {
6128
- merchantName,
6129
- availableBalance: 0,
6130
- remainingLimit: selectedSource != null ? selectedSource.remainingAllowance ?? null : selectedAccount?.remainingAllowance ?? null,
6131
- tokenCount,
6132
- initialAmount: depositAmount ?? 5,
6133
- processing: false,
6134
- error: state.error,
6135
- onDeposit: handlers.onPay,
6136
- onSwitchWallet: () => handlers.onNavigate("wallet-picker"),
6137
- onBack: onBack ?? (() => handlers.onLogout()),
6138
- onLogout: handlers.onLogout,
6139
- accounts: depositEligibleAccounts,
6140
- selectedAccountId: state.selectedAccountId,
6141
- onSelectAccount: handlers.onSelectAccount,
6142
- onAuthorizeAccount: handlers.onContinueConnection,
6143
- onAddProvider: () => handlers.onNavigate("wallet-picker"),
6144
- selectedSourceLabel,
6145
- selectedTokenSymbol: selectedSource?.token.symbol
6146
- }
6147
- );
6148
6211
  }
6149
- return null;
6150
6212
  }
6151
6213
 
6152
6214
  // src/sentry.ts
@@ -6383,52 +6445,6 @@ function useAuthHandlers(dispatch, verificationTarget) {
6383
6445
  handleResendLoginCode
6384
6446
  };
6385
6447
  }
6386
-
6387
- // src/mobileFlow.ts
6388
- function hasActiveWallet(accounts) {
6389
- return accounts.some((account) => account.wallets.some((wallet) => wallet.status === "ACTIVE"));
6390
- }
6391
- function resolvePostAuthStep(state) {
6392
- if (!state.hasPasskey) {
6393
- return { step: "create-passkey", clearPersistedFlow: false };
6394
- }
6395
- if (state.persistedMobileFlow) {
6396
- if (state.persistedMobileFlow.isReauthorization) {
6397
- return { step: "open-wallet", clearPersistedFlow: false };
6398
- }
6399
- if (state.persistedMobileFlow.isSetup && hasActiveWallet(state.accounts)) {
6400
- return { step: "deposit", clearPersistedFlow: true };
6401
- }
6402
- return { step: "open-wallet", clearPersistedFlow: false };
6403
- }
6404
- if (state.mobileSetupInProgress && !hasActiveWallet(state.accounts)) {
6405
- return { step: "open-wallet", clearPersistedFlow: false };
6406
- }
6407
- if ((state.accounts.length === 0 || !hasActiveWallet(state.accounts)) && !state.connectingNewAccount) {
6408
- return { step: "wallet-picker", clearPersistedFlow: false };
6409
- }
6410
- return { step: "deposit", clearPersistedFlow: false };
6411
- }
6412
- function resolveRestoredMobileFlow(transferStatus, isSetup) {
6413
- if (transferStatus === "AUTHORIZED") {
6414
- return isSetup ? { kind: "resume-setup-deposit", step: "deposit", clearPersistedFlow: true } : { kind: "resume-confirm-sign", step: "confirm-sign", clearPersistedFlow: true };
6415
- }
6416
- if (transferStatus === "COMPLETED") {
6417
- return { kind: "resume-success", step: "success", clearPersistedFlow: true };
6418
- }
6419
- if (transferStatus === "FAILED") {
6420
- return { kind: "resume-failed", step: "success", clearPersistedFlow: true };
6421
- }
6422
- if (transferStatus === "SENDING" || transferStatus === "SENT") {
6423
- return { kind: "resume-processing", step: "processing", clearPersistedFlow: true };
6424
- }
6425
- if (isSetup) {
6426
- return { kind: "resume-stale-setup", step: "wallet-picker", clearPersistedFlow: true };
6427
- }
6428
- return { kind: "resume-open-wallet", step: "open-wallet", clearPersistedFlow: false };
6429
- }
6430
-
6431
- // src/hooks/usePasskeyHandlers.ts
6432
6448
  function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef, guestPreauthAccountId) {
6433
6449
  const { user, getAccessToken } = usePrivy();
6434
6450
  const checkingPasskeyRef = useRef(false);
@@ -6440,35 +6456,14 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6440
6456
  reportPasskeyActivity(apiBaseUrl, token, credentialId).catch(() => {
6441
6457
  });
6442
6458
  }
6443
- const resolved = resolvePostAuthStep({
6444
- hasPasskey: true,
6445
- accounts,
6446
- persistedMobileFlow: loadMobileFlowState(),
6447
- mobileSetupInProgress: mobileSetupFlowRef.current,
6448
- connectingNewAccount: false
6449
- });
6450
- if (resolved.clearPersistedFlow) clearMobileFlowState();
6451
- dispatch({ type: "NAVIGATE", step: resolved.step });
6452
- }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6459
+ }, [getAccessToken, apiBaseUrl, dispatch]);
6453
6460
  const completePasskeyRegistration = useCallback(async (credentialId, publicKey) => {
6454
6461
  const token = await getAccessToken();
6455
6462
  if (!token) throw new Error("Not authenticated");
6456
6463
  await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
6457
6464
  dispatch({ type: "PASSKEY_ACTIVATED", credentialId, publicKey });
6458
6465
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
6459
- if (guestPreauthAccountId) {
6460
- return;
6461
- }
6462
- const resolved = resolvePostAuthStep({
6463
- hasPasskey: true,
6464
- accounts,
6465
- persistedMobileFlow: loadMobileFlowState(),
6466
- mobileSetupInProgress: mobileSetupFlowRef.current,
6467
- connectingNewAccount: false
6468
- });
6469
- if (resolved.clearPersistedFlow) clearMobileFlowState();
6470
- dispatch({ type: "NAVIGATE", step: resolved.step });
6471
- }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, guestPreauthAccountId, dispatch]);
6466
+ }, [getAccessToken, apiBaseUrl, dispatch]);
6472
6467
  const handleRegisterPasskey = useCallback(async () => {
6473
6468
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
6474
6469
  dispatch({ type: "SET_ERROR", error: null });
@@ -6532,15 +6527,6 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6532
6527
  const { credentialId } = await createPasskeyViaPopup(popupOptions);
6533
6528
  dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
6534
6529
  localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
6535
- const resolved = resolvePostAuthStep({
6536
- hasPasskey: true,
6537
- accounts,
6538
- persistedMobileFlow: loadMobileFlowState(),
6539
- mobileSetupInProgress: mobileSetupFlowRef.current,
6540
- connectingNewAccount: false
6541
- });
6542
- if (resolved.clearPersistedFlow) clearMobileFlowState();
6543
- dispatch({ type: "NAVIGATE", step: resolved.step });
6544
6530
  } catch (err) {
6545
6531
  captureException(err);
6546
6532
  dispatch({
@@ -6550,7 +6536,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6550
6536
  } finally {
6551
6537
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
6552
6538
  }
6553
- }, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, accounts, mobileSetupFlowRef, dispatch]);
6539
+ }, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, dispatch]);
6554
6540
  const handleVerifyPasskeyViaPopup = useCallback(async () => {
6555
6541
  dispatch({ type: "SET_VERIFYING_PASSKEY", value: true });
6556
6542
  dispatch({ type: "SET_ERROR", error: null });
@@ -6569,15 +6555,6 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6569
6555
  reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
6570
6556
  });
6571
6557
  }
6572
- const resolved = resolvePostAuthStep({
6573
- hasPasskey: true,
6574
- accounts,
6575
- persistedMobileFlow: loadMobileFlowState(),
6576
- mobileSetupInProgress: mobileSetupFlowRef.current,
6577
- connectingNewAccount: false
6578
- });
6579
- if (resolved.clearPersistedFlow) clearMobileFlowState();
6580
- dispatch({ type: "NAVIGATE", step: resolved.step });
6581
6558
  } else {
6582
6559
  dispatch({
6583
6560
  type: "SET_ERROR",
@@ -6593,7 +6570,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6593
6570
  } finally {
6594
6571
  dispatch({ type: "SET_VERIFYING_PASSKEY", value: false });
6595
6572
  }
6596
- }, [knownCredentialIds, getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6573
+ }, [knownCredentialIds, getAccessToken, apiBaseUrl, dispatch]);
6597
6574
  return {
6598
6575
  handleRegisterPasskey,
6599
6576
  handleCreatePasskeyViaPopup,
@@ -6646,10 +6623,9 @@ function useTransferHandlers(deps) {
6646
6623
  }
6647
6624
  if (!activeCredentialId) {
6648
6625
  dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
6649
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
6650
6626
  return;
6651
6627
  }
6652
- dispatch({ type: "PAY_STARTED", isSetupRedirect: false });
6628
+ dispatch({ type: "PAY_STARTED" });
6653
6629
  processingStartedAtRef.current = Date.now();
6654
6630
  try {
6655
6631
  if (transfer?.status === "AUTHORIZED") {
@@ -6696,7 +6672,7 @@ function useTransferHandlers(deps) {
6696
6672
  } catch (err) {
6697
6673
  captureException(err);
6698
6674
  const msg = err instanceof Error ? err.message : "Transfer failed";
6699
- dispatch({ type: "PAY_ERROR", error: msg, fallbackStep: "deposit" });
6675
+ dispatch({ type: "PAY_ERROR", error: msg });
6700
6676
  onError?.(msg);
6701
6677
  } finally {
6702
6678
  dispatch({ type: "PAY_ENDED" });
@@ -6746,7 +6722,6 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
6746
6722
  const [selectSourceChainName, setSelectSourceChainName] = useState("");
6747
6723
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = useState("");
6748
6724
  const initializedSelectSourceActionRef = useRef(null);
6749
- const preSelectSourceStepRef = useRef(null);
6750
6725
  const pendingSelectSourceAction = authExecutor.pendingSelectSource;
6751
6726
  const selectSourceChoices = useMemo(() => {
6752
6727
  if (!pendingSelectSourceAction) return [];
@@ -6804,8 +6779,7 @@ function useSourceSelectionHandlers(dispatch, authExecutor) {
6804
6779
  handleSelectSourceChainChange,
6805
6780
  handleConfirmSelectSource,
6806
6781
  pendingSelectSourceAction,
6807
- initializedSelectSourceActionRef,
6808
- preSelectSourceStepRef
6782
+ initializedSelectSourceActionRef
6809
6783
  };
6810
6784
  }
6811
6785
  function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransferIdRef, stateTransfer, refs, onComplete) {
@@ -6824,7 +6798,7 @@ function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransfe
6824
6798
  guestPollingActiveRef.current = true;
6825
6799
  let cancelled = false;
6826
6800
  const POLL_INTERVAL_MS = 3e3;
6827
- dispatch({ type: "NAVIGATE", step: "processing" });
6801
+ dispatch({ type: "SET_ERROR", error: null });
6828
6802
  const poll = async () => {
6829
6803
  if (cancelled) return;
6830
6804
  try {
@@ -6958,7 +6932,6 @@ function useProviderHandlers(deps) {
6958
6932
  }
6959
6933
  if (!activeCredentialId) {
6960
6934
  dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
6961
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
6962
6935
  return null;
6963
6936
  }
6964
6937
  const provider = providers.find((p) => p.id === providerId);
@@ -6979,7 +6952,7 @@ function useProviderHandlers(deps) {
6979
6952
  } catch (err) {
6980
6953
  captureException(err);
6981
6954
  const msg = err instanceof Error ? err.message : "Failed to set up wallet";
6982
- dispatch({ type: "PAY_ERROR", error: msg, fallbackStep: "wallet-picker" });
6955
+ dispatch({ type: "PAY_ERROR", error: msg });
6983
6956
  onError?.(msg);
6984
6957
  return null;
6985
6958
  }
@@ -6987,7 +6960,7 @@ function useProviderHandlers(deps) {
6987
6960
  const handleGuestSelectProvider = useCallback(async (providerId) => {
6988
6961
  if (!merchantAuthorization || !destination) {
6989
6962
  const msg = "Missing payment configuration for guest checkout.";
6990
- dispatch({ type: "PAY_ERROR", error: msg, fallbackStep: "wallet-picker" });
6963
+ dispatch({ type: "PAY_ERROR", error: msg });
6991
6964
  onError?.(msg);
6992
6965
  return;
6993
6966
  }
@@ -7009,7 +6982,7 @@ function useProviderHandlers(deps) {
7009
6982
  });
7010
6983
  if (isMobile) {
7011
6984
  if (!result.uri) {
7012
- dispatch({ type: "PAY_ERROR", error: "This wallet is not available on mobile.", fallbackStep: "wallet-picker" });
6985
+ dispatch({ type: "PAY_ERROR", error: "This wallet is not available on mobile." });
7013
6986
  return;
7014
6987
  }
7015
6988
  persistMobileFlowState({
@@ -7027,7 +7000,7 @@ function useProviderHandlers(deps) {
7027
7000
  if (!account.isConnected) {
7028
7001
  const connector = connectors.find((c) => c.type === "injected") ?? connectors[0];
7029
7002
  if (!connector) {
7030
- dispatch({ type: "PAY_ERROR", error: "No wallet extension found. Please install a supported wallet.", fallbackStep: "wallet-picker" });
7003
+ dispatch({ type: "PAY_ERROR", error: "No wallet extension found. Please install a supported wallet." });
7031
7004
  return;
7032
7005
  }
7033
7006
  await connectAsync({ connector });
@@ -7042,7 +7015,7 @@ function useProviderHandlers(deps) {
7042
7015
  } catch (err) {
7043
7016
  captureException(err);
7044
7017
  const msg = err instanceof Error ? err.message : "Failed to start guest checkout";
7045
- dispatch({ type: "PAY_ERROR", error: msg, fallbackStep: "wallet-picker" });
7018
+ dispatch({ type: "PAY_ERROR", error: msg });
7046
7019
  onError?.(msg);
7047
7020
  }
7048
7021
  }, [
@@ -7065,7 +7038,6 @@ function useProviderHandlers(deps) {
7065
7038
  dispatch({ type: "SELECT_PROVIDER", providerId });
7066
7039
  if (!activeCredentialId) {
7067
7040
  dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
7068
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
7069
7041
  return;
7070
7042
  }
7071
7043
  const provider = providers.find((p) => p.id === providerId);
@@ -7075,8 +7047,7 @@ function useProviderHandlers(deps) {
7075
7047
  userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
7076
7048
  });
7077
7049
  if (!isMobile) {
7078
- dispatch({ type: "PAY_STARTED", isSetupRedirect: false });
7079
- dispatch({ type: "NAVIGATE", step: "open-wallet" });
7050
+ dispatch({ type: "PAY_STARTED" });
7080
7051
  }
7081
7052
  try {
7082
7053
  let accountId;
@@ -7118,12 +7089,11 @@ function useProviderHandlers(deps) {
7118
7089
  } else {
7119
7090
  await authExecutor.executeSessionById(sessionId);
7120
7091
  await reloadAccounts();
7121
- dispatch({ type: "NAVIGATE", step: "deposit" });
7122
7092
  }
7123
7093
  } catch (err) {
7124
7094
  captureException(err);
7125
7095
  const msg = err instanceof Error ? err.message : "Failed to set up wallet";
7126
- dispatch({ type: "PAY_ERROR", error: msg, fallbackStep: "wallet-picker" });
7096
+ dispatch({ type: "PAY_ERROR", error: msg });
7127
7097
  onError?.(msg);
7128
7098
  } finally {
7129
7099
  if (!isMobile) {
@@ -7187,7 +7157,6 @@ function useProviderHandlers(deps) {
7187
7157
  }
7188
7158
  if (!activeCredentialId) {
7189
7159
  dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
7190
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
7191
7160
  return;
7192
7161
  }
7193
7162
  const acct = accounts.find((a) => a.id === selectedAccountId);
@@ -7233,10 +7202,8 @@ function useProviderHandlers(deps) {
7233
7202
  dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
7234
7203
  triggerDeeplink(session.uri);
7235
7204
  } else {
7236
- dispatch({ type: "NAVIGATE", step: "open-wallet" });
7237
7205
  await authExecutor.executeSessionById(session.id);
7238
7206
  await reloadAccounts();
7239
- dispatch({ type: "NAVIGATE", step: "deposit" });
7240
7207
  }
7241
7208
  } catch (err) {
7242
7209
  captureException(err);
@@ -7268,12 +7235,8 @@ function useProviderHandlers(deps) {
7268
7235
  reauthTokenRef
7269
7236
  ]);
7270
7237
  const handleNavigateToTokenPicker = useCallback(() => {
7271
- if (authExecutor.pendingSelectSource) {
7272
- dispatch({ type: "NAVIGATE", step: "select-source" });
7273
- } else {
7274
- dispatch({ type: "NAVIGATE", step: "token-picker" });
7275
- }
7276
- }, [dispatch, authExecutor.pendingSelectSource]);
7238
+ dispatch({ type: "SET_USER_INTENT", intent: "pick-token" });
7239
+ }, [dispatch]);
7277
7240
  const handleSelectAuthorizedToken = useCallback((walletId, tokenSymbol) => {
7278
7241
  dispatch({ type: "SELECT_TOKEN", walletId, tokenSymbol });
7279
7242
  }, [dispatch]);
@@ -7284,7 +7247,6 @@ function useProviderHandlers(deps) {
7284
7247
  }
7285
7248
  if (!activeCredentialId) {
7286
7249
  dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
7287
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
7288
7250
  return;
7289
7251
  }
7290
7252
  const acct = accounts.find((a) => a.id === selectedAccountId);
@@ -7326,7 +7288,6 @@ function useProviderHandlers(deps) {
7326
7288
  dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
7327
7289
  triggerDeeplink(session.uri);
7328
7290
  } else {
7329
- dispatch({ type: "NAVIGATE", step: "open-wallet" });
7330
7291
  await authExecutor.executeSessionById(session.id);
7331
7292
  await reloadAccounts();
7332
7293
  dispatch({ type: "SELECT_TOKEN", walletId: _walletId, tokenSymbol });
@@ -7398,7 +7359,6 @@ function useGuestTransferHandlers(deps) {
7398
7359
  isGuestFlow,
7399
7360
  guestTransferId,
7400
7361
  guestSessionToken,
7401
- step,
7402
7362
  onComplete,
7403
7363
  onError
7404
7364
  } = deps;
@@ -7412,8 +7372,7 @@ function useGuestTransferHandlers(deps) {
7412
7372
  const fetchedRef = useRef(false);
7413
7373
  const selectedGuestTokenRef = useRef(null);
7414
7374
  useEffect(() => {
7415
- if (!isGuestFlow || step !== "token-picker" || fetchedRef.current) return;
7416
- if (!guestTransferId || !guestSessionToken) return;
7375
+ if (!isGuestFlow || !guestTransferId || !guestSessionToken || fetchedRef.current) return;
7417
7376
  const account = getAccount(wagmiConfig2);
7418
7377
  if (!account.address) return;
7419
7378
  fetchedRef.current = true;
@@ -7427,7 +7386,7 @@ function useGuestTransferHandlers(deps) {
7427
7386
  captureException(err);
7428
7387
  dispatch({ type: "SET_ERROR", error: "Failed to fetch token balances." });
7429
7388
  }).finally(() => setLoadingBalances(false));
7430
- }, [isGuestFlow, step, guestTransferId, guestSessionToken, apiBaseUrl, wagmiConfig2, dispatch]);
7389
+ }, [isGuestFlow, guestTransferId, guestSessionToken, apiBaseUrl, wagmiConfig2, dispatch]);
7431
7390
  useEffect(() => {
7432
7391
  if (!isGuestFlow) {
7433
7392
  fetchedRef.current = false;
@@ -7456,7 +7415,6 @@ function useGuestTransferHandlers(deps) {
7456
7415
  entry.tokenAddress
7457
7416
  );
7458
7417
  selectedGuestTokenRef.current = entry;
7459
- dispatch({ type: "NAVIGATE", step: "processing" });
7460
7418
  } catch (err) {
7461
7419
  captureException(err);
7462
7420
  const msg = err instanceof Error ? err.message : "Failed to set transfer sender";
@@ -7467,9 +7425,10 @@ function useGuestTransferHandlers(deps) {
7467
7425
  }
7468
7426
  }, [guestTransferId, guestSessionToken, wagmiConfig2, apiBaseUrl, dispatch, onError]);
7469
7427
  useEffect(() => {
7470
- if (!isGuestFlow || step !== "processing" || !guestTransferId || !guestSessionToken) return;
7428
+ if (!isGuestFlow || !guestTransferId || !guestSessionToken || !selectedGuestTokenRef.current) return;
7471
7429
  if (executingBridgeRef.current) return;
7472
7430
  executingBridgeRef.current = true;
7431
+ dispatch({ type: "PAY_STARTED" });
7473
7432
  const execute = async () => {
7474
7433
  try {
7475
7434
  let signPayload = null;
@@ -7481,7 +7440,7 @@ function useGuestTransferHandlers(deps) {
7481
7440
  break;
7482
7441
  }
7483
7442
  if (transfer.status === "FAILED") {
7484
- dispatch({ type: "PAY_ERROR", error: "Transfer failed.", fallbackStep: "wallet-picker" });
7443
+ dispatch({ type: "PAY_ERROR", error: "Transfer failed." });
7485
7444
  return;
7486
7445
  }
7487
7446
  await new Promise((r) => setTimeout(r, GUEST_SIGN_POLL_MS));
@@ -7489,8 +7448,7 @@ function useGuestTransferHandlers(deps) {
7489
7448
  if (!signPayload) {
7490
7449
  dispatch({
7491
7450
  type: "PAY_ERROR",
7492
- error: "Timed out waiting for bridge quote. Please try again.",
7493
- fallbackStep: "wallet-picker"
7451
+ error: "Timed out waiting for bridge quote. Please try again."
7494
7452
  });
7495
7453
  return;
7496
7454
  }
@@ -7510,7 +7468,7 @@ function useGuestTransferHandlers(deps) {
7510
7468
  const walletClient = await getWalletClient(wagmiConfig2);
7511
7469
  const sender = account.address;
7512
7470
  if (!sender) {
7513
- dispatch({ type: "PAY_ERROR", error: "Wallet not connected.", fallbackStep: "wallet-picker" });
7471
+ dispatch({ type: "PAY_ERROR", error: "Wallet not connected." });
7514
7472
  return;
7515
7473
  }
7516
7474
  let lastTxHash = null;
@@ -7535,7 +7493,7 @@ function useGuestTransferHandlers(deps) {
7535
7493
  lastTxHash = txHash;
7536
7494
  }
7537
7495
  if (!lastTxHash) {
7538
- dispatch({ type: "PAY_ERROR", error: "No bridge transactions were executed.", fallbackStep: "wallet-picker" });
7496
+ dispatch({ type: "PAY_ERROR", error: "No bridge transactions were executed." });
7539
7497
  return;
7540
7498
  }
7541
7499
  console.info(`[blink-sdk] type=guest Submitting originTxHash: ${lastTxHash}`);
@@ -7556,22 +7514,22 @@ function useGuestTransferHandlers(deps) {
7556
7514
  }
7557
7515
  dispatch({
7558
7516
  type: "PAY_ERROR",
7559
- error: "Transfer is taking longer than expected. It may still complete.",
7560
- fallbackStep: "wallet-picker"
7517
+ error: "Transfer is taking longer than expected. It may still complete."
7561
7518
  });
7562
7519
  } catch (err) {
7563
7520
  captureException(err);
7564
7521
  const msg = err instanceof Error ? err.message : "Bridge execution failed";
7565
7522
  console.error("[blink-sdk] type=guest Bridge execution error:", err);
7566
7523
  const displayMsg = isUserRejection2(msg) ? "You rejected the transaction. Please approve in your wallet to continue." : msg;
7567
- dispatch({ type: "PAY_ERROR", error: displayMsg, fallbackStep: "wallet-picker" });
7524
+ dispatch({ type: "PAY_ERROR", error: displayMsg });
7568
7525
  onError?.(displayMsg);
7569
7526
  } finally {
7570
7527
  executingBridgeRef.current = false;
7528
+ dispatch({ type: "PAY_ENDED" });
7571
7529
  }
7572
7530
  };
7573
7531
  execute();
7574
- }, [isGuestFlow, step, guestTransferId, guestSessionToken, apiBaseUrl, wagmiConfig2, switchChainAsync, dispatch, onComplete, onError]);
7532
+ }, [isGuestFlow, guestTransferId, guestSessionToken, settingSender, apiBaseUrl, wagmiConfig2, switchChainAsync, dispatch, onComplete, onError]);
7575
7533
  return {
7576
7534
  guestTokenEntries,
7577
7535
  loadingBalances,
@@ -7612,12 +7570,10 @@ function useOneTapSetupHandlers(deps) {
7612
7570
  }
7613
7571
  oneTapLimitSavedDuringSetupRef.current = true;
7614
7572
  authExecutor.resolveSelectSource({ chainName, tokenSymbol });
7615
- dispatch({ type: "NAVIGATE", step: "open-wallet" });
7616
7573
  } else if (authExecutor.pendingOneTapSetup) {
7617
7574
  authExecutor.resolveOneTapSetup();
7618
- } else {
7619
- dispatch({ type: "NAVIGATE", step: "deposit" });
7620
7575
  }
7576
+ dispatch({ type: "SET_USER_INTENT", intent: null });
7621
7577
  } catch (err) {
7622
7578
  captureException(err);
7623
7579
  dispatch({
@@ -7638,12 +7594,11 @@ function useOneTapSetupHandlers(deps) {
7638
7594
  // src/dataLoading.ts
7639
7595
  function resolveDataLoadAction({
7640
7596
  authenticated,
7641
- step,
7642
7597
  accountsCount,
7643
7598
  hasActiveCredential,
7644
7599
  loading
7645
7600
  }) {
7646
- if (!authenticated || step === "login" || step === "otp-verify" || accountsCount > 0 || !hasActiveCredential) {
7601
+ if (!authenticated || accountsCount > 0 || !hasActiveCredential) {
7647
7602
  return "reset";
7648
7603
  }
7649
7604
  if (loading) {
@@ -7690,7 +7645,6 @@ function usePaymentEffects(deps) {
7690
7645
  authenticated,
7691
7646
  apiBaseUrl,
7692
7647
  depositAmount,
7693
- useWalletConnectorProp,
7694
7648
  onComplete,
7695
7649
  onError,
7696
7650
  polling,
@@ -7717,7 +7671,6 @@ function usePaymentEffects(deps) {
7717
7671
  setSelectSourceChainName,
7718
7672
  setSelectSourceTokenSymbol,
7719
7673
  initializedSelectSourceActionRef,
7720
- preSelectSourceStepRef,
7721
7674
  oneTapLimitSavedDuringSetupRef,
7722
7675
  handleAuthorizedMobileReturn
7723
7676
  } = deps;
@@ -7737,27 +7690,27 @@ function usePaymentEffects(deps) {
7737
7690
  }
7738
7691
  }, [depositAmount, dispatch]);
7739
7692
  useEffect(() => {
7740
- if (authenticated || state.step !== "otp-verify") return;
7693
+ if (authenticated || !state.verificationTarget) return;
7741
7694
  if (activeOtpErrorMessage) dispatch({ type: "SET_ERROR", error: activeOtpErrorMessage });
7742
- }, [activeOtpErrorMessage, authenticated, state.step, dispatch]);
7695
+ }, [activeOtpErrorMessage, authenticated, state.verificationTarget, dispatch]);
7743
7696
  useEffect(() => {
7744
- if (state.step === "otp-verify" && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus === "awaiting-code-input") {
7697
+ if (state.verificationTarget && !authenticated && /^\d{6}$/.test(otpCode.trim()) && activeOtpStatus === "awaiting-code-input") {
7745
7698
  handleVerifyLoginCode();
7746
7699
  }
7747
- }, [otpCode, state.step, activeOtpStatus, handleVerifyLoginCode]);
7700
+ }, [otpCode, state.verificationTarget, authenticated, activeOtpStatus, handleVerifyLoginCode]);
7748
7701
  useEffect(() => {
7749
7702
  if (!ready || !authenticated) {
7750
7703
  checkingPasskeyRef.current = false;
7751
7704
  return;
7752
7705
  }
7753
- if (state.step !== "login" && state.step !== "otp-verify") return;
7706
+ if (state.passkeyConfigLoaded || state.activeCredentialId) return;
7754
7707
  if (checkingPasskeyRef.current) return;
7755
7708
  checkingPasskeyRef.current = true;
7756
7709
  let cancelled = false;
7757
7710
  dispatch({ type: "SET_ERROR", error: null });
7758
7711
  setAuthInput("");
7759
7712
  setOtpCode("");
7760
- const restoreOrDeposit = async (credId, token) => {
7713
+ const restoreState = async (credId, token) => {
7761
7714
  const persisted = loadMobileFlowState();
7762
7715
  let accts = [];
7763
7716
  try {
@@ -7765,117 +7718,118 @@ function usePaymentEffects(deps) {
7765
7718
  if (cancelled) return;
7766
7719
  } catch {
7767
7720
  }
7768
- const resolved = resolvePostAuthStep({
7769
- hasPasskey: true,
7770
- accounts: accts,
7771
- persistedMobileFlow: persisted,
7772
- mobileSetupInProgress: false,
7773
- connectingNewAccount: false
7774
- });
7775
- if (resolved.clearPersistedFlow) clearMobileFlowState();
7776
- if (resolved.step === "deposit" && persisted && persisted.isSetup && persisted.transferId) {
7777
- try {
7778
- const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
7779
- if (cancelled) return;
7780
- if (existingTransfer.status === "AUTHORIZED") {
7781
- await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
7782
- return;
7783
- }
7784
- } catch {
7785
- }
7786
- }
7787
- if (resolved.step === "open-wallet" && persisted && persisted.isReauthorization && persisted.sessionId) {
7788
- try {
7789
- const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
7790
- if (cancelled) return;
7791
- if (session.status === "AUTHORIZED") {
7792
- clearMobileFlowState();
7793
- dispatch({ type: "NAVIGATE", step: "deposit" });
7794
- if (persisted.reauthorizationToken) {
7795
- dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
7796
- }
7797
- return;
7798
- }
7799
- } catch {
7800
- }
7801
- reauthSessionIdRef.current = persisted.sessionId;
7802
- reauthTokenRef.current = persisted.reauthorizationToken ?? null;
7803
- mobileSetupFlowRef.current = true;
7804
- setupAccountIdRef.current = persisted.accountId ?? null;
7805
- dispatch({
7806
- type: "ENTER_MOBILE_FLOW",
7807
- deeplinkUri: persisted.deeplinkUri,
7808
- providerId: persisted.providerId
7809
- });
7810
- return;
7811
- }
7812
- if (resolved.step === "open-wallet" && persisted && persisted.accountId && !persisted.transferId) {
7813
- if (persisted.sessionId) {
7721
+ if (persisted) {
7722
+ if (persisted.isReauthorization && persisted.sessionId) {
7814
7723
  try {
7815
7724
  const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
7816
7725
  if (cancelled) return;
7817
7726
  if (session.status === "AUTHORIZED") {
7818
7727
  clearMobileFlowState();
7819
- dispatch({ type: "NAVIGATE", step: "deposit" });
7728
+ if (persisted.reauthorizationToken) {
7729
+ dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
7730
+ }
7820
7731
  return;
7821
7732
  }
7822
7733
  } catch {
7823
7734
  }
7735
+ reauthSessionIdRef.current = persisted.sessionId;
7736
+ reauthTokenRef.current = persisted.reauthorizationToken ?? null;
7737
+ mobileSetupFlowRef.current = true;
7738
+ setupAccountIdRef.current = persisted.accountId ?? null;
7739
+ dispatch({
7740
+ type: "ENTER_MOBILE_FLOW",
7741
+ deeplinkUri: persisted.deeplinkUri,
7742
+ providerId: persisted.providerId
7743
+ });
7744
+ return;
7824
7745
  }
7825
- mobileSetupFlowRef.current = true;
7826
- setupAccountIdRef.current = persisted.accountId;
7827
- dispatch({
7828
- type: "ENTER_MOBILE_FLOW",
7829
- deeplinkUri: persisted.deeplinkUri,
7830
- providerId: persisted.providerId
7831
- });
7832
- return;
7833
- }
7834
- if (resolved.step === "open-wallet" && persisted && persisted.transferId) {
7835
- try {
7836
- const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
7837
- if (cancelled) return;
7838
- const mobileResolution = resolveRestoredMobileFlow(
7839
- existingTransfer.status,
7840
- persisted.isSetup
7841
- );
7842
- if (mobileResolution.kind === "resume-setup-deposit") {
7843
- await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
7844
- return;
7845
- }
7846
- if (mobileResolution.kind === "resume-confirm-sign") {
7847
- await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
7848
- return;
7849
- }
7850
- if (mobileResolution.kind === "resume-success") {
7851
- clearMobileFlowState();
7852
- dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
7853
- onCompleteRef.current?.(existingTransfer);
7854
- return;
7855
- }
7856
- if (mobileResolution.kind === "resume-failed") {
7857
- clearMobileFlowState();
7858
- dispatch({ type: "MOBILE_RESUME_FAILED", transfer: existingTransfer });
7859
- return;
7746
+ if (persisted.isSetup && persisted.transferId) {
7747
+ try {
7748
+ const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
7749
+ if (cancelled) return;
7750
+ if (existingTransfer.status === "AUTHORIZED") {
7751
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
7752
+ return;
7753
+ }
7754
+ } catch {
7860
7755
  }
7861
- if (mobileResolution.kind === "resume-processing") {
7862
- clearMobileFlowState();
7863
- dispatch({ type: "MOBILE_RESUME_PROCESSING", transfer: existingTransfer });
7864
- pollingRef.current.startPolling(existingTransfer.id);
7865
- return;
7756
+ }
7757
+ if (persisted.isSetup && accts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"))) {
7758
+ clearMobileFlowState();
7759
+ return;
7760
+ }
7761
+ if (persisted.accountId && !persisted.transferId) {
7762
+ if (persisted.sessionId) {
7763
+ try {
7764
+ const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
7765
+ if (cancelled) return;
7766
+ if (session.status === "AUTHORIZED") {
7767
+ clearMobileFlowState();
7768
+ return;
7769
+ }
7770
+ } catch {
7771
+ }
7866
7772
  }
7867
- if (mobileResolution.kind === "resume-stale-setup") {
7868
- clearMobileFlowState();
7869
- if (!cancelled) dispatch({ type: "NAVIGATE", step: "wallet-picker" });
7773
+ mobileSetupFlowRef.current = true;
7774
+ setupAccountIdRef.current = persisted.accountId;
7775
+ dispatch({
7776
+ type: "ENTER_MOBILE_FLOW",
7777
+ deeplinkUri: persisted.deeplinkUri,
7778
+ providerId: persisted.providerId
7779
+ });
7780
+ return;
7781
+ }
7782
+ if (persisted.transferId) {
7783
+ try {
7784
+ const existingTransfer = await fetchTransfer(apiBaseUrl, token, persisted.transferId);
7785
+ if (cancelled) return;
7786
+ if (existingTransfer.status === "COMPLETED") {
7787
+ clearMobileFlowState();
7788
+ dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
7789
+ onCompleteRef.current?.(existingTransfer);
7790
+ return;
7791
+ }
7792
+ if (existingTransfer.status === "FAILED") {
7793
+ clearMobileFlowState();
7794
+ dispatch({ type: "MOBILE_RESUME_FAILED", transfer: existingTransfer });
7795
+ return;
7796
+ }
7797
+ if (existingTransfer.status === "SENDING" || existingTransfer.status === "SENT") {
7798
+ clearMobileFlowState();
7799
+ dispatch({ type: "MOBILE_RESUME_PROCESSING", transfer: existingTransfer });
7800
+ pollingRef.current.startPolling(existingTransfer.id);
7801
+ return;
7802
+ }
7803
+ if (existingTransfer.status === "AUTHORIZED") {
7804
+ if (persisted.isSetup) {
7805
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, true);
7806
+ } else {
7807
+ await handleAuthorizedMobileReturnRef.current(existingTransfer, false);
7808
+ }
7809
+ return;
7810
+ }
7811
+ if (persisted.isSetup) {
7812
+ clearMobileFlowState();
7813
+ return;
7814
+ }
7815
+ } catch (err) {
7816
+ if (cancelled) return;
7817
+ dispatch({
7818
+ type: "ENTER_MOBILE_FLOW",
7819
+ deeplinkUri: persisted.deeplinkUri,
7820
+ providerId: persisted.providerId,
7821
+ error: err instanceof Error ? err.message : "Unable to refresh wallet authorization status."
7822
+ });
7823
+ pollingTransferIdRef.current = persisted.transferId ?? null;
7824
+ mobileSetupFlowRef.current = persisted.isSetup;
7825
+ setupAccountIdRef.current = persisted.accountId ?? null;
7826
+ if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
7870
7827
  return;
7871
7828
  }
7872
- } catch (err) {
7873
- if (cancelled) return;
7874
7829
  dispatch({
7875
7830
  type: "ENTER_MOBILE_FLOW",
7876
7831
  deeplinkUri: persisted.deeplinkUri,
7877
- providerId: persisted.providerId,
7878
- error: err instanceof Error ? err.message : "Unable to refresh wallet authorization status."
7832
+ providerId: persisted.providerId
7879
7833
  });
7880
7834
  pollingTransferIdRef.current = persisted.transferId ?? null;
7881
7835
  mobileSetupFlowRef.current = persisted.isSetup;
@@ -7883,18 +7837,7 @@ function usePaymentEffects(deps) {
7883
7837
  if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
7884
7838
  return;
7885
7839
  }
7886
- dispatch({
7887
- type: "ENTER_MOBILE_FLOW",
7888
- deeplinkUri: persisted.deeplinkUri,
7889
- providerId: persisted.providerId
7890
- });
7891
- pollingTransferIdRef.current = persisted.transferId ?? null;
7892
- mobileSetupFlowRef.current = persisted.isSetup;
7893
- setupAccountIdRef.current = persisted.accountId ?? null;
7894
- if (persisted.transferId) pollingRef.current.startPolling(persisted.transferId);
7895
- return;
7896
7840
  }
7897
- dispatch({ type: "NAVIGATE", step: resolved.step });
7898
7841
  };
7899
7842
  const checkPasskey = async () => {
7900
7843
  try {
@@ -7904,11 +7847,7 @@ function usePaymentEffects(deps) {
7904
7847
  if (token || cancelled) break;
7905
7848
  await new Promise((r) => setTimeout(r, 1e3));
7906
7849
  }
7907
- if (!token) {
7908
- if (!cancelled) dispatch({ type: "NAVIGATE", step: "create-passkey" });
7909
- return;
7910
- }
7911
- if (cancelled) return;
7850
+ if (!token || cancelled) return;
7912
7851
  const { config } = await fetchUserConfig(apiBaseUrl, token);
7913
7852
  if (cancelled) return;
7914
7853
  const allPasskeys = config.passkeys ?? (config.passkey ? [config.passkey] : []);
@@ -7918,11 +7857,10 @@ function usePaymentEffects(deps) {
7918
7857
  oneTapLimit: config.defaultAllowance ?? void 0
7919
7858
  });
7920
7859
  if (allPasskeys.length === 0) {
7921
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
7922
7860
  return;
7923
7861
  }
7924
7862
  if (state.activeCredentialId && allPasskeys.some((p) => p.credentialId === state.activeCredentialId)) {
7925
- await restoreOrDeposit(state.activeCredentialId, token);
7863
+ await restoreState(state.activeCredentialId, token);
7926
7864
  return;
7927
7865
  }
7928
7866
  if (cancelled) return;
@@ -7944,12 +7882,9 @@ function usePaymentEffects(deps) {
7944
7882
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, matched);
7945
7883
  reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
7946
7884
  });
7947
- await restoreOrDeposit(matched, token);
7948
- return;
7885
+ await restoreState(matched, token);
7949
7886
  }
7950
- dispatch({ type: "NAVIGATE", step: "create-passkey" });
7951
7887
  } catch {
7952
- if (!cancelled) dispatch({ type: "NAVIGATE", step: "create-passkey" });
7953
7888
  }
7954
7889
  };
7955
7890
  checkPasskey();
@@ -7957,11 +7892,10 @@ function usePaymentEffects(deps) {
7957
7892
  cancelled = true;
7958
7893
  checkingPasskeyRef.current = false;
7959
7894
  };
7960
- }, [ready, authenticated, state.step, apiBaseUrl, state.activeCredentialId]);
7895
+ }, [ready, authenticated, apiBaseUrl, state.activeCredentialId, state.passkeyConfigLoaded]);
7961
7896
  useEffect(() => {
7962
7897
  const loadAction = resolveDataLoadAction({
7963
7898
  authenticated,
7964
- step: state.step,
7965
7899
  accountsCount: state.accounts.length,
7966
7900
  hasActiveCredential: !!state.activeCredentialId,
7967
7901
  loading: loadingDataRef.current
@@ -7994,24 +7928,16 @@ function usePaymentEffects(deps) {
7994
7928
  const parsedAmt = depositAmount != null ? depositAmount : 0;
7995
7929
  const defaults = resolveDepositSelection(accts, parsedAmt, state.selectedAccountId);
7996
7930
  const persisted = loadMobileFlowState();
7997
- const resolved = resolvePostAuthStep({
7998
- hasPasskey: !!state.activeCredentialId,
7999
- accounts: accts,
8000
- persistedMobileFlow: persisted,
8001
- mobileSetupInProgress: mobileSetupFlowRef.current,
8002
- connectingNewAccount: false
8003
- });
8004
- const correctableSteps = ["deposit", "wallet-picker", "open-wallet"];
7931
+ const clearMobile = persisted?.isSetup && accts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
8005
7932
  dispatch({
8006
7933
  type: "DATA_LOADED",
8007
7934
  providers: prov,
8008
7935
  accounts: accts,
8009
7936
  chains: chn,
8010
7937
  defaults,
8011
- resolvedStep: correctableSteps.includes(state.step) && !state.creatingTransfer ? resolved.step : void 0,
8012
- clearMobileState: resolved.clearPersistedFlow
7938
+ clearMobileState: clearMobile
8013
7939
  });
8014
- if (resolved.clearPersistedFlow) clearMobileFlowState();
7940
+ if (clearMobile) clearMobileFlowState();
8015
7941
  } catch (err) {
8016
7942
  if (!cancelled) {
8017
7943
  captureException(err);
@@ -8034,7 +7960,6 @@ function usePaymentEffects(deps) {
8034
7960
  };
8035
7961
  }, [
8036
7962
  authenticated,
8037
- state.step,
8038
7963
  state.accounts.length,
8039
7964
  apiBaseUrl,
8040
7965
  state.activeCredentialId,
@@ -8043,7 +7968,7 @@ function usePaymentEffects(deps) {
8043
7968
  ]);
8044
7969
  useEffect(() => {
8045
7970
  if (authenticated || state.providers.length > 0) return;
8046
- if (state.step !== "wallet-picker") return;
7971
+ if (state.activeCredentialId) return;
8047
7972
  let cancelled = false;
8048
7973
  const loadProviders = async () => {
8049
7974
  try {
@@ -8066,7 +7991,7 @@ function usePaymentEffects(deps) {
8066
7991
  return () => {
8067
7992
  cancelled = true;
8068
7993
  };
8069
- }, [authenticated, state.step, state.providers.length, apiBaseUrl]);
7994
+ }, [authenticated, state.providers.length, state.activeCredentialId, apiBaseUrl]);
8070
7995
  useEffect(() => {
8071
7996
  if (!polling.transfer) return;
8072
7997
  if (polling.transfer.status === "COMPLETED") {
@@ -8080,13 +8005,21 @@ function usePaymentEffects(deps) {
8080
8005
  }
8081
8006
  }, [polling.transfer, onComplete, dispatch, reloadAccounts]);
8082
8007
  useEffect(() => {
8083
- if (state.step === "deposit" && state.accounts.length > 0 && authenticated && Date.now() - lastAccountFetchRef.current > 15e3) {
8008
+ if (state.accounts.length > 0 && state.activeCredentialId && !state.loadingData && !state.transfer && authenticated && Date.now() - lastAccountFetchRef.current > 15e3) {
8084
8009
  lastAccountFetchRef.current = Date.now();
8085
8010
  reloadAccounts();
8086
8011
  }
8087
- }, [state.step, state.accounts.length, authenticated, reloadAccounts]);
8012
+ }, [
8013
+ state.accounts.length,
8014
+ state.activeCredentialId,
8015
+ state.loadingData,
8016
+ state.transfer,
8017
+ authenticated,
8018
+ reloadAccounts
8019
+ ]);
8088
8020
  useEffect(() => {
8089
- if (state.step !== "processing") {
8021
+ const isProcessing = state.creatingTransfer || state.transfer != null && ["CREATED", "SENDING", "SENT"].includes(state.transfer.status);
8022
+ if (!isProcessing) {
8090
8023
  processingStartedAtRef.current = null;
8091
8024
  return;
8092
8025
  }
@@ -8110,7 +8043,15 @@ function usePaymentEffects(deps) {
8110
8043
  }
8111
8044
  const timeoutId = window.setTimeout(handleTimeout, remainingMs);
8112
8045
  return () => window.clearTimeout(timeoutId);
8113
- }, [state.step, polling.transfer, state.transfer, polling.stopPolling, onError, dispatch, processingStartedAtRef]);
8046
+ }, [
8047
+ state.creatingTransfer,
8048
+ state.transfer,
8049
+ polling.transfer,
8050
+ polling.stopPolling,
8051
+ onError,
8052
+ dispatch,
8053
+ processingStartedAtRef
8054
+ ]);
8114
8055
  useEffect(() => {
8115
8056
  if (!state.mobileFlow) {
8116
8057
  handlingMobileReturnRef.current = false;
@@ -8123,7 +8064,6 @@ function usePaymentEffects(deps) {
8123
8064
  }, [state.mobileFlow, polling.transfer, handleAuthorizedMobileReturn, handlingMobileReturnRef, mobileSetupFlowRef]);
8124
8065
  useEffect(() => {
8125
8066
  if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
8126
- if (state.step !== "open-wallet") return;
8127
8067
  if (!state.activeCredentialId || !setupAccountIdRef.current) return;
8128
8068
  const accountId = setupAccountIdRef.current;
8129
8069
  const credentialId = state.activeCredentialId;
@@ -8216,7 +8156,6 @@ function usePaymentEffects(deps) {
8216
8156
  };
8217
8157
  }, [
8218
8158
  state.mobileFlow,
8219
- state.step,
8220
8159
  state.activeCredentialId,
8221
8160
  apiBaseUrl,
8222
8161
  reloadAccounts,
@@ -8286,46 +8225,22 @@ function usePaymentEffects(deps) {
8286
8225
  setSelectSourceTokenSymbol,
8287
8226
  initializedSelectSourceActionRef
8288
8227
  ]);
8228
+ const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
8289
8229
  useEffect(() => {
8290
- if (pendingSelectSourceAction && (state.step === "processing" || state.step === "open-wallet" || state.step === "setup-status")) {
8291
- const isDesktop = shouldUseWalletConnector({
8292
- useWalletConnector: useWalletConnectorProp,
8293
- userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
8294
- });
8295
- if (isDesktop && (state.step === "setup-status" || state.step === "open-wallet")) {
8296
- preSelectSourceStepRef.current = state.step;
8297
- dispatch({ type: "NAVIGATE", step: "setup" });
8298
- return;
8299
- }
8300
- preSelectSourceStepRef.current = state.step;
8301
- dispatch({ type: "NAVIGATE", step: "select-source" });
8302
- } else if (!pendingSelectSourceAction && state.step === "select-source") {
8303
- dispatch({ type: "NAVIGATE", step: preSelectSourceStepRef.current ?? "processing" });
8304
- preSelectSourceStepRef.current = null;
8230
+ if (pendingOneTapSetupAction && oneTapLimitSavedDuringSetupRef.current) {
8231
+ oneTapLimitSavedDuringSetupRef.current = false;
8232
+ authExecutor.resolveOneTapSetup();
8305
8233
  }
8306
- }, [pendingSelectSourceAction, state.step, useWalletConnectorProp, dispatch, preSelectSourceStepRef, authExecutor]);
8307
- const pendingOneTapSetupAction = authExecutor.pendingOneTapSetup;
8308
- const preOneTapSetupStepRef = useRef(null);
8234
+ }, [pendingOneTapSetupAction, authExecutor, oneTapLimitSavedDuringSetupRef]);
8309
8235
  useEffect(() => {
8310
- if (pendingOneTapSetupAction && (state.step === "setup-status" || state.step === "open-wallet")) {
8311
- if (oneTapLimitSavedDuringSetupRef.current) {
8312
- oneTapLimitSavedDuringSetupRef.current = false;
8313
- authExecutor.resolveOneTapSetup();
8314
- } else {
8315
- preOneTapSetupStepRef.current = state.step;
8316
- reloadAccounts().then(() => {
8317
- dispatch({ type: "NAVIGATE", step: "setup" });
8318
- });
8319
- }
8320
- } else if (!pendingOneTapSetupAction && state.step === "setup" && preOneTapSetupStepRef.current) {
8321
- dispatch({ type: "NAVIGATE", step: preOneTapSetupStepRef.current });
8322
- preOneTapSetupStepRef.current = null;
8236
+ if (pendingOneTapSetupAction && !oneTapLimitSavedDuringSetupRef.current) {
8237
+ reloadAccounts();
8323
8238
  }
8324
- }, [pendingOneTapSetupAction, state.step, reloadAccounts, authExecutor, dispatch, oneTapLimitSavedDuringSetupRef]);
8239
+ }, [pendingOneTapSetupAction, reloadAccounts, oneTapLimitSavedDuringSetupRef]);
8325
8240
  useEffect(() => {
8326
- if (state.step !== "success") return;
8327
8241
  if (!state.guestSessionToken) return;
8328
8242
  if (state.guestPreauthAccountId) return;
8243
+ if (!state.transfer || state.transfer.status !== "COMPLETED") return;
8329
8244
  let cancelled = false;
8330
8245
  const checkPreauth = async () => {
8331
8246
  try {
@@ -8341,7 +8256,7 @@ function usePaymentEffects(deps) {
8341
8256
  return () => {
8342
8257
  cancelled = true;
8343
8258
  };
8344
- }, [state.step, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8259
+ }, [state.transfer, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8345
8260
  const settingOwnerRef = useRef(false);
8346
8261
  useEffect(() => {
8347
8262
  if (!state.guestPreauthAccountId) return;
@@ -8512,7 +8427,6 @@ function BlinkPaymentInner({
8512
8427
  isGuestFlow: state.isGuestFlow,
8513
8428
  guestTransferId: state.guestTransferId,
8514
8429
  guestSessionToken: state.guestSessionToken,
8515
- step: state.step,
8516
8430
  onComplete,
8517
8431
  onError
8518
8432
  });
@@ -8520,14 +8434,13 @@ function BlinkPaymentInner({
8520
8434
  clearMobileFlowState();
8521
8435
  transfer.processingStartedAtRef.current = null;
8522
8436
  transfer.pollingTransferIdRef.current = null;
8523
- sourceSelection.preSelectSourceStepRef.current = null;
8524
8437
  oneTapSetup.oneTapLimitSavedDuringSetupRef.current = false;
8525
8438
  dispatch({
8526
8439
  type: "NEW_PAYMENT",
8527
8440
  depositAmount,
8528
8441
  firstAccountId: state.accounts.length > 0 ? state.accounts[0].id : null
8529
8442
  });
8530
- }, [depositAmount, state.accounts, transfer, sourceSelection, provider, oneTapSetup]);
8443
+ }, [depositAmount, state.accounts, transfer, oneTapSetup]);
8531
8444
  const handleLogout = useCallback(async () => {
8532
8445
  try {
8533
8446
  await logout();
@@ -8538,13 +8451,12 @@ function BlinkPaymentInner({
8538
8451
  window.localStorage.removeItem(ACTIVE_CREDENTIAL_STORAGE_KEY);
8539
8452
  }
8540
8453
  polling.stopPolling();
8541
- sourceSelection.preSelectSourceStepRef.current = null;
8542
8454
  passkey.checkingPasskeyRef.current = false;
8543
8455
  oneTapSetup.oneTapLimitSavedDuringSetupRef.current = false;
8544
8456
  auth.setAuthInput("");
8545
8457
  auth.setOtpCode("");
8546
8458
  dispatch({ type: "LOGOUT", depositAmount });
8547
- }, [logout, polling, depositAmount, auth, sourceSelection, provider, passkey, oneTapSetup]);
8459
+ }, [logout, polling, depositAmount, auth, passkey, oneTapSetup]);
8548
8460
  usePaymentEffects({
8549
8461
  state,
8550
8462
  dispatch,
@@ -8552,7 +8464,6 @@ function BlinkPaymentInner({
8552
8464
  authenticated,
8553
8465
  apiBaseUrl,
8554
8466
  depositAmount,
8555
- useWalletConnectorProp,
8556
8467
  onComplete,
8557
8468
  onError,
8558
8469
  polling,
@@ -8579,22 +8490,24 @@ function BlinkPaymentInner({
8579
8490
  setSelectSourceChainName: sourceSelection.setSelectSourceChainName,
8580
8491
  setSelectSourceTokenSymbol: sourceSelection.setSelectSourceTokenSymbol,
8581
8492
  initializedSelectSourceActionRef: sourceSelection.initializedSelectSourceActionRef,
8582
- preSelectSourceStepRef: sourceSelection.preSelectSourceStepRef,
8583
8493
  oneTapLimitSavedDuringSetupRef: oneTapSetup.oneTapLimitSavedDuringSetupRef,
8584
8494
  handleAuthorizedMobileReturn: mobileFlow.handleAuthorizedMobileReturn
8585
8495
  });
8586
8496
  const autoSelectingRef = useRef(false);
8587
8497
  useEffect(() => {
8588
- if (state.step !== "wallet-picker" || !state.isGuestFlow || !state.selectedProviderId || !state.activeCredentialId || !authenticated || autoSelectingRef.current) return;
8498
+ if (!state.isGuestFlow || !state.selectedProviderId || !state.activeCredentialId || !authenticated || autoSelectingRef.current || state.transfer != null) return;
8499
+ const hasActive = state.accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
8500
+ if (hasActive) return;
8589
8501
  autoSelectingRef.current = true;
8590
8502
  provider.handleSelectProvider(state.selectedProviderId).finally(() => {
8591
8503
  autoSelectingRef.current = false;
8592
8504
  });
8593
8505
  }, [
8594
- state.step,
8595
8506
  state.isGuestFlow,
8596
8507
  state.selectedProviderId,
8597
8508
  state.activeCredentialId,
8509
+ state.transfer,
8510
+ state.accounts,
8598
8511
  authenticated,
8599
8512
  provider
8600
8513
  ]);
@@ -8617,9 +8530,10 @@ function BlinkPaymentInner({
8617
8530
  onIncreaseLimit: provider.handleIncreaseLimit,
8618
8531
  onConfirmSign: transfer.handleConfirmSign,
8619
8532
  onRetryMobileStatus: mobileFlow.handleRetryMobileStatus,
8533
+ onBackFromOpenWallet: () => dispatch({ type: "CLEAR_MOBILE_STATE" }),
8620
8534
  onLogout: handleLogout,
8621
8535
  onNewPayment: handleNewPayment,
8622
- onNavigate: (step) => dispatch({ type: "NAVIGATE", step }),
8536
+ onSetUserIntent: (intent) => dispatch({ type: "SET_USER_INTENT", intent }),
8623
8537
  onSetAuthInput: auth.setAuthInput,
8624
8538
  onSetOtpCode: (code) => {
8625
8539
  auth.setOtpCode(code);
@@ -8633,8 +8547,8 @@ function BlinkPaymentInner({
8633
8547
  onSelectAuthorizedToken: provider.handleSelectAuthorizedToken,
8634
8548
  onAuthorizeToken: provider.handleAuthorizeToken,
8635
8549
  onSelectGuestToken: guestTransfer.handleSelectGuestToken,
8636
- onLogin: () => dispatch({ type: "NAVIGATE", step: "login" }),
8637
- onPreauthorize: () => dispatch({ type: "NAVIGATE", step: "login" })
8550
+ onLogin: () => dispatch({ type: "REQUEST_LOGIN" }),
8551
+ onPreauthorize: () => dispatch({ type: "REQUEST_LOGIN" })
8638
8552
  }), [
8639
8553
  auth,
8640
8554
  passkey,
@@ -8657,8 +8571,12 @@ function BlinkPaymentInner({
8657
8571
  pollingTransfer: polling.transfer,
8658
8572
  pollingError: polling.error,
8659
8573
  authExecutorError: authExecutor.error,
8574
+ inlineAuthorizationExecuting: authExecutor.executing,
8660
8575
  transferSigningSigning: transferSigning.signing,
8661
8576
  transferSigningError: transferSigning.error,
8577
+ pendingSelectSource: authExecutor.pendingSelectSource,
8578
+ pendingOneTapSetup: authExecutor.pendingOneTapSetup,
8579
+ oneTapLimitAlreadySaved: oneTapSetup.oneTapLimitSavedDuringSetupRef.current,
8662
8580
  pendingConnections: derived.pendingConnections,
8663
8581
  depositEligibleAccounts: derived.depositEligibleAccounts,
8664
8582
  sourceName: derived.sourceName,
@@ -8686,6 +8604,6 @@ function BlinkPaymentInner({
8686
8604
  );
8687
8605
  }
8688
8606
 
8689
- export { AdvancedSourceScreen, BLINK_LOGO, BLINK_MASCOT, BlinkLoadingScreen, BlinkPayment, BlinkProvider, FlowPhaseProvider, IconCircle, InfoBanner, OutlineButton, PasskeyIframeBlockedError, PasskeyScreen, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, TokenPickerScreen, api_exports as blinkApi, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, useAuthorizationExecutor, useBlinkConfig, useBlinkDepositAmount, useTransferPolling, useTransferSigning };
8607
+ export { AdvancedSourceScreen, BLINK_LOGO, BLINK_MASCOT, BlinkLoadingScreen, BlinkPayment, BlinkProvider, FlowPhaseProvider, IconCircle, InfoBanner, OutlineButton, PasskeyIframeBlockedError, PasskeyScreen, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, TokenPickerScreen, api_exports as blinkApi, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, resolveScreen, useAuthorizationExecutor, useBlinkConfig, useBlinkDepositAmount, useTransferPolling, useTransferSigning };
8690
8608
  //# sourceMappingURL=index.js.map
8691
8609
  //# sourceMappingURL=index.js.map