@dynamic-labs-sdk/client 1.22.0 → 1.22.1

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.
Files changed (78) hide show
  1. package/dist/{NativeModuleNotLinkedError-BK7v1pWC.native.esm.js → NativeModuleNotLinkedError-C1P6K16j.native.esm.js} +188 -166
  2. package/dist/NativeModuleNotLinkedError-C1P6K16j.native.esm.js.map +1 -0
  3. package/dist/{consumeMfaTokenIfRequiredForAction-csagEe9v.cjs → consumeMfaTokenIfRequiredForAction-D1iSuzzl.cjs} +2 -2
  4. package/dist/{consumeMfaTokenIfRequiredForAction-csagEe9v.cjs.map → consumeMfaTokenIfRequiredForAction-D1iSuzzl.cjs.map} +1 -1
  5. package/dist/{consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js → consumeMfaTokenIfRequiredForAction-NVOBPPQW.esm.js} +2 -2
  6. package/dist/{consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js.map → consumeMfaTokenIfRequiredForAction-NVOBPPQW.esm.js.map} +1 -1
  7. package/dist/core.cjs +6 -6
  8. package/dist/core.esm.js +6 -6
  9. package/dist/core.native.esm.js +5 -5
  10. package/dist/{getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js → getNetworkProviderFromNetworkId-CkKboiVD.esm.js} +2 -2
  11. package/dist/{getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js.map → getNetworkProviderFromNetworkId-CkKboiVD.esm.js.map} +1 -1
  12. package/dist/{getNetworkProviderFromNetworkId-BAbc7qAr.cjs → getNetworkProviderFromNetworkId-Cn1w40Jn.cjs} +2 -2
  13. package/dist/{getNetworkProviderFromNetworkId-BAbc7qAr.cjs.map → getNetworkProviderFromNetworkId-Cn1w40Jn.cjs.map} +1 -1
  14. package/dist/{getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js → getNetworkProviderFromNetworkId-W8EeAcf_.native.esm.js} +3 -3
  15. package/dist/getNetworkProviderFromNetworkId-W8EeAcf_.native.esm.js.map +1 -0
  16. package/dist/{getSignedSessionId-DpZexHsP.cjs → getSignedSessionId-DXrCyLJT.cjs} +2 -2
  17. package/dist/{getSignedSessionId-DpZexHsP.cjs.map → getSignedSessionId-DXrCyLJT.cjs.map} +1 -1
  18. package/dist/{getSignedSessionId-C9EFdGfb.native.esm.js → getSignedSessionId-DgEVnuO-.native.esm.js} +3 -3
  19. package/dist/{getSignedSessionId-C9EFdGfb.native.esm.js.map → getSignedSessionId-DgEVnuO-.native.esm.js.map} +1 -1
  20. package/dist/{getSignedSessionId-bbTK-sA0.esm.js → getSignedSessionId-DjHPdrA_.esm.js} +2 -2
  21. package/dist/{getSignedSessionId-bbTK-sA0.esm.js.map → getSignedSessionId-DjHPdrA_.esm.js.map} +1 -1
  22. package/dist/{getWalletProviderByKey-D_TZdpYc.esm.js → getWalletProviderByKey-BAmDpbgi.esm.js} +2 -2
  23. package/dist/{getWalletProviderByKey-D_TZdpYc.esm.js.map → getWalletProviderByKey-BAmDpbgi.esm.js.map} +1 -1
  24. package/dist/{getWalletProviderByKey-DVBZq2sg.native.esm.js → getWalletProviderByKey-ClOKL5JG.native.esm.js} +2 -2
  25. package/dist/{getWalletProviderByKey-DVBZq2sg.native.esm.js.map → getWalletProviderByKey-ClOKL5JG.native.esm.js.map} +1 -1
  26. package/dist/{getWalletProviderByKey-Bmqc0Duc.cjs → getWalletProviderByKey-o0urQYPF.cjs} +2 -2
  27. package/dist/{getWalletProviderByKey-Bmqc0Duc.cjs.map → getWalletProviderByKey-o0urQYPF.cjs.map} +1 -1
  28. package/dist/index.cjs +6 -6
  29. package/dist/index.esm.js +6 -6
  30. package/dist/index.native.esm.js +6 -6
  31. package/dist/{isDynamicWaasEnabled-BJimir8s.esm.js → isDynamicWaasEnabled-C0x4cUHe.esm.js} +2 -2
  32. package/dist/{isDynamicWaasEnabled-BJimir8s.esm.js.map → isDynamicWaasEnabled-C0x4cUHe.esm.js.map} +1 -1
  33. package/dist/{isDynamicWaasEnabled-NC2_jndd.native.esm.js → isDynamicWaasEnabled-CF-T5TSi.native.esm.js} +2 -2
  34. package/dist/{isDynamicWaasEnabled-NC2_jndd.native.esm.js.map → isDynamicWaasEnabled-CF-T5TSi.native.esm.js.map} +1 -1
  35. package/dist/{isDynamicWaasEnabled-Bfd-h02Q.cjs → isDynamicWaasEnabled-DQe8Wxd0.cjs} +2 -2
  36. package/dist/{isDynamicWaasEnabled-Bfd-h02Q.cjs.map → isDynamicWaasEnabled-DQe8Wxd0.cjs.map} +1 -1
  37. package/dist/{isMfaRequiredForAction-DMB9vA5-.esm.js → isMfaRequiredForAction-BK_4B7Gi.esm.js} +2 -2
  38. package/dist/{isMfaRequiredForAction-DMB9vA5-.esm.js.map → isMfaRequiredForAction-BK_4B7Gi.esm.js.map} +1 -1
  39. package/dist/{isMfaRequiredForAction-W1y6oe6Y.cjs → isMfaRequiredForAction-BcO-fQ-N.cjs} +2 -2
  40. package/dist/{isMfaRequiredForAction-W1y6oe6Y.cjs.map → isMfaRequiredForAction-BcO-fQ-N.cjs.map} +1 -1
  41. package/dist/{isMfaRequiredForAction-MdS-yMQf.native.esm.js → isMfaRequiredForAction-Ce0neLQQ.native.esm.js} +2 -2
  42. package/dist/{isMfaRequiredForAction-MdS-yMQf.native.esm.js.map → isMfaRequiredForAction-Ce0neLQQ.native.esm.js.map} +1 -1
  43. package/dist/{isUserOnboardingComplete-BmGd69SF.cjs → isUserOnboardingComplete-B4hlrt5N.cjs} +3 -3
  44. package/dist/{isUserOnboardingComplete-BmGd69SF.cjs.map → isUserOnboardingComplete-B4hlrt5N.cjs.map} +1 -1
  45. package/dist/{isUserOnboardingComplete-Bj0ClaGP.native.esm.js → isUserOnboardingComplete-BK7GcrpI.native.esm.js} +3 -3
  46. package/dist/{isUserOnboardingComplete-Bj0ClaGP.native.esm.js.map → isUserOnboardingComplete-BK7GcrpI.native.esm.js.map} +1 -1
  47. package/dist/{isUserOnboardingComplete-Cm2VLmIH.esm.js → isUserOnboardingComplete-CssbJY_7.esm.js} +3 -3
  48. package/dist/{isUserOnboardingComplete-Cm2VLmIH.esm.js.map → isUserOnboardingComplete-CssbJY_7.esm.js.map} +1 -1
  49. package/dist/{migrateFromFireblocks-rs5CZz-4.native.esm.js → migrateFromFireblocks-BX9JTaOI.native.esm.js} +3 -3
  50. package/dist/{migrateFromFireblocks-rs5CZz-4.native.esm.js.map → migrateFromFireblocks-BX9JTaOI.native.esm.js.map} +1 -1
  51. package/dist/{migrateFromFireblocks-BUuulRx2.esm.js → migrateFromFireblocks-Btox03CB.esm.js} +4 -4
  52. package/dist/{migrateFromFireblocks-BUuulRx2.esm.js.map → migrateFromFireblocks-Btox03CB.esm.js.map} +1 -1
  53. package/dist/{migrateFromFireblocks-rQkE9cQa.cjs → migrateFromFireblocks-CIE4qLS6.cjs} +4 -4
  54. package/dist/{migrateFromFireblocks-rQkE9cQa.cjs.map → migrateFromFireblocks-CIE4qLS6.cjs.map} +1 -1
  55. package/dist/modules/apiClient/constants.d.ts +7 -0
  56. package/dist/modules/apiClient/constants.d.ts.map +1 -1
  57. package/dist/modules/apiClient/createApiClient.d.ts +1 -2
  58. package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
  59. package/dist/modules/apiClient/createBaseApiClient.d.ts +16 -0
  60. package/dist/modules/apiClient/createBaseApiClient.d.ts.map +1 -0
  61. package/dist/modules/auth/logoutWithReason/logoutWithReason.d.ts.map +1 -1
  62. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  63. package/dist/{updateAuthFromVerifyResponse-85pmbAH4.esm.js → updateAuthFromVerifyResponse-BhILXMm_.esm.js} +189 -167
  64. package/dist/updateAuthFromVerifyResponse-BhILXMm_.esm.js.map +1 -0
  65. package/dist/{updateAuthFromVerifyResponse-CNfUcLNC.cjs → updateAuthFromVerifyResponse-CK3pAERc.cjs} +188 -166
  66. package/dist/updateAuthFromVerifyResponse-CK3pAERc.cjs.map +1 -0
  67. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -1
  68. package/dist/waas.cjs +5 -5
  69. package/dist/waas.esm.js +5 -5
  70. package/dist/waas.native.esm.js +4 -4
  71. package/dist/waasCore.cjs +7 -7
  72. package/dist/waasCore.esm.js +7 -7
  73. package/dist/waasCore.native.esm.js +6 -6
  74. package/package.json +2 -2
  75. package/dist/NativeModuleNotLinkedError-BK7v1pWC.native.esm.js.map +0 -1
  76. package/dist/getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js.map +0 -1
  77. package/dist/updateAuthFromVerifyResponse-85pmbAH4.esm.js.map +0 -1
  78. package/dist/updateAuthFromVerifyResponse-CNfUcLNC.cjs.map +0 -1
