@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
@@ -3,10 +3,10 @@ import * as z from "zod/mini";
3
3
 
4
4
  //#region package.json
5
5
  var name = "@dynamic-labs-sdk/client";
6
- var version = "1.21.2";
6
+ var version = "1.22.1";
7
7
  var dependencies = {
8
8
  "@dynamic-labs-sdk/assert-package-version": "workspace:*",
9
- "@dynamic-labs-wallet/browser-wallet-client": "1.0.73",
9
+ "@dynamic-labs-wallet/browser-wallet-client": "1.0.79",
10
10
  "@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
11
11
  "@dynamic-labs/sdk-api-core": "catalog:",
12
12
  "@simplewebauthn/browser": "13.1.0",
@@ -138,26 +138,6 @@ const setDefaultClient = (client) => {
138
138
  const NONCE_POOL_EXPIRATION_TIME = 6e4 * 60 * 24;
139
139
  const NONCE_POOL_SIZE = 5;
140
140
 
141
- //#endregion
142
- //#region src/modules/apiClient/constants.ts
143
- const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
144
- const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
145
- const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
146
- const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
147
- const MFA_TOKEN_HEADER = "x-mfa-auth-token";
148
- const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
149
- const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
150
- const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
151
- /**
152
- * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
153
- *
154
- * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
155
- * webview-controller already sends, so the backend receives a consistent
156
- * platform signal across SDK generations.
157
- */
158
- const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
159
- const CLIENT_SDK_NAME = "ClientSDK";
160
-
161
141
  //#endregion
162
142
  //#region src/utils/getPlatform/getPlatform.ts
163
143
  /**
@@ -284,6 +264,33 @@ const getSessionKeys = (client) => {
284
264
  return { publicKey };
285
265
  };
286
266
 
267
+ //#endregion
268
+ //#region src/modules/apiClient/constants.ts
269
+ const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
270
+ const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
271
+ const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
272
+ /**
273
+ * Reports *why* the SDK is logging the user out on the `revokeSession`
274
+ * (`/sdk/{env}/revoke`) request. The backend logs it so SDK-initiated session
275
+ * revocations are attributable in Datadog (e.g. `token-expired`,
276
+ * `keychain-key-missing`) instead of being inferred from downstream 401s.
277
+ */
278
+ const DYNAMIC_LOGOUT_REASON_HEADER = "x-dyn-logout-reason";
279
+ const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
280
+ const MFA_TOKEN_HEADER = "x-mfa-auth-token";
281
+ const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
282
+ const DYNAMIC_SDK_API_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
283
+ const DYNAMIC_SDK_SESSION_ID_HEADER = "x-dyn-session-id";
284
+ /**
285
+ * Reports the runtime platform (`web` or `react-native`) to the Dynamic API.
286
+ *
287
+ * Named `x-dynamic-platform` (not `x-dyn-*`) to match the header the legacy
288
+ * webview-controller already sends, so the backend receives a consistent
289
+ * platform signal across SDK generations.
290
+ */
291
+ const DYNAMIC_PLATFORM_HEADER = "x-dynamic-platform";
292
+ const CLIENT_SDK_NAME = "ClientSDK";
293
+
287
294
  //#endregion
288
295
  //#region src/errors/APIError/APIError.ts
289
296
  var APIError = class APIError extends BaseError {
@@ -455,6 +462,81 @@ const createConvertToApiErrorMiddleware = ({ errorMappers = [] }) => ({ post: as
455
462
  return context.response;
456
463
  } });
457
464
 
465
+ //#endregion
466
+ //#region src/errors/UnauthorizedError.ts
467
+ var UnauthorizedError = class extends BaseError {
468
+ constructor({ cause }) {
469
+ super({
470
+ cause,
471
+ code: "unauthorized_error",
472
+ docsUrl: null,
473
+ name: "UnauthorizedError",
474
+ shortMessage: "Unauthorized"
475
+ });
476
+ }
477
+ };
478
+
479
+ //#endregion
480
+ //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
481
+ /** @notInstrumented */
482
+ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
483
+ if (context.response.status === 401) {
484
+ let cause = null;
485
+ try {
486
+ const errorBody = await context.response.clone().json();
487
+ if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
488
+ } catch {}
489
+ throw new UnauthorizedError({ cause });
490
+ }
491
+ return context.response;
492
+ } });
493
+
494
+ //#endregion
495
+ //#region src/modules/apiClient/createBaseApiClient.ts
496
+ /**
497
+ * Creates the base SDK API client from the client's core state, applying the
498
+ * standard headers and the always-on error-conversion and unauthorized
499
+ * middleware. Any middleware passed via `middleware` runs before those two.
500
+ * @notInstrumented
501
+ */
502
+ const createBaseApiClient = ({ middleware = [], options = {} }, client) => {
503
+ const core = getCore(client);
504
+ const coreState = core.state.get();
505
+ const settings = {
506
+ basePath: core.apiBaseUrl,
507
+ headers: {
508
+ "Content-Type": "application/json",
509
+ [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
510
+ [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
511
+ [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
512
+ [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
513
+ [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
514
+ ...core.getApiHeaders(),
515
+ ...options.headers
516
+ }
517
+ };
518
+ if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
519
+ if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
520
+ if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
521
+ if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
522
+ if (options.elevatedAccessTokenScope) {
523
+ const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
524
+ if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
525
+ }
526
+ const sessionPublicKey = getSessionKeys(client)?.publicKey;
527
+ const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
528
+ if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
529
+ return new SDKApi(new Configuration({
530
+ ...settings,
531
+ fetchApi: core.fetch,
532
+ middleware: [
533
+ ...middleware,
534
+ createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
535
+ createUnauthorizedMiddleware()
536
+ ]
537
+ }));
538
+ };
539
+
458
540
  //#endregion
459
541
  //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
460
542
  /** @notInstrumented */
@@ -505,6 +587,85 @@ const updateNoncePoolStorage = async ({ update }, client) => {
505
587
  return storedBeforeUpdate;
506
588
  };
507
589
 
590
+ //#endregion
591
+ //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
592
+ /**
593
+ * Fetches a batch of nonces from the API and appends them to the pool in
594
+ * storage.
595
+ *
596
+ * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
597
+ * redirect). On iOS, a network request (like fetching a nonce) between a user
598
+ * action and a deeplink call will break the gesture chain, causing iOS to
599
+ * silently ignore the deeplink. By prefetching nonces ahead of time,
600
+ * `getNonce` can return from the stored pool without an interrupting network
601
+ * round-trip.
602
+ *
603
+ * New nonces are **appended** to the stored pool so that unconsumed entries
604
+ * are not discarded by a background refetch; an expired stored pool is
605
+ * replaced instead, since its nonces have already been evicted server-side.
606
+ *
607
+ * Concurrent refills are coalesced behind a single in-flight promise so that
608
+ * simultaneous callers share one `GET /nonces` round-trip instead of each
609
+ * issuing their own (which would inflate the pool and hammer the backend).
610
+ * @notInstrumented
611
+ */
612
+ const fetchAndStoreNonces = async (client) => {
613
+ const core = getCore(client);
614
+ const inFlight = core.state.get().nonceFetchInFlight;
615
+ if (inFlight) return inFlight;
616
+ const { environmentId } = core;
617
+ const apiClient = createBaseApiClient({}, client);
618
+ const fetchPromise = (async () => {
619
+ const { nonces } = await apiClient.getNonces({
620
+ count: NONCE_POOL_SIZE,
621
+ environmentId
622
+ });
623
+ const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
624
+ await updateNoncePoolStorage({ update: (stored) => {
625
+ return {
626
+ expiration,
627
+ nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
628
+ };
629
+ } }, client);
630
+ })().finally(() => {
631
+ core.state.set({ nonceFetchInFlight: null });
632
+ });
633
+ core.state.set({ nonceFetchInFlight: fetchPromise });
634
+ return fetchPromise;
635
+ };
636
+
637
+ //#endregion
638
+ //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
639
+ /**
640
+ * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
641
+ * document is running in a secure context, or an empty string otherwise.
642
+ *
643
+ * The `Secure` attribute prevents the browser from ever transmitting the cookie
644
+ * over an unencrypted `http://` connection, which mitigates cleartext token
645
+ * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
646
+ * because browsers reject `Secure` cookies set over `http://` and that would
647
+ * silently break local testing.
648
+ *
649
+ * Used when building the Dynamic auth JWT cookie string so the attribute is
650
+ * applied consistently on both the write (sign-in/refresh) and clear (logout)
651
+ * paths.
652
+ *
653
+ * @notInstrumented
654
+ */
655
+ const getSecureCookieAttribute = () => {
656
+ return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
657
+ };
658
+
659
+ //#endregion
660
+ //#region src/utils/setCookie/setCookie.ts
661
+ /**
662
+ * Sefelly sets the cookie in the browser.
663
+ * @notInstrumented
664
+ */
665
+ const setCookie = (cookie) => {
666
+ document.cookie = cookie;
667
+ };
668
+
508
669
  //#endregion
509
670
  //#region src/utils/getNonce/getNonce.ts
510
671
  /**
@@ -607,35 +768,6 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
607
768
  } };
608
769
  };
609
770
 
610
- //#endregion
611
- //#region src/errors/UnauthorizedError.ts
612
- var UnauthorizedError = class extends BaseError {
613
- constructor({ cause }) {
614
- super({
615
- cause,
616
- code: "unauthorized_error",
617
- docsUrl: null,
618
- name: "UnauthorizedError",
619
- shortMessage: "Unauthorized"
620
- });
621
- }
622
- };
623
-
624
- //#endregion
625
- //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
626
- /** @notInstrumented */
627
- const createUnauthorizedMiddleware = () => ({ post: async (context) => {
628
- if (context.response.status === 401) {
629
- let cause = null;
630
- try {
631
- const errorBody = await context.response.clone().json();
632
- if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
633
- } catch {}
634
- throw new UnauthorizedError({ cause });
635
- }
636
- return context.response;
637
- } });
638
-
639
771
  //#endregion
640
772
  //#region src/modules/apiClient/createApiClient.ts
641
773
  /**
@@ -645,120 +777,10 @@ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
645
777
  * @notInstrumented
646
778
  */
647
779
  const createApiClient = (options = {}, client) => {
648
- const core = getCore(client);
649
- const coreState = core.state.get();
650
- const settings = {
651
- basePath: core.apiBaseUrl,
652
- headers: {
653
- "Content-Type": "application/json",
654
- [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
655
- [DYNAMIC_PLATFORM_HEADER]: getPlatform(),
656
- [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
657
- [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
658
- [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
659
- ...core.getApiHeaders(),
660
- ...options.headers
661
- }
662
- };
663
- if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
664
- if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
665
- if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
666
- if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
667
- if (options.elevatedAccessTokenScope) {
668
- const elevatedToken = getElevatedAccessToken({ scope: options.elevatedAccessTokenScope }, client);
669
- if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
670
- }
671
- const sessionPublicKey = getSessionKeys(client)?.publicKey;
672
- const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
673
- if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
674
- return new SDKApi(new Configuration({
675
- ...settings,
676
- fetchApi: core.fetch,
677
- middleware: [
678
- createDeviceSignatureHeadersMiddleware(client),
679
- createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
680
- createUnauthorizedMiddleware()
681
- ]
682
- }));
683
- };
684
-
685
- //#endregion
686
- //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
687
- /**
688
- * Fetches a batch of nonces from the API and appends them to the pool in
689
- * storage.
690
- *
691
- * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
692
- * redirect). On iOS, a network request (like fetching a nonce) between a user
693
- * action and a deeplink call will break the gesture chain, causing iOS to
694
- * silently ignore the deeplink. By prefetching nonces ahead of time,
695
- * `getNonce` can return from the stored pool without an interrupting network
696
- * round-trip.
697
- *
698
- * New nonces are **appended** to the stored pool so that unconsumed entries
699
- * are not discarded by a background refetch; an expired stored pool is
700
- * replaced instead, since its nonces have already been evicted server-side.
701
- *
702
- * Concurrent refills are coalesced behind a single in-flight promise so that
703
- * simultaneous callers share one `GET /nonces` round-trip instead of each
704
- * issuing their own (which would inflate the pool and hammer the backend).
705
- * @notInstrumented
706
- */
707
- const fetchAndStoreNonces = async (client) => {
708
- const core = getCore(client);
709
- const inFlight = core.state.get().nonceFetchInFlight;
710
- if (inFlight) return inFlight;
711
- const { environmentId } = core;
712
- const apiClient = createApiClient({}, client);
713
- const fetchPromise = (async () => {
714
- const { nonces } = await apiClient.getNonces({
715
- count: NONCE_POOL_SIZE,
716
- environmentId
717
- });
718
- const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
719
- await updateNoncePoolStorage({ update: (stored) => {
720
- return {
721
- expiration,
722
- nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
723
- };
724
- } }, client);
725
- })().finally(() => {
726
- core.state.set({ nonceFetchInFlight: null });
727
- });
728
- core.state.set({ nonceFetchInFlight: fetchPromise });
729
- return fetchPromise;
730
- };
731
-
732
- //#endregion
733
- //#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
734
- /**
735
- * Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
736
- * document is running in a secure context, or an empty string otherwise.
737
- *
738
- * The `Secure` attribute prevents the browser from ever transmitting the cookie
739
- * over an unencrypted `http://` connection, which mitigates cleartext token
740
- * capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
741
- * because browsers reject `Secure` cookies set over `http://` and that would
742
- * silently break local testing.
743
- *
744
- * Used when building the Dynamic auth JWT cookie string so the attribute is
745
- * applied consistently on both the write (sign-in/refresh) and clear (logout)
746
- * paths.
747
- *
748
- * @notInstrumented
749
- */
750
- const getSecureCookieAttribute = () => {
751
- return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
752
- };
753
-
754
- //#endregion
755
- //#region src/utils/setCookie/setCookie.ts
756
- /**
757
- * Sefelly sets the cookie in the browser.
758
- * @notInstrumented
759
- */
760
- const setCookie = (cookie) => {
761
- document.cookie = cookie;
780
+ return createBaseApiClient({
781
+ middleware: [createDeviceSignatureHeadersMiddleware(client)],
782
+ options
783
+ }, client);
762
784
  };
763
785
 
764
786
  //#endregion
@@ -1147,6 +1169,7 @@ const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client
1147
1169
  return {
1148
1170
  address: verifiedCredential.address,
1149
1171
  addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
1172
+ businessAccountId: verifiedCredential.walletProperties?.businessAccountId ?? verifiedCredential.businessAccountProperties?.businessAccountId,
1150
1173
  chain,
1151
1174
  hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
1152
1175
  id: walletAccountId,
@@ -1967,7 +1990,7 @@ const logoutWithReason = async ({ reason }, client) => {
1967
1990
  core.logger.debug("[logoutWithReason] Logging out...", { reason });
1968
1991
  await destroyWalletProviders({ reason }, client);
1969
1992
  if (client.user !== null) {
1970
- const apiClient = createApiClient({}, client);
1993
+ const apiClient = createApiClient({ headers: { [DYNAMIC_LOGOUT_REASON_HEADER]: reason } }, client);
1971
1994
  try {
1972
1995
  await apiClient.revokeSession({ environmentId: core.environmentId });
1973
1996
  } catch (error) {
@@ -2301,5 +2324,5 @@ const updateAuthFromVerifyResponse = ({ response }, client) => {
2301
2324
  };
2302
2325
 
2303
2326
  //#endregion
2304
- export { getNonce as $, generateSessionKeys as A, splitWalletProviderKey as B, getOperatingSystem as C, name as Ct, getWalletProviderRegistry as D, WalletProviderPriority as E, normalizeWalletNameWithChain as F, onEvent as G, retryOnFail as H, getChainFromVerifiedCredentialChain as I, createApiClient as J, onceEvent as K, CHAINS_INFO_MAP as L, isSignedIn as M, getWalletAccounts as N, createRuntimeServiceAccessKey as O, formatWalletProviderKey as P, getDeviceSigner as Q, formatWalletAccountId as R, getUserAgent as S, getCore as St, getWalletProviderFromWalletAccount as T, emitEvent as U, InvalidWalletProviderKeyError as V, offEvent as W, createDeviceSignatureHeadersMiddleware as X, UnauthorizedError as Y, getHeadersForNonceSignedByDeviceSigners as Z, SDK_API_CORE_VERSION as _, NONCE_POOL_SIZE as _t, initializeWaasClientsForEagerRecovery as a, LinkCredentialError as at, scrubParameters as b, ClientNotFoundError as bt, isWaasWalletProvider as c, getSessionKeys as ct, DYNAMIC_WAAS_METADATA as d, ValueMustBeDefinedError as dt, updateNoncePoolStorage as et, getWalletProviders as f, getElevatedAccessToken as ft, DYNAMIC_ICONIC_SPRITE_URL as g, DYNAMIC_SDK_API_VERSION as gt, emitWalletAccountsChangedEvent as h, CLIENT_SDK_NAME as ht, InvalidParamError as i, MfaInvalidOtpError as it, fetchProjectSettings as j, NoWalletProviderFoundError as k, DEFAULT_WAAS_BASE_API_URL as l, isCookieEnabled as lt, checkAndRaiseWalletAccountsChangedEvent as m, getPlatform as mt, upsertElevatedAccessToken as n, SandboxMaximumThresholdReachedError as nt, isWaasWalletAccount as o, InvalidExternalAuthError as ot, isUserMissingMfaAuth as p, randomString as pt, fetchAndStoreNonces as q, parseElevatedAccessToken as r, MfaRateLimitedError as rt, findWaasWalletProviderByChain as s, APIError as st, updateAuthFromVerifyResponse as t, createStorageKeySchema as tt, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as u, assertDefined as ut, __logoutWithReason_wrapped 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, normalizeAddress as z };
2305
- //# sourceMappingURL=updateAuthFromVerifyResponse-U7zoE0b1.esm.js.map
2327
+ export { updateNoncePoolStorage as $, generateSessionKeys as A, splitWalletProviderKey as B, getOperatingSystem as C, name as Ct, getWalletProviderRegistry as D, WalletProviderPriority as E, normalizeWalletNameWithChain as F, onEvent as G, retryOnFail as H, getChainFromVerifiedCredentialChain as I, createDeviceSignatureHeadersMiddleware as J, onceEvent as K, CHAINS_INFO_MAP as L, isSignedIn as M, getWalletAccounts as N, createRuntimeServiceAccessKey as O, formatWalletProviderKey as P, fetchAndStoreNonces as Q, formatWalletAccountId as R, getUserAgent as S, getCore as St, getWalletProviderFromWalletAccount as T, emitEvent as U, InvalidWalletProviderKeyError as V, offEvent as W, getDeviceSigner as X, getHeadersForNonceSignedByDeviceSigners as Y, getNonce as Z, SDK_API_CORE_VERSION as _, NONCE_POOL_SIZE as _t, initializeWaasClientsForEagerRecovery as a, LinkCredentialError as at, scrubParameters as b, ClientNotFoundError as bt, isWaasWalletProvider as c, CLIENT_SDK_NAME as ct, DYNAMIC_WAAS_METADATA as d, isCookieEnabled as dt, createStorageKeySchema as et, getWalletProviders as f, assertDefined as ft, DYNAMIC_ICONIC_SPRITE_URL as g, getPlatform as gt, emitWalletAccountsChangedEvent as h, randomString as ht, InvalidParamError as i, MfaInvalidOtpError as it, fetchProjectSettings as j, NoWalletProviderFoundError as k, DEFAULT_WAAS_BASE_API_URL as l, DYNAMIC_SDK_API_VERSION as lt, checkAndRaiseWalletAccountsChangedEvent as m, getElevatedAccessToken as mt, upsertElevatedAccessToken as n, SandboxMaximumThresholdReachedError as nt, isWaasWalletAccount as o, InvalidExternalAuthError as ot, isUserMissingMfaAuth as p, ValueMustBeDefinedError as pt, createApiClient as q, parseElevatedAccessToken as r, MfaRateLimitedError as rt, findWaasWalletProviderByChain as s, APIError as st, updateAuthFromVerifyResponse as t, UnauthorizedError as tt, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as u, getSessionKeys as ut, __logoutWithReason_wrapped 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, normalizeAddress as z };
2328
+ //# sourceMappingURL=updateAuthFromVerifyResponse-BhILXMm_.esm.js.map