@swype-org/react-sdk 0.1.219 → 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.d.cts CHANGED
@@ -94,7 +94,7 @@ interface Amount {
94
94
  /** Transfer destination in a response */
95
95
  interface TransferDestination {
96
96
  id: string;
97
- chainId: string;
97
+ chainId: number;
98
98
  address: string;
99
99
  token: {
100
100
  address: string;
@@ -167,7 +167,7 @@ interface SourceSelection {
167
167
  }
168
168
  /** Destination input provided by the host app */
169
169
  interface Destination {
170
- chainId: string;
170
+ chainId: number;
171
171
  address: string;
172
172
  token: {
173
173
  address: string;
@@ -308,7 +308,7 @@ declare function useBlinkDepositAmount(): {
308
308
  setAmount: (amount: number | null) => void;
309
309
  };
310
310
 
311
- declare function fetchProviders(apiBaseUrl: string, token: string): Promise<Provider[]>;
311
+ declare function fetchProviders(apiBaseUrl: string, token?: string | null): Promise<Provider[]>;
312
312
  declare function fetchChains(apiBaseUrl: string, token: string): Promise<Chain[]>;
313
313
  declare function fetchAccounts(apiBaseUrl: string, token: string, credentialId: string): Promise<Account[]>;
314
314
  declare function fetchAccount(apiBaseUrl: string, token: string, accountId: string, credentialId: string): Promise<Account>;
@@ -389,7 +389,7 @@ interface CreateGuestTransferParams {
389
389
  id?: string;
390
390
  merchantAuthorization: MerchantAuthorization;
391
391
  destinations: Array<{
392
- chainId: string;
392
+ chainId: number;
393
393
  token: {
394
394
  address: string;
395
395
  };
@@ -428,7 +428,7 @@ declare function getTransferByGuestToken(apiBaseUrl: string, guestToken: string)
428
428
  * Set the sender's wallet address and selected source token on a guest transfer.
429
429
  * PUT /v1/transfers/:id/sender
430
430
  */
431
- declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: string, sourceToken: string): Promise<Transfer>;
431
+ declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: number, sourceToken: string): Promise<Transfer>;
432
432
  /**
433
433
  * Submit the origin chain tx hash for a guest transfer.
434
434
  * PATCH /v1/transfers/:id with { originTxHash }
@@ -441,13 +441,26 @@ declare function signGuestTransfer(apiBaseUrl: string, transferId: string, guest
441
441
  declare function getGuestTransfer(apiBaseUrl: string, transferId: string, guestSessionToken: string): Promise<Transfer>;
442
442
  /** Balance option returned by the guest transfer balances endpoint. */
443
443
  interface GuestBalanceOption extends SourceOption {
444
- sourceChainId: string;
444
+ sourceChainId: number;
445
445
  }
446
446
  /**
447
447
  * Fetch stablecoin balances for a wallet address, scoped to a guest transfer.
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
@@ -94,7 +94,7 @@ interface Amount {
94
94
  /** Transfer destination in a response */
95
95
  interface TransferDestination {
96
96
  id: string;
97
- chainId: string;
97
+ chainId: number;
98
98
  address: string;
99
99
  token: {
100
100
  address: string;
@@ -167,7 +167,7 @@ interface SourceSelection {
167
167
  }
168
168
  /** Destination input provided by the host app */
169
169
  interface Destination {
170
- chainId: string;
170
+ chainId: number;
171
171
  address: string;
172
172
  token: {
173
173
  address: string;
@@ -308,7 +308,7 @@ declare function useBlinkDepositAmount(): {
308
308
  setAmount: (amount: number | null) => void;
309
309
  };
310
310
 
311
- declare function fetchProviders(apiBaseUrl: string, token: string): Promise<Provider[]>;
311
+ declare function fetchProviders(apiBaseUrl: string, token?: string | null): Promise<Provider[]>;
312
312
  declare function fetchChains(apiBaseUrl: string, token: string): Promise<Chain[]>;
313
313
  declare function fetchAccounts(apiBaseUrl: string, token: string, credentialId: string): Promise<Account[]>;
314
314
  declare function fetchAccount(apiBaseUrl: string, token: string, accountId: string, credentialId: string): Promise<Account>;
@@ -389,7 +389,7 @@ interface CreateGuestTransferParams {
389
389
  id?: string;
390
390
  merchantAuthorization: MerchantAuthorization;
391
391
  destinations: Array<{
392
- chainId: string;
392
+ chainId: number;
393
393
  token: {
394
394
  address: string;
395
395
  };
@@ -428,7 +428,7 @@ declare function getTransferByGuestToken(apiBaseUrl: string, guestToken: string)
428
428
  * Set the sender's wallet address and selected source token on a guest transfer.
429
429
  * PUT /v1/transfers/:id/sender
430
430
  */
431
- declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: string, sourceToken: string): Promise<Transfer>;
431
+ declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: number, sourceToken: string): Promise<Transfer>;
432
432
  /**
433
433
  * Submit the origin chain tx hash for a guest transfer.
434
434
  * PATCH /v1/transfers/:id with { originTxHash }
@@ -441,13 +441,26 @@ declare function signGuestTransfer(apiBaseUrl: string, transferId: string, guest
441
441
  declare function getGuestTransfer(apiBaseUrl: string, transferId: string, guestSessionToken: string): Promise<Transfer>;
442
442
  /** Balance option returned by the guest transfer balances endpoint. */
443
443
  interface GuestBalanceOption extends SourceOption {
444
- sourceChainId: string;
444
+ sourceChainId: number;
445
445
  }
446
446
  /**
447
447
  * Fetch stablecoin balances for a wallet address, scoped to a guest transfer.
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,
@@ -488,9 +490,11 @@ async function throwApiError(res) {
488
490
  throw new Error(`${res.status} \u2014 ${code}: ${msg}`);
489
491
  }
490
492
  async function fetchProviders(apiBaseUrl, token) {
491
- const res = await fetch(`${apiBaseUrl}/v1/providers`, {
492
- headers: { Authorization: `Bearer ${token}` }
493
- });
493
+ const headers = {};
494
+ if (token) {
495
+ headers.Authorization = `Bearer ${token}`;
496
+ }
497
+ const res = await fetch(`${apiBaseUrl}/v1/providers`, { headers });
494
498
  if (!res.ok) await throwApiError(res);
495
499
  const data = await res.json();
496
500
  return data.items;
@@ -761,6 +765,25 @@ async function fetchGuestTransferBalances(apiBaseUrl, transferId, guestSessionTo
761
765
  const data = await res.json();
762
766
  return data.items;
763
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
+ }
764
787
  async function reportActionCompletion(apiBaseUrl, actionId, result) {
765
788
  const res = await fetch(
766
789
  `${apiBaseUrl}/v1/authorization-actions/${actionId}`,
@@ -1935,7 +1958,9 @@ function createInitialState(config) {
1935
1958
  previousStep: null,
1936
1959
  isGuestFlow: false,
1937
1960
  guestTransferId: null,
1938
- guestSessionToken: null
1961
+ guestSessionToken: null,
1962
+ guestPreauthAccountId: null,
1963
+ activePublicKey: null
1939
1964
  };
1940
1965
  }
1941
1966
  function paymentReducer(state, action) {
@@ -1966,6 +1991,7 @@ function paymentReducer(state, action) {
1966
1991
  return {
1967
1992
  ...state,
1968
1993
  activeCredentialId: action.credentialId,
1994
+ activePublicKey: action.publicKey ?? state.activePublicKey,
1969
1995
  passkeyPopupNeeded: false
1970
1996
  };
1971
1997
  case "SET_PASSKEY_POPUP_NEEDED":
@@ -2179,6 +2205,20 @@ function paymentReducer(state, action) {
2179
2205
  mobileFlow: false,
2180
2206
  deeplinkUri: null
2181
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
+ };
2182
2222
  // ── Navigation & error ───────────────────────────────────────
2183
2223
  case "NAVIGATE":
2184
2224
  return { ...state, step: action.step, previousStep: state.step, error: null };
@@ -2199,7 +2239,9 @@ function paymentReducer(state, action) {
2199
2239
  selectedAccountId: action.firstAccountId,
2200
2240
  isGuestFlow: false,
2201
2241
  guestTransferId: null,
2202
- guestSessionToken: null
2242
+ guestSessionToken: null,
2243
+ guestPreauthAccountId: null,
2244
+ activePublicKey: null
2203
2245
  };
2204
2246
  case "LOGOUT":
2205
2247
  return {
@@ -4443,6 +4485,7 @@ function SuccessScreen({
4443
4485
  onLogout,
4444
4486
  onIncreaseLimits,
4445
4487
  onManageAccount,
4488
+ onPreauthorize,
4446
4489
  autoCloseSeconds
4447
4490
  }) {
4448
4491
  const { tokens } = useBlinkConfig();
@@ -4477,6 +4520,15 @@ function SuccessScreen({
4477
4520
  {
4478
4521
  footer: /* @__PURE__ */ jsxs(Fragment, { children: [
4479
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
+ ),
4480
4532
  effectiveAutoClose != null && effectiveAutoClose > 0 && /* @__PURE__ */ jsxs("p", { style: countdownStyle(tokens.textMuted), children: [
4481
4533
  "Returning to app in ",
4482
4534
  countdown,
@@ -4606,6 +4658,19 @@ var upsellLinkStyle = (color) => ({
4606
4658
  fontFamily: "inherit",
4607
4659
  padding: 0
4608
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
+ });
4609
4674
  var countdownStyle = (color) => ({
4610
4675
  fontSize: "0.82rem",
4611
4676
  color,
@@ -6084,6 +6149,7 @@ function StepRendererContent({
6084
6149
  })() : void 0,
6085
6150
  onDone: onDismiss ?? handlers.onNewPayment,
6086
6151
  onLogout: handlers.onLogout,
6152
+ onPreauthorize: state.isGuestFlow ? handlers.onPreauthorize : void 0,
6087
6153
  autoCloseSeconds
6088
6154
  }
6089
6155
  );
@@ -6396,7 +6462,7 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
6396
6462
  }
6397
6463
 
6398
6464
  // src/hooks/usePasskeyHandlers.ts
6399
- function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
6465
+ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef, guestPreauthAccountId) {
6400
6466
  const { user, getAccessToken } = usePrivy();
6401
6467
  const checkingPasskeyRef = useRef(false);
6402
6468
  const activateExistingCredential = useCallback(async (credentialId) => {
@@ -6421,8 +6487,11 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6421
6487
  const token = await getAccessToken();
6422
6488
  if (!token) throw new Error("Not authenticated");
6423
6489
  await registerPasskey(apiBaseUrl, token, credentialId, publicKey);
6424
- dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
6490
+ dispatch({ type: "PASSKEY_ACTIVATED", credentialId, publicKey });
6425
6491
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
6492
+ if (guestPreauthAccountId) {
6493
+ return;
6494
+ }
6426
6495
  const resolved = resolvePostAuthStep({
6427
6496
  hasPasskey: true,
6428
6497
  accounts,
@@ -6432,7 +6501,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6432
6501
  });
6433
6502
  if (resolved.clearPersistedFlow) clearMobileFlowState();
6434
6503
  dispatch({ type: "NAVIGATE", step: resolved.step });
6435
- }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6504
+ }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, guestPreauthAccountId, dispatch]);
6436
6505
  const handleRegisterPasskey = useCallback(async () => {
6437
6506
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
6438
6507
  dispatch({ type: "SET_ERROR", error: null });
@@ -7988,6 +8057,32 @@ function usePaymentEffects(deps) {
7988
8057
  state.selectedAccountId,
7989
8058
  depositAmount
7990
8059
  ]);
8060
+ useEffect(() => {
8061
+ if (authenticated || state.providers.length > 0) return;
8062
+ if (state.step !== "wallet-picker") return;
8063
+ let cancelled = false;
8064
+ const loadProviders = async () => {
8065
+ try {
8066
+ const providers = await fetchProviders(apiBaseUrl);
8067
+ if (cancelled) return;
8068
+ dispatch({
8069
+ type: "DATA_LOADED",
8070
+ providers,
8071
+ accounts: state.accounts,
8072
+ chains: state.chains,
8073
+ defaults: null
8074
+ });
8075
+ } catch (err) {
8076
+ if (!cancelled) {
8077
+ captureException(err);
8078
+ }
8079
+ }
8080
+ };
8081
+ loadProviders();
8082
+ return () => {
8083
+ cancelled = true;
8084
+ };
8085
+ }, [authenticated, state.step, state.providers.length, apiBaseUrl]);
7991
8086
  useEffect(() => {
7992
8087
  if (!polling.transfer) return;
7993
8088
  if (polling.transfer.status === "COMPLETED") {
@@ -8243,6 +8338,77 @@ function usePaymentEffects(deps) {
8243
8338
  preOneTapSetupStepRef.current = null;
8244
8339
  }
8245
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
+ ]);
8246
8412
  }
8247
8413
  function BlinkPayment(props) {
8248
8414
  const resetKey = useRef(0);
@@ -8293,7 +8459,8 @@ function BlinkPaymentInner({
8293
8459
  apiBaseUrl,
8294
8460
  state.accounts,
8295
8461
  state.knownCredentialIds,
8296
- mobileFlowRefs.mobileSetupFlowRef
8462
+ mobileFlowRefs.mobileSetupFlowRef,
8463
+ state.guestPreauthAccountId
8297
8464
  );
8298
8465
  const transfer = useTransferHandlers({
8299
8466
  dispatch,
@@ -8469,7 +8636,8 @@ function BlinkPaymentInner({
8469
8636
  onSelectAuthorizedToken: provider.handleSelectAuthorizedToken,
8470
8637
  onAuthorizeToken: provider.handleAuthorizeToken,
8471
8638
  onSelectGuestToken: guestTransfer.handleSelectGuestToken,
8472
- onLogin: () => dispatch({ type: "NAVIGATE", step: "login" })
8639
+ onLogin: () => dispatch({ type: "NAVIGATE", step: "login" }),
8640
+ onPreauthorize: () => dispatch({ type: "NAVIGATE", step: "login" })
8473
8641
  }), [
8474
8642
  auth,
8475
8643
  passkey,