@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 +267 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +267 -135
- 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
|
|
@@ -2535,6 +2535,23 @@ function applyAction(state, action) {
|
|
|
2535
2535
|
};
|
|
2536
2536
|
case "GUEST_PREAUTH_SETUP_COMPLETE_DISMISSED":
|
|
2537
2537
|
return { ...state, guestPreauthSetupCompletePending: false };
|
|
2538
|
+
case "RESTORE_GUEST_PREAUTH_MOBILE":
|
|
2539
|
+
return {
|
|
2540
|
+
...state,
|
|
2541
|
+
transfer: action.transfer,
|
|
2542
|
+
isGuestFlow: true,
|
|
2543
|
+
guestSessionToken: action.guestSessionToken,
|
|
2544
|
+
guestTransferId: action.transfer.id,
|
|
2545
|
+
guestPreauthAccountId: action.guestPreauthAccountId,
|
|
2546
|
+
guestPreauthSessionId: action.guestPreauthSessionId,
|
|
2547
|
+
selectedProviderId: action.selectedProviderId,
|
|
2548
|
+
selectedAccountId: action.guestPreauthAccountId,
|
|
2549
|
+
selectedWalletId: null,
|
|
2550
|
+
selectedTokenSymbol: null,
|
|
2551
|
+
mobileFlow: action.mobileOpen,
|
|
2552
|
+
deeplinkUri: action.mobileOpen ? action.deeplinkUri : null,
|
|
2553
|
+
error: null
|
|
2554
|
+
};
|
|
2538
2555
|
// ── User intent & error ──────────────────────────────────────
|
|
2539
2556
|
case "SET_USER_INTENT":
|
|
2540
2557
|
return { ...state, phase: action.intent };
|
|
@@ -4865,11 +4882,9 @@ function SuccessScreen({
|
|
|
4865
4882
|
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4866
4883
|
/* @__PURE__ */ jsx(PrimaryButton, { onClick: onDone, children: succeeded ? "Done" : "Try again" }),
|
|
4867
4884
|
succeeded && onPreauthorize && /* @__PURE__ */ jsx(
|
|
4868
|
-
|
|
4885
|
+
PrimaryButton,
|
|
4869
4886
|
{
|
|
4870
|
-
type: "button",
|
|
4871
4887
|
onClick: onPreauthorize,
|
|
4872
|
-
style: preauthorizeStyle(tokens.accent, tokens.border),
|
|
4873
4888
|
children: "Preauthorize future transfers"
|
|
4874
4889
|
}
|
|
4875
4890
|
),
|
|
@@ -4997,19 +5012,6 @@ var upsellLinkStyle = (color) => ({
|
|
|
4997
5012
|
fontFamily: "inherit",
|
|
4998
5013
|
padding: 0
|
|
4999
5014
|
});
|
|
5000
|
-
var preauthorizeStyle = (accentColor, borderColor) => ({
|
|
5001
|
-
width: "100%",
|
|
5002
|
-
padding: "14px 0",
|
|
5003
|
-
marginTop: 8,
|
|
5004
|
-
background: "transparent",
|
|
5005
|
-
border: `1px solid ${borderColor}`,
|
|
5006
|
-
borderRadius: 20,
|
|
5007
|
-
color: accentColor,
|
|
5008
|
-
fontWeight: 600,
|
|
5009
|
-
fontSize: "0.92rem",
|
|
5010
|
-
cursor: "pointer",
|
|
5011
|
-
fontFamily: "inherit"
|
|
5012
|
-
});
|
|
5013
5015
|
var manageStyle = (color) => ({
|
|
5014
5016
|
background: "transparent",
|
|
5015
5017
|
border: "none",
|
|
@@ -7311,6 +7313,7 @@ function useProviderHandlers(deps) {
|
|
|
7311
7313
|
merchantAuthorization,
|
|
7312
7314
|
destination,
|
|
7313
7315
|
guestSessionToken,
|
|
7316
|
+
guestTransferId,
|
|
7314
7317
|
selectedProviderId
|
|
7315
7318
|
} = deps;
|
|
7316
7319
|
const wagmiConfig2 = useConfig();
|
|
@@ -7744,7 +7747,9 @@ function useProviderHandlers(deps) {
|
|
|
7744
7747
|
deeplinkUri: created.sessionUri,
|
|
7745
7748
|
providerId: selectedProviderId,
|
|
7746
7749
|
isSetup: true,
|
|
7747
|
-
guestSessionToken
|
|
7750
|
+
guestSessionToken,
|
|
7751
|
+
transferId: guestTransferId ?? void 0,
|
|
7752
|
+
isGuestPreauth: true
|
|
7748
7753
|
});
|
|
7749
7754
|
triggerDeeplink(created.sessionUri);
|
|
7750
7755
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: created.sessionUri });
|
|
@@ -7767,6 +7772,7 @@ function useProviderHandlers(deps) {
|
|
|
7767
7772
|
}
|
|
7768
7773
|
}, [
|
|
7769
7774
|
guestSessionToken,
|
|
7775
|
+
guestTransferId,
|
|
7770
7776
|
selectedProviderId,
|
|
7771
7777
|
providers,
|
|
7772
7778
|
apiBaseUrl,
|
|
@@ -8603,6 +8609,66 @@ function useMobilePollingEffect(deps) {
|
|
|
8603
8609
|
if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
|
|
8604
8610
|
void handleAuthorizedMobileReturnRef.current(polledTransfer, mobileSetupFlowRef.current);
|
|
8605
8611
|
}, [state.mobileFlow, polling.transfer, handlingMobileReturnRef, mobileSetupFlowRef]);
|
|
8612
|
+
useEffect(() => {
|
|
8613
|
+
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8614
|
+
if (!setupAccountIdRef.current) return;
|
|
8615
|
+
if (!state.guestPreauthSessionId || !state.isGuestFlow) return;
|
|
8616
|
+
if (state.activeCredentialId) return;
|
|
8617
|
+
const sessionId = state.guestPreauthSessionId;
|
|
8618
|
+
let cancelled = false;
|
|
8619
|
+
let completedGuestPreauth = false;
|
|
8620
|
+
const POLL_INTERVAL_MS = 3e3;
|
|
8621
|
+
const completeGuestPreauthSetup = async () => {
|
|
8622
|
+
if (completedGuestPreauth) return;
|
|
8623
|
+
completedGuestPreauth = true;
|
|
8624
|
+
cancelled = true;
|
|
8625
|
+
mobileSetupFlowRef.current = false;
|
|
8626
|
+
setupAccountIdRef.current = null;
|
|
8627
|
+
clearMobileFlowState();
|
|
8628
|
+
try {
|
|
8629
|
+
await reloadAccounts();
|
|
8630
|
+
} catch {
|
|
8631
|
+
}
|
|
8632
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8633
|
+
};
|
|
8634
|
+
const pollGuestPreauthSession = async () => {
|
|
8635
|
+
try {
|
|
8636
|
+
if (cancelled) return;
|
|
8637
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, sessionId);
|
|
8638
|
+
if (cancelled) return;
|
|
8639
|
+
if (session.status === "AUTHORIZED") {
|
|
8640
|
+
await completeGuestPreauthSetup();
|
|
8641
|
+
}
|
|
8642
|
+
} catch {
|
|
8643
|
+
}
|
|
8644
|
+
};
|
|
8645
|
+
pollGuestPreauthSession();
|
|
8646
|
+
const intervalId = window.setInterval(pollGuestPreauthSession, POLL_INTERVAL_MS);
|
|
8647
|
+
const handleVisibility = () => {
|
|
8648
|
+
if (document.visibilityState === "visible" && !cancelled) void pollGuestPreauthSession();
|
|
8649
|
+
};
|
|
8650
|
+
const handlePageShow = (e) => {
|
|
8651
|
+
if (e.persisted && !cancelled) void pollGuestPreauthSession();
|
|
8652
|
+
};
|
|
8653
|
+
document.addEventListener("visibilitychange", handleVisibility);
|
|
8654
|
+
window.addEventListener("pageshow", handlePageShow);
|
|
8655
|
+
return () => {
|
|
8656
|
+
cancelled = true;
|
|
8657
|
+
window.clearInterval(intervalId);
|
|
8658
|
+
document.removeEventListener("visibilitychange", handleVisibility);
|
|
8659
|
+
window.removeEventListener("pageshow", handlePageShow);
|
|
8660
|
+
};
|
|
8661
|
+
}, [
|
|
8662
|
+
state.mobileFlow,
|
|
8663
|
+
state.activeCredentialId,
|
|
8664
|
+
state.guestPreauthSessionId,
|
|
8665
|
+
state.isGuestFlow,
|
|
8666
|
+
apiBaseUrl,
|
|
8667
|
+
reloadAccounts,
|
|
8668
|
+
dispatch,
|
|
8669
|
+
mobileSetupFlowRef,
|
|
8670
|
+
setupAccountIdRef
|
|
8671
|
+
]);
|
|
8606
8672
|
useEffect(() => {
|
|
8607
8673
|
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8608
8674
|
if (!state.activeCredentialId || !setupAccountIdRef.current) return;
|
|
@@ -8733,6 +8799,63 @@ function useMobilePollingEffect(deps) {
|
|
|
8733
8799
|
pollingTransferIdRef
|
|
8734
8800
|
]);
|
|
8735
8801
|
}
|
|
8802
|
+
var guestPreauthRestoreAttemptedKeys = /* @__PURE__ */ new Set();
|
|
8803
|
+
function guestPreauthRestoreKey(sessionId, transferId) {
|
|
8804
|
+
return `${sessionId}:${transferId}`;
|
|
8805
|
+
}
|
|
8806
|
+
function useGuestPreauthMobileRestoreEffect(deps) {
|
|
8807
|
+
const {
|
|
8808
|
+
dispatch,
|
|
8809
|
+
apiBaseUrl,
|
|
8810
|
+
privyReady,
|
|
8811
|
+
authenticated,
|
|
8812
|
+
mobileSetupFlowRef,
|
|
8813
|
+
setupAccountIdRef
|
|
8814
|
+
} = deps;
|
|
8815
|
+
useEffect(() => {
|
|
8816
|
+
if (!privyReady || authenticated) return;
|
|
8817
|
+
const persisted = loadMobileFlowState();
|
|
8818
|
+
if (!persisted?.isGuestPreauth || !persisted.transferId || !persisted.guestSessionToken || !persisted.sessionId || !persisted.deeplinkUri || persisted.accountId == null) {
|
|
8819
|
+
return;
|
|
8820
|
+
}
|
|
8821
|
+
const key = guestPreauthRestoreKey(persisted.sessionId, persisted.transferId);
|
|
8822
|
+
if (guestPreauthRestoreAttemptedKeys.has(key)) return;
|
|
8823
|
+
guestPreauthRestoreAttemptedKeys.add(key);
|
|
8824
|
+
let cancelled = false;
|
|
8825
|
+
void (async () => {
|
|
8826
|
+
try {
|
|
8827
|
+
const [transfer, session] = await Promise.all([
|
|
8828
|
+
getGuestTransfer(apiBaseUrl, persisted.transferId, persisted.guestSessionToken),
|
|
8829
|
+
fetchAuthorizationSession(apiBaseUrl, persisted.sessionId)
|
|
8830
|
+
]);
|
|
8831
|
+
if (cancelled) return;
|
|
8832
|
+
const mobileOpen = session.status !== "AUTHORIZED";
|
|
8833
|
+
dispatch({
|
|
8834
|
+
type: "RESTORE_GUEST_PREAUTH_MOBILE",
|
|
8835
|
+
transfer,
|
|
8836
|
+
guestSessionToken: persisted.guestSessionToken,
|
|
8837
|
+
guestPreauthAccountId: persisted.accountId,
|
|
8838
|
+
guestPreauthSessionId: persisted.sessionId,
|
|
8839
|
+
selectedProviderId: persisted.providerId,
|
|
8840
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
8841
|
+
mobileOpen
|
|
8842
|
+
});
|
|
8843
|
+
if (mobileOpen) {
|
|
8844
|
+
mobileSetupFlowRef.current = true;
|
|
8845
|
+
setupAccountIdRef.current = persisted.accountId;
|
|
8846
|
+
} else {
|
|
8847
|
+
clearMobileFlowState();
|
|
8848
|
+
}
|
|
8849
|
+
} catch (err) {
|
|
8850
|
+
guestPreauthRestoreAttemptedKeys.delete(key);
|
|
8851
|
+
captureException(err);
|
|
8852
|
+
}
|
|
8853
|
+
})();
|
|
8854
|
+
return () => {
|
|
8855
|
+
cancelled = true;
|
|
8856
|
+
};
|
|
8857
|
+
}, [privyReady, authenticated, apiBaseUrl, dispatch, mobileSetupFlowRef, setupAccountIdRef]);
|
|
8858
|
+
}
|
|
8736
8859
|
function useSelectSourceEffect(deps) {
|
|
8737
8860
|
const {
|
|
8738
8861
|
pendingSelectSourceAction,
|
|
@@ -9108,6 +9231,7 @@ function BlinkPaymentInner({
|
|
|
9108
9231
|
merchantAuthorization,
|
|
9109
9232
|
destination,
|
|
9110
9233
|
guestSessionToken: state.guestSessionToken,
|
|
9234
|
+
guestTransferId: state.guestTransferId,
|
|
9111
9235
|
selectedProviderId: state.selectedProviderId
|
|
9112
9236
|
});
|
|
9113
9237
|
const guestPostPayPreauth = useMemo(
|
|
@@ -9169,6 +9293,14 @@ function BlinkPaymentInner({
|
|
|
9169
9293
|
}
|
|
9170
9294
|
}, [depositAmount, dispatch]);
|
|
9171
9295
|
usePrivySessionSyncEffect({ dispatch, ready, authenticated });
|
|
9296
|
+
useGuestPreauthMobileRestoreEffect({
|
|
9297
|
+
dispatch,
|
|
9298
|
+
apiBaseUrl,
|
|
9299
|
+
privyReady: state.privyReady,
|
|
9300
|
+
authenticated,
|
|
9301
|
+
mobileSetupFlowRef: mobileFlowRefs.mobileSetupFlowRef,
|
|
9302
|
+
setupAccountIdRef: mobileFlowRefs.setupAccountIdRef
|
|
9303
|
+
});
|
|
9172
9304
|
useOtpEffects({
|
|
9173
9305
|
state,
|
|
9174
9306
|
dispatch,
|