@swype-org/react-sdk 0.1.259 → 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.js CHANGED
@@ -2057,143 +2057,143 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
2057
2057
  }
2058
2058
  }
2059
2059
  function resolvePhase(state) {
2060
- const p = state.phase;
2060
+ const currentPhase = state.phase;
2061
2061
  const transferCompleted = state.transfer?.status === "COMPLETED";
2062
2062
  const needsPasskeyBootstrap = state.privyAuthenticated && !state.activeCredentialId;
2063
- const guestPreauthPin = transferCompleted && state.guestPreauthorizing && !state.verificationTarget && isGuestPreauthCompletedTransferPinPhase(p);
2063
+ const guestPreauthPinsCurrentPhase = transferCompleted && state.guestPreauthorizing && !state.verificationTarget && isGuestPreauthCompletedTransferPinPhase(currentPhase);
2064
2064
  const guestPostPayLogin = transferCompleted && state.isGuestFlow && state.guestPreauthSessionId != null && !state.guestPreauthorizing && !state.verificationTarget && !state.privyAuthenticated;
2065
- 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");
2066
- const guestTokenPicker = state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestPreauthAccountId;
2067
- const walletPickerSwitch = p.step === "wallet-picker" && p.reason === "switch" && !state.creatingTransfer && !(state.mobileFlow && state.deeplinkUri);
2068
- const passkeyBlock = state.passkeyConfigLoaded && !state.activeCredentialId;
2069
- const passkeyVerify = passkeyBlock && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded;
2070
- const c1 = state.guestPreauthSetupCompletePending && state.privyReady && state.privyAuthenticated;
2071
- const c2 = !c1 && guestPreauthPin;
2072
- const c3 = !c1 && !c2 && guestPostPayLogin;
2073
- const c4 = !c1 && !c2 && !c3 && transferCompleted && !state.verificationTarget && !needsPasskeyBootstrap;
2074
- const c5 = !c1 && !c2 && !c3 && !c4 && state.transfer?.status === "FAILED";
2075
- const c6 = !c1 && !c2 && !c3 && !c4 && !c5 && (state.creatingTransfer || isTransferAwaitingCompletion(state.transfer));
2076
- const c7 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && pinSubflow;
2077
- const c8 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && state.mobileFlow && state.deeplinkUri != null;
2078
- const c9 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && p.step === "wallet-setup" && p.mobile == null && state.guestPreauthorizing;
2079
- const c10 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && guestTokenPicker;
2080
- const c11 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && walletPickerSwitch;
2081
- const c12 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !state.privyReady;
2082
- const c13 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && state.privyAuthenticated && !state.activeCredentialId && !state.passkeyConfigLoaded;
2083
- const c14 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && state.verificationTarget != null && !state.privyAuthenticated;
2084
- const c15 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && state.loginRequested;
2085
- const c16 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && passkeyVerify;
2086
- const c17 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && passkeyBlock;
2087
- 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);
2088
- 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;
2089
- 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;
2090
- const c21 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && !c9 && !c10 && !c11 && !c12 && !c13 && !c14 && !c15 && !c16 && !c17 && !c18 && !c19 && !c20 && state.isGuestFlow;
2091
- const flags = [
2092
- c1,
2093
- c2,
2094
- c3,
2095
- c4,
2096
- c5,
2097
- c6,
2098
- c7,
2099
- c8,
2100
- c9,
2101
- c10,
2102
- c11,
2103
- c12,
2104
- c13,
2105
- c14,
2106
- c15,
2107
- c16,
2108
- c17,
2109
- c18,
2110
- c19,
2111
- c20,
2112
- c21
2065
+ 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");
2066
+ const guestTokenPickerEligible = state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestPreauthAccountId;
2067
+ const walletPickerSwitchEligible = currentPhase.step === "wallet-picker" && currentPhase.reason === "switch" && !state.creatingTransfer && !(state.mobileFlow && state.deeplinkUri);
2068
+ const missingActivePasskeyCredential = state.passkeyConfigLoaded && !state.activeCredentialId;
2069
+ const shouldPromptPasskeyVerification = missingActivePasskeyCredential && state.knownCredentialIds.length > 0 && state.passkeyPopupNeeded;
2070
+ const branchGuestSetupComplete = state.guestPreauthSetupCompletePending && state.privyReady && state.privyAuthenticated;
2071
+ const branchKeepGuestPreauthPin = !branchGuestSetupComplete && guestPreauthPinsCurrentPhase;
2072
+ const branchGuestPostPayLogin = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && guestPostPayLogin;
2073
+ const branchCompleted = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && transferCompleted && !state.verificationTarget && !needsPasskeyBootstrap;
2074
+ const branchFailed = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && state.transfer?.status === "FAILED";
2075
+ const branchProcessing = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && (state.creatingTransfer || isTransferAwaitingCompletion(state.transfer));
2076
+ const branchKeepFundingSubflow = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && isFundingSourceSubflow;
2077
+ const branchMobileWalletSetup = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && state.mobileFlow && state.deeplinkUri != null;
2078
+ const branchKeepGuestWalletSetup = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && currentPhase.step === "wallet-setup" && currentPhase.mobile == null && state.guestPreauthorizing;
2079
+ const branchGuestTokenPicker = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && guestTokenPickerEligible;
2080
+ const branchKeepWalletPickerSwitch = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && walletPickerSwitchEligible;
2081
+ const branchInitializingPrivy = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !state.privyReady;
2082
+ const branchInitializingPasskeyConfig = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && state.privyAuthenticated && !state.activeCredentialId && !state.passkeyConfigLoaded;
2083
+ const branchOtpVerify = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && state.verificationTarget != null && !state.privyAuthenticated;
2084
+ const branchLoginRequested = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && state.loginRequested;
2085
+ const branchPasskeyVerify = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && shouldPromptPasskeyVerification;
2086
+ const branchPasskeyCreate = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && missingActivePasskeyCredential;
2087
+ 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);
2088
+ 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;
2089
+ 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;
2090
+ const branchWalletPickerGuestEntry = !branchGuestSetupComplete && !branchKeepGuestPreauthPin && !branchGuestPostPayLogin && !branchCompleted && !branchFailed && !branchProcessing && !branchKeepFundingSubflow && !branchMobileWalletSetup && !branchKeepGuestWalletSetup && !branchGuestTokenPicker && !branchKeepWalletPickerSwitch && !branchInitializingPrivy && !branchInitializingPasskeyConfig && !branchOtpVerify && !branchLoginRequested && !branchPasskeyVerify && !branchPasskeyCreate && !branchDataLoading && !branchWalletPickerLink && !branchDeposit && state.isGuestFlow;
2091
+ const exclusiveBranchFlags = [
2092
+ branchGuestSetupComplete,
2093
+ branchKeepGuestPreauthPin,
2094
+ branchGuestPostPayLogin,
2095
+ branchCompleted,
2096
+ branchFailed,
2097
+ branchProcessing,
2098
+ branchKeepFundingSubflow,
2099
+ branchMobileWalletSetup,
2100
+ branchKeepGuestWalletSetup,
2101
+ branchGuestTokenPicker,
2102
+ branchKeepWalletPickerSwitch,
2103
+ branchInitializingPrivy,
2104
+ branchInitializingPasskeyConfig,
2105
+ branchOtpVerify,
2106
+ branchLoginRequested,
2107
+ branchPasskeyVerify,
2108
+ branchPasskeyCreate,
2109
+ branchDataLoading,
2110
+ branchWalletPickerLink,
2111
+ branchDeposit,
2112
+ branchWalletPickerGuestEntry
2113
2113
  ];
