@swype-org/react-sdk 0.1.220 → 0.1.222

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.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 {
@@ -492,7 +507,6 @@ interface BlinkPaymentProps {
492
507
  merchantName?: string;
493
508
  onBack?: () => void;
494
509
  onDismiss?: () => void;
495
- autoCloseSeconds?: number;
496
510
  }
497
511
  declare function BlinkPayment(props: BlinkPaymentProps): react_jsx_runtime.JSX.Element;
498
512
 
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 {
@@ -492,7 +507,6 @@ interface BlinkPaymentProps {
492
507
  merchantName?: string;
493
508
  onBack?: () => void;
494
509
  onDismiss?: () => void;
495
- autoCloseSeconds?: number;
496
510
  }
497
511
  declare function BlinkPayment(props: BlinkPaymentProps): react_jsx_runtime.JSX.Element;
498
512
 
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,45 +4485,23 @@ function SuccessScreen({
4445
4485
  onLogout,
4446
4486
  onIncreaseLimits,
4447
4487
  onManageAccount,
4448
- autoCloseSeconds
4488
+ onPreauthorize
4449
4489
  }) {
4450
4490
  const { tokens } = useBlinkConfig();
4451
- const effectiveAutoClose = succeeded ? autoCloseSeconds : void 0;
4452
- const [countdown, setCountdown] = useState(effectiveAutoClose ?? 0);
4453
- const doneCalledRef = useRef(false);
4454
- const handleDone = useCallback(() => {
4455
- if (doneCalledRef.current) return;
4456
- doneCalledRef.current = true;
4457
- onDone();
4458
- }, [onDone]);
4459
- useEffect(() => {
4460
- if (!effectiveAutoClose || effectiveAutoClose <= 0) return;
4461
- const intervalId = window.setInterval(() => {
4462
- setCountdown((prev) => {
4463
- if (prev <= 1) {
4464
- window.clearInterval(intervalId);
4465
- return 0;
4466
- }
4467
- return prev - 1;
4468
- });
4469
- }, 1e3);
4470
- return () => window.clearInterval(intervalId);
4471
- }, [effectiveAutoClose]);
4472
- useEffect(() => {
4473
- if (effectiveAutoClose && countdown === 0) {
4474
- handleDone();
4475
- }
4476
- }, [effectiveAutoClose, countdown, handleDone]);
4477
4491
  return /* @__PURE__ */ jsxs(
4478
4492
  ScreenLayout,
4479
4493
  {
4480
4494
  footer: /* @__PURE__ */ jsxs(Fragment, { children: [
4481
- /* @__PURE__ */ jsx(PrimaryButton, { onClick: handleDone, children: succeeded ? "Done" : "Try again" }),
4482
- effectiveAutoClose != null && effectiveAutoClose > 0 && /* @__PURE__ */ jsxs("p", { style: countdownStyle(tokens.textMuted), children: [
4483
- "Returning to app in ",
4484
- countdown,
4485
- "s\u2026"
4486
- ] }),
4495
+ /* @__PURE__ */ jsx(PrimaryButton, { onClick: onDone, children: succeeded ? "Done" : "Try again" }),
4496
+ succeeded && onPreauthorize && /* @__PURE__ */ jsx(
4497
+ "button",
4498
+ {
4499
+ type: "button",
4500
+ onClick: onPreauthorize,
4501
+ style: preauthorizeStyle(tokens.accent, tokens.border),
4502
+ children: "Preauthorize future transfers"
4503
+ }
4504
+ ),
4487
4505
  onManageAccount && /* @__PURE__ */ jsx("button", { type: "button", onClick: onManageAccount, style: manageStyle(tokens.textMuted), children: "Manage Blink account \u2192" }),
4488
4506
  /* @__PURE__ */ jsx(PoweredByFooter, {})
4489
4507
  ] }),
@@ -4608,11 +4626,18 @@ var upsellLinkStyle = (color) => ({
4608
4626
  fontFamily: "inherit",
4609
4627
  padding: 0
4610
4628
  });
4611
- var countdownStyle = (color) => ({
4612
- fontSize: "0.82rem",
4613
- color,
4614
- margin: "10px 0 0",
4615
- textAlign: "center"
4629
+ var preauthorizeStyle = (accentColor, borderColor) => ({
4630
+ width: "100%",
4631
+ padding: "14px 0",
4632
+ marginTop: 8,
4633
+ background: "transparent",
4634
+ border: `1px solid ${borderColor}`,
4635
+ borderRadius: 20,
4636
+ color: accentColor,
4637
+ fontWeight: 600,
4638
+ fontSize: "0.92rem",
4639
+ cursor: "pointer",
4640
+ fontFamily: "inherit"
4616
4641
  });
4617
4642
  var manageStyle = (color) => ({
4618
4643
  background: "transparent",
@@ -5809,7 +5834,6 @@ function StepRendererContent({
5809
5834
  merchantName,
5810
5835
  onBack,
5811
5836
  onDismiss,
5812
- autoCloseSeconds,
5813
5837
  depositAmount,
5814
5838
  handlers
5815
5839
  }) {
@@ -6086,7 +6110,7 @@ function StepRendererContent({
6086
6110
  })() : void 0,
6087
6111
  onDone: onDismiss ?? handlers.onNewPayment,
6088
6112
  onLogout: handlers.onLogout,
6089
- autoCloseSeconds
6113
+ onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0
6090
6114
  }
6091
6115
  );
6092
6116
  }
@@ -6398,7 +6422,7 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
6398
6422
  }
6399
6423
 
6400
6424
  // src/hooks/usePasskeyHandlers.ts
6401
- function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
6425
+ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef, guestPreauthAccountId) {
6402
6426
  const { user, getAccessToken } = usePrivy();
6403
6427
  const checkingPasskeyRef = useRef(false);
6404
6428
  const activateExistingCredential = useCallback(async (credentialId) => {
@@ -6423,8 +6447,11 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6423
6447
  const token = await getAccessToken();
6424
6448
  if (!token) throw new Error("Not authenticated");
6425
6449
  await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
6426
- dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
6450
+ dispatch({ type: "PASSKEY_ACTIVATED", credentialId, publicKey });
6427
6451
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
6452
+ if (guestPreauthAccountId) {
6453
+ return;
6454
+ }
6428
6455
  const resolved = resolvePostAuthStep({
6429
6456
  hasPasskey: true,
6430
6457
  accounts,
@@ -6434,7 +6461,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6434
6461
  });
6435
6462
  if (resolved.clearPersistedFlow) clearMobileFlowState();
6436
6463
  dispatch({ type: "NAVIGATE", step: resolved.step });
6437
- }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6464
+ }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, guestPreauthAccountId, dispatch]);
6438
6465
  const handleRegisterPasskey = useCallback(async () => {
6439
6466
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
6440
6467
  dispatch({ type: "SET_ERROR", error: null });
@@ -8271,6 +8298,77 @@ function usePaymentEffects(deps) {
8271
8298
  preOneTapSetupStepRef.current = null;
8272
8299
  }
8273
8300
  }, [pendingOneTapSetupAction, state.step, reloadAccounts, authExecutor, dispatch, oneTapLimitSavedDuringSetupRef]);
8301
+ useEffect(() => {
8302
+ if (state.step !== "success") return;
8303
+ if (!state.guestSessionToken) return;
8304
+ if (state.guestPreauthAccountId) return;
8305
+ let cancelled = false;
8306
+ const checkPreauth = async () => {
8307
+ try {
8308
+ const result = await fetchGuestPreauthAccount(apiBaseUrl, state.guestSessionToken);
8309
+ if (cancelled) return;
8310
+ if (result && !result.hasPasskey) {
8311
+ dispatch({ type: "GUEST_PREAUTH_DETECTED", accountId: result.accountId });
8312
+ }
8313
+ } catch {
8314
+ }
8315
+ };
8316
+ checkPreauth();
8317
+ return () => {
8318
+ cancelled = true;
8319
+ };
8320
+ }, [state.step, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8321
+ const claimingRef = useRef(false);
8322
+ useEffect(() => {
8323
+ if (!state.guestPreauthAccountId) return;
8324
+ if (!state.activeCredentialId) return;
8325
+ if (!state.activePublicKey) return;
8326
+ if (!authenticated) return;
8327
+ if (!state.guestSessionToken) return;
8328
+ if (claimingRef.current) return;
8329
+ claimingRef.current = true;
8330
+ let cancelled = false;
8331
+ const claimPreauth = async () => {
8332
+ try {
8333
+ const token = await getAccessTokenRef.current();
8334
+ if (!token || cancelled) return;
8335
+ await claimAccount(apiBaseUrl, token, state.guestPreauthAccountId, {
8336
+ guestToken: state.guestSessionToken,
8337
+ credentialId: state.activeCredentialId,
8338
+ publicKey: state.activePublicKey
8339
+ });
8340
+ if (cancelled) return;
8341
+ try {
8342
+ await reloadAccounts();
8343
+ } catch {
8344
+ }
8345
+ if (cancelled) return;
8346
+ dispatch({ type: "GUEST_PREAUTH_CLAIMED" });
8347
+ } catch (err) {
8348
+ if (cancelled) return;
8349
+ captureException(err);
8350
+ dispatch({
8351
+ type: "SET_ERROR",
8352
+ error: err instanceof Error ? err.message : "Failed to claim account"
8353
+ });
8354
+ } finally {
8355
+ claimingRef.current = false;
8356
+ }
8357
+ };
8358
+ claimPreauth();
8359
+ return () => {
8360
+ cancelled = true;
8361
+ };
8362
+ }, [
8363
+ state.guestPreauthAccountId,
8364
+ state.activeCredentialId,
8365
+ state.activePublicKey,
8366
+ state.guestSessionToken,
8367
+ authenticated,
8368
+ apiBaseUrl,
8369
+ dispatch,
8370
+ reloadAccounts
8371
+ ]);
8274
8372
  }
8275
8373
  function BlinkPayment(props) {
8276
8374
  const resetKey = useRef(0);
@@ -8288,8 +8386,7 @@ function BlinkPaymentInner({
8288
8386
  merchantAuthorization,
8289
8387
  merchantName,
8290
8388
  onBack,
8291
- onDismiss,
8292
- autoCloseSeconds
8389
+ onDismiss
8293
8390
  }) {
8294
8391
  const { apiBaseUrl, depositAmount } = useBlinkConfig();
8295
8392
  const { ready, authenticated, logout, getAccessToken } = usePrivy();
@@ -8321,7 +8418,8 @@ function BlinkPaymentInner({
8321
8418
  apiBaseUrl,
8322
8419
  state.accounts,
8323
8420
  state.knownCredentialIds,
8324
- mobileFlowRefs.mobileSetupFlowRef
8421
+ mobileFlowRefs.mobileSetupFlowRef,
8422
+ state.guestPreauthAccountId
8325
8423
  );
8326
8424
  const transfer = useTransferHandlers({
8327
8425
  dispatch,
@@ -8497,7 +8595,8 @@ function BlinkPaymentInner({
8497
8595
  onSelectAuthorizedToken: provider.handleSelectAuthorizedToken,
8498
8596
  onAuthorizeToken: provider.handleAuthorizeToken,
8499
8597
  onSelectGuestToken: guestTransfer.handleSelectGuestToken,
8500
- onLogin: () => dispatch({ type: "NAVIGATE", step: "login" })
8598
+ onLogin: () => dispatch({ type: "NAVIGATE", step: "login" }),
8599
+ onPreauthorize: () => dispatch({ type: "NAVIGATE", step: "login" })
8501
8600
  }), [
8502
8601
  auth,
8503
8602
  passkey,
@@ -8543,7 +8642,6 @@ function BlinkPaymentInner({
8543
8642
  merchantName,
8544
8643
  onBack,
8545
8644
  onDismiss,
8546
- autoCloseSeconds,
8547
8645
  depositAmount,
8548
8646
  handlers
8549
8647
  }