@swype-org/react-sdk 0.1.223 → 0.1.225

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 CHANGED
@@ -459,7 +459,6 @@ async function waitForTransactionReceipt(config, parameters) {
459
459
  // src/api.ts
460
460
  var api_exports = {};
461
461
  __export(api_exports, {
462
- claimAccount: () => claimAccount,
463
462
  createAccount: () => createAccount,
464
463
  createAccountAuthorizationSession: () => createAccountAuthorizationSession,
465
464
  createGuestTransfer: () => createGuestTransfer,
@@ -479,6 +478,7 @@ __export(api_exports, {
479
478
  registerPasskey: () => registerPasskey,
480
479
  reportActionCompletion: () => reportActionCompletion,
481
480
  reportPasskeyActivity: () => reportPasskeyActivity,
481
+ setAccountOwner: () => setAccountOwner,
482
482
  setTransferSender: () => setTransferSender,
483
483
  signGuestTransfer: () => signGuestTransfer,
484
484
  signTransfer: () => signTransfer,
@@ -776,12 +776,13 @@ async function fetchGuestPreauthAccount(apiBaseUrl, guestToken) {
776
776
  if (!res.ok) await throwApiError(res);
777
777
  return await res.json();
778
778
  }
779
- async function claimAccount(apiBaseUrl, accessToken, accountId, body) {
780
- const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/claim`, {
781
- method: "POST",
779
+ async function setAccountOwner(apiBaseUrl, accessToken, accountId, guestSessionToken, body) {
780
+ const res = await fetch(`${apiBaseUrl}/v1/accounts/${accountId}/owner`, {
781
+ method: "PUT",
782
782
  headers: {
783
783
  "Content-Type": "application/json",
784
- "Authorization": `Bearer ${accessToken}`
784
+ "Authorization": `Bearer ${accessToken}`,
785
+ "x-guest-session-token": guestSessionToken
785
786
  },
786
787
  body: JSON.stringify(body)
787
788
  });
@@ -2207,7 +2208,9 @@ function paymentReducer(state, action) {
2207
2208
  transfer: action.transfer,
2208
2209
  step: "success",
2209
2210
  mobileFlow: false,
2210
- deeplinkUri: null
2211
+ deeplinkUri: null,
2212
+ isGuestFlow: true,
2213
+ guestSessionToken: action.guestSessionToken ?? state.guestSessionToken
2211
2214
  };
2212
2215
  case "GUEST_PREAUTH_DETECTED":
2213
2216
  return {
@@ -2215,7 +2218,7 @@ function paymentReducer(state, action) {
2215
2218
  guestPreauthAccountId: action.accountId,
2216
2219
  step: "login"
2217
2220
  };
2218
- case "GUEST_PREAUTH_CLAIMED":
2221
+ case "ACCOUNT_OWNER_SET":
2219
2222
  return {
2220
2223
  ...state,
2221
2224
  guestPreauthAccountId: null,
@@ -6837,7 +6840,7 @@ function useMobileFlowHandlers(dispatch, polling, reloadAccounts, pollingTransfe
6837
6840
  cancelled = true;
6838
6841
  guestPollingActiveRef.current = false;
6839
6842
  clearMobileFlowState();
6840
- dispatch({ type: "GUEST_TRANSFER_COMPLETED", transfer });
6843
+ dispatch({ type: "GUEST_TRANSFER_COMPLETED", transfer, guestSessionToken });
6841
6844
  onCompleteRef.current?.(transfer);
6842
6845
  } else if (transfer.status === "FAILED") {
6843
6846
  cancelled = true;
@@ -8325,22 +8328,21 @@ function usePaymentEffects(deps) {
8325
8328
  cancelled = true;
8326
8329
  };
8327
8330
  }, [state.step, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8328
- const claimingRef = react.useRef(false);
8331
+ const settingOwnerRef = react.useRef(false);
8329
8332
  react.useEffect(() => {
8330
8333
  if (!state.guestPreauthAccountId) return;
8331
8334
  if (!state.activeCredentialId) return;
8332
8335
  if (!state.activePublicKey) return;
8333
8336
  if (!authenticated) return;
8334
8337
  if (!state.guestSessionToken) return;
8335
- if (claimingRef.current) return;
8336
- claimingRef.current = true;
8338
+ if (settingOwnerRef.current) return;
8339
+ settingOwnerRef.current = true;
8337
8340
  let cancelled = false;
8338
- const claimPreauth = async () => {
8341
+ const setOwner = async () => {
8339
8342
  try {
8340
8343
  const token = await getAccessTokenRef.current();
8341
8344
  if (!token || cancelled) return;
8342
- await claimAccount(apiBaseUrl, token, state.guestPreauthAccountId, {
8343
- guestToken: state.guestSessionToken,
8345
+ await setAccountOwner(apiBaseUrl, token, state.guestPreauthAccountId, state.guestSessionToken, {
8344
8346
  credentialId: state.activeCredentialId,
8345
8347
  publicKey: state.activePublicKey
8346
8348
  });
@@ -8350,19 +8352,19 @@ function usePaymentEffects(deps) {
8350
8352
  } catch {
8351
8353
  }
8352
8354
  if (cancelled) return;
8353
- dispatch({ type: "GUEST_PREAUTH_CLAIMED" });
8355
+ dispatch({ type: "ACCOUNT_OWNER_SET" });
8354
8356
  } catch (err) {
8355
8357
  if (cancelled) return;
8356
8358
  captureException(err);
8357
8359
  dispatch({
8358
8360
  type: "SET_ERROR",
8359
- error: err instanceof Error ? err.message : "Failed to claim account"
8361
+ error: err instanceof Error ? err.message : "Failed to set account owner"
8360
8362
  });
8361
8363
  } finally {
8362
- claimingRef.current = false;
8364
+ settingOwnerRef.current = false;
8363
8365
  }
8364
8366
  };
8365
- claimPreauth();
8367
+ setOwner();
8366
8368
  return () => {
8367
8369
  cancelled = true;
8368
8370
  };