2114
- const matchCount = flags.filter(Boolean).length;
2114
+ const matchCount = exclusiveBranchFlags.filter(Boolean).length;
2115
2115
  if (matchCount > 1) {
2116
2116
  console.error("resolvePhase: multiple exclusive branches matched", {
2117
- flags: {
2118
- c1,
2119
- c2,
2120
- c3,
2121
- c4,
2122
- c5,
2123
- c6,
2124
- c7,
2125
- c8,
2126
- c9,
2127
- c10,
2128
- c11,
2129
- c12,
2130
- c13,
2131
- c14,
2132
- c15,
2133
- c16,
2134
- c17,
2135
- c18,
2136
- c19,
2137
- c20,
2138
- c21
2117
+ branches: {
2118
+ branchGuestSetupComplete,
2119
+ branchKeepGuestPreauthPin,
2120
+ branchGuestPostPayLogin,
2121
+ branchCompleted,
2122
+ branchFailed,
2123
+ branchProcessing,
2124
+ branchKeepFundingSubflow,
2125
+ branchMobileWalletSetup,
2126
+ branchKeepGuestWalletSetup,
2127
+ branchGuestTokenPicker,
2128
+ branchKeepWalletPickerSwitch,
2129
+ branchInitializingPrivy,
2130
+ branchInitializingPasskeyConfig,
2131
+ branchOtpVerify,
2132
+ branchLoginRequested,
2133
+ branchPasskeyVerify,
2134
+ branchPasskeyCreate,
2135
+ branchDataLoading,
2136
+ branchWalletPickerLink,
2137
+ branchDeposit,
2138
+ branchWalletPickerGuestEntry
2139
2139
  }
2140
2140
  });
2141
2141
  }
2142
- let resolved;
2143
- if (c1) {
2144
- resolved = { step: "guest-setup-complete" };
2145
- } else if (c2) {
2146
- resolved = p;
2147
- } else if (c3) {
2148
- resolved = { step: "login" };
2149
- } else if (c4) {
2150
- resolved = { step: "completed", transfer: state.transfer };
2151
- } else if (c5) {
2152
- resolved = {
2142
+ let nextPhase;
2143
+ if (branchGuestSetupComplete) {
2144
+ nextPhase = { step: "guest-setup-complete" };
2145
+ } else if (branchKeepGuestPreauthPin) {
2146
+ nextPhase = currentPhase;
2147
+ } else if (branchGuestPostPayLogin) {
2148
+ nextPhase = { step: "login" };
2149
+ } else if (branchCompleted) {
2150
+ nextPhase = { step: "completed", transfer: state.transfer };
2151
+ } else if (branchFailed) {
2152
+ nextPhase = {
2153
2153
  step: "failed",
2154
2154
  transfer: state.transfer,
2155
2155
  error: state.error ?? "Transfer failed."
2156
2156
  };
2157
- } else if (c6) {
2158
- resolved = { step: "processing", transfer: state.transfer };
2159
- } else if (c7) {
2160
- resolved = p;
2161
- } else if (c8) {
2162
- resolved = {
2157
+ } else if (branchProcessing) {
2158
+ nextPhase = { step: "processing", transfer: state.transfer };
2159
+ } else if (branchKeepFundingSubflow) {
2160
+ nextPhase = currentPhase;
2161
+ } else if (branchMobileWalletSetup) {
2162
+ nextPhase = {
2163
2163
  step: "wallet-setup",
2164
2164
  mobile: { deeplinkUri: state.deeplinkUri, providerId: state.selectedProviderId },
2165
2165
  accountId: null
2166
2166
  };
2167
- } else if (c9) {
2168
- resolved = p;
2169
- } else if (c10) {
2170
- resolved = { step: "guest-token-picker" };
2171
- } else if (c11) {
2172
- resolved = p;
2173
- } else if (c12) {
2174
- resolved = { step: "initializing" };
2175
- } else if (c13) {
2176
- resolved = { step: "initializing" };
2177
- } else if (c14) {
2178
- resolved = { step: "otp-verify", target: state.verificationTarget };
2179
- } else if (c15) {
2180
- resolved = { step: "login" };
2181
- } else if (c16) {
2182
- resolved = { step: "passkey-verify" };
2183
- } else if (c17) {
2184
- resolved = { step: "passkey-create", popupFallback: state.passkeyPopupNeeded };
2185
- } else if (c18) {
2186
- resolved = { step: "data-loading" };
2187
- } else if (c19) {
2188
- resolved = { step: "wallet-picker", reason: "link" };
2189
- } else if (c20) {
2190
- resolved = { step: "deposit" };
2191
- } else if (c21) {
2192
- resolved = { step: "wallet-picker", reason: "guest-entry" };
2167
+ } else if (branchKeepGuestWalletSetup) {
2168
+ nextPhase = currentPhase;
2169
+ } else if (branchGuestTokenPicker) {
2170
+ nextPhase = { step: "guest-token-picker" };
2171
+ } else if (branchKeepWalletPickerSwitch) {
2172
+ nextPhase = currentPhase;
2173
+ } else if (branchInitializingPrivy) {
2174
+ nextPhase = { step: "initializing" };
2175
+ } else if (branchInitializingPasskeyConfig) {
2176
+ nextPhase = { step: "initializing" };
2177
+ } else if (branchOtpVerify) {
2178
+ nextPhase = { step: "otp-verify", target: state.verificationTarget };
2179
+ } else if (branchLoginRequested) {
2180
+ nextPhase = { step: "login" };
2181
+ } else if (branchPasskeyVerify) {
2182
+ nextPhase = { step: "passkey-verify" };
2183
+ } else if (branchPasskeyCreate) {
2184
+ nextPhase = { step: "passkey-create", popupFallback: state.passkeyPopupNeeded };
2185
+ } else if (branchDataLoading) {
2186
+ nextPhase = { step: "data-loading" };
2187
+ } else if (branchWalletPickerLink) {
2188
+ nextPhase = { step: "wallet-picker", reason: "link" };
2189
+ } else if (branchDeposit) {
2190
+ nextPhase = { step: "deposit" };
2191
+ } else if (branchWalletPickerGuestEntry) {
2192
+ nextPhase = { step: "wallet-picker", reason: "guest-entry" };
2193
2193
  } else {
2194
- resolved = { step: "wallet-picker", reason: "entry" };
2194
+ nextPhase = { step: "wallet-picker", reason: "entry" };
2195
2195
  }
2196
- return resolved;
2196
+ return nextPhase;
2197
2197
  }
2198
2198
 
2199
2199
  // src/paymentReducer.ts