@swype-org/react-sdk 0.1.85 → 0.1.86

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
@@ -167,6 +167,7 @@ __export(api_exports, {
167
167
  fetchUserConfig: () => fetchUserConfig,
168
168
  registerPasskey: () => registerPasskey,
169
169
  reportActionCompletion: () => reportActionCompletion,
170
+ reportPasskeyActivity: () => reportPasskeyActivity,
170
171
  signTransfer: () => signTransfer,
171
172
  updateUserConfig: () => updateUserConfig,
172
173
  updateUserConfigBySession: () => updateUserConfigBySession
@@ -289,6 +290,17 @@ async function registerPasskey(apiBaseUrl, token, credentialId, publicKey) {
289
290
  });
290
291
  if (!res.ok) await throwApiError(res);
291
292
  }
293
+ async function reportPasskeyActivity(apiBaseUrl, token, credentialId) {
294
+ const res = await fetch(`${apiBaseUrl}/v1/users/config/passkey`, {
295
+ method: "PATCH",
296
+ headers: {
297
+ "Content-Type": "application/json",
298
+ Authorization: `Bearer ${token}`
299
+ },
300
+ body: JSON.stringify({ credentialId })
301
+ });
302
+ if (!res.ok) await throwApiError(res);
303
+ }
292
304
  async function fetchUserConfig(apiBaseUrl, token) {
293
305
  const res = await fetch(`${apiBaseUrl}/v1/users/config`, {
294
306
  headers: { Authorization: `Bearer ${token}` }
@@ -5052,6 +5064,8 @@ function SwypePaymentInner({
5052
5064
  if (matched) {
5053
5065
  setActiveCredentialId(matched);
5054
5066
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, matched);
5067
+ reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
5068
+ });
5055
5069
  await restoreOrDeposit(matched, token);
5056
5070
  return;
5057
5071
  }
@@ -5584,6 +5598,11 @@ function SwypePaymentInner({
5584
5598
  if (matched) {
5585
5599
  setActiveCredentialId(matched);
5586
5600
  window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, matched);
5601
+ const token = await getAccessToken();
5602
+ if (token) {
5603
+ reportPasskeyActivity(apiBaseUrl, token, matched).catch(() => {
5604
+ });
5605
+ }
5587
5606
  setStep("login");
5588
5607
  } else {
5589
5608
  setStep("create-passkey");
@@ -5593,7 +5612,7 @@ function SwypePaymentInner({
5593
5612
  } finally {
5594
5613
  setVerifyingPasskeyPopup(false);
5595
5614
  }
5596
- }, [knownCredentialIds]);
5615
+ }, [knownCredentialIds, getAccessToken, apiBaseUrl]);
5597
5616
  const handleSelectProvider = react.useCallback((providerId) => {
5598
5617
  setSelectedProviderId(providerId);
5599
5618
  setSelectedAccountId(null);