@dynamic-labs-sdk/client 1.21.2 → 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 (109) hide show
  1. package/dist/{NativeModuleNotLinkedError-Duh8DMLT.native.esm.js → NativeModuleNotLinkedError-C1P6K16j.native.esm.js} +190 -167
  2. package/dist/NativeModuleNotLinkedError-C1P6K16j.native.esm.js.map +1 -0
  3. package/dist/{consumeMfaTokenIfRequiredForAction-B2zzOTIn.cjs → consumeMfaTokenIfRequiredForAction-D1iSuzzl.cjs} +2 -2
  4. package/dist/{consumeMfaTokenIfRequiredForAction-B2zzOTIn.cjs.map → consumeMfaTokenIfRequiredForAction-D1iSuzzl.cjs.map} +1 -1
  5. package/dist/{consumeMfaTokenIfRequiredForAction-CJxVqCmj.esm.js → consumeMfaTokenIfRequiredForAction-NVOBPPQW.esm.js} +2 -2
  6. package/dist/{consumeMfaTokenIfRequiredForAction-CJxVqCmj.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/exports/waas.d.ts +2 -3
  11. package/dist/exports/waas.d.ts.map +1 -1
  12. package/dist/{getNetworkProviderFromNetworkId-_2e6e2Ro.esm.js → getNetworkProviderFromNetworkId-CkKboiVD.esm.js} +2 -2
  13. package/dist/{getNetworkProviderFromNetworkId-_2e6e2Ro.esm.js.map → getNetworkProviderFromNetworkId-CkKboiVD.esm.js.map} +1 -1
  14. package/dist/{getNetworkProviderFromNetworkId-h1eFbUp8.cjs → getNetworkProviderFromNetworkId-Cn1w40Jn.cjs} +2 -2
  15. package/dist/{getNetworkProviderFromNetworkId-h1eFbUp8.cjs.map → getNetworkProviderFromNetworkId-Cn1w40Jn.cjs.map} +1 -1
  16. package/dist/{getNetworkProviderFromNetworkId-C0FLeQ5n.native.esm.js → getNetworkProviderFromNetworkId-W8EeAcf_.native.esm.js} +3 -3
  17. package/dist/getNetworkProviderFromNetworkId-W8EeAcf_.native.esm.js.map +1 -0
  18. package/dist/{getSignedSessionId-DPh7vAKs.cjs → getSignedSessionId-DXrCyLJT.cjs} +2 -2
  19. package/dist/{getSignedSessionId-DPh7vAKs.cjs.map → getSignedSessionId-DXrCyLJT.cjs.map} +1 -1
  20. package/dist/{getSignedSessionId-BZO5AD86.native.esm.js → getSignedSessionId-DgEVnuO-.native.esm.js} +3 -3
  21. package/dist/{getSignedSessionId-BZO5AD86.native.esm.js.map → getSignedSessionId-DgEVnuO-.native.esm.js.map} +1 -1
  22. package/dist/{getSignedSessionId-BhWiqoE7.esm.js → getSignedSessionId-DjHPdrA_.esm.js} +2 -2
  23. package/dist/{getSignedSessionId-BhWiqoE7.esm.js.map → getSignedSessionId-DjHPdrA_.esm.js.map} +1 -1
  24. package/dist/{getWalletProviderByKey-CjaJQ7fI.esm.js → getWalletProviderByKey-BAmDpbgi.esm.js} +2 -2
  25. package/dist/{getWalletProviderByKey-CjaJQ7fI.esm.js.map → getWalletProviderByKey-BAmDpbgi.esm.js.map} +1 -1
  26. package/dist/{getWalletProviderByKey-CHwDF-wB.native.esm.js → getWalletProviderByKey-ClOKL5JG.native.esm.js} +2 -2
  27. package/dist/{getWalletProviderByKey-CHwDF-wB.native.esm.js.map → getWalletProviderByKey-ClOKL5JG.native.esm.js.map} +1 -1
  28. package/dist/{getWalletProviderByKey-V57IQFGI.cjs → getWalletProviderByKey-o0urQYPF.cjs} +2 -2
  29. package/dist/{getWalletProviderByKey-V57IQFGI.cjs.map → getWalletProviderByKey-o0urQYPF.cjs.map} +1 -1
  30. package/dist/index.cjs +6 -6
  31. package/dist/index.esm.js +6 -6
  32. package/dist/index.native.esm.js +6 -6
  33. package/dist/{isDynamicWaasEnabled-DON8Wgtw.esm.js → isDynamicWaasEnabled-C0x4cUHe.esm.js} +2 -2
  34. package/dist/{isDynamicWaasEnabled-DON8Wgtw.esm.js.map → isDynamicWaasEnabled-C0x4cUHe.esm.js.map} +1 -1
  35. package/dist/{isDynamicWaasEnabled-SALOnUiM.native.esm.js → isDynamicWaasEnabled-CF-T5TSi.native.esm.js} +2 -2
  36. package/dist/{isDynamicWaasEnabled-SALOnUiM.native.esm.js.map → isDynamicWaasEnabled-CF-T5TSi.native.esm.js.map} +1 -1
  37. package/dist/{isDynamicWaasEnabled-DcvyqHqI.cjs → isDynamicWaasEnabled-DQe8Wxd0.cjs} +2 -2
  38. package/dist/{isDynamicWaasEnabled-DcvyqHqI.cjs.map → isDynamicWaasEnabled-DQe8Wxd0.cjs.map} +1 -1
  39. package/dist/{isMfaRequiredForAction-Bde90-Y6.esm.js → isMfaRequiredForAction-BK_4B7Gi.esm.js} +2 -2
  40. package/dist/{isMfaRequiredForAction-Bde90-Y6.esm.js.map → isMfaRequiredForAction-BK_4B7Gi.esm.js.map} +1 -1
  41. package/dist/{isMfaRequiredForAction-GI_7_DG1.cjs → isMfaRequiredForAction-BcO-fQ-N.cjs} +2 -2
  42. package/dist/{isMfaRequiredForAction-GI_7_DG1.cjs.map → isMfaRequiredForAction-BcO-fQ-N.cjs.map} +1 -1
  43. package/dist/{isMfaRequiredForAction-BUupsHJw.native.esm.js → isMfaRequiredForAction-Ce0neLQQ.native.esm.js} +2 -2
  44. package/dist/{isMfaRequiredForAction-BUupsHJw.native.esm.js.map → isMfaRequiredForAction-Ce0neLQQ.native.esm.js.map} +1 -1
  45. package/dist/{isUserOnboardingComplete-BTQbWpvO.cjs → isUserOnboardingComplete-B4hlrt5N.cjs} +3 -3
  46. package/dist/{isUserOnboardingComplete-BTQbWpvO.cjs.map → isUserOnboardingComplete-B4hlrt5N.cjs.map} +1 -1
  47. package/dist/{isUserOnboardingComplete-bsAUasR2.native.esm.js → isUserOnboardingComplete-BK7GcrpI.native.esm.js} +3 -3
  48. package/dist/{isUserOnboardingComplete-bsAUasR2.native.esm.js.map → isUserOnboardingComplete-BK7GcrpI.native.esm.js.map} +1 -1
  49. package/dist/{isUserOnboardingComplete-CDMV5llq.esm.js → isUserOnboardingComplete-CssbJY_7.esm.js} +3 -3
  50. package/dist/{isUserOnboardingComplete-CDMV5llq.esm.js.map → isUserOnboardingComplete-CssbJY_7.esm.js.map} +1 -1
  51. package/dist/{migrateFromFireblocks-CdacJXcs.native.esm.js → migrateFromFireblocks-BX9JTaOI.native.esm.js} +3 -3
  52. package/dist/{migrateFromFireblocks-CdacJXcs.native.esm.js.map → migrateFromFireblocks-BX9JTaOI.native.esm.js.map} +1 -1
  53. package/dist/{migrateFromFireblocks-CuKYRnBI.esm.js → migrateFromFireblocks-Btox03CB.esm.js} +4 -4
  54. package/dist/{migrateFromFireblocks-CuKYRnBI.esm.js.map → migrateFromFireblocks-Btox03CB.esm.js.map} +1 -1
  55. package/dist/{migrateFromFireblocks-BKQe7GHD.cjs → migrateFromFireblocks-CIE4qLS6.cjs} +4 -4
  56. package/dist/{migrateFromFireblocks-BKQe7GHD.cjs.map → migrateFromFireblocks-CIE4qLS6.cjs.map} +1 -1
  57. package/dist/modules/apiClient/constants.d.ts +7 -0
  58. package/dist/modules/apiClient/constants.d.ts.map +1 -1
  59. package/dist/modules/apiClient/createApiClient.d.ts +1 -2
  60. package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
  61. package/dist/modules/apiClient/createBaseApiClient.d.ts +16 -0
  62. package/dist/modules/apiClient/createBaseApiClient.d.ts.map +1 -0
  63. package/dist/modules/auth/logoutWithReason/logoutWithReason.d.ts.map +1 -1
  64. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -1
  65. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -1
  66. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts.map +1 -1
  67. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/index.d.ts +2 -0
  68. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/index.d.ts.map +1 -0
  69. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts +32 -0
  70. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts.map +1 -0
  71. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  72. package/dist/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.d.ts +4 -1
  73. package/dist/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.d.ts.map +1 -1
  74. package/dist/modules/waas/waas.types.d.ts +2 -1
  75. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  76. package/dist/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.d.ts.map +1 -1
  77. package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts +2 -0
  78. package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts.map +1 -1
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/{updateAuthFromVerifyResponse-U7zoE0b1.esm.js → updateAuthFromVerifyResponse-BhILXMm_.esm.js} +191 -168
  81. package/dist/updateAuthFromVerifyResponse-BhILXMm_.esm.js.map +1 -0
  82. package/dist/{updateAuthFromVerifyResponse-Bm6bI0ds.cjs → updateAuthFromVerifyResponse-CK3pAERc.cjs} +190 -167
  83. package/dist/updateAuthFromVerifyResponse-CK3pAERc.cjs.map +1 -0
  84. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -1
  85. package/dist/waas.cjs +56 -77
  86. package/dist/waas.cjs.map +1 -1
  87. package/dist/waas.esm.js +56 -76
  88. package/dist/waas.esm.js.map +1 -1
  89. package/dist/waas.native.esm.js +55 -75
  90. package/dist/waas.native.esm.js.map +1 -1
  91. package/dist/waasCore.cjs +9 -8
  92. package/dist/waasCore.cjs.map +1 -1
  93. package/dist/waasCore.esm.js +9 -8
  94. package/dist/waasCore.esm.js.map +1 -1
  95. package/dist/waasCore.native.esm.js +8 -7
  96. package/dist/waasCore.native.esm.js.map +1 -1
  97. package/package.json +4 -4
  98. package/dist/NativeModuleNotLinkedError-Duh8DMLT.native.esm.js.map +0 -1
  99. package/dist/getNetworkProviderFromNetworkId-C0FLeQ5n.native.esm.js.map +0 -1
  100. package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/getEmbeddedWalletsRequiringUpgrade.d.ts +0 -30
  101. package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/getEmbeddedWalletsRequiringUpgrade.d.ts.map +0 -1
  102. package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/index.d.ts +0 -2
  103. package/dist/modules/waas/getEmbeddedWalletsRequiringUpgrade/index.d.ts.map +0 -1
  104. package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/hasEmbeddedWalletsRequiringUpgrade.d.ts +0 -23
  105. package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/hasEmbeddedWalletsRequiringUpgrade.d.ts.map +0 -1
  106. package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/index.d.ts +0 -2
  107. package/dist/modules/waas/hasEmbeddedWalletsRequiringUpgrade/index.d.ts.map +0 -1
  108. package/dist/updateAuthFromVerifyResponse-Bm6bI0ds.cjs.map +0 -1
  109. package/dist/updateAuthFromVerifyResponse-U7zoE0b1.esm.js.map +0 -1
@@ -31,10 +31,10 @@ zod_mini = __toESM(zod_mini);
31
31
 
32
32
  //#region package.json
33
33
  var name = "@dynamic-labs-sdk/client";
34
- var version = "1.21.2";
34
+ var version = "1.22.1";
35
35
  var dependencies = {
36
36
  "@dynamic-labs-sdk/assert-package-version": "workspace:*",
37
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.73",
37
+ "@dynamic-labs-wallet/browser-wallet-client": "1.0.79",
38
38
  "@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
39
39
  "@dynamic-labs/sdk-api-core": "catalog:",
40
40
  "@simplewebauthn/browser": "13.1.0",
@@ -166,26 +166,6 @@ const setDefaultClient = (client) => {
166
166
  const NONCE_POOL_EXPIRATION_TIME = 6e4 * 60 * 24;
167
167
  const NONCE_POOL_SIZE = 5;
168
168
 
169
- //#endregion
170
- //#region src/modules/apiClient/constants.ts
171
- const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
172
- const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
173
- const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
174
- const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
175
- const MFA_TOKEN_HEADER = "x-mfa-auth-token";
176
- const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
177
- const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
178
- const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
179
- /**
180
- * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
181
- *
182
- * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
183
- * webview-controller already sends, so the backend receives a consistent
184
- * platform signal across SDK generations.
185
- */
186
- const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
187
- const CLIENT_SDK_NAME = "ClientSDK";
188
-
189
169
  //#endregion
190
170
  //#region src/utils/getPlatform/getPlatform.ts
191
171
  /**
@@ -312,6 +292,33 @@ const getSessionKeys = (client) => {
312
292
  return { publicKey };
313
293
  };
314
294
 
295
+ //#endregion
296
+ //#region src/modules/apiClient/constants.ts
297
+ const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
298
+ const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
299
+ const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
300
+ /**
301
+ * Reports *why* the SDK is logging the user out on the `revokeSession`
302
+ * (`/sdk/{env}/revoke`) request. The backend logs it so SDK-initiated session
303
+ * revocations are attributable in Datadog (e.g. `token-expired`,
304
+ * `keychain-key-missing`) instead of being inferred from downstream 401s.
305
+ */
306
+ const DYNAMIC_LOGOUT_REASON_HEADER = "x-dyn-logout-reason";
307
+ const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
308
+ const MFA_TOKEN_HEADER = "x-mfa-auth-token";
309
+ const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
310
+ const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
311
+ const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
312
+ /**
313
+ * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
314
+ *
315
+ * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
316
+ * webview-controller already sends, so the backend receives a consistent
317
+ * platform signal across SDK generations.
318
+ */
319
+ const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
320
+ const CLIENT_SDK_NAME = "ClientSDK";
321
+
315
322
  //#endregion
316
323
  //#region src/errors/APIError/APIError.ts
317
324
  var APIError = class APIError extends BaseError {
@@ -483,6 +490,81 @@ const createConvertToApiErrorMiddleware = ({ errorMappers = [] }) => ({ post: as
483
490
  return context.response;
484
491
  } });
485
492
 
493
+ //#endregion
494
+ //#region src/errors/UnauthorizedError.ts
495
+ var UnauthorizedError = class extends BaseError {
496
+ constructor({ cause }) {
497
+ super({
498
+ cause,
499
+ code: "unauthorized_error",
500
+ docsUrl: null,
501
+ name: "UnauthorizedError",
502
+ shortMessage: "Unauthorized"
503
+ });
504
+ }
505
+ };
506
+
507
+ //#endregion
508
+ //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
509
+ /** @notInstrumented */
510
+ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
511
+ if (context.response.status === 401) {
512
+ let cause = null;
513
+ try {
514
+ const errorBody = await context.response.clone().json();
515
+ if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
516
+ } catch {}
517
+ throw new UnauthorizedError({ cause });
518
+ }
519
+ return context.response;
520
+ } });
521
+
522
+ //#endregion
523
+ //#region src/modules/apiClient/createBaseApiClient.ts
524
+ /**
525
+ * Creates the base SDK API client from the client's core state, applying the
526
+ * standard headers and the always-on error-conversion and unauthorized
527
+ * middleware. Any middleware passed via `middleware` runs before those two.
528
+ * @notInstrumented
529
+ */
530
+ const createBaseApiClient = ({ middleware = [], options = {} }, client) => {
531
+ const core = getCore(client);
532
+ const coreState = core.state.get();
533
+ const settings = {
534
+ basePath: core.apiBaseUrl,
535
+ headers: {
536
+ "Content-Type": "application/json",
537
+ [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
538
+ [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
539
+ [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
540
+ [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
541
+ [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
542
+ ...core.getApiHeaders(),
543
+ ...options.headers
544
+ }
545
+ };
546
+ if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
547
+ if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
548
+ if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
549
+ if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
550
+ if (options.elevatedAccessTokenScope) {
551
+ const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
552
+ if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
553
+ }
554
+ const sessionPublicKey = getSessionKeys(client)?.publicKey;
555
+ const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
556
+ if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
557
+ return new _dynamic_labs_sdk_api_core.SDKApi(new _dynamic_labs_sdk_api_core.Configuration({
558
+ ...settings,
559
+ fetchApi: core.fetch,
560
+ middleware: [
561
+ ...middleware,
562
+ createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
563
+ createUnauthorizedMiddleware()
564
+ ]
565
+ }));
566
+ };
567
+
486
568
  //#endregion
487
569
  //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
488
570
  /** @notInstrumented */
@@ -533,6 +615,85 @@ const updateNoncePoolStorage = async ({ update }, client) => {
533
615
  return storedBeforeUpdate;
534
616
  };
535
617
 
618
+ //#endregion
619
+ //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
620
+ /**
621
+ * Fetches a batch of nonces from the API and appends them to the pool in
622
+ * storage.
623
+ *
624
+ * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
625
+ * redirect). On iOS, a network request (like fetching a nonce) between a user
626
+ * action and a deeplink call will break the gesture chain, causing iOS to
627
+ * silently ignore the deeplink. By prefetching nonces ahead of time,
628
+ * `getNonce` can return from the stored pool without an interrupting network
629
+ * round-trip.
630
+ *
631
+ * New nonces are **appended** to the stored pool so that unconsumed entries
632
+ * are not discarded by a background refetch; an expired stored pool is
633
+ * replaced instead, since its nonces have already been evicted server-side.
634
+ *
635
+ * Concurrent refills are coalesced behind a single in-flight promise so that
636
+ * simultaneous callers share one `GET /nonces` round-trip instead of each
637
+ * issuing their own (which would inflate the pool and hammer the backend).
638
+ * @notInstrumented
639
+ */
640
+ const fetchAndStoreNonces = async (client) => {
641
+ const core = getCore(client);
642
+ const inFlight = core.state.get().nonceFetchInFlight;
643
+ if (inFlight) return inFlight;
644
+ const { environmentId } = core;
645
+ const apiClient = createBaseApiClient({}, client);
646
+ const fetchPromise = (async () => {
647
+ const { nonces } = await apiClient.getNonces({
648
+ count: NONCE_POOL_SIZE,
649
+ environmentId
650
+ });
651
+ const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
652
+ await updateNoncePoolStorage({ update: (stored) => {
653
+ return {
654
+ expiration,
655
+ nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
656
+ };
657
+ } }, client);
658
+ })().finally(() => {
659
+ core.state.set({ nonceFetchInFlight: null });
660
+ });
661
+ core.state.set({ nonceFetchInFlight: fetchPromise });
662
+ return fetchPromise;
663
+ };
664
+
665
+ //#endregion
666
+ //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
667
+ /**
668
+ * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
669
+ * document is running in a secure context, or an empty string otherwise.
670
+ *
671
+ * The `Secure` attribute prevents the browser from ever transmitting the cookie
672
+ * over an unencrypted `http://` connection, which mitigates cleartext token
673
+ * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
674
+ * because browsers reject `Secure` cookies set over `http://` and that would
675
+ * silently break local testing.
676
+ *
677
+ * Used when building the Dynamic auth JWT cookie string so the attribute is
678
+ * applied consistently on both the write (sign-in/refresh) and clear (logout)
679
+ * paths.
680
+ *
681
+ * @notInstrumented
682
+ */
683
+ const getSecureCookieAttribute = () => {
684
+ return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
685
+ };
686
+
687
+ //#endregion
688
+ //#region src/utils/setCookie/setCookie.ts
689
+ /**
690
+ * Sefelly sets the cookie in the browser.
691
+ * @notInstrumented
692
+ */
693
+ const setCookie = (cookie) => {
694
+ document.cookie = cookie;
695
+ };
696
+
536
697
  //#endregion
537
698
  //#region src/utils/getNonce/getNonce.ts
538
699
  /**
@@ -635,35 +796,6 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
635
796
  } };
636
797
  };
637
798
 
638
- //#endregion
639
- //#region src/errors/UnauthorizedError.ts
640
- var UnauthorizedError = class extends BaseError {
641
- constructor({ cause }) {
642
- super({
643
- cause,
644
- code: "unauthorized_error",
645
- docsUrl: null,
646
- name: "UnauthorizedError",
647
- shortMessage: "Unauthorized"
648
- });
649
- }
650
- };
651
-
652
- //#endregion
653
- //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
654
- /** @notInstrumented */
655
- const createUnauthorizedMiddleware = () => ({ post: async (context) => {
656
- if (context.response.status === 401) {
657
- let cause = null;
658
- try {
659
- const errorBody = await context.response.clone().json();
660
- if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
661
- } catch {}
662
- throw new UnauthorizedError({ cause });
663
- }
664
- return context.response;
665
- } });
666
-
667
799
  //#endregion
668
800
  //#region src/modules/apiClient/createApiClient.ts
669
801
  /**
@@ -673,120 +805,10 @@ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
673
805
  * @notInstrumented
674
806
  */
675
807
  const createApiClient = (options = {}, client) => {
676
- const core = getCore(client);
677
- const coreState = core.state.get();
678
- const settings = {
679
- basePath: core.apiBaseUrl,
680
- headers: {
681
- "Content-Type": "application/json",
682
- [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
683
- [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
684
- [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
685
- [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
686
- [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
687
- ...core.getApiHeaders(),
688
- ...options.headers
689
- }
690
- };
691
- if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
692
- if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
693
- if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
694
- if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
695
- if (options.elevatedAccessTokenScope) {
696
- const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
697
- if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
698
- }
699
- const sessionPublicKey = getSessionKeys(client)?.publicKey;
700
- const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
701
- if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
702
- return new _dynamic_labs_sdk_api_core.SDKApi(new _dynamic_labs_sdk_api_core.Configuration({
703
- ...settings,
704
- fetchApi: core.fetch,
705
- middleware: [
706
- createDeviceSignatureHeadersMiddleware(client),
707
- createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
708
- createUnauthorizedMiddleware()
709
- ]
710
- }));
711
- };
712
-
713
- //#endregion
714
- //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
715
- /**
716
- * Fetches a batch of nonces from the API and appends them to the pool in
717
- * storage.
718
- *
719
- * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
720
- * redirect). On iOS, a network request (like fetching a nonce) between a user
721
- * action and a deeplink call will break the gesture chain, causing iOS to
722
- * silently ignore the deeplink. By prefetching nonces ahead of time,
723
- * `getNonce` can return from the stored pool without an interrupting network
724
- * round-trip.
725
- *
726
- * New nonces are **appended** to the stored pool so that unconsumed entries
727
- * are not discarded by a background refetch; an expired stored pool is
728
- * replaced instead, since its nonces have already been evicted server-side.
729
- *
730
- * Concurrent refills are coalesced behind a single in-flight promise so that
731
- * simultaneous callers share one `GET /nonces` round-trip instead of each
732
- * issuing their own (which would inflate the pool and hammer the backend).
733
- * @notInstrumented
734
- */
735
- const fetchAndStoreNonces = async (client) => {
736
- const core = getCore(client);
737
- const inFlight = core.state.get().nonceFetchInFlight;
738
- if (inFlight) return inFlight;
739
- const { environmentId } = core;
740
- const apiClient = createApiClient({}, client);
741
- const fetchPromise = (async () => {
742
- const { nonces } = await apiClient.getNonces({
743
- count: NONCE_POOL_SIZE,
744
- environmentId
745
- });
746
- const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
747
- await updateNoncePoolStorage({ update: (stored) => {
748
- return {
749
- expiration,
750
- nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
751
- };
752
- } }, client);
753
- })().finally(() => {
754
- core.state.set({ nonceFetchInFlight: null });
755
- });
756
- core.state.set({ nonceFetchInFlight: fetchPromise });
757
- return fetchPromise;
758
- };
759
-
760
- //#endregion
761
- //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
762
- /**
763
- * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
764
- * document is running in a secure context, or an empty string otherwise.
765
- *
766
- * The `Secure` attribute prevents the browser from ever transmitting the cookie
767
- * over an unencrypted `http://` connection, which mitigates cleartext token
768
- * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
769
- * because browsers reject `Secure` cookies set over `http://` and that would
770
- * silently break local testing.
771
- *
772
- * Used when building the Dynamic auth JWT cookie string so the attribute is
773
- * applied consistently on both the write (sign-in/refresh) and clear (logout)
774
- * paths.
775
- *
776
- * @notInstrumented
777
- */
778
- const getSecureCookieAttribute = () => {
779
- return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
780
- };
781
-
782
- //#endregion
783
- //#region src/utils/setCookie/setCookie.ts
784
- /**
785
- * Sefelly sets the cookie in the browser.
786
- * @notInstrumented
787
- */
788
- const setCookie = (cookie) => {
789
- document.cookie = cookie;
808
+ return createBaseApiClient({
809
+ middleware: [createDeviceSignatureHeadersMiddleware(client)],
810
+ options
811
+ }, client);
790
812
  };
791
813
 
792
814
  //#endregion
@@ -1175,6 +1197,7 @@ const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client
1175
1197
  return {
1176
1198
  address: verifiedCredential.address,
1177
1199
  addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
1200
+ businessAccountId: verifiedCredential.walletProperties?.businessAccountId ?? verifiedCredential.businessAccountProperties?.businessAccountId,
1178
1201
  chain,
1179
1202
  hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
1180
1203
  id: walletAccountId,
@@ -1995,7 +2018,7 @@ const logoutWithReason = async ({ reason }, client) => {
1995
2018
  core.logger.debug("[logoutWithReason] Logging out...", { reason });
1996
2019
  await destroyWalletProviders({ reason }, client);
1997
2020
  if (client.user !== null) {
1998
- const apiClient = createApiClient({}, client);
2021
+ const apiClient = createApiClient({ headers: { [DYNAMIC_LOGOUT_REASON_HEADER]: reason } }, client);
1999
2022
  try {
2000
2023
  await apiClient.revokeSession({ environmentId: core.environmentId });
2001
2024
  } catch (error) {
@@ -2803,4 +2826,4 @@ Object.defineProperty(exports, 'version', {
2803
2826
  return version;
2804
2827
  }
2805
2828
  });
2806
- //# sourceMappingURL=updateAuthFromVerifyResponse-Bm6bI0ds.cjs.map
2829
+ //# sourceMappingURL=updateAuthFromVerifyResponse-CK3pAERc.cjs.map