@swype-org/react-sdk 0.1.220 → 0.1.221
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 +147 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +147 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -448,6 +448,19 @@ interface GuestBalanceOption extends SourceOption {
|
|
|
448
448
|
* GET /v1/transfers/:id/balances?walletAddress=...
|
|
449
449
|
*/
|
|
450
450
|
declare function fetchGuestTransferBalances(apiBaseUrl: string, transferId: string, guestSessionToken: string, walletAddress: string): Promise<GuestBalanceOption[]>;
|
|
451
|
+
declare function fetchGuestPreauthAccount(apiBaseUrl: string, guestToken: string): Promise<{
|
|
452
|
+
accountId: string;
|
|
453
|
+
hasPasskey: boolean;
|
|
454
|
+
walletAddress: string | null;
|
|
455
|
+
} | null>;
|
|
456
|
+
declare function claimAccount(apiBaseUrl: string, accessToken: string, accountId: string, body: {
|
|
457
|
+
guestToken: string;
|
|
458
|
+
credentialId: string;
|
|
459
|
+
publicKey: string;
|
|
460
|
+
}): Promise<{
|
|
461
|
+
accountId: string;
|
|
462
|
+
smartAccountAddress: string;
|
|
463
|
+
}>;
|
|
451
464
|
declare function reportActionCompletion(apiBaseUrl: string, actionId: string, result: Record<string, unknown>): Promise<AuthorizationSessionDetail>;
|
|
452
465
|
|
|
453
466
|
type api_CreateAccountParams = CreateAccountParams;
|
|
@@ -455,6 +468,7 @@ type api_CreateGuestTransferParams = CreateGuestTransferParams;
|
|
|
455
468
|
type api_CreateTransferParams = CreateTransferParams;
|
|
456
469
|
type api_GuestBalanceOption = GuestBalanceOption;
|
|
457
470
|
type api_GuestTransferResult = GuestTransferResult;
|
|
471
|
+
declare const api_claimAccount: typeof claimAccount;
|
|
458
472
|
declare const api_createAccount: typeof createAccount;
|
|
459
473
|
declare const api_createAccountAuthorizationSession: typeof createAccountAuthorizationSession;
|
|
460
474
|
declare const api_createGuestTransfer: typeof createGuestTransfer;
|
|
@@ -463,6 +477,7 @@ declare const api_fetchAccount: typeof fetchAccount;
|
|
|
463
477
|
declare const api_fetchAccounts: typeof fetchAccounts;
|
|
464
478
|
declare const api_fetchAuthorizationSession: typeof fetchAuthorizationSession;
|
|
465
479
|
declare const api_fetchChains: typeof fetchChains;
|
|
480
|
+
declare const api_fetchGuestPreauthAccount: typeof fetchGuestPreauthAccount;
|
|
466
481
|
declare const api_fetchGuestTransferBalances: typeof fetchGuestTransferBalances;
|
|
467
482
|
declare const api_fetchMerchantPublicKey: typeof fetchMerchantPublicKey;
|
|
468
483
|
declare const api_fetchProviders: typeof fetchProviders;
|
|
@@ -479,7 +494,7 @@ declare const api_signTransfer: typeof signTransfer;
|
|
|
479
494
|
declare const api_updateUserConfig: typeof updateUserConfig;
|
|
480
495
|
declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
|
|
481
496
|
declare namespace api {
|
|
482
|
-
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
497
|
+
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_claimAccount as claimAccount, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestPreauthAccount as fetchGuestPreauthAccount, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
483
498
|
}
|
|
484
499
|
|
|
485
500
|
interface BlinkPaymentProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -448,6 +448,19 @@ interface GuestBalanceOption extends SourceOption {
|
|
|
448
448
|
* GET /v1/transfers/:id/balances?walletAddress=...
|
|
449
449
|
*/
|
|
450
450
|
declare function fetchGuestTransferBalances(apiBaseUrl: string, transferId: string, guestSessionToken: string, walletAddress: string): Promise<GuestBalanceOption[]>;
|
|
451
|
+
declare function fetchGuestPreauthAccount(apiBaseUrl: string, guestToken: string): Promise<{
|
|
452
|
+
accountId: string;
|
|
453
|
+
hasPasskey: boolean;
|
|
454
|
+
walletAddress: string | null;
|
|
455
|
+
} | null>;
|
|
456
|
+
declare function claimAccount(apiBaseUrl: string, accessToken: string, accountId: string, body: {
|
|
457
|
+
guestToken: string;
|
|
458
|
+
credentialId: string;
|
|
459
|
+
publicKey: string;
|
|
460
|
+
}): Promise<{
|
|
461
|
+
accountId: string;
|
|
462
|
+
smartAccountAddress: string;
|
|
463
|
+
}>;
|
|
451
464
|
declare function reportActionCompletion(apiBaseUrl: string, actionId: string, result: Record<string, unknown>): Promise<AuthorizationSessionDetail>;
|
|
452
465
|
|
|
453
466
|
type api_CreateAccountParams = CreateAccountParams;
|
|
@@ -455,6 +468,7 @@ type api_CreateGuestTransferParams = CreateGuestTransferParams;
|
|
|
455
468
|
type api_CreateTransferParams = CreateTransferParams;
|
|
456
469
|
type api_GuestBalanceOption = GuestBalanceOption;
|
|
457
470
|
type api_GuestTransferResult = GuestTransferResult;
|
|
471
|
+
declare const api_claimAccount: typeof claimAccount;
|
|
458
472
|
declare const api_createAccount: typeof createAccount;
|
|
459
473
|
declare const api_createAccountAuthorizationSession: typeof createAccountAuthorizationSession;
|
|
460
474
|
declare const api_createGuestTransfer: typeof createGuestTransfer;
|
|
@@ -463,6 +477,7 @@ declare const api_fetchAccount: typeof fetchAccount;
|
|
|
463
477
|
declare const api_fetchAccounts: typeof fetchAccounts;
|
|
464
478
|
declare const api_fetchAuthorizationSession: typeof fetchAuthorizationSession;
|
|
465
479
|
declare const api_fetchChains: typeof fetchChains;
|
|
480
|
+
declare const api_fetchGuestPreauthAccount: typeof fetchGuestPreauthAccount;
|
|
466
481
|
declare const api_fetchGuestTransferBalances: typeof fetchGuestTransferBalances;
|
|
467
482
|
declare const api_fetchMerchantPublicKey: typeof fetchMerchantPublicKey;
|
|
468
483
|
declare const api_fetchProviders: typeof fetchProviders;
|
|
@@ -479,7 +494,7 @@ declare const api_signTransfer: typeof signTransfer;
|
|
|
479
494
|
declare const api_updateUserConfig: typeof updateUserConfig;
|
|
480
495
|
declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
|
|
481
496
|
declare namespace api {
|
|
482
|
-
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
497
|
+
export { type api_CreateAccountParams as CreateAccountParams, type api_CreateGuestTransferParams as CreateGuestTransferParams, type api_CreateTransferParams as CreateTransferParams, type api_GuestBalanceOption as GuestBalanceOption, type api_GuestTransferResult as GuestTransferResult, api_claimAccount as claimAccount, api_createAccount as createAccount, api_createAccountAuthorizationSession as createAccountAuthorizationSession, api_createGuestTransfer as createGuestTransfer, api_createTransfer as createTransfer, api_fetchAccount as fetchAccount, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchGuestPreauthAccount as fetchGuestPreauthAccount, api_fetchGuestTransferBalances as fetchGuestTransferBalances, api_fetchMerchantPublicKey as fetchMerchantPublicKey, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_fetchUserConfig as fetchUserConfig, api_getGuestTransfer as getGuestTransfer, api_getTransferByGuestToken as getTransferByGuestToken, api_registerPasskey as registerPasskey, api_reportActionCompletion as reportActionCompletion, api_reportPasskeyActivity as reportPasskeyActivity, api_setTransferSender as setTransferSender, api_signGuestTransfer as signGuestTransfer, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
|
|
483
498
|
}
|
|
484
499
|
|
|
485
500
|
interface BlinkPaymentProps {
|
package/dist/index.js
CHANGED
|
@@ -456,6 +456,7 @@ async function waitForTransactionReceipt(config, parameters) {
|
|
|
456
456
|
// src/api.ts
|
|
457
457
|
var api_exports = {};
|
|
458
458
|
__export(api_exports, {
|
|
459
|
+
claimAccount: () => claimAccount,
|
|
459
460
|
createAccount: () => createAccount,
|
|
460
461
|
createAccountAuthorizationSession: () => createAccountAuthorizationSession,
|
|
461
462
|
createGuestTransfer: () => createGuestTransfer,
|
|
@@ -464,6 +465,7 @@ __export(api_exports, {
|
|
|
464
465
|
fetchAccounts: () => fetchAccounts,
|
|
465
466
|
fetchAuthorizationSession: () => fetchAuthorizationSession,
|
|
466
467
|
fetchChains: () => fetchChains,
|
|
468
|
+
fetchGuestPreauthAccount: () => fetchGuestPreauthAccount,
|
|
467
469
|
fetchGuestTransferBalances: () => fetchGuestTransferBalances,
|
|
468
470
|
fetchMerchantPublicKey: () => fetchMerchantPublicKey,
|
|
469
471
|
fetchProviders: () => fetchProviders,
|
|
@@ -763,6 +765,25 @@ async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionTo
|
|
|
763
765
|
const data = await res.json();
|
|
764
766
|
return data.items;
|
|
765
767
|
}
|
|
768
|
+
async function fetchGuestPreauthAccount(apiBaseUrl, guestToken) {
|
|
769
|
+
const params = new URLSearchParams({ guestToken });
|
|
770
|
+
const res = await fetch(`${apiBaseUrl}/v1/guest-preauth?${params.toString()}`);
|
|
771
|
+
if (res.status === 404) return null;
|
|
772
|
+
if (!res.ok) await throwApiError(res);
|
|
773
|
+
return await res.json();
|
|
774
|
+
}
|
|
775
|
+
async function claimAccount(apiBaseUrl, accessToken, accountId, body) {
|
|
776
|
+
const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/claim`, {
|
|
777
|
+
method: "POST",
|
|
778
|
+
headers: {
|
|
779
|
+
"Content-Type": "application/json",
|
|
780
|
+
"Authorization": `Bearer ${accessToken}`
|
|
781
|
+
},
|
|
782
|
+
body: JSON.stringify(body)
|
|
783
|
+
});
|
|
784
|
+
if (!res.ok) await throwApiError(res);
|
|
785
|
+
return await res.json();
|
|
786
|
+
}
|
|
766
787
|
async function reportActionCompletion(apiBaseUrl, actionId, result) {
|
|
767
788
|
const res = await fetch(
|
|
768
789
|
`${apiBaseUrl}/v1/authorization-actions/${actionId}`,
|
|
@@ -1937,7 +1958,9 @@ function createInitialState(config) {
|
|
|
1937
1958
|
previousStep: null,
|
|
1938
1959
|
isGuestFlow: false,
|
|
1939
1960
|
guestTransferId: null,
|
|
1940
|
-
guestSessionToken: null
|
|
1961
|
+
guestSessionToken: null,
|
|
1962
|
+
guestPreauthAccountId: null,
|
|
1963
|
+
activePublicKey: null
|
|
1941
1964
|
};
|
|
1942
1965
|
}
|
|
1943
1966
|
function paymentReducer(state, action) {
|
|
@@ -1968,6 +1991,7 @@ function paymentReducer(state, action) {
|
|
|
1968
1991
|
return {
|
|
1969
1992
|
...state,
|
|
1970
1993
|
activeCredentialId: action.credentialId,
|
|
1994
|
+
activePublicKey: action.publicKey ?? state.activePublicKey,
|
|
1971
1995
|
passkeyPopupNeeded: false
|
|
1972
1996
|
};
|
|
1973
1997
|
case "SET_PASSKEY_POPUP_NEEDED":
|
|
@@ -2181,6 +2205,20 @@ function paymentReducer(state, action) {
|
|
|
2181
2205
|
mobileFlow: false,
|
|
2182
2206
|
deeplinkUri: null
|
|
2183
2207
|
};
|
|
2208
|
+
case "GUEST_PREAUTH_DETECTED":
|
|
2209
|
+
return {
|
|
2210
|
+
...state,
|
|
2211
|
+
guestPreauthAccountId: action.accountId,
|
|
2212
|
+
step: "login"
|
|
2213
|
+
};
|
|
2214
|
+
case "GUEST_PREAUTH_CLAIMED":
|
|
2215
|
+
return {
|
|
2216
|
+
...state,
|
|
2217
|
+
guestPreauthAccountId: null,
|
|
2218
|
+
activePublicKey: null,
|
|
2219
|
+
step: "deposit",
|
|
2220
|
+
error: null
|
|
2221
|
+
};
|
|
2184
2222
|
// ── Navigation & error ───────────────────────────────────────
|
|
2185
2223
|
case "NAVIGATE":
|
|
2186
2224
|
return { ...state, step: action.step, previousStep: state.step, error: null };
|
|
@@ -2201,7 +2239,9 @@ function paymentReducer(state, action) {
|
|
|
2201
2239
|
selectedAccountId: action.firstAccountId,
|
|
2202
2240
|
isGuestFlow: false,
|
|
2203
2241
|
guestTransferId: null,
|
|
2204
|
-
guestSessionToken: null
|
|
2242
|
+
guestSessionToken: null,
|
|
2243
|
+
guestPreauthAccountId: null,
|
|
2244
|
+
activePublicKey: null
|
|
2205
2245
|
};
|
|
2206
2246
|
case "LOGOUT":
|
|
2207
2247
|
return {
|
|
@@ -4445,6 +4485,7 @@ function SuccessScreen({
|
|
|
4445
4485
|
onLogout,
|
|
4446
4486
|
onIncreaseLimits,
|
|
4447
4487
|
onManageAccount,
|
|
4488
|
+
onPreauthorize,
|
|
4448
4489
|
autoCloseSeconds
|
|
4449
4490
|
}) {
|
|
4450
4491
|
const { tokens } = useBlinkConfig();
|
|
@@ -4479,6 +4520,15 @@ function SuccessScreen({
|
|
|
4479
4520
|
{
|
|
4480
4521
|
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4481
4522
|
/* @__PURE__ */ jsx(PrimaryButton, { onClick: handleDone, children: succeeded ? "Done" : "Try again" }),
|
|
4523
|
+
succeeded && onPreauthorize && /* @__PURE__ */ jsx(
|
|
4524
|
+
"button",
|
|
4525
|
+
{
|
|
4526
|
+
type: "button",
|
|
4527
|
+
onClick: onPreauthorize,
|
|
4528
|
+
style: preauthorizeStyle(tokens.accent, tokens.border),
|
|
4529
|
+
children: "Preauthorize future transfers"
|
|
4530
|
+
}
|
|
4531
|
+
),
|
|
4482
4532
|
effectiveAutoClose != null && effectiveAutoClose > 0 && /* @__PURE__ */ jsxs("p", { style: countdownStyle(tokens.textMuted), children: [
|
|
4483
4533
|
"Returning to app in ",
|
|
4484
4534
|
countdown,
|
|
@@ -4608,6 +4658,19 @@ var upsellLinkStyle = (color) => ({
|
|
|
4608
4658
|
fontFamily: "inherit",
|
|
4609
4659
|
padding: 0
|
|
4610
4660
|
});
|
|
4661
|
+
var preauthorizeStyle = (accentColor, borderColor) => ({
|
|
4662
|
+
width: "100%",
|
|
4663
|
+
padding: "14px 0",
|
|
4664
|
+
marginTop: 8,
|
|
4665
|
+
background: "transparent",
|
|
4666
|
+
border: `1px solid ${borderColor}`,
|
|
4667
|
+
borderRadius: 20,
|
|
4668
|
+
color: accentColor,
|
|
4669
|
+
fontWeight: 600,
|
|
4670
|
+
fontSize: "0.92rem",
|
|
4671
|
+
cursor: "pointer",
|
|
4672
|
+
fontFamily: "inherit"
|
|
4673
|
+
});
|
|
4611
4674
|
var countdownStyle = (color) => ({
|
|
4612
4675
|
fontSize: "0.82rem",
|
|
4613
4676
|
color,
|
|
@@ -6086,6 +6149,7 @@ function StepRendererContent({
|
|
|
6086
6149
|
})() : void 0,
|
|
6087
6150
|
onDone: onDismiss ?? handlers.onNewPayment,
|
|
6088
6151
|
onLogout: handlers.onLogout,
|
|
6152
|
+
onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0,
|
|
6089
6153
|
autoCloseSeconds
|
|
6090
6154
|
}
|
|
6091
6155
|
);
|
|
@@ -6398,7 +6462,7 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
|
|
|
6398
6462
|
}
|
|
6399
6463
|
|
|
6400
6464
|
// src/hooks/usePasskeyHandlers.ts
|
|
6401
|
-
function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
|
|
6465
|
+
function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef, guestPreauthAccountId) {
|
|
6402
6466
|
const { user, getAccessToken } = usePrivy();
|
|
6403
6467
|
const checkingPasskeyRef = useRef(false);
|
|
6404
6468
|
const activateExistingCredential = useCallback(async (credentialId) => {
|
|
@@ -6423,8 +6487,11 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6423
6487
|
const token = await getAccessToken();
|
|
6424
6488
|
if (!token) throw new Error("Not authenticated");
|
|
6425
6489
|
await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
|
|
6426
|
-
dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
|
|
6490
|
+
dispatch({ type: "PASSKEY_ACTIVATED", credentialId, publicKey });
|
|
6427
6491
|
window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
|
|
6492
|
+
if (guestPreauthAccountId) {
|
|
6493
|
+
return;
|
|
6494
|
+
}
|
|
6428
6495
|
const resolved = resolvePostAuthStep({
|
|
6429
6496
|
hasPasskey: true,
|
|
6430
6497
|
accounts,
|
|
@@ -6434,7 +6501,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6434
6501
|
});
|
|
6435
6502
|
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6436
6503
|
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6437
|
-
}, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
|
|
6504
|
+
}, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, guestPreauthAccountId, dispatch]);
|
|
6438
6505
|
const handleRegisterPasskey = useCallback(async () => {
|
|
6439
6506
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6440
6507
|
dispatch({ type: "SET_ERROR", error: null });
|
|
@@ -8271,6 +8338,77 @@ function usePaymentEffects(deps) {
|
|
|
8271
8338
|
preOneTapSetupStepRef.current = null;
|
|
8272
8339
|
}
|
|
8273
8340
|
}, [pendingOneTapSetupAction, state.step, reloadAccounts, authExecutor, dispatch, oneTapLimitSavedDuringSetupRef]);
|
|
8341
|
+
useEffect(() => {
|
|
8342
|
+
if (state.step !== "success") return;
|
|
8343
|
+
if (!state.guestSessionToken) return;
|
|
8344
|
+
if (state.guestPreauthAccountId) return;
|
|
8345
|
+
let cancelled = false;
|
|
8346
|
+
const checkPreauth = async () => {
|
|
8347
|
+
try {
|
|
8348
|
+
const result = await fetchGuestPreauthAccount(apiBaseUrl, state.guestSessionToken);
|
|
8349
|
+
if (cancelled) return;
|
|
8350
|
+
if (result && !result.hasPasskey) {
|
|
8351
|
+
dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: result.accountId });
|
|
8352
|
+
}
|
|
8353
|
+
} catch {
|
|
8354
|
+
}
|
|
8355
|
+
};
|
|
8356
|
+
checkPreauth();
|
|
8357
|
+
return () => {
|
|
8358
|
+
cancelled = true;
|
|
8359
|
+
};
|
|
8360
|
+
}, [state.step, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
|
|
8361
|
+
const claimingRef = useRef(false);
|
|
8362
|
+
useEffect(() => {
|
|
8363
|
+
if (!state.guestPreauthAccountId) return;
|
|
8364
|
+
if (!state.activeCredentialId) return;
|
|
8365
|
+
if (!state.activePublicKey) return;
|
|
8366
|
+
if (!authenticated) return;
|
|
8367
|
+
if (!state.guestSessionToken) return;
|
|
8368
|
+
if (claimingRef.current) return;
|
|
8369
|
+
claimingRef.current = true;
|
|
8370
|
+
let cancelled = false;
|
|
8371
|
+
const claimPreauth = async () => {
|
|
8372
|
+
try {
|
|
8373
|
+
const token = await getAccessTokenRef.current();
|
|
8374
|
+
if (!token || cancelled) return;
|
|
8375
|
+
await claimAccount(apiBaseUrl, token, state.guestPreauthAccountId, {
|
|
8376
|
+
guestToken: state.guestSessionToken,
|
|
8377
|
+
credentialId: state.activeCredentialId,
|
|
8378
|
+
publicKey: state.activePublicKey
|
|
8379
|
+
});
|
|
8380
|
+
if (cancelled) return;
|
|
8381
|
+
try {
|
|
8382
|
+
await reloadAccounts();
|
|
8383
|
+
} catch {
|
|
8384
|
+
}
|
|
8385
|
+
if (cancelled) return;
|
|
8386
|
+
dispatch({ type: "GUEST_PREAUTH_CLAIMED" });
|
|
8387
|
+
} catch (err) {
|
|
8388
|
+
if (cancelled) return;
|
|
8389
|
+
captureException(err);
|
|
8390
|
+
dispatch({
|
|
8391
|
+
type: "SET_ERROR",
|
|
8392
|
+
error: err instanceof Error ? err.message : "Failed to claim account"
|
|
8393
|
+
});
|
|
8394
|
+
} finally {
|
|
8395
|
+
claimingRef.current = false;
|
|
8396
|
+
}
|
|
8397
|
+
};
|
|
8398
|
+
claimPreauth();
|
|
8399
|
+
return () => {
|
|
8400
|
+
cancelled = true;
|
|
8401
|
+
};
|
|
8402
|
+
}, [
|
|
8403
|
+
state.guestPreauthAccountId,
|
|
8404
|
+
state.activeCredentialId,
|
|
8405
|
+
state.activePublicKey,
|
|
8406
|
+
state.guestSessionToken,
|
|
8407
|
+
authenticated,
|
|
8408
|
+
apiBaseUrl,
|
|
8409
|
+
dispatch,
|
|
8410
|
+
reloadAccounts
|
|
8411
|
+
]);
|
|
8274
8412
|
}
|
|
8275
8413
|
function BlinkPayment(props) {
|
|
8276
8414
|
const resetKey = useRef(0);
|
|
@@ -8321,7 +8459,8 @@ function BlinkPaymentInner({
|
|
|
8321
8459
|
apiBaseUrl,
|
|
8322
8460
|
state.accounts,
|
|
8323
8461
|
state.knownCredentialIds,
|
|
8324
|
-
mobileFlowRefs.mobileSetupFlowRef
|
|
8462
|
+
mobileFlowRefs.mobileSetupFlowRef,
|
|
8463
|
+
state.guestPreauthAccountId
|
|
8325
8464
|
);
|
|
8326
8465
|
const transfer = useTransferHandlers({
|
|
8327
8466
|
dispatch,
|
|
@@ -8497,7 +8636,8 @@ function BlinkPaymentInner({
|
|
|
8497
8636
|
onSelectAuthorizedToken: provider.handleSelectAuthorizedToken,
|
|
8498
8637
|
onAuthorizeToken: provider.handleAuthorizeToken,
|
|
8499
8638
|
onSelectGuestToken: guestTransfer.handleSelectGuestToken,
|
|
8500
|
-
onLogin: () => dispatch({ type: "NAVIGATE", step: "login" })
|
|
8639
|
+
onLogin: () => dispatch({ type: "NAVIGATE", step: "login" }),
|
|
8640
|
+
onPreauthorize: () => dispatch({ type: "NAVIGATE", step: "login" })
|
|
8501
8641
|
}), [
|
|
8502
8642
|
auth,
|
|
8503
8643
|
passkey,
|