@swype-org/react-sdk 0.1.241 → 0.1.251
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 +217 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +217 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -828,7 +828,7 @@ interface NormalizedAuthIdentifier {
|
|
|
828
828
|
value: string;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
type ScreenName = 'loading' | 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'success' | 'processing' | 'confirm-sign' | 'select-source' | 'setup' | 'open-wallet' | 'setup-status' | 'guest-token-picker' | 'wallet-picker' | 'token-picker' | 'deposit';
|
|
831
|
+
type ScreenName = 'loading' | 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'success' | 'processing' | 'confirm-sign' | 'select-source' | 'setup' | 'open-wallet' | 'setup-status' | 'guest-token-picker' | 'wallet-picker' | 'token-picker' | 'deposit' | 'guest-setup-complete';
|
|
832
832
|
interface MobileFlowState {
|
|
833
833
|
deeplinkUri: string;
|
|
834
834
|
providerId: string | null;
|
|
@@ -854,6 +854,8 @@ type PaymentPhase = {
|
|
|
854
854
|
step: 'wallet-setup';
|
|
855
855
|
mobile: MobileFlowState | null;
|
|
856
856
|
accountId: string | null;
|
|
857
|
+
/** Desktop: use OpenWalletScreen (extension popups) instead of SetupStatusScreen. */
|
|
858
|
+
guestDesktopExtension?: boolean;
|
|
857
859
|
} | {
|
|
858
860
|
step: 'select-source';
|
|
859
861
|
action: AuthorizationAction;
|
|
@@ -880,6 +882,8 @@ type PaymentPhase = {
|
|
|
880
882
|
step: 'failed';
|
|
881
883
|
transfer: Transfer;
|
|
882
884
|
error: string;
|
|
885
|
+
} | {
|
|
886
|
+
step: 'guest-setup-complete';
|
|
883
887
|
};
|
|
884
888
|
declare function screenForPhase(phase: PaymentPhase): ScreenName;
|
|
885
889
|
|
package/dist/index.d.ts
CHANGED
|
@@ -828,7 +828,7 @@ interface NormalizedAuthIdentifier {
|
|
|
828
828
|
value: string;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
type ScreenName = 'loading' | 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'success' | 'processing' | 'confirm-sign' | 'select-source' | 'setup' | 'open-wallet' | 'setup-status' | 'guest-token-picker' | 'wallet-picker' | 'token-picker' | 'deposit';
|
|
831
|
+
type ScreenName = 'loading' | 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'success' | 'processing' | 'confirm-sign' | 'select-source' | 'setup' | 'open-wallet' | 'setup-status' | 'guest-token-picker' | 'wallet-picker' | 'token-picker' | 'deposit' | 'guest-setup-complete';
|
|
832
832
|
interface MobileFlowState {
|
|
833
833
|
deeplinkUri: string;
|
|
834
834
|
providerId: string | null;
|
|
@@ -854,6 +854,8 @@ type PaymentPhase = {
|
|
|
854
854
|
step: 'wallet-setup';
|
|
855
855
|
mobile: MobileFlowState | null;
|
|
856
856
|
accountId: string | null;
|
|
857
|
+
/** Desktop: use OpenWalletScreen (extension popups) instead of SetupStatusScreen. */
|
|
858
|
+
guestDesktopExtension?: boolean;
|
|
857
859
|
} | {
|
|
858
860
|
step: 'select-source';
|
|
859
861
|
action: AuthorizationAction;
|
|
@@ -880,6 +882,8 @@ type PaymentPhase = {
|
|
|
880
882
|
step: 'failed';
|
|
881
883
|
transfer: Transfer;
|
|
882
884
|
error: string;
|
|
885
|
+
} | {
|
|
886
|
+
step: 'guest-setup-complete';
|
|
883
887
|
};
|
|
884
888
|
declare function screenForPhase(phase: PaymentPhase): ScreenName;
|
|
885
889
|
|
package/dist/index.js
CHANGED
|
@@ -2008,7 +2008,8 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
|
2008
2008
|
case "one-tap-setup":
|
|
2009
2009
|
case "token-picker":
|
|
2010
2010
|
case "login":
|
|
2011
|
-
|
|
2011
|
+
// otp-verify not pinned: after OTP, verificationTarget clears but phase can be stale until
|
|
2012
|
+
// resolvePhase runs; pinning would block passkey.
|
|
2012
2013
|
case "passkey-create":
|
|
2013
2014
|
case "passkey-verify":
|
|
2014
2015
|
case "data-loading":
|
|
@@ -2021,11 +2022,20 @@ function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
|
2021
2022
|
}
|
|
2022
2023
|
function resolvePhase(state) {
|
|
2023
2024
|
const p = state.phase;
|
|
2024
|
-
if (state.
|
|
2025
|
+
if (state.guestPreauthSetupCompletePending && state.privyReady && state.privyAuthenticated) {
|
|
2026
|
+
return { step: "guest-setup-complete" };
|
|
2027
|
+
}
|
|
2028
|
+
if (state.transfer?.status === "COMPLETED" && state.guestPreauthorizing && !state.verificationTarget && isGuestPreauthCompletedTransferPinPhase(p)) {
|
|
2025
2029
|
return p;
|
|
2026
2030
|
}
|
|
2027
|
-
if (state.transfer?.status === "COMPLETED") {
|
|
2028
|
-
return { step: "
|
|
2031
|
+
if (state.transfer?.status === "COMPLETED" && state.isGuestFlow && state.guestPreauthSessionId && !state.guestPreauthorizing && !state.verificationTarget && !state.privyAuthenticated) {
|
|
2032
|
+
return { step: "login" };
|
|
2033
|
+
}
|
|
2034
|
+
if (state.transfer?.status === "COMPLETED" && !state.verificationTarget) {
|
|
2035
|
+
const needsPasskeyBootstrap = state.privyAuthenticated && !state.activeCredentialId;
|
|
2036
|
+
if (!needsPasskeyBootstrap) {
|
|
2037
|
+
return { step: "completed", transfer: state.transfer };
|
|
2038
|
+
}
|
|
2029
2039
|
}
|
|
2030
2040
|
if (state.transfer?.status === "FAILED") {
|
|
2031
2041
|
return { step: "failed", transfer: state.transfer, error: state.error ?? "Transfer failed." };
|
|
@@ -2043,10 +2053,10 @@ function resolvePhase(state) {
|
|
|
2043
2053
|
accountId: null
|
|
2044
2054
|
};
|
|
2045
2055
|
}
|
|
2046
|
-
if (p.step === "wallet-setup" && p.mobile == null) {
|
|
2056
|
+
if (p.step === "wallet-setup" && p.mobile == null && state.guestPreauthorizing) {
|
|
2047
2057
|
return p;
|
|
2048
2058
|
}
|
|
2049
|
-
if (state.isGuestFlow && state.selectedProviderId != null && !state.transfer) {
|
|
2059
|
+
if (state.isGuestFlow && state.selectedProviderId != null && !state.transfer && !state.guestPreauthAccountId) {
|
|
2050
2060
|
return { step: "guest-token-picker" };
|
|
2051
2061
|
}
|
|
2052
2062
|
if (p.step === "wallet-picker" && !state.creatingTransfer && !(state.mobileFlow && state.deeplinkUri)) {
|
|
@@ -2058,7 +2068,7 @@ function resolvePhase(state) {
|
|
|
2058
2068
|
if (state.privyAuthenticated && !state.activeCredentialId && !state.passkeyConfigLoaded) {
|
|
2059
2069
|
return { step: "initializing" };
|
|
2060
2070
|
}
|
|
2061
|
-
if (state.verificationTarget) {
|
|
2071
|
+
if (state.verificationTarget && !state.privyAuthenticated) {
|
|
2062
2072
|
return { step: "otp-verify", target: state.verificationTarget };
|
|
2063
2073
|
}
|
|
2064
2074
|
if (state.loginRequested) {
|
|
@@ -2130,13 +2140,26 @@ function createInitialState(config) {
|
|
|
2130
2140
|
activePublicKey: null,
|
|
2131
2141
|
loginRequested: false,
|
|
2132
2142
|
guestPreauthorizing: false,
|
|
2143
|
+
guestPreauthSetupCompletePending: false,
|
|
2133
2144
|
privyReady: false,
|
|
2134
2145
|
privyAuthenticated: false
|
|
2135
2146
|
};
|
|
2136
2147
|
}
|
|
2137
2148
|
function paymentReducer(state, action) {
|
|
2138
2149
|
const next = applyAction(state, action);
|
|
2139
|
-
|
|
2150
|
+
const phase = resolvePhase(next);
|
|
2151
|
+
if (action.type === "CODE_SENT") {
|
|
2152
|
+
console.debug("[Swype SDK] login code sent", {
|
|
2153
|
+
resolvedPhase: phase.step,
|
|
2154
|
+
verificationTargetKind: action.target.kind,
|
|
2155
|
+
guestPreauthorizing: next.guestPreauthorizing,
|
|
2156
|
+
transferStatus: next.transfer?.status ?? null,
|
|
2157
|
+
isGuestFlow: next.isGuestFlow,
|
|
2158
|
+
hasGuestPreauthSessionId: next.guestPreauthSessionId != null,
|
|
2159
|
+
loginRequested: next.loginRequested
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
return { ...next, phase };
|
|
2140
2163
|
}
|
|
2141
2164
|
function applyAction(state, action) {
|
|
2142
2165
|
switch (action.type) {
|
|
@@ -2397,13 +2420,20 @@ function applyAction(state, action) {
|
|
|
2397
2420
|
case "ACCOUNT_OWNER_SET":
|
|
2398
2421
|
return {
|
|
2399
2422
|
...state,
|
|
2423
|
+
transfer: null,
|
|
2400
2424
|
guestPreauthAccountId: null,
|
|
2401
2425
|
guestPreauthSessionId: null,
|
|
2402
2426
|
activePublicKey: null,
|
|
2403
2427
|
error: null,
|
|
2404
2428
|
guestPreauthorizing: false,
|
|
2405
|
-
|
|
2429
|
+
isGuestFlow: false,
|
|
2430
|
+
selectedProviderId: null,
|
|
2431
|
+
guestTransferId: null,
|
|
2432
|
+
guestSessionToken: null,
|
|
2433
|
+
guestPreauthSetupCompletePending: true
|
|
2406
2434
|
};
|
|
2435
|
+
case "GUEST_PREAUTH_SETUP_COMPLETE_DISMISSED":
|
|
2436
|
+
return { ...state, guestPreauthSetupCompletePending: false };
|
|
2407
2437
|
// ── User intent & error ──────────────────────────────────────
|
|
2408
2438
|
case "SET_USER_INTENT":
|
|
2409
2439
|
return { ...state, phase: action.intent };
|
|
@@ -2438,7 +2468,8 @@ function applyAction(state, action) {
|
|
|
2438
2468
|
activePublicKey: null,
|
|
2439
2469
|
loginRequested: false,
|
|
2440
2470
|
oneTapLimitSavedDuringSetup: false,
|
|
2441
|
-
guestPreauthorizing: false
|
|
2471
|
+
guestPreauthorizing: false,
|
|
2472
|
+
guestPreauthSetupCompletePending: false
|
|
2442
2473
|
};
|
|
2443
2474
|
case "LOGOUT":
|
|
2444
2475
|
return {
|
|
@@ -2454,7 +2485,10 @@ function applyAction(state, action) {
|
|
|
2454
2485
|
return {
|
|
2455
2486
|
...state,
|
|
2456
2487
|
privyReady: action.ready,
|
|
2457
|
-
privyAuthenticated: action.authenticated
|
|
2488
|
+
privyAuthenticated: action.authenticated,
|
|
2489
|
+
// OTP complete: Privy is source of truth; clear so resolvePhase can leave otp-verify
|
|
2490
|
+
// and guest-preauth pin rules cannot re-pin a stale otp-verify phase.
|
|
2491
|
+
...action.authenticated ? { verificationTarget: null, loginRequested: false } : {}
|
|
2458
2492
|
};
|
|
2459
2493
|
case "SYNC_AMOUNT":
|
|
2460
2494
|
return { ...state, amount: action.amount };
|
|
@@ -2520,7 +2554,10 @@ function screenForPhase(phase) {
|
|
|
2520
2554
|
case "wallet-picker":
|
|
2521
2555
|
return "wallet-picker";
|
|
2522
2556
|
case "wallet-setup":
|
|
2523
|
-
|
|
2557
|
+
if (phase.mobile || phase.guestDesktopExtension) {
|
|
2558
|
+
return "open-wallet";
|
|
2559
|
+
}
|
|
2560
|
+
return "setup-status";
|
|
2524
2561
|
case "select-source":
|
|
2525
2562
|
return phase.isDesktop ? "setup" : "select-source";
|
|
2526
2563
|
case "one-tap-setup":
|
|
@@ -2538,6 +2575,8 @@ function screenForPhase(phase) {
|
|
|
2538
2575
|
case "completed":
|
|
2539
2576
|
case "failed":
|
|
2540
2577
|
return "success";
|
|
2578
|
+
case "guest-setup-complete":
|
|
2579
|
+
return "guest-setup-complete";
|
|
2541
2580
|
}
|
|
2542
2581
|
}
|
|
2543
2582
|
var MUTED = "#7fa4b0";
|
|
@@ -6007,6 +6046,60 @@ var emptyStyle = (color) => ({
|
|
|
6007
6046
|
padding: "32px 0",
|
|
6008
6047
|
lineHeight: 1.5
|
|
6009
6048
|
});
|
|
6049
|
+
function GuestPreauthSetupCompleteScreen({
|
|
6050
|
+
onClose,
|
|
6051
|
+
onLogout
|
|
6052
|
+
}) {
|
|
6053
|
+
const { tokens } = useBlinkConfig();
|
|
6054
|
+
return /* @__PURE__ */ jsxs(
|
|
6055
|
+
ScreenLayout,
|
|
6056
|
+
{
|
|
6057
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6058
|
+
/* @__PURE__ */ jsx(PrimaryButton, { onClick: onClose, children: "Close" }),
|
|
6059
|
+
/* @__PURE__ */ jsx(PoweredByFooter, {})
|
|
6060
|
+
] }),
|
|
6061
|
+
children: [
|
|
6062
|
+
/* @__PURE__ */ jsx(ScreenHeader, { onLogout }),
|
|
6063
|
+
/* @__PURE__ */ jsxs("div", { style: contentStyle9, children: [
|
|
6064
|
+
/* @__PURE__ */ jsx(IconCircle, { variant: "success", size: 64, children: /* @__PURE__ */ jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
|
|
6065
|
+
"path",
|
|
6066
|
+
{
|
|
6067
|
+
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",
|
|
6068
|
+
fill: tokens.success
|
|
6069
|
+
}
|
|
6070
|
+
) }) }),
|
|
6071
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle12(tokens.text), children: "Setup complete" }),
|
|
6072
|
+
/* @__PURE__ */ jsx("p", { style: subtitleStyle10(tokens.textSecondary), children: "Your account is linked and ready. You can close this window or make another deposit." })
|
|
6073
|
+
] })
|
|
6074
|
+
]
|
|
6075
|
+
}
|
|
6076
|
+
);
|
|
6077
|
+
}
|
|
6078
|
+
var contentStyle9 = {
|
|
6079
|
+
display: "flex",
|
|
6080
|
+
flexDirection: "column",
|
|
6081
|
+
alignItems: "center",
|
|
6082
|
+
textAlign: "center",
|
|
6083
|
+
gap: 12,
|
|
6084
|
+
paddingTop: 8
|
|
6085
|
+
};
|
|
6086
|
+
function headingStyle12(color) {
|
|
6087
|
+
return {
|
|
6088
|
+
margin: 0,
|
|
6089
|
+
fontSize: 22,
|
|
6090
|
+
fontWeight: 600,
|
|
6091
|
+
color
|
|
6092
|
+
};
|
|
6093
|
+
}
|
|
6094
|
+
function subtitleStyle10(color) {
|
|
6095
|
+
return {
|
|
6096
|
+
margin: 0,
|
|
6097
|
+
fontSize: 15,
|
|
6098
|
+
lineHeight: 1.45,
|
|
6099
|
+
color,
|
|
6100
|
+
maxWidth: 320
|
|
6101
|
+
};
|
|
6102
|
+
}
|
|
6010
6103
|
var LINK_SCREENS = /* @__PURE__ */ new Set([
|
|
6011
6104
|
"create-passkey",
|
|
6012
6105
|
"verify-passkey",
|
|
@@ -6308,6 +6401,14 @@ function StepRendererContent({
|
|
|
6308
6401
|
onBack: handlers.onGuestBackFromTokenPicker
|
|
6309
6402
|
}
|
|
6310
6403
|
);
|
|
6404
|
+
case "guest-setup-complete":
|
|
6405
|
+
return /* @__PURE__ */ jsx(
|
|
6406
|
+
GuestPreauthSetupCompleteScreen,
|
|
6407
|
+
{
|
|
6408
|
+
onClose: handlers.onGuestSetupCompleteClose,
|
|
6409
|
+
onLogout: handlers.onLogout
|
|
6410
|
+
}
|
|
6411
|
+
);
|
|
6311
6412
|
case "processing": {
|
|
6312
6413
|
const polledStatus = pollingTransfer?.status;
|
|
6313
6414
|
const transferPhase = state.creatingTransfer ? "creating" : polledStatus === "SENDING" || polledStatus === "SENT" ? "sent" : "verifying";
|
|
@@ -6401,7 +6502,7 @@ var PaymentErrorBoundary = class extends Component {
|
|
|
6401
6502
|
/* @__PURE__ */ jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
6402
6503
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
|
|
6403
6504
|
] }) }),
|
|
6404
|
-
/* @__PURE__ */ jsx("h2", { style:
|
|
6505
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle13, children: "Something went wrong" }),
|
|
6405
6506
|
/* @__PURE__ */ jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
|
|
6406
6507
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
|
|
6407
6508
|
] });
|
|
@@ -6421,7 +6522,7 @@ var containerStyle9 = {
|
|
|
6421
6522
|
var iconStyle3 = {
|
|
6422
6523
|
marginBottom: 20
|
|
6423
6524
|
};
|
|
6424
|
-
var
|
|
6525
|
+
var headingStyle13 = {
|
|
6425
6526
|
fontSize: "1.25rem",
|
|
6426
6527
|
fontWeight: 700,
|
|
6427
6528
|
color: "#1a1a1a",
|
|
@@ -6920,18 +7021,31 @@ function useSourceSelectionHandlers(dispatch, authExecutor, options) {
|
|
|
6920
7021
|
[selectSourceChoices, selectSourceRecommended]
|
|
6921
7022
|
);
|
|
6922
7023
|
const handleConfirmSelectSource = useCallback(() => {
|
|
7024
|
+
const guestPostPayPreauth = !!options?.guestPreauthSessionId && !!options?.isGuestFlow || !!options?.guestPreauthorizing && !!options?.isDesktop;
|
|
7025
|
+
if (guestPostPayPreauth) {
|
|
7026
|
+
dispatch({ type: "REQUEST_LOGIN" });
|
|
7027
|
+
if (options?.guestPreauthAccountId != null) {
|
|
7028
|
+
const intent = {
|
|
7029
|
+
step: "wallet-setup",
|
|
7030
|
+
mobile: null,
|
|
7031
|
+
accountId: options.guestPreauthAccountId,
|
|
7032
|
+
guestDesktopExtension: true
|
|
7033
|
+
};
|
|
7034
|
+
dispatch({ type: "SET_USER_INTENT", intent });
|
|
7035
|
+
}
|
|
7036
|
+
}
|
|
6923
7037
|
authExecutor.resolveSelectSource({
|
|
6924
7038
|
chainName: selectSourceChainName,
|
|
6925
7039
|
tokenSymbol: selectSourceTokenSymbol
|
|
6926
7040
|
});
|
|
6927
|
-
if (options?.guestPreauthorizing && options?.isDesktop) {
|
|
6928
|
-
dispatch({ type: "REQUEST_LOGIN" });
|
|
6929
|
-
}
|
|
6930
7041
|
}, [
|
|
6931
7042
|
authExecutor,
|
|
6932
7043
|
dispatch,
|
|
7044
|
+
options?.guestPreauthSessionId,
|
|
7045
|
+
options?.guestPreauthAccountId,
|
|
6933
7046
|
options?.guestPreauthorizing,
|
|
6934
7047
|
options?.isDesktop,
|
|
7048
|
+
options?.isGuestFlow,
|
|
6935
7049
|
selectSourceChainName,
|
|
6936
7050
|
selectSourceTokenSymbol
|
|
6937
7051
|
]);
|
|
@@ -8308,6 +8422,10 @@ function useProcessingEffect(deps) {
|
|
|
8308
8422
|
} = deps;
|
|
8309
8423
|
useEffect(() => {
|
|
8310
8424
|
if (!polling.transfer) return;
|
|
8425
|
+
if (state.loginRequested || state.verificationTarget) return;
|
|
8426
|
+
if (!state.transfer && (polling.transfer.status === "COMPLETED" || polling.transfer.status === "FAILED")) {
|
|
8427
|
+
return;
|
|
8428
|
+
}
|
|
8311
8429
|
if (polling.transfer.status === "COMPLETED") {
|
|
8312
8430
|
clearMobileFlowState();
|
|
8313
8431
|
dispatch({ type: "TRANSFER_COMPLETED", transfer: polling.transfer });
|
|
@@ -8317,7 +8435,15 @@ function useProcessingEffect(deps) {
|
|
|
8317
8435
|
clearMobileFlowState();
|
|
8318
8436
|
dispatch({ type: "TRANSFER_FAILED", transfer: polling.transfer, error: "Transfer failed." });
|
|
8319
8437
|
}
|
|
8320
|
-
}, [
|
|
8438
|
+
}, [
|
|
8439
|
+
polling.transfer,
|
|
8440
|
+
state.transfer,
|
|
8441
|
+
state.loginRequested,
|
|
8442
|
+
state.verificationTarget,
|
|
8443
|
+
onComplete,
|
|
8444
|
+
dispatch,
|
|
8445
|
+
reloadAccounts
|
|
8446
|
+
]);
|
|
8321
8447
|
useEffect(() => {
|
|
8322
8448
|
const isProcessing = state.creatingTransfer || state.transfer != null && ["CREATED", "SENDING", "SENT"].includes(state.transfer.status);
|
|
8323
8449
|
if (!isProcessing) {
|
|
@@ -8568,6 +8694,42 @@ function useOneTapAutoResolveEffect(deps) {
|
|
|
8568
8694
|
}
|
|
8569
8695
|
}, [pendingOneTapSetupAction, reloadAccounts, oneTapLimitSavedDuringSetup]);
|
|
8570
8696
|
}
|
|
8697
|
+
|
|
8698
|
+
// src/guestPreauthClaimWait.ts
|
|
8699
|
+
var GUEST_PREAUTH_SESSION_POLL_INTERVAL_MS = 1e3;
|
|
8700
|
+
var GUEST_PREAUTH_SESSION_POLL_TIMEOUT_MS = 12e4;
|
|
8701
|
+
async function waitForGuestPreauthAuthorizationSession(apiBaseUrl, sessionId, fetchSession, signal, options) {
|
|
8702
|
+
const intervalMs = GUEST_PREAUTH_SESSION_POLL_INTERVAL_MS;
|
|
8703
|
+
const timeoutMs = GUEST_PREAUTH_SESSION_POLL_TIMEOUT_MS;
|
|
8704
|
+
const deadline = Date.now() + timeoutMs;
|
|
8705
|
+
const sleepAbortable = (ms) => new Promise((resolve, reject) => {
|
|
8706
|
+
if (signal.aborted) {
|
|
8707
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
8708
|
+
return;
|
|
8709
|
+
}
|
|
8710
|
+
const t = setTimeout(() => {
|
|
8711
|
+
signal.removeEventListener("abort", onAbort);
|
|
8712
|
+
resolve();
|
|
8713
|
+
}, ms);
|
|
8714
|
+
const onAbort = () => {
|
|
8715
|
+
clearTimeout(t);
|
|
8716
|
+
signal.removeEventListener("abort", onAbort);
|
|
8717
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
8718
|
+
};
|
|
8719
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
8720
|
+
});
|
|
8721
|
+
while (Date.now() < deadline) {
|
|
8722
|
+
if (signal.aborted) {
|
|
8723
|
+
throw new DOMException("Aborted", "AbortError");
|
|
8724
|
+
}
|
|
8725
|
+
const session = await fetchSession(apiBaseUrl, sessionId);
|
|
8726
|
+
if (session.status === "AUTHORIZED") return;
|
|
8727
|
+
await sleepAbortable(intervalMs);
|
|
8728
|
+
}
|
|
8729
|
+
throw new Error("Authorization session did not become AUTHORIZED in time.");
|
|
8730
|
+
}
|
|
8731
|
+
|
|
8732
|
+
// src/hooks/useGuestPreauthEffect.ts
|
|
8571
8733
|
function useGuestPreauthEffect(deps) {
|
|
8572
8734
|
const { state, dispatch, authenticated, apiBaseUrl, reloadAccounts } = deps;
|
|
8573
8735
|
const { getAccessToken } = usePrivy();
|
|
@@ -8581,12 +8743,25 @@ function useGuestPreauthEffect(deps) {
|
|
|
8581
8743
|
if (!authenticated) return;
|
|
8582
8744
|
if (!state.guestSessionToken) return;
|
|
8583
8745
|
if (settingOwnerRef.current) return;
|
|
8584
|
-
const hasActive = state.accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
|
|
8585
|
-
if (!hasActive) return;
|
|
8586
8746
|
settingOwnerRef.current = true;
|
|
8747
|
+
const abort = new AbortController();
|
|
8587
8748
|
let cancelled = false;
|
|
8588
8749
|
const setOwner = async () => {
|
|
8589
8750
|
try {
|
|
8751
|
+
if (state.guestPreauthSessionId) {
|
|
8752
|
+
try {
|
|
8753
|
+
await waitForGuestPreauthAuthorizationSession(
|
|
8754
|
+
apiBaseUrl,
|
|
8755
|
+
state.guestPreauthSessionId,
|
|
8756
|
+
fetchAuthorizationSession,
|
|
8757
|
+
abort.signal
|
|
8758
|
+
);
|
|
8759
|
+
} catch (waitErr) {
|
|
8760
|
+
if (waitErr instanceof DOMException && waitErr.name === "AbortError") return;
|
|
8761
|
+
throw waitErr;
|
|
8762
|
+
}
|
|
8763
|
+
}
|
|
8764
|
+
if (cancelled) return;
|
|
8590
8765
|
const token = await getAccessTokenRef.current();
|
|
8591
8766
|
if (!token || cancelled) return;
|
|
8592
8767
|
await setAccountOwner(apiBaseUrl, token, state.guestPreauthAccountId, state.guestSessionToken, {
|
|
@@ -8611,16 +8786,17 @@ function useGuestPreauthEffect(deps) {
|
|
|
8611
8786
|
settingOwnerRef.current = false;
|
|
8612
8787
|
}
|
|
8613
8788
|
};
|
|
8614
|
-
setOwner();
|
|
8789
|
+
void setOwner();
|
|
8615
8790
|
return () => {
|
|
8616
8791
|
cancelled = true;
|
|
8792
|
+
abort.abort();
|
|
8617
8793
|
};
|
|
8618
8794
|
}, [
|
|
8619
8795
|
state.guestPreauthAccountId,
|
|
8796
|
+
state.guestPreauthSessionId,
|
|
8620
8797
|
state.activeCredentialId,
|
|
8621
8798
|
state.activePublicKey,
|
|
8622
8799
|
state.guestSessionToken,
|
|
8623
|
-
state.accounts,
|
|
8624
8800
|
authenticated,
|
|
8625
8801
|
apiBaseUrl,
|
|
8626
8802
|
dispatch,
|
|
@@ -8691,24 +8867,23 @@ function useGuestPreauthPhaseSyncEffect(deps) {
|
|
|
8691
8867
|
]);
|
|
8692
8868
|
}
|
|
8693
8869
|
function useGuestPreauthWalletSetupEffect(deps) {
|
|
8694
|
-
const { state, dispatch, authExecutor, isDesktop
|
|
8870
|
+
const { state, dispatch, authExecutor, isDesktop } = deps;
|
|
8695
8871
|
useEffect(() => {
|
|
8696
8872
|
if (!isDesktop || !state.guestPreauthorizing || !state.guestPreauthSessionId) return;
|
|
8873
|
+
if (!state.guestPreauthAccountId) return;
|
|
8697
8874
|
if (!authExecutor.executing || authExecutor.pendingSelectSource) return;
|
|
8698
|
-
if (!privyAuthenticated || !state.activeCredentialId) return;
|
|
8699
8875
|
if (state.verificationTarget) return;
|
|
8700
|
-
if (state.loginRequested) return;
|
|
8701
8876
|
const p = state.phase;
|
|
8702
|
-
if (p.step === "wallet-setup" && p.mobile == null) {
|
|
8703
|
-
|
|
8704
|
-
if (id != null && p.accountId === id) return;
|
|
8877
|
+
if (p.step === "wallet-setup" && p.mobile == null && p.guestDesktopExtension && p.accountId === state.guestPreauthAccountId) {
|
|
8878
|
+
return;
|
|
8705
8879
|
}
|
|
8706
8880
|
dispatch({
|
|
8707
8881
|
type: "SET_USER_INTENT",
|
|
8708
8882
|
intent: {
|
|
8709
8883
|
step: "wallet-setup",
|
|
8710
8884
|
mobile: null,
|
|
8711
|
-
accountId: state.guestPreauthAccountId
|
|
8885
|
+
accountId: state.guestPreauthAccountId,
|
|
8886
|
+
guestDesktopExtension: true
|
|
8712
8887
|
}
|
|
8713
8888
|
});
|
|
8714
8889
|
}, [
|
|
@@ -8716,14 +8891,11 @@ function useGuestPreauthWalletSetupEffect(deps) {
|
|
|
8716
8891
|
state.guestPreauthorizing,
|
|
8717
8892
|
state.guestPreauthSessionId,
|
|
8718
8893
|
state.guestPreauthAccountId,
|
|
8719
|
-
state.activeCredentialId,
|
|
8720
8894
|
state.verificationTarget,
|
|
8721
|
-
state.loginRequested,
|
|
8722
8895
|
state.phase,
|
|
8723
8896
|
authExecutor.executing,
|
|
8724
8897
|
authExecutor.pendingSelectSource,
|
|
8725
|
-
dispatch
|
|
8726
|
-
privyAuthenticated
|
|
8898
|
+
dispatch
|
|
8727
8899
|
]);
|
|
8728
8900
|
}
|
|
8729
8901
|
function BlinkPayment(props) {
|
|
@@ -8811,6 +8983,9 @@ function BlinkPaymentInner({
|
|
|
8811
8983
|
onComplete
|
|
8812
8984
|
);
|
|
8813
8985
|
const sourceSelection = useSourceSelectionHandlers(dispatch, authExecutor, {
|
|
8986
|
+
guestPreauthSessionId: state.guestPreauthSessionId,
|
|
8987
|
+
guestPreauthAccountId: state.guestPreauthAccountId,
|
|
8988
|
+
isGuestFlow: state.isGuestFlow,
|
|
8814
8989
|
guestPreauthorizing: state.guestPreauthorizing,
|
|
8815
8990
|
isDesktop
|
|
8816
8991
|
});
|
|
@@ -8990,8 +9165,7 @@ function BlinkPaymentInner({
|
|
|
8990
9165
|
state,
|
|
8991
9166
|
dispatch,
|
|
8992
9167
|
authExecutor,
|
|
8993
|
-
isDesktop
|
|
8994
|
-
privyAuthenticated: authenticated
|
|
9168
|
+
isDesktop
|
|
8995
9169
|
});
|
|
8996
9170
|
const handlers = useMemo(() => ({
|
|
8997
9171
|
onSendLoginCode: auth.handleSendLoginCode,
|
|
@@ -9031,7 +9205,11 @@ function BlinkPaymentInner({
|
|
|
9031
9205
|
onSelectGuestToken: guestTransfer.handleSelectGuestToken,
|
|
9032
9206
|
onGuestBackFromTokenPicker: guestTransfer.handleGuestBackFromTokenPicker,
|
|
9033
9207
|
onLogin: () => dispatch({ type: "REQUEST_LOGIN" }),
|
|
9034
|
-
onPreauthorize: provider.handlePreauthorize
|
|
9208
|
+
onPreauthorize: provider.handlePreauthorize,
|
|
9209
|
+
onGuestSetupCompleteClose: () => {
|
|
9210
|
+
dispatch({ type: "GUEST_PREAUTH_SETUP_COMPLETE_DISMISSED" });
|
|
9211
|
+
onDismiss?.();
|
|
9212
|
+
}
|
|
9035
9213
|
}), [
|
|
9036
9214
|
auth,
|
|
9037
9215
|
passkey,
|
|
@@ -9042,7 +9220,9 @@ function BlinkPaymentInner({
|
|
|
9042
9220
|
oneTapSetup,
|
|
9043
9221
|
guestTransfer,
|
|
9044
9222
|
handleLogout,
|
|
9045
|
-
handleNewPayment
|
|
9223
|
+
handleNewPayment,
|
|
9224
|
+
onDismiss,
|
|
9225
|
+
dispatch
|
|
9046
9226
|
]);
|
|
9047
9227
|
return /* @__PURE__ */ jsx(
|
|
9048
9228
|
StepRenderer,
|