@swype-org/react-sdk 0.1.258 → 0.1.260

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.cjs CHANGED
@@ -2060,143 +2060,143 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
2060
2060
  }
2061
2061
  }
2062
2062
  function resolvePhase(state) {
2063
- const p = state.phase;
2063
+ const currentPhase = state.phase;
2064
2064
  const transferCompleted = state.transfer?.status === "COMPLETED";
2065
2065
  const needsPasskeyBootstrap = state.privyAuthenticated && !state.activeCredentialId;
2066
- const guestPreauthPin = transferCompleted && state.guestPreauthorizing && !state.verificationTarget && isGuestPreauthCompletedTransferPinPhase(p);
2066
+ const guestPreauthPinsCurrentPhase = transferCompleted && state.guestPreauthorizing && !state.verificationTarget && isGuestPreauthCompletedTransferPinPhase(currentPhase);
2067
2067
  const guestPostPayLogin = transferCompleted && state.isGuestFlow && state.guestPreauthSessionId != null && !state.guestPreauthorizing && !state.verificationTarget && !state.privyAuthenticated;
2068
- const pinSubflow = !state.loginRequested && (p.step === "token-picker" || p.step === "one-tap-setup" || p.step === "select-source" || p.step === "confirm-sign" || p.step === "guest-token-picker");
2069
- const guestTokenPicker = state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestPreauthAccountId;
2070
- const walletPickerSwitch = p.step === "wallet-picker" && p.reason === "switch" && !state.creatingTransfer && !(state.mobileFlow && state.deeplinkUri);
2071
- const passkeyBlock = state.passkeyConfigLoaded && !state.activeCredentialId;
2072
- const passkeyVerify = passkeyBlock && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded;
2073
- const c1 = state.guestPreauthSetupCompletePending && state.privyReady && state.privyAuthenticated;
2074
- const c2 = !c1 && guestPreauthPin;
2075
- const c3 = !c1 && !c2 && guestPostPayLogin;
2076
- const c4 = !c1 && !c2 && !c3 && transferCompleted && !state.verificationTarget && !needsPasskeyBootstrap;
2077
- const c5 = !c1 && !c2 && !c3 && !c4 && state.transfer?.status === "FAILED";
2078
- const c6 = !c1 && !c2 && !c3 && !c4 && !c5 && (state.creatingTransfer || isTransferAwaitingCompletion(state.transfer));
2079
- const c7 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && pinSubflow;
2080
- const c8 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && state.mobileFlow && state.deeplinkUri != null;
2081
- const c9 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && p.step === "wallet-setup" && p.mobile == null && state.guestPreauthorizing;
2082
- const c10 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && guestTokenPicker;
2083
- const c11 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && walletPickerSwitch;
2084
- const c12 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !state.privyReady;
2085
- const c13 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && state.privyAuthenticated && !state.activeCredentialId && !state.passkeyConfigLoaded;
2086
- const c14 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && state.verificationTarget != null && !state.privyAuthenticated;
2087
- const c15 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && state.loginRequested;
2088
- const c16 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && passkeyVerify;
2089
- const c17 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && passkeyBlock;
2090
- const c18 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && !c17 && state.loadingData && state.activeCredentialId != null && hasActiveWallet(state.accounts);
2091
- const c19 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && !c17 && !c18 && state.activeCredentialId != null && !hasActiveWallet(state.accounts) && !state.mobileFlow;
2092
- const c20 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && !c17 && !c18 && !c19 && state.activeCredentialId != null && hasActiveWallet(state.accounts) && !state.loadingData;
2093
- const c21 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && !c17 && !c18 && !c19 && !c20 && state.isGuestFlow;
2094
- const flags = [
2095
- c1,
2096
- c2,
2097
- c3,
2098
- c4,
2099
- c5,
2100
- c6,
2101
- c7,
2102
- c8,
2103
- c9,
2104
- c10,
2105
- c11,
2106
- c12,
2107
- c13,
2108
- c14,
2109
- c15,
2110
- c16,
2111
- c17,
2112
- c18,
2113
- c19,
2114
- c20,
2115
- c21
2068
+ const isFundingSourceSubflow = !state.loginRequested && (currentPhase.step === "token-picker" || currentPhase.step === "one-tap-setup" || currentPhase.step === "select-source" || currentPhase.step === "confirm-sign" || currentPhase.step === "guest-token-picker");
2069
+ const guestTokenPickerEligible = state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestPreauthAccountId;
2070
+ const walletPickerSwitchEligible = currentPhase.step === "wallet-picker" && currentPhase.reason === "switch" && !state.creatingTransfer && !(state.mobileFlow && state.deeplinkUri);
2071
+ const missingActivePasskeyCredential = state.passkeyConfigLoaded && !state.activeCredentialId;
2072
+ const shouldPromptPasskeyVerification = missingActivePasskeyCredential && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded;
2073
+ const branchGuestSetupComplete = state.guestPreauthSetupCompletePending && state.privyReady && state.privyAuthenticated;
2074
+ const branchKeepGuestPreauthPin = !branchGuestSetupComplete && guestPreauthPinsCurrentPhase;
2075
+ const branchGuestPostPayLogin = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && guestPostPayLogin;
2076
+ const branchCompleted = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && transferCompleted && !state.verificationTarget && !needsPasskeyBootstrap;
2077
+ const branchFailed = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && state.transfer?.status === "FAILED";
2078
+ const branchProcessing = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && (state.creatingTransfer || isTransferAwaitingCompletion(state.transfer));
2079
+ const branchKeepFundingSubflow = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && isFundingSourceSubflow;
2080
+ const branchMobileWalletSetup = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && state.mobileFlow && state.deeplinkUri != null;
2081
+ const branchKeepGuestWalletSetup = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && currentPhase.step === "wallet-setup" && currentPhase.mobile == null && state.guestPreauthorizing;
2082
+ const branchGuestTokenPicker = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && guestTokenPickerEligible;
2083
+ const branchKeepWalletPickerSwitch = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && walletPickerSwitchEligible;
2084
+ const branchInitializingPrivy = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !state.privyReady;
2085
+ const branchInitializingPasskeyConfig = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && state.privyAuthenticated && !state.activeCredentialId && !state.passkeyConfigLoaded;
2086
+ const branchOtpVerify = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && state.verificationTarget != null && !state.privyAuthenticated;
2087
+ const branchLoginRequested = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && state.loginRequested;
2088
+ const branchPasskeyVerify = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && shouldPromptPasskeyVerification;
2089
+ const branchPasskeyCreate = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && missingActivePasskeyCredential;
2090
+ const branchDataLoading = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && !branchPasskeyCreate && state.loadingData && state.activeCredentialId != null && hasActiveWallet(state.accounts);
2091
+ const branchWalletPickerLink = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && !branchPasskeyCreate && !branchDataLoading && state.activeCredentialId != null && !hasActiveWallet(state.accounts) && !state.mobileFlow;
2092
+ const branchDeposit = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && !branchPasskeyCreate && !branchDataLoading && !branchWalletPickerLink && state.activeCredentialId != null && hasActiveWallet(state.accounts) && !state.loadingData;
2093
+ const branchWalletPickerGuestEntry = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && !branchPasskeyCreate && !branchDataLoading && !branchWalletPickerLink && !branchDeposit && state.isGuestFlow;
2094
+ const exclusiveBranchFlags = [
2095
+ branchGuestSetupComplete,
2096
+ branchKeepGuestPreauthPin,
2097
+ branchGuestPostPayLogin,
2098
+ branchCompleted,
2099
+ branchFailed,
2100
+ branchProcessing,
2101
+ branchKeepFundingSubflow,
2102
+ branchMobileWalletSetup,
2103
+ branchKeepGuestWalletSetup,
2104
+ branchGuestTokenPicker,
2105
+ branchKeepWalletPickerSwitch,
2106
+ branchInitializingPrivy,
2107
+ branchInitializingPasskeyConfig,
2108
+ branchOtpVerify,
2109
+ branchLoginRequested,
2110
+ branchPasskeyVerify,
2111
+ branchPasskeyCreate,
2112
+ branchDataLoading,
2113
+ branchWalletPickerLink,
2114
+ branchDeposit,
2115
+ branchWalletPickerGuestEntry
2116
2116
  ];
2117
- const matchCount = flags.filter(Boolean).length;
2117
+ const matchCount = exclusiveBranchFlags.filter(Boolean).length;
2118
2118
  if (matchCount > 1) {
2119
2119
  console.error("resolvePhase: multiple exclusive branches matched", {
2120
- flags: {
2121
- c1,
2122
- c2,
2123
- c3,
2124
- c4,
2125
- c5,
2126
- c6,
2127
- c7,
2128
- c8,
2129
- c9,
2130
- c10,
2131
- c11,
2132
- c12,
2133
- c13,
2134
- c14,
2135
- c15,
2136
- c16,
2137
- c17,
2138
- c18,
2139
- c19,
2140
- c20,
2141
- c21
2120
+ branches: {
2121
+ branchGuestSetupComplete,
2122
+ branchKeepGuestPreauthPin,
2123
+ branchGuestPostPayLogin,
2124
+ branchCompleted,
2125
+ branchFailed,
2126
+ branchProcessing,
2127
+ branchKeepFundingSubflow,
2128
+ branchMobileWalletSetup,
2129
+ branchKeepGuestWalletSetup,
2130
+ branchGuestTokenPicker,
2131
+ branchKeepWalletPickerSwitch,
2132
+ branchInitializingPrivy,
2133
+ branchInitializingPasskeyConfig,
2134
+ branchOtpVerify,
2135
+ branchLoginRequested,
2136
+ branchPasskeyVerify,
2137
+ branchPasskeyCreate,
2138
+ branchDataLoading,
2139
+ branchWalletPickerLink,
2140
+ branchDeposit,
2141
+ branchWalletPickerGuestEntry
2142
2142
  }
2143
2143
  });
2144
2144
  }
2145
- let resolved;
2146
- if (c1) {
2147
- resolved = { step: "guest-setup-complete" };
2148
- } else if (c2) {
2149
- resolved = p;
2150
- } else if (c3) {
2151
- resolved = { step: "login" };
2152
- } else if (c4) {
2153
- resolved = { step: "completed", transfer: state.transfer };
2154
- } else if (c5) {
2155
- resolved = {
2145
+ let nextPhase;
2146
+ if (branchGuestSetupComplete) {
2147
+ nextPhase = { step: "guest-setup-complete" };
2148
+ } else if (branchKeepGuestPreauthPin) {
2149
+ nextPhase = currentPhase;
2150
+ } else if (branchGuestPostPayLogin) {
2151
+ nextPhase = { step: "login" };
2152
+ } else if (branchCompleted) {
2153
+ nextPhase = { step: "completed", transfer: state.transfer };
2154
+ } else if (branchFailed) {
2155
+ nextPhase = {
2156
2156
  step: "failed",
2157
2157
  transfer: state.transfer,
2158
2158
  error: state.error ?? "Transfer failed."
2159
2159
  };
2160
- } else if (c6) {
2161
- resolved = { step: "processing", transfer: state.transfer };
2162
- } else if (c7) {
2163
- resolved = p;
2164
- } else if (c8) {
2165
- resolved = {
2160
+ } else if (branchProcessing) {
2161
+ nextPhase = { step: "processing", transfer: state.transfer };
2162
+ } else if (branchKeepFundingSubflow) {
2163
+ nextPhase = currentPhase;
2164
+ } else if (branchMobileWalletSetup) {
2165
+ nextPhase = {
2166
2166
  step: "wallet-setup",
2167
2167
  mobile: { deeplinkUri: state.deeplinkUri, providerId: state.selectedProviderId },
2168
2168
  accountId: null
2169
2169
  };
2170
- } else if (c9) {
2171
- resolved = p;
2172
- } else if (c10) {
2173
- resolved = { step: "guest-token-picker" };
2174
- } else if (c11) {
2175
- resolved = p;
2176
- } else if (c12) {
2177
- resolved = { step: "initializing" };
2178
- } else if (c13) {
2179
- resolved = { step: "initializing" };
2180
- } else if (c14) {
2181
- resolved = { step: "otp-verify", target: state.verificationTarget };
2182
- } else if (c15) {
2183
- resolved = { step: "login" };
2184
- } else if (c16) {
2185
- resolved = { step: "passkey-verify" };
2186
- } else if (c17) {
2187
- resolved = { step: "passkey-create", popupFallback: state.passkeyPopupNeeded };
2188
- } else if (c18) {
2189
- resolved = { step: "data-loading" };
2190
- } else if (c19) {
2191
- resolved = { step: "wallet-picker", reason: "link" };
2192
- } else if (c20) {
2193
- resolved = { step: "deposit" };
2194
- } else if (c21) {
2195
- resolved = { step: "wallet-picker", reason: "guest-entry" };
2170
+ } else if (branchKeepGuestWalletSetup) {
2171
+ nextPhase = currentPhase;
2172
+ } else if (branchGuestTokenPicker) {
2173
+ nextPhase = { step: "guest-token-picker" };
2174
+ } else if (branchKeepWalletPickerSwitch) {
2175
+ nextPhase = currentPhase;
2176
+ } else if (branchInitializingPrivy) {
2177
+ nextPhase = { step: "initializing" };
2178
+ } else if (branchInitializingPasskeyConfig) {
2179
+ nextPhase = { step: "initializing" };
2180
+ } else if (branchOtpVerify) {
2181
+ nextPhase = { step: "otp-verify", target: state.verificationTarget };
2182
+ } else if (branchLoginRequested) {
2183
+ nextPhase = { step: "login" };
2184
+ } else if (branchPasskeyVerify) {
2185
+ nextPhase = { step: "passkey-verify" };
2186
+ } else if (branchPasskeyCreate) {
2187
+ nextPhase = { step: "passkey-create", popupFallback: state.passkeyPopupNeeded };
2188
+ } else if (branchDataLoading) {
2189
+ nextPhase = { step: "data-loading" };
2190
+ } else if (branchWalletPickerLink) {
2191
+ nextPhase = { step: "wallet-picker", reason: "link" };
2192
+ } else if (branchDeposit) {
2193
+ nextPhase = { step: "deposit" };
2194
+ } else if (branchWalletPickerGuestEntry) {
2195
+ nextPhase = { step: "wallet-picker", reason: "guest-entry" };
2196
2196
  } else {
2197
- resolved = { step: "wallet-picker", reason: "entry" };
2197
+ nextPhase = { step: "wallet-picker", reason: "entry" };
2198
2198
  }
2199
- return resolved;
2199
+ return nextPhase;
2200
2200
  }
2201
2201
 
2202
2202
  // src/paymentReducer.ts
@@ -2538,6 +2538,23 @@ function applyAction(state, action) {
2538
2538
  };
2539
2539
  case "GUEST_PREAUTH_SETUP_COMPLETE_DISMISSED":
2540
2540
  return { ...state, guestPreauthSetupCompletePending: false };
2541
+ case "RESTORE_GUEST_PREAUTH_MOBILE":
2542
+ return {
2543
+ ...state,
2544
+ transfer: action.transfer,
2545
+ isGuestFlow: true,
2546
+ guestSessionToken: action.guestSessionToken,
2547
+ guestTransferId: action.transfer.id,
2548
+ guestPreauthAccountId: action.guestPreauthAccountId,
2549
+ guestPreauthSessionId: action.guestPreauthSessionId,
2550
+ selectedProviderId: action.selectedProviderId,
2551
+ selectedAccountId: action.guestPreauthAccountId,
2552
+ selectedWalletId: null,
2553
+ selectedTokenSymbol: null,
2554
+ mobileFlow: action.mobileOpen,
2555
+ deeplinkUri: action.mobileOpen ? action.deeplinkUri : null,
2556
+ error: null
2557
+ };
2541
2558
  // ── User intent & error ──────────────────────────────────────
2542
2559
  case "SET_USER_INTENT":
2543
2560
  return { ...state, phase: action.intent };
@@ -4868,11 +4885,9 @@ function SuccessScreen({
4868
4885
  footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4869
4886
  /* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: onDone, children: succeeded ? "Done" : "Try again" }),
4870
4887
  succeeded && onPreauthorize && /* @__PURE__ */ jsxRuntime.jsx(
4871
- "button",
4888
+ PrimaryButton,
4872
4889
  {
4873
- type: "button",
4874
4890
  onClick: onPreauthorize,
4875
- style: preauthorizeStyle(tokens.accent, tokens.border),
4876
4891
  children: "Preauthorize future transfers"
4877
4892
  }
4878
4893
  ),
@@ -5000,19 +5015,6 @@ var upsellLinkStyle = (color) => ({
5000
5015
  fontFamily: "inherit",
5001
5016
  padding: 0
5002
5017
  });
5003
- var preauthorizeStyle = (accentColor, borderColor) => ({
5004
- width: "100%",
5005
- padding: "14px 0",
5006
- marginTop: 8,
5007
- background: "transparent",
5008
- border: `1px solid ${borderColor}`,
5009
- borderRadius: 20,
5010
- color: accentColor,
5011
- fontWeight: 600,
5012
- fontSize: "0.92rem",
5013
- cursor: "pointer",
5014
- fontFamily: "inherit"
5015
- });
5016
5018
  var manageStyle = (color) => ({
5017
5019
  background: "transparent",
5018
5020
  border: "none",
@@ -7314,6 +7316,7 @@ function useProviderHandlers(deps) {
7314
7316
  merchantAuthorization,
7315
7317
  destination,
7316
7318
  guestSessionToken,
7319
+ guestTransferId,
7317
7320
  selectedProviderId
7318
7321
  } = deps;
7319
7322
  const wagmiConfig2 = wagmi.useConfig();
@@ -7747,7 +7750,9 @@ function useProviderHandlers(deps) {
7747
7750
  deeplinkUri: created.sessionUri,
7748
7751
  providerId: selectedProviderId,
7749
7752
  isSetup: true,
7750
- guestSessionToken
7753
+ guestSessionToken,
7754
+ transferId: guestTransferId ?? void 0,
7755
+ isGuestPreauth: true
7751
7756
  });
7752
7757
  triggerDeeplink(created.sessionUri);
7753
7758
  dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: created.sessionUri });
@@ -7770,6 +7775,7 @@ function useProviderHandlers(deps) {
7770
7775
  }
7771
7776
  }, [
7772
7777
  guestSessionToken,
7778
+ guestTransferId,
7773
7779
  selectedProviderId,
7774
7780
  providers,
7775
7781
  apiBaseUrl,
@@ -8606,6 +8612,66 @@ function useMobilePollingEffect(deps) {
8606
8612
  if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
8607
8613
  void handleAuthorizedMobileReturnRef.current(polledTransfer, mobileSetupFlowRef.current);
8608
8614
  }, [state.mobileFlow, polling.transfer, handlingMobileReturnRef, mobileSetupFlowRef]);
8615
+ react.useEffect(() => {
8616
+ if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
8617
+ if (!setupAccountIdRef.current) return;
8618
+ if (!state.guestPreauthSessionId || !state.isGuestFlow) return;
8619
+ if (state.activeCredentialId) return;
8620
+ const sessionId = state.guestPreauthSessionId;
8621
+ let cancelled = false;
8622
+ let completedGuestPreauth = false;
8623
+ const POLL_INTERVAL_MS = 3e3;
8624
+ const completeGuestPreauthSetup = async () => {
8625
+ if (completedGuestPreauth) return;
8626
+ completedGuestPreauth = true;
8627
+ cancelled = true;
8628
+ mobileSetupFlowRef.current = false;
8629
+ setupAccountIdRef.current = null;
8630
+ clearMobileFlowState();
8631
+ try {
8632
+ await reloadAccounts();
8633
+ } catch {
8634
+ }
8635
+ dispatch({ type: "MOBILE_SETUP_COMPLETE" });
8636
+ };
8637
+ const pollGuestPreauthSession = async () => {
8638
+ try {
8639
+ if (cancelled) return;
8640
+ const session = await fetchAuthorizationSession(apiBaseUrl, sessionId);
8641
+ if (cancelled) return;
8642
+ if (session.status === "AUTHORIZED") {
8643
+ await completeGuestPreauthSetup();
8644
+ }
8645
+ } catch {
8646
+ }
8647
+ };
8648
+ pollGuestPreauthSession();
8649
+ const intervalId = window.setInterval(pollGuestPreauthSession, POLL_INTERVAL_MS);
8650
+ const handleVisibility = () => {
8651
+ if (document.visibilityState === "visible" && !cancelled) void pollGuestPreauthSession();
8652
+ };
8653
+ const handlePageShow = (e) => {
8654
+ if (e.persisted && !cancelled) void pollGuestPreauthSession();
8655
+ };
8656
+ document.addEventListener("visibilitychange", handleVisibility);
8657
+ window.addEventListener("pageshow", handlePageShow);
8658
+ return () => {
8659
+ cancelled = true;
8660
+ window.clearInterval(intervalId);
8661
+ document.removeEventListener("visibilitychange", handleVisibility);
8662
+ window.removeEventListener("pageshow", handlePageShow);
8663
+ };
8664
+ }, [
8665
+ state.mobileFlow,
8666
+ state.activeCredentialId,
8667
+ state.guestPreauthSessionId,
8668
+ state.isGuestFlow,
8669
+ apiBaseUrl,
8670
+ reloadAccounts,
8671
+ dispatch,
8672
+ mobileSetupFlowRef,
8673
+ setupAccountIdRef
8674
+ ]);
8609
8675
  react.useEffect(() => {
8610
8676
  if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
8611
8677
  if (!state.activeCredentialId || !setupAccountIdRef.current) return;
@@ -8736,6 +8802,63 @@ function useMobilePollingEffect(deps) {
8736
8802
  pollingTransferIdRef
8737
8803
  ]);
8738
8804
  }
8805
+ var guestPreauthRestoreAttemptedKeys = /* @__PURE__ */ new Set();
8806
+ function guestPreauthRestoreKey(sessionId, transferId) {
8807
+ return `${sessionId}:${transferId}`;
8808
+ }
8809
+ function useGuestPreauthMobileRestoreEffect(deps) {
8810
+ const {
8811
+ dispatch,
8812
+ apiBaseUrl,
8813
+ privyReady,
8814
+ authenticated,
8815
+ mobileSetupFlowRef,
8816
+ setupAccountIdRef
8817
+ } = deps;
8818
+ react.useEffect(() => {
8819
+ if (!privyReady || authenticated) return;
8820
+ const persisted = loadMobileFlowState();
8821
+ if (!persisted?.isGuestPreauth || !persisted.transferId || !persisted.guestSessionToken || !persisted.sessionId || !persisted.deeplinkUri || persisted.accountId == null) {
8822
+ return;
8823
+ }
8824
+ const key = guestPreauthRestoreKey(persisted.sessionId, persisted.transferId);
8825
+ if (guestPreauthRestoreAttemptedKeys.has(key)) return;
8826
+ guestPreauthRestoreAttemptedKeys.add(key);
8827
+ let cancelled = false;
8828
+ void (async () => {
8829
+ try {
8830
+ const [transfer, session] = await Promise.all([
8831
+ getGuestTransfer(apiBaseUrl, persisted.transferId, persisted.guestSessionToken),
8832
+ fetchAuthorizationSession(apiBaseUrl, persisted.sessionId)
8833
+ ]);
8834
+ if (cancelled) return;
8835
+ const mobileOpen = session.status !== "AUTHORIZED";
8836
+ dispatch({
8837
+ type: "RESTORE_GUEST_PREAUTH_MOBILE",
8838
+ transfer,
8839
+ guestSessionToken: persisted.guestSessionToken,
8840
+ guestPreauthAccountId: persisted.accountId,
8841
+ guestPreauthSessionId: persisted.sessionId,
8842
+ selectedProviderId: persisted.providerId,
8843
+ deeplinkUri: persisted.deeplinkUri,
8844
+ mobileOpen
8845
+ });
8846
+ if (mobileOpen) {
8847
+ mobileSetupFlowRef.current = true;
8848
+ setupAccountIdRef.current = persisted.accountId;
8849
+ } else {
8850
+ clearMobileFlowState();
8851
+ }
8852
+ } catch (err) {
8853
+ guestPreauthRestoreAttemptedKeys.delete(key);
8854
+ captureException(err);
8855
+ }
8856
+ })();
8857
+ return () => {
8858
+ cancelled = true;
8859
+ };
8860
+ }, [privyReady, authenticated, apiBaseUrl, dispatch, mobileSetupFlowRef, setupAccountIdRef]);
8861
+ }
8739
8862
  function useSelectSourceEffect(deps) {
8740
8863
  const {
8741
8864
  pendingSelectSourceAction,
@@ -9111,6 +9234,7 @@ function BlinkPaymentInner({
9111
9234
  merchantAuthorization,
9112
9235
  destination,
9113
9236
  guestSessionToken: state.guestSessionToken,
9237
+ guestTransferId: state.guestTransferId,
9114
9238
  selectedProviderId: state.selectedProviderId
9115
9239
  });
9116
9240
  const guestPostPayPreauth = react.useMemo(
@@ -9172,6 +9296,14 @@ function BlinkPaymentInner({
9172
9296
  }
9173
9297
  }, [depositAmount, dispatch]);
9174
9298
  usePrivySessionSyncEffect({ dispatch, ready, authenticated });
9299
+ useGuestPreauthMobileRestoreEffect({
9300
+ dispatch,
9301
+ apiBaseUrl,
9302
+ privyReady: state.privyReady,
9303
+ authenticated,
9304
+ mobileSetupFlowRef: mobileFlowRefs.mobileSetupFlowRef,
9305
+ setupAccountIdRef: mobileFlowRefs.setupAccountIdRef
9306
+ });
9175
9307
  useOtpEffects({
9176
9308
  state,
9177
9309
  dispatch,