@@ -6,7 +6,7 @@ import { Platform } from "react-native";
6
6
 
7
7
  //#region package.json
8
8
  var name = "@dynamic-labs-sdk/client";
9
- var version = "1.22.0";
9
+ var version = "1.22.1";
10
10
  var dependencies = {
11
11
  "@dynamic-labs-sdk/assert-package-version": "workspace:*",
12
12
  "@dynamic-labs-wallet/browser-wallet-client": "1.0.79",
@@ -141,26 +141,6 @@ const setDefaultClient = (client) => {
141
141
  const NONCE_POOL_EXPIRATION_TIME = 6e4 * 60 * 24;
142
142
  const NONCE_POOL_SIZE = 5;
143
143
 
144
- //#endregion
145
- //#region src/modules/apiClient/constants.ts
146
- const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
147
- const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
148
- const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
149
- const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
150
- const MFA_TOKEN_HEADER = "x-mfa-auth-token";
151
- const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
152
- const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
153
- const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
154
- /**
155
- * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
156
- *
157
- * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
158
- * webview-controller already sends, so the backend receives a consistent
159
- * platform signal across SDK generations.
160
- */
161
- const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
162
- const CLIENT_SDK_NAME = "ClientSDK";
163
-
164
144
  //#endregion
165
145
  //#region src/utils/getPlatform/getPlatform.native.ts
166
146
  /**
@@ -287,6 +267,33 @@ const getSessionKeys = (client) => {
287
267
  return { publicKey };
288
268
  };
289
269
 
270
+ //#endregion
271
+ //#region src/modules/apiClient/constants.ts
272
+ const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
273
+ const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
274
+ const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
275
+ /**
276
+ * Reports *why* the SDK is logging the user out on the `revokeSession`
277
+ * (`/sdk/{env}/revoke`) request. The backend logs it so SDK-initiated session
278
+ * revocations are attributable in Datadog (e.g. `token-expired`,
279
+ * `keychain-key-missing`) instead of being inferred from downstream 401s.
280
+ */
281
+ const DYNAMIC_LOGOUT_REASON_HEADER = "x-dyn-logout-reason";
282
+ const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
283
+ const MFA_TOKEN_HEADER = "x-mfa-auth-token";
284
+ const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
285
+ const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
286
+ const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
287
+ /**
288
+ * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
289
+ *
290
+ * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
291
+ * webview-controller already sends, so the backend receives a consistent
292
+ * platform signal across SDK generations.
293
+ */
294
+ const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
295
+ const CLIENT_SDK_NAME = "ClientSDK";
296
+
290
297
  //#endregion
291
298
  //#region src/errors/APIError/APIError.ts
292
299
  var APIError = class APIError extends BaseError {
@@ -458,6 +465,81 @@ const createConvertToApiErrorMiddleware = ({ errorMappers = [] }) => ({ post: as
458
465
  return context.response;
459
466
  } });
460
467
 
468
+ //#endregion
469
+ //#region src/errors/UnauthorizedError.ts
470
+ var UnauthorizedError = class extends BaseError {
471
+ constructor({ cause }) {
472
+ super({
473
+ cause,
474
+ code: "unauthorized_error",
475
+ docsUrl: null,
476
+ name: "UnauthorizedError",
477
+ shortMessage: "Unauthorized"
478
+ });
479
+ }
480
+ };
481
+
482
+ //#endregion
483
+ //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
484
+ /** @notInstrumented */
485
+ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
486
+ if (context.response.status === 401) {
487
+ let cause = null;
488
+ try {
489
+ const errorBody = await context.response.clone().json();
490
+ if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
491
+ } catch {}
492
+ throw new UnauthorizedError({ cause });
493
+ }
494
+ return context.response;
495
+ } });
496
+
497
+ //#endregion
498
+ //#region src/modules/apiClient/createBaseApiClient.ts
499
+ /**
500
+ * Creates the base SDK API client from the client's core state, applying the
501
+ * standard headers and the always-on error-conversion and unauthorized
502
+ * middleware. Any middleware passed via `middleware` runs before those two.
503
+ * @notInstrumented
504
+ */
505
+ const createBaseApiClient = ({ middleware = [], options = {} }, client) => {
506
+ const core = getCore(client);
507
+ const coreState = core.state.get();
508
+ const settings = {
509
+ basePath: core.apiBaseUrl,
510
+ headers: {
511
+ "Content-Type": "application/json",
512
+ [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
513
+ [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
514
+ [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
515
+ [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
516
+ [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
517
+ ...core.getApiHeaders(),
518
+ ...options.headers
519
+ }
520
+ };
521
+ if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
522
+ if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
523
+ if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
524
+ if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
525
+ if (options.elevatedAccessTokenScope) {
526
+ const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
527
+ if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
528
+ }
529
+ const sessionPublicKey = getSessionKeys(client)?.publicKey;
530
+ const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
531
+ if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
532
+ return new SDKApi(new Configuration({
533
+ ...settings,
534
+ fetchApi: core.fetch,
535
+ middleware: [
536
+ ...middleware,
537
+ createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
538
+ createUnauthorizedMiddleware()
539
+ ]
540
+ }));
541
+ };
542
+
461
543
  //#endregion
462
544
  //#region src/services/storage/createLocalStorageAdapter/createLocalStorageAdapter.native.ts
463
545
  const NAMESPACE = "dynamic";
@@ -539,6 +621,85 @@ const updateNoncePoolStorage = async ({ update }, client) => {
539
621
  return storedBeforeUpdate;
540
622
  };
541
623
 
624
+ //#endregion
625
+ //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
626
+ /**
627
+ * Fetches a batch of nonces from the API and appends them to the pool in
628
+ * storage.
629
+ *
630
+ * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
631
+ * redirect). On iOS, a network request (like fetching a nonce) between a user
632
+ * action and a deeplink call will break the gesture chain, causing iOS to
633
+ * silently ignore the deeplink. By prefetching nonces ahead of time,
634
+ * `getNonce` can return from the stored pool without an interrupting network
635
+ * round-trip.
636
+ *
637
+ * New nonces are **appended** to the stored pool so that unconsumed entries
638
+ * are not discarded by a background refetch; an expired stored pool is
639
+ * replaced instead, since its nonces have already been evicted server-side.
640
+ *
641
+ * Concurrent refills are coalesced behind a single in-flight promise so that
642
+ * simultaneous callers share one `GET /nonces` round-trip instead of each
643
+ * issuing their own (which would inflate the pool and hammer the backend).
644
+ * @notInstrumented
645
+ */
646
+ const fetchAndStoreNonces = async (client) => {
647
+ const core = getCore(client);
648
+ const inFlight = core.state.get().nonceFetchInFlight;
649
+ if (inFlight) return inFlight;
650
+ const { environmentId } = core;
651
+ const apiClient = createBaseApiClient({}, client);
652
+ const fetchPromise = (async () => {
653
+ const { nonces } = await apiClient.getNonces({
654
+ count: NONCE_POOL_SIZE,
655
+ environmentId
656
+ });
657
+ const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
658
+ await updateNoncePoolStorage({ update: (stored) => {
659
+ return {
660
+ expiration,
661
+ nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
662
+ };
663
+ } }, client);
664
+ })().finally(() => {
665
+ core.state.set({ nonceFetchInFlight: null });
666
+ });
667
+ core.state.set({ nonceFetchInFlight: fetchPromise });
668
+ return fetchPromise;
669
+ };
670
+
671
+ //#endregion
672
+ //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
673
+ /**
674
+ * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
675
+ * document is running in a secure context, or an empty string otherwise.
676
+ *
677
+ * The `Secure` attribute prevents the browser from ever transmitting the cookie
678
+ * over an unencrypted `http://` connection, which mitigates cleartext token
679
+ * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
680
+ * because browsers reject `Secure` cookies set over `http://` and that would
681
+ * silently break local testing.
682
+ *
683
+ * Used when building the Dynamic auth JWT cookie string so the attribute is
684
+ * applied consistently on both the write (sign-in/refresh) and clear (logout)
685
+ * paths.
686
+ *
687
+ * @notInstrumented
688
+ */
689
+ const getSecureCookieAttribute = () => {
690
+ return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
691
+ };
692
+
693
+ //#endregion
694
+ //#region src/utils/setCookie/setCookie.ts
695
+ /**
696
+ * Sefelly sets the cookie in the browser.
697
+ * @notInstrumented
698
+ */
699
+ const setCookie = (cookie) => {
700
+ document.cookie = cookie;
701
+ };
702
+
542
703
  //#endregion
543
704
  //#region src/utils/getNonce/getNonce.ts
544
705
  /**
@@ -641,35 +802,6 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
641
802
  } };
642
803
  };
643
804
 
644
- //#endregion
645
- //#region src/errors/UnauthorizedError.ts
646
- var UnauthorizedError = class extends BaseError {
647
- constructor({ cause }) {
648
- super({
649
- cause,
650
- code: "unauthorized_error",
651
- docsUrl: null,
652
- name: "UnauthorizedError",
653
- shortMessage: "Unauthorized"
654
- });
655
- }
656
- };
657
-
658
- //#endregion
659
- //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
660
- /** @notInstrumented */
661
- const createUnauthorizedMiddleware = () => ({ post: async (context) => {
662
- if (context.response.status === 401) {
663
- let cause = null;
664
- try {
665
- const errorBody = await context.response.clone().json();
666
- if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
667
- } catch {}
668
- throw new UnauthorizedError({ cause });
669
- }
670
- return context.response;
671
- } });
672
-
673
805
  //#endregion
674
806
  //#region src/modules/apiClient/createApiClient.ts
675
807
  /**
@@ -679,120 +811,10 @@ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
679
811
  * @notInstrumented
680
812
  */
681
813
  const createApiClient = (options = {}, client) => {
682
- const core = getCore(client);
683
- const coreState = core.state.get();
684
- const settings = {
685
- basePath: core.apiBaseUrl,
686
- headers: {
687
- "Content-Type": "application/json",
688
- [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
689
- [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
690
- [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
691
- [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
692
- [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
693
- ...core.getApiHeaders(),
694
- ...options.headers
695
- }
696
- };
697
- if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
698
- if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
699
- if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
700
- if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
701
- if (options.elevatedAccessTokenScope) {
702
- const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
703
- if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
704
- }
705
- const sessionPublicKey = getSessionKeys(client)?.publicKey;
706
- const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
707
- if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
708
- return new SDKApi(new Configuration({
709
- ...settings,
710
- fetchApi: core.fetch,
711
- middleware: [
712
- createDeviceSignatureHeadersMiddleware(client),
713
- createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
714
- createUnauthorizedMiddleware()
715
- ]
716
- }));
717
- };
718
-
719
- //#endregion
720
- //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
721
- /**
722
- * Fetches a batch of nonces from the API and appends them to the pool in
723
- * storage.
724
- *
725
- * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
726
- * redirect). On iOS, a network request (like fetching a nonce) between a user
727
- * action and a deeplink call will break the gesture chain, causing iOS to
728
- * silently ignore the deeplink. By prefetching nonces ahead of time,
729
- * `getNonce` can return from the stored pool without an interrupting network
730
- * round-trip.
731
- *
732
- * New nonces are **appended** to the stored pool so that unconsumed entries
733
- * are not discarded by a background refetch; an expired stored pool is
734
- * replaced instead, since its nonces have already been evicted server-side.
735
- *
736
- * Concurrent refills are coalesced behind a single in-flight promise so that
737
- * simultaneous callers share one `GET /nonces` round-trip instead of each
738
- * issuing their own (which would inflate the pool and hammer the backend).
739
- * @notInstrumented
740
- */
741
- const fetchAndStoreNonces = async (client) => {
742
- const core = getCore(client);
743
- const inFlight = core.state.get().nonceFetchInFlight;
744
- if (inFlight) return inFlight;
745
- const { environmentId } = core;
746
- const apiClient = createApiClient({}, client);
747
- const fetchPromise = (async () => {
748
- const { nonces } = await apiClient.getNonces({
749
- count: NONCE_POOL_SIZE,
750
- environmentId
751
- });
752
- const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
753
- await updateNoncePoolStorage({ update: (stored) => {
754
- return {
755
- expiration,
756
- nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
757
- };
758
- } }, client);
759
- })().finally(() => {
760
- core.state.set({ nonceFetchInFlight: null });
761
- });
762
- core.state.set({ nonceFetchInFlight: fetchPromise });
763
- return fetchPromise;
764
- };
765
-
766
- //#endregion
767
- //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
768
- /**
769
- * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
770
- * document is running in a secure context, or an empty string otherwise.
771
- *
772
- * The `Secure` attribute prevents the browser from ever transmitting the cookie
773
- * over an unencrypted `http://` connection, which mitigates cleartext token
774
- * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
775
- * because browsers reject `Secure` cookies set over `http://` and that would
776
- * silently break local testing.
777
- *
778
- * Used when building the Dynamic auth JWT cookie string so the attribute is
779
- * applied consistently on both the write (sign-in/refresh) and clear (logout)
780
- * paths.
781
- *
782
- * @notInstrumented
783
- */
784
- const getSecureCookieAttribute = () => {
785
- return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
786
- };
787
-
788
- //#endregion
789
- //#region src/utils/setCookie/setCookie.ts
790
- /**
791
- * Sefelly sets the cookie in the browser.
792
- * @notInstrumented
793
- */
794
- const setCookie = (cookie) => {
795
- document.cookie = cookie;
814
+ return createBaseApiClient({
815
+ middleware: [createDeviceSignatureHeadersMiddleware(client)],
816
+ options
817
+ }, client);
796
818
  };
797
819
 
798
820
  //#endregion
@@ -2101,5 +2123,5 @@ var NativeModuleNotLinkedError = class extends BaseError {
2101
2123
  };
2102
2124
 
2103
2125
  //#endregion
2104
- export { updateNoncePoolStorage as $, NoWalletProviderFoundError as A, emitEvent as B, getOperatingSystem as C, name as Ct, WalletProviderPriority as D, getWalletProviderFromWalletAccount as E, CHAINS_INFO_MAP as F, getSecureCookieAttribute as G, onEvent as H, formatWalletAccountId as I, UnauthorizedError as J, fetchAndStoreNonces as K, normalizeAddress as L, formatWalletProviderKey as M, normalizeWalletNameWithChain as N, getWalletProviderRegistry as O, getChainFromVerifiedCredentialChain as P, getNonce as Q, splitWalletProviderKey as R, getUserAgent as S, getCore as St, DYNAMIC_AUTH_COOKIE_NAME as T, onceEvent as U, offEvent as V, setCookie as W, getHeadersForNonceSignedByDeviceSigners as X, createDeviceSignatureHeadersMiddleware as Y, getDeviceSigner as Z, DYNAMIC_ICONIC_SPRITE_URL as _, NONCE_POOL_SIZE as _t, InvalidParamError as a, LinkCredentialError as at, scrubParameters as b, ClientNotFoundError as bt, findWaasWalletProviderByChain as c, getSessionKeys as ct, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as d, ValueMustBeDefinedError as dt, createStorageKeySchema as et, DYNAMIC_WAAS_METADATA as f, getElevatedAccessToken as ft, emitWalletAccountsChangedEvent as g, DYNAMIC_SDK_API_VERSION as gt, checkAndRaiseWalletAccountsChangedEvent as h, CLIENT_SDK_NAME as ht, parseElevatedAccessToken as i, MfaInvalidOtpError as it, getWalletAccounts as j, createRuntimeServiceAccessKey as k, isWaasWalletProvider as l, isCookieEnabled as lt, isUserMissingMfaAuth as m, getPlatform as mt, updateAuthFromVerifyResponse as n, SandboxMaximumThresholdReachedError as nt, initializeWaasClientsForEagerRecovery as o, InvalidExternalAuthError as ot, getWalletProviders as p, randomString as pt, createApiClient as q, upsertElevatedAccessToken as r, MfaRateLimitedError as rt, isWaasWalletAccount as s, APIError as st, NativeModuleNotLinkedError as t, createLocalStorageAdapter as tt, DEFAULT_WAAS_BASE_API_URL as u, assertDefined as ut, SDK_API_CORE_VERSION as v, getDefaultClient as vt, extractSessionId as w, version as wt, DEFAULT_PII_FIELDS as x, BaseError as xt, instrumentFunction as y, setDefaultClient as yt, InvalidWalletProviderKeyError as z };
2105
- //# sourceMappingURL=NativeModuleNotLinkedError-BK7v1pWC.native.esm.js.map
2126
+ export { createStorageKeySchema as $, NoWalletProviderFoundError as A, emitEvent as B, getOperatingSystem as C, getCore as Ct, WalletProviderPriority as D, getWalletProviderFromWalletAccount as E, CHAINS_INFO_MAP as F, createDeviceSignatureHeadersMiddleware as G, onEvent as H, formatWalletAccountId as I, getNonce as J, getHeadersForNonceSignedByDeviceSigners as K, normalizeAddress as L, formatWalletProviderKey as M, normalizeWalletNameWithChain as N, getWalletProviderRegistry as O, getChainFromVerifiedCredentialChain as P, updateNoncePoolStorage as Q, splitWalletProviderKey as R, getUserAgent as S, BaseError as St, DYNAMIC_AUTH_COOKIE_NAME as T, version as Tt, onceEvent as U, offEvent as V, createApiClient as W, getSecureCookieAttribute as X, setCookie as Y, fetchAndStoreNonces as Z, DYNAMIC_ICONIC_SPRITE_URL as _, getPlatform as _t, InvalidParamError as a, LinkCredentialError as at, scrubParameters as b, setDefaultClient as bt, findWaasWalletProviderByChain as c, CLIENT_SDK_NAME as ct, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as d, getSessionKeys as dt, createLocalStorageAdapter as et, DYNAMIC_WAAS_METADATA as f, isCookieEnabled as ft, emitWalletAccountsChangedEvent as g, randomString as gt, checkAndRaiseWalletAccountsChangedEvent as h, getElevatedAccessToken as ht, parseElevatedAccessToken as i, MfaInvalidOtpError as it, getWalletAccounts as j, createRuntimeServiceAccessKey as k, isWaasWalletProvider as l, DYNAMIC_LOGOUT_REASON_HEADER as lt, isUserMissingMfaAuth as m, ValueMustBeDefinedError as mt, updateAuthFromVerifyResponse as n, SandboxMaximumThresholdReachedError as nt, initializeWaasClientsForEagerRecovery as o, InvalidExternalAuthError as ot, getWalletProviders as p, assertDefined as pt, getDeviceSigner as q, upsertElevatedAccessToken as r, MfaRateLimitedError as rt, isWaasWalletAccount as s, APIError as st, NativeModuleNotLinkedError as t, UnauthorizedError as tt, DEFAULT_WAAS_BASE_API_URL as u, DYNAMIC_SDK_API_VERSION as ut, SDK_API_CORE_VERSION as v, NONCE_POOL_SIZE as vt, extractSessionId as w, name as wt, DEFAULT_PII_FIELDS as x, ClientNotFoundError as xt, instrumentFunction as y, getDefaultClient as yt, InvalidWalletProviderKeyError as z };
2127
+ //# sourceMappingURL=NativeModuleNotLinkedError-C1P6K16j.native.esm.js.map