@swype-org/react-sdk 0.1.224 → 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
  });
@@ -2217,7 +2218,7 @@ function paymentReducer(state, action) {
2217
2218
  guestPreauthAccountId: action.accountId,
2218
2219
  step: "login"
2219
2220
  };
2220
- case "GUEST_PREAUTH_CLAIMED":
2221
+ case "ACCOUNT_OWNER_SET":
2221
2222
  return {
2222
2223
  ...state,
2223
2224
  guestPreauthAccountId: null,
@@ -8327,22 +8328,21 @@ function usePaymentEffects(deps) {
8327
8328
  cancelled = true;
8328
8329
  };
8329
8330
  }, [state.step, state.guestSessionToken, state.guestPreauthAccountId, apiBaseUrl, dispatch]);
8330
- const claimingRef = react.useRef(false);
8331
+ const settingOwnerRef = react.useRef(false);
8331
8332
  react.useEffect(() => {
8332
8333
  if (!state.guestPreauthAccountId) return;
8333
8334
  if (!state.activeCredentialId) return;
8334
8335
  if (!state.activePublicKey) return;
8335
8336
  if (!authenticated) return;
8336
8337
  if (!state.guestSessionToken) return;
8337
- if (claimingRef.current) return;
8338
- claimingRef.current = true;
8338
+ if (settingOwnerRef.current) return;
8339
+ settingOwnerRef.current = true;
8339
8340
  let cancelled = false;
8340
- const claimPreauth = async () => {
8341
+ const setOwner = async () => {
8341
8342
  try {
8342
8343
  const token = await getAccessTokenRef.current();
8343
8344
  if (!token || cancelled) return;
8344
- await claimAccount(apiBaseUrl, token, state.guestPreauthAccountId, {
8345
- guestToken: state.guestSessionToken,
8345
+ await setAccountOwner(apiBaseUrl, token, state.guestPreauthAccountId, state.guestSessionToken, {
8346
8346
  credentialId: state.activeCredentialId,
8347
8347
  publicKey: state.activePublicKey
8348
8348
  });
@@ -8352,19 +8352,19 @@ function usePaymentEffects(deps) {
8352
8352
  } catch {
8353
8353
  }
8354
8354
  if (cancelled) return;
8355
- dispatch({ type: "GUEST_PREAUTH_CLAIMED" });
8355
+ dispatch({ type: "ACCOUNT_OWNER_SET" });
8356
8356
  } catch (err) {
8357
8357
  if (cancelled) return;
8358
8358
  captureException(err);
8359
8359
  dispatch({
8360
8360
  type: "SET_ERROR",
8361
- error: err instanceof Error ? err.message : "Failed to claim account"
8361
+ error: err instanceof Error ? err.message : "Failed to set account owner"
8362
8362
  });
8363
8363
  } finally {
8364
- claimingRef.current = false;
8364
+ settingOwnerRef.current = false;
8365
8365
  }
8366
8366
  };
8367
- claimPreauth();
8367
+ setOwner();
8368
8368
  return () => {
8369
8369
  cancelled = true;
8370
8370
  };