@swype-org/react-sdk 0.1.259 → 0.1.261
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 +238 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +238 -123
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2057,143 +2057,143 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
|
2057
2057
|
}
|
|
2058
2058
|
}
|
|
2059
2059
|
function resolvePhase(state) {
|
|
2060
|
-
const
|
|
2060
|
+
const currentPhase = state.phase;
|
|
2061
2061
|
const transferCompleted = state.transfer?.status === "COMPLETED";
|
|
2062
2062
|
const needsPasskeyBootstrap = state.privyAuthenticated && !state.activeCredentialId;
|
|
2063
|
-
const
|
|
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
|
|
2066
|
-
const
|
|
2067
|
-
const
|
|
2068
|
-
const
|
|
2069
|
-
const
|
|
2070
|
-
const
|
|
2071
|
-
const
|
|
2072
|
-
const
|
|
2073
|
-
const
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2076
|
-
const
|
|
2077
|
-
const
|
|
2078
|
-
const
|
|
2079
|
-
const
|
|
2080
|
-
const
|
|
2081
|
-
const
|
|
2082
|
-
const
|
|
2083
|
-
const
|
|
2084
|
-
const
|
|
2085
|
-
const
|
|
2086
|
-
const
|
|
2087
|
-
const
|
|
2088
|
-
const
|
|
2089
|
-
const
|
|
2090
|
-
const
|
|
2091
|
-
const
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
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 =
|
|
2114
|
+
const matchCount = exclusiveBranchFlags.filter(Boolean).length;
|
|
2115
2115
|
if (matchCount > 1) {
|
|
2116
2116
|
console.error("resolvePhase: multiple exclusive branches matched", {
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
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
|
|
2143
|
-
if (
|
|
2144
|
-
|
|
2145
|
-
} else if (
|
|
2146
|
-
|
|
2147
|
-
} else if (
|
|
2148
|
-
|
|
2149
|
-
} else if (
|
|
2150
|
-
|
|
2151
|
-
} else if (
|
|
2152
|
-
|
|
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 (
|
|
2158
|
-
|
|
2159
|
-
} else if (
|
|
2160
|
-
|
|
2161
|
-
} else if (
|
|
2162
|
-
|
|
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 (
|
|
2168
|
-
|
|
2169
|
-
} else if (
|
|
2170
|
-
|
|
2171
|
-
} else if (
|
|
2172
|
-
|
|
2173
|
-
} else if (
|
|
2174
|
-
|
|
2175
|
-
} else if (
|
|
2176
|
-
|
|
2177
|
-
} else if (
|
|
2178
|
-
|
|
2179
|
-
} else if (
|
|
2180
|
-
|
|
2181
|
-
} else if (
|
|
2182
|
-
|
|
2183
|
-
} else if (
|
|
2184
|
-
|
|
2185
|
-
} else if (
|
|
2186
|
-
|
|
2187
|
-
} else if (
|
|
2188
|
-
|
|
2189
|
-
} else if (
|
|
2190
|
-
|
|
2191
|
-
} else if (
|
|
2192
|
-
|
|
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
|
-
|
|
2194
|
+
nextPhase = { step: "wallet-picker", reason: "entry" };
|
|
2195
2195
|
}
|
|
2196
|
-
return
|
|
2196
|
+
return nextPhase;
|
|
2197
2197
|
}
|
|
2198
2198
|
|
|
2199
2199
|
// src/paymentReducer.ts
|
|
@@ -2439,13 +2439,37 @@ function applyAction(state, action) {
|
|
|
2439
2439
|
selectedProviderId: action.providerId ?? state.selectedProviderId,
|
|
2440
2440
|
error: action.error ?? null
|
|
2441
2441
|
};
|
|
2442
|
-
case "MOBILE_RESUME_SUCCESS":
|
|
2442
|
+
case "MOBILE_RESUME_SUCCESS": {
|
|
2443
|
+
const guestResume = action.guestCheckoutResume;
|
|
2443
2444
|
return {
|
|
2444
2445
|
...state,
|
|
2445
2446
|
transfer: action.transfer,
|
|
2446
2447
|
error: null,
|
|
2447
2448
|
mobileFlow: false,
|
|
2448
|
-
deeplinkUri: null
|
|
2449
|
+
deeplinkUri: null,
|
|
2450
|
+
...guestResume ? {
|
|
2451
|
+
isGuestFlow: true,
|
|
2452
|
+
guestSessionToken: guestResume.guestSessionToken,
|
|
2453
|
+
guestTransferId: action.transfer.id
|
|
2454
|
+
} : {}
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
case "GUEST_PREAUTH_RESUME_WITH_TRANSFER":
|
|
2458
|
+
return {
|
|
2459
|
+
...state,
|
|
2460
|
+
transfer: action.transfer,
|
|
2461
|
+
error: null,
|
|
2462
|
+
mobileFlow: false,
|
|
2463
|
+
deeplinkUri: null,
|
|
2464
|
+
isGuestFlow: true,
|
|
2465
|
+
guestSessionToken: action.guestSessionToken,
|
|
2466
|
+
guestTransferId: action.transfer.id,
|
|
2467
|
+
guestPreauthAccountId: action.guestPreauthAccountId,
|
|
2468
|
+
guestPreauthSessionId: action.guestPreauthSessionId ?? state.guestPreauthSessionId,
|
|
2469
|
+
selectedProviderId: action.selectedProviderId,
|
|
2470
|
+
selectedAccountId: action.guestPreauthAccountId,
|
|
2471
|
+
selectedWalletId: null,
|
|
2472
|
+
selectedTokenSymbol: null
|
|
2449
2473
|
};
|
|
2450
2474
|
case "MOBILE_RESUME_FAILED":
|
|
2451
2475
|
return {
|
|
@@ -8239,6 +8263,38 @@ function usePasskeyCheckEffect(deps) {
|
|
|
8239
8263
|
if (cancelled) return;
|
|
8240
8264
|
if (existingTransfer.status === "COMPLETED") {
|
|
8241
8265
|
clearMobileFlowState();
|
|
8266
|
+
if (persisted.isGuestPreauth && persisted.guestSessionToken) {
|
|
8267
|
+
let guestLookup = null;
|
|
8268
|
+
try {
|
|
8269
|
+
guestLookup = await fetchGuestAccount(
|
|
8270
|
+
apiBaseUrl,
|
|
8271
|
+
persisted.guestSessionToken
|
|
8272
|
+
);
|
|
8273
|
+
} catch {
|
|
8274
|
+
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
8275
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8276
|
+
return;
|
|
8277
|
+
}
|
|
8278
|
+
if (guestLookup == null) {
|
|
8279
|
+
dispatch({
|
|
8280
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8281
|
+
transfer: existingTransfer,
|
|
8282
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8283
|
+
});
|
|
8284
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8285
|
+
return;
|
|
8286
|
+
}
|
|
8287
|
+
dispatch({
|
|
8288
|
+
type: "GUEST_PREAUTH_RESUME_WITH_TRANSFER",
|
|
8289
|
+
transfer: existingTransfer,
|
|
8290
|
+
guestSessionToken: persisted.guestSessionToken,
|
|
8291
|
+
guestPreauthAccountId: guestLookup.accountId,
|
|
8292
|
+
guestPreauthSessionId: persisted.sessionId ?? null,
|
|
8293
|
+
selectedProviderId: persisted.providerId
|
|
8294
|
+
});
|
|
8295
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8296
|
+
return;
|
|
8297
|
+
}
|
|
8242
8298
|
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
8243
8299
|
onCompleteRef.current?.(existingTransfer);
|
|
8244
8300
|
return;
|
|
@@ -8594,9 +8650,11 @@ function useMobilePollingEffect(deps) {
|
|
|
8594
8650
|
reloadAccounts,
|
|
8595
8651
|
apiBaseUrl
|
|
8596
8652
|
} = deps;
|
|
8597
|
-
const { getAccessToken } = usePrivy();
|
|
8653
|
+
const { getAccessToken, authenticated: privyAuthenticated } = usePrivy();
|
|
8598
8654
|
const getAccessTokenRef = useRef(getAccessToken);
|
|
8599
8655
|
getAccessTokenRef.current = getAccessToken;
|
|
8656
|
+
const privyAuthenticatedRef = useRef(privyAuthenticated);
|
|
8657
|
+
privyAuthenticatedRef.current = privyAuthenticated;
|
|
8600
8658
|
const handleAuthorizedMobileReturnRef = useRef(deps.handleAuthorizedMobileReturn);
|
|
8601
8659
|
handleAuthorizedMobileReturnRef.current = deps.handleAuthorizedMobileReturn;
|
|
8602
8660
|
useEffect(() => {
|
|
@@ -8629,6 +8687,34 @@ function useMobilePollingEffect(deps) {
|
|
|
8629
8687
|
await reloadAccounts();
|
|
8630
8688
|
} catch {
|
|
8631
8689
|
}
|
|
8690
|
+
const guestToken = state.guestSessionToken;
|
|
8691
|
+
const preauthAccountId = state.guestPreauthAccountId;
|
|
8692
|
+
const preauthSessionId = state.guestPreauthSessionId;
|
|
8693
|
+
if (!guestToken) {
|
|
8694
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8695
|
+
return;
|
|
8696
|
+
}
|
|
8697
|
+
let guestLookup = null;
|
|
8698
|
+
try {
|
|
8699
|
+
guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
|
|
8700
|
+
} catch {
|
|
8701
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8702
|
+
return;
|
|
8703
|
+
}
|
|
8704
|
+
if (guestLookup == null) {
|
|
8705
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8706
|
+
return;
|
|
8707
|
+
}
|
|
8708
|
+
if (guestLookup.accountId !== preauthAccountId) {
|
|
8709
|
+
dispatch({
|
|
8710
|
+
type: "GUEST_PREAUTH_DETECTED",
|
|
8711
|
+
accountId: guestLookup.accountId,
|
|
8712
|
+
sessionId: preauthSessionId ?? void 0
|
|
8713
|
+
});
|
|
8714
|
+
}
|
|
8715
|
+
if (!privyAuthenticatedRef.current) {
|
|
8716
|
+
dispatch({ type: "REQUEST_LOGIN" });
|
|
8717
|
+
}
|
|
8632
8718
|
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8633
8719
|
};
|
|
8634
8720
|
const pollGuestPreauthSession = async () => {
|
|
@@ -8663,6 +8749,8 @@ function useMobilePollingEffect(deps) {
|
|
|
8663
8749
|
state.activeCredentialId,
|
|
8664
8750
|
state.guestPreauthSessionId,
|
|
8665
8751
|
state.isGuestFlow,
|
|
8752
|
+
state.guestSessionToken,
|
|
8753
|
+
state.guestPreauthAccountId,
|
|
8666
8754
|
apiBaseUrl,
|
|
8667
8755
|
reloadAccounts,
|
|
8668
8756
|
dispatch,
|
|
@@ -8830,11 +8918,38 @@ function useGuestPreauthMobileRestoreEffect(deps) {
|
|
|
8830
8918
|
]);
|
|
8831
8919
|
if (cancelled) return;
|
|
8832
8920
|
const mobileOpen = session.status !== "AUTHORIZED";
|
|
8921
|
+
let guestLookup = null;
|
|
8922
|
+
if (!mobileOpen) {
|
|
8923
|
+
try {
|
|
8924
|
+
guestLookup = await fetchGuestAccount(
|
|
8925
|
+
apiBaseUrl,
|
|
8926
|
+
persisted.guestSessionToken
|
|
8927
|
+
);
|
|
8928
|
+
} catch {
|
|
8929
|
+
dispatch({
|
|
8930
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8931
|
+
transfer,
|
|
8932
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8933
|
+
});
|
|
8934
|
+
clearMobileFlowState();
|
|
8935
|
+
return;
|
|
8936
|
+
}
|
|
8937
|
+
if (guestLookup == null) {
|
|
8938
|
+
dispatch({
|
|
8939
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8940
|
+
transfer,
|
|
8941
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8942
|
+
});
|
|
8943
|
+
clearMobileFlowState();
|
|
8944
|
+
return;
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
const guestPreauthAccountId = !mobileOpen && guestLookup != null ? guestLookup.accountId : persisted.accountId;
|
|
8833
8948
|
dispatch({
|
|
8834
8949
|
type: "RESTORE_GUEST_PREAUTH_MOBILE",
|
|
8835
8950
|
transfer,
|
|
8836
8951
|
guestSessionToken: persisted.guestSessionToken,
|
|
8837
|
-
guestPreauthAccountId
|
|
8952
|
+
guestPreauthAccountId,
|
|
8838
8953
|
guestPreauthSessionId: persisted.sessionId,
|
|
8839
8954
|
selectedProviderId: persisted.providerId,
|
|
8840
8955
|
deeplinkUri: persisted.deeplinkUri,
|
|
@@ -8842,7 +8957,7 @@ function useGuestPreauthMobileRestoreEffect(deps) {
|
|
|
8842
8957
|
});
|
|
8843
8958
|
if (mobileOpen) {
|
|
8844
8959
|
mobileSetupFlowRef.current = true;
|
|
8845
|
-
setupAccountIdRef.current = persisted.accountId;
|
|
8960
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
8846
8961
|
} else {
|
|
8847
8962
|
clearMobileFlowState();
|
|
8848
8963
|
}
|