@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.cjs
CHANGED
|
@@ -2060,143 +2060,143 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
|
2060
2060
|
}
|
|
2061
2061
|
}
|
|
2062
2062
|
function resolvePhase(state) {
|
|
2063
|
-
const
|
|
2063
|
+
const currentPhase = state.phase;
|
|
2064
2064
|
const transferCompleted = state.transfer?.status === "COMPLETED";
|
|
2065
2065
|
const needsPasskeyBootstrap = state.privyAuthenticated && !state.activeCredentialId;
|
|
2066
|
-
const
|
|
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
|
|
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
|
-
const
|
|
2093
|
-
const
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
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 =
|
|
2117
|
+
const matchCount = exclusiveBranchFlags.filter(Boolean).length;
|
|
2118
2118
|
if (matchCount > 1) {
|
|
2119
2119
|
console.error("resolvePhase: multiple exclusive branches matched", {
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
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
|
|
2146
|
-
if (
|
|
2147
|
-
|
|
2148
|
-
} else if (
|
|
2149
|
-
|
|
2150
|
-
} else if (
|
|
2151
|
-
|
|
2152
|
-
} else if (
|
|
2153
|
-
|
|
2154
|
-
} else if (
|
|
2155
|
-
|
|
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 (
|
|
2161
|
-
|
|
2162
|
-
} else if (
|
|
2163
|
-
|
|
2164
|
-
} else if (
|
|
2165
|
-
|
|
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 (
|
|
2171
|
-
|
|
2172
|
-
} else if (
|
|
2173
|
-
|
|
2174
|
-
} else if (
|
|
2175
|
-
|
|
2176
|
-
} else if (
|
|
2177
|
-
|
|
2178
|
-
} else if (
|
|
2179
|
-
|
|
2180
|
-
} else if (
|
|
2181
|
-
|
|
2182
|
-
} else if (
|
|
2183
|
-
|
|
2184
|
-
} else if (
|
|
2185
|
-
|
|
2186
|
-
} else if (
|
|
2187
|
-
|
|
2188
|
-
} else if (
|
|
2189
|
-
|
|
2190
|
-
} else if (
|
|
2191
|
-
|
|
2192
|
-
} else if (
|
|
2193
|
-
|
|
2194
|
-
} else if (
|
|
2195
|
-
|
|
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
|
-
|
|
2197
|
+
nextPhase = { step: "wallet-picker", reason: "entry" };
|
|
2198
2198
|
}
|
|
2199
|
-
return
|
|
2199
|
+
return nextPhase;
|
|
2200
2200
|
}
|
|
2201
2201
|
|
|
2202
2202
|
// src/paymentReducer.ts
|
|
@@ -2442,13 +2442,37 @@ function applyAction(state, action) {
|
|
|
2442
2442
|
selectedProviderId: action.providerId ?? state.selectedProviderId,
|
|
2443
2443
|
error: action.error ?? null
|
|
2444
2444
|
};
|
|
2445
|
-
case "MOBILE_RESUME_SUCCESS":
|
|
2445
|
+
case "MOBILE_RESUME_SUCCESS": {
|
|
2446
|
+
const guestResume = action.guestCheckoutResume;
|
|
2446
2447
|
return {
|
|
2447
2448
|
...state,
|
|
2448
2449
|
transfer: action.transfer,
|
|
2449
2450
|
error: null,
|
|
2450
2451
|
mobileFlow: false,
|
|
2451
|
-
deeplinkUri: null
|
|
2452
|
+
deeplinkUri: null,
|
|
2453
|
+
...guestResume ? {
|
|
2454
|
+
isGuestFlow: true,
|
|
2455
|
+
guestSessionToken: guestResume.guestSessionToken,
|
|
2456
|
+
guestTransferId: action.transfer.id
|
|
2457
|
+
} : {}
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
case "GUEST_PREAUTH_RESUME_WITH_TRANSFER":
|
|
2461
|
+
return {
|
|
2462
|
+
...state,
|
|
2463
|
+
transfer: action.transfer,
|
|
2464
|
+
error: null,
|
|
2465
|
+
mobileFlow: false,
|
|
2466
|
+
deeplinkUri: null,
|
|
2467
|
+
isGuestFlow: true,
|
|
2468
|
+
guestSessionToken: action.guestSessionToken,
|
|
2469
|
+
guestTransferId: action.transfer.id,
|
|
2470
|
+
guestPreauthAccountId: action.guestPreauthAccountId,
|
|
2471
|
+
guestPreauthSessionId: action.guestPreauthSessionId ?? state.guestPreauthSessionId,
|
|
2472
|
+
selectedProviderId: action.selectedProviderId,
|
|
2473
|
+
selectedAccountId: action.guestPreauthAccountId,
|
|
2474
|
+
selectedWalletId: null,
|
|
2475
|
+
selectedTokenSymbol: null
|
|
2452
2476
|
};
|
|
2453
2477
|
case "MOBILE_RESUME_FAILED":
|
|
2454
2478
|
return {
|
|
@@ -8242,6 +8266,38 @@ function usePasskeyCheckEffect(deps) {
|
|
|
8242
8266
|
if (cancelled) return;
|
|
8243
8267
|
if (existingTransfer.status === "COMPLETED") {
|
|
8244
8268
|
clearMobileFlowState();
|
|
8269
|
+
if (persisted.isGuestPreauth && persisted.guestSessionToken) {
|
|
8270
|
+
let guestLookup = null;
|
|
8271
|
+
try {
|
|
8272
|
+
guestLookup = await fetchGuestAccount(
|
|
8273
|
+
apiBaseUrl,
|
|
8274
|
+
persisted.guestSessionToken
|
|
8275
|
+
);
|
|
8276
|
+
} catch {
|
|
8277
|
+
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
8278
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8279
|
+
return;
|
|
8280
|
+
}
|
|
8281
|
+
if (guestLookup == null) {
|
|
8282
|
+
dispatch({
|
|
8283
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8284
|
+
transfer: existingTransfer,
|
|
8285
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8286
|
+
});
|
|
8287
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8288
|
+
return;
|
|
8289
|
+
}
|
|
8290
|
+
dispatch({
|
|
8291
|
+
type: "GUEST_PREAUTH_RESUME_WITH_TRANSFER",
|
|
8292
|
+
transfer: existingTransfer,
|
|
8293
|
+
guestSessionToken: persisted.guestSessionToken,
|
|
8294
|
+
guestPreauthAccountId: guestLookup.accountId,
|
|
8295
|
+
guestPreauthSessionId: persisted.sessionId ?? null,
|
|
8296
|
+
selectedProviderId: persisted.providerId
|
|
8297
|
+
});
|
|
8298
|
+
onCompleteRef.current?.(existingTransfer);
|
|
8299
|
+
return;
|
|
8300
|
+
}
|
|
8245
8301
|
dispatch({ type: "MOBILE_RESUME_SUCCESS", transfer: existingTransfer });
|
|
8246
8302
|
onCompleteRef.current?.(existingTransfer);
|
|
8247
8303
|
return;
|
|
@@ -8597,9 +8653,11 @@ function useMobilePollingEffect(deps) {
|
|
|
8597
8653
|
reloadAccounts,
|
|
8598
8654
|
apiBaseUrl
|
|
8599
8655
|
} = deps;
|
|
8600
|
-
const { getAccessToken } = reactAuth.usePrivy();
|
|
8656
|
+
const { getAccessToken, authenticated: privyAuthenticated } = reactAuth.usePrivy();
|
|
8601
8657
|
const getAccessTokenRef = react.useRef(getAccessToken);
|
|
8602
8658
|
getAccessTokenRef.current = getAccessToken;
|
|
8659
|
+
const privyAuthenticatedRef = react.useRef(privyAuthenticated);
|
|
8660
|
+
privyAuthenticatedRef.current = privyAuthenticated;
|
|
8603
8661
|
const handleAuthorizedMobileReturnRef = react.useRef(deps.handleAuthorizedMobileReturn);
|
|
8604
8662
|
handleAuthorizedMobileReturnRef.current = deps.handleAuthorizedMobileReturn;
|
|
8605
8663
|
react.useEffect(() => {
|
|
@@ -8632,6 +8690,34 @@ function useMobilePollingEffect(deps) {
|
|
|
8632
8690
|
await reloadAccounts();
|
|
8633
8691
|
} catch {
|
|
8634
8692
|
}
|
|
8693
|
+
const guestToken = state.guestSessionToken;
|
|
8694
|
+
const preauthAccountId = state.guestPreauthAccountId;
|
|
8695
|
+
const preauthSessionId = state.guestPreauthSessionId;
|
|
8696
|
+
if (!guestToken) {
|
|
8697
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8698
|
+
return;
|
|
8699
|
+
}
|
|
8700
|
+
let guestLookup = null;
|
|
8701
|
+
try {
|
|
8702
|
+
guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
|
|
8703
|
+
} catch {
|
|
8704
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8705
|
+
return;
|
|
8706
|
+
}
|
|
8707
|
+
if (guestLookup == null) {
|
|
8708
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8709
|
+
return;
|
|
8710
|
+
}
|
|
8711
|
+
if (guestLookup.accountId !== preauthAccountId) {
|
|
8712
|
+
dispatch({
|
|
8713
|
+
type: "GUEST_PREAUTH_DETECTED",
|
|
8714
|
+
accountId: guestLookup.accountId,
|
|
8715
|
+
sessionId: preauthSessionId ?? void 0
|
|
8716
|
+
});
|
|
8717
|
+
}
|
|
8718
|
+
if (!privyAuthenticatedRef.current) {
|
|
8719
|
+
dispatch({ type: "REQUEST_LOGIN" });
|
|
8720
|
+
}
|
|
8635
8721
|
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8636
8722
|
};
|
|
8637
8723
|
const pollGuestPreauthSession = async () => {
|
|
@@ -8666,6 +8752,8 @@ function useMobilePollingEffect(deps) {
|
|
|
8666
8752
|
state.activeCredentialId,
|
|
8667
8753
|
state.guestPreauthSessionId,
|
|
8668
8754
|
state.isGuestFlow,
|
|
8755
|
+
state.guestSessionToken,
|
|
8756
|
+
state.guestPreauthAccountId,
|
|
8669
8757
|
apiBaseUrl,
|
|
8670
8758
|
reloadAccounts,
|
|
8671
8759
|
dispatch,
|
|
@@ -8833,11 +8921,38 @@ function useGuestPreauthMobileRestoreEffect(deps) {
|
|
|
8833
8921
|
]);
|
|
8834
8922
|
if (cancelled) return;
|
|
8835
8923
|
const mobileOpen = session.status !== "AUTHORIZED";
|
|
8924
|
+
let guestLookup = null;
|
|
8925
|
+
if (!mobileOpen) {
|
|
8926
|
+
try {
|
|
8927
|
+
guestLookup = await fetchGuestAccount(
|
|
8928
|
+
apiBaseUrl,
|
|
8929
|
+
persisted.guestSessionToken
|
|
8930
|
+
);
|
|
8931
|
+
} catch {
|
|
8932
|
+
dispatch({
|
|
8933
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8934
|
+
transfer,
|
|
8935
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8936
|
+
});
|
|
8937
|
+
clearMobileFlowState();
|
|
8938
|
+
return;
|
|
8939
|
+
}
|
|
8940
|
+
if (guestLookup == null) {
|
|
8941
|
+
dispatch({
|
|
8942
|
+
type: "MOBILE_RESUME_SUCCESS",
|
|
8943
|
+
transfer,
|
|
8944
|
+
guestCheckoutResume: { guestSessionToken: persisted.guestSessionToken }
|
|
8945
|
+
});
|
|
8946
|
+
clearMobileFlowState();
|
|
8947
|
+
return;
|
|
8948
|
+
}
|
|
8949
|
+
}
|
|
8950
|
+
const guestPreauthAccountId = !mobileOpen && guestLookup != null ? guestLookup.accountId : persisted.accountId;
|
|
8836
8951
|
dispatch({
|
|
8837
8952
|
type: "RESTORE_GUEST_PREAUTH_MOBILE",
|
|
8838
8953
|
transfer,
|
|
8839
8954
|
guestSessionToken: persisted.guestSessionToken,
|
|
8840
|
-
guestPreauthAccountId
|
|
8955
|
+
guestPreauthAccountId,
|
|
8841
8956
|
guestPreauthSessionId: persisted.sessionId,
|
|
8842
8957
|
selectedProviderId: persisted.providerId,
|
|
8843
8958
|
deeplinkUri: persisted.deeplinkUri,
|
|
@@ -8845,7 +8960,7 @@ function useGuestPreauthMobileRestoreEffect(deps) {
|
|
|
8845
8960
|
});
|
|
8846
8961
|
if (mobileOpen) {
|
|
8847
8962
|
mobileSetupFlowRef.current = true;
|
|
8848
|
-
setupAccountIdRef.current = persisted.accountId;
|
|
8963
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
8849
8964
|
} else {
|
|
8850
8965
|
clearMobileFlowState();
|
|
8851
8966
|
}
|