@dynamic-labs-sdk/client 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NativeModuleNotLinkedError-BK7v1pWC.native.esm.js → NativeModuleNotLinkedError-DIpQjh_K.native.esm.js} +196 -182
- package/dist/NativeModuleNotLinkedError-DIpQjh_K.native.esm.js.map +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/{consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js → consumeMfaTokenIfRequiredForAction-jsAdDyDj.esm.js} +2 -2
- package/dist/{consumeMfaTokenIfRequiredForAction-BIgGN1OX.esm.js.map → consumeMfaTokenIfRequiredForAction-jsAdDyDj.esm.js.map} +1 -1
- package/dist/{consumeMfaTokenIfRequiredForAction-csagEe9v.cjs → consumeMfaTokenIfRequiredForAction-pUcqlY3s.cjs} +2 -2
- package/dist/{consumeMfaTokenIfRequiredForAction-csagEe9v.cjs.map → consumeMfaTokenIfRequiredForAction-pUcqlY3s.cjs.map} +1 -1
- package/dist/core.cjs +8 -7
- package/dist/core.cjs.map +1 -1
- package/dist/core.esm.js +7 -7
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +6 -6
- package/dist/core.native.esm.js.map +1 -1
- package/dist/exports/core.d.ts +2 -0
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/waas.d.ts +1 -0
- package/dist/exports/waas.d.ts.map +1 -1
- package/dist/generated/dependencyCatalog.d.ts +4 -0
- package/dist/generated/dependencyCatalog.d.ts.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-BAbc7qAr.cjs → getNetworkProviderFromNetworkId-DPFHY3b8.cjs} +2 -2
- package/dist/{getNetworkProviderFromNetworkId-BAbc7qAr.cjs.map → getNetworkProviderFromNetworkId-DPFHY3b8.cjs.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js → getNetworkProviderFromNetworkId-DTNPpR5H.esm.js} +2 -2
- package/dist/{getNetworkProviderFromNetworkId-4Xoiy8NQ.esm.js.map → getNetworkProviderFromNetworkId-DTNPpR5H.esm.js.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js → getNetworkProviderFromNetworkId-YcalZlDG.native.esm.js} +3 -3
- package/dist/getNetworkProviderFromNetworkId-YcalZlDG.native.esm.js.map +1 -0
- package/dist/{getSignedSessionId-C9EFdGfb.native.esm.js → getSignedSessionId-BjhgfsJD.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-C9EFdGfb.native.esm.js.map → getSignedSessionId-BjhgfsJD.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-bbTK-sA0.esm.js → getSignedSessionId-Btl5p_7b.esm.js} +2 -2
- package/dist/{getSignedSessionId-bbTK-sA0.esm.js.map → getSignedSessionId-Btl5p_7b.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-DpZexHsP.cjs → getSignedSessionId-VX7LkxVJ.cjs} +2 -2
- package/dist/{getSignedSessionId-DpZexHsP.cjs.map → getSignedSessionId-VX7LkxVJ.cjs.map} +1 -1
- package/dist/{getWalletProviderByKey-Bmqc0Duc.cjs → getWalletProviderByKey--K4N2u-M.cjs} +2 -2
- package/dist/{getWalletProviderByKey-Bmqc0Duc.cjs.map → getWalletProviderByKey--K4N2u-M.cjs.map} +1 -1
- package/dist/{getWalletProviderByKey-D_TZdpYc.esm.js → getWalletProviderByKey-5sZK6kAJ.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-D_TZdpYc.esm.js.map → getWalletProviderByKey-5sZK6kAJ.esm.js.map} +1 -1
- package/dist/{getWalletProviderByKey-DVBZq2sg.native.esm.js → getWalletProviderByKey-BhcBoGMW.native.esm.js} +2 -2
- package/dist/{getWalletProviderByKey-DVBZq2sg.native.esm.js.map → getWalletProviderByKey-BhcBoGMW.native.esm.js.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.esm.js +6 -6
- package/dist/index.native.esm.js +6 -6
- package/dist/{isDynamicWaasEnabled-NC2_jndd.native.esm.js → isDynamicWaasEnabled-BR_pG4jM.native.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-NC2_jndd.native.esm.js.map → isDynamicWaasEnabled-BR_pG4jM.native.esm.js.map} +1 -1
- package/dist/{isDynamicWaasEnabled-Bfd-h02Q.cjs → isDynamicWaasEnabled-MtEVK3ov.cjs} +2 -2
- package/dist/{isDynamicWaasEnabled-Bfd-h02Q.cjs.map → isDynamicWaasEnabled-MtEVK3ov.cjs.map} +1 -1
- package/dist/{isDynamicWaasEnabled-BJimir8s.esm.js → isDynamicWaasEnabled-sI3vpWvA.esm.js} +2 -2
- package/dist/{isDynamicWaasEnabled-BJimir8s.esm.js.map → isDynamicWaasEnabled-sI3vpWvA.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-W1y6oe6Y.cjs → isMfaRequiredForAction-BiPVqg49.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-W1y6oe6Y.cjs.map → isMfaRequiredForAction-BiPVqg49.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-DMB9vA5-.esm.js → isMfaRequiredForAction-DJ2UX11y.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-DMB9vA5-.esm.js.map → isMfaRequiredForAction-DJ2UX11y.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-MdS-yMQf.native.esm.js → isMfaRequiredForAction-GWZny7T2.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-MdS-yMQf.native.esm.js.map → isMfaRequiredForAction-GWZny7T2.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-BmGd69SF.cjs → isUserOnboardingComplete-D1hw1c5_.cjs} +3 -3
- package/dist/{isUserOnboardingComplete-BmGd69SF.cjs.map → isUserOnboardingComplete-D1hw1c5_.cjs.map} +1 -1
- package/dist/{isUserOnboardingComplete-Bj0ClaGP.native.esm.js → isUserOnboardingComplete-Hzz6fwTk.native.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-Bj0ClaGP.native.esm.js.map → isUserOnboardingComplete-Hzz6fwTk.native.esm.js.map} +1 -1
- package/dist/{isUserOnboardingComplete-Cm2VLmIH.esm.js → isUserOnboardingComplete-OvzVH1rg.esm.js} +3 -3
- package/dist/{isUserOnboardingComplete-Cm2VLmIH.esm.js.map → isUserOnboardingComplete-OvzVH1rg.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-rs5CZz-4.native.esm.js → migrateFromFireblocks-BiLoNIkA.native.esm.js} +3 -3
- package/dist/{migrateFromFireblocks-rs5CZz-4.native.esm.js.map → migrateFromFireblocks-BiLoNIkA.native.esm.js.map} +1 -1
- package/dist/{migrateFromFireblocks-rQkE9cQa.cjs → migrateFromFireblocks-NRfLh1JL.cjs} +4 -4
- package/dist/{migrateFromFireblocks-rQkE9cQa.cjs.map → migrateFromFireblocks-NRfLh1JL.cjs.map} +1 -1
- package/dist/{migrateFromFireblocks-BUuulRx2.esm.js → migrateFromFireblocks-Y5pPtmew.esm.js} +4 -4
- package/dist/{migrateFromFireblocks-BUuulRx2.esm.js.map → migrateFromFireblocks-Y5pPtmew.esm.js.map} +1 -1
- package/dist/modules/apiClient/constants.d.ts +8 -1
- package/dist/modules/apiClient/constants.d.ts.map +1 -1
- package/dist/modules/apiClient/createApiClient.d.ts +1 -2
- package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
- package/dist/modules/apiClient/createBaseApiClient.d.ts +16 -0
- package/dist/modules/apiClient/createBaseApiClient.d.ts.map +1 -0
- package/dist/modules/auth/logoutWithReason/logoutWithReason.d.ts.map +1 -1
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/index.d.ts +2 -0
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/index.d.ts.map +1 -0
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts +35 -0
- package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/{updateAuthFromVerifyResponse-CNfUcLNC.cjs → updateAuthFromVerifyResponse-ChnvPY0m.cjs} +196 -188
- package/dist/updateAuthFromVerifyResponse-ChnvPY0m.cjs.map +1 -0
- package/dist/{updateAuthFromVerifyResponse-85pmbAH4.esm.js → updateAuthFromVerifyResponse-Ct1Y6O_T.esm.js} +197 -183
- package/dist/updateAuthFromVerifyResponse-Ct1Y6O_T.esm.js.map +1 -0
- package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -1
- package/dist/waas.cjs +45 -5
- package/dist/waas.cjs.map +1 -1
- package/dist/waas.esm.js +46 -7
- package/dist/waas.esm.js.map +1 -1
- package/dist/waas.native.esm.js +45 -6
- package/dist/waas.native.esm.js.map +1 -1
- package/dist/waasCore.cjs +7 -7
- package/dist/waasCore.esm.js +7 -7
- package/dist/waasCore.native.esm.js +6 -6
- package/package.json +6 -4
- package/dist/NativeModuleNotLinkedError-BK7v1pWC.native.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-BZJXSy5b.native.esm.js.map +0 -1
- package/dist/updateAuthFromVerifyResponse-85pmbAH4.esm.js.map +0 -1
- package/dist/updateAuthFromVerifyResponse-CNfUcLNC.cjs.map +0 -1
|
@@ -6,18 +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.
|
|
10
|
-
var dependencies = {
|
|
11
|
-
"@dynamic-labs-sdk/assert-package-version": "workspace:*",
|
|
12
|
-
"@dynamic-labs-wallet/browser-wallet-client": "1.0.79",
|
|
13
|
-
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
14
|
-
"@dynamic-labs/sdk-api-core": "catalog:",
|
|
15
|
-
"@simplewebauthn/browser": "13.1.0",
|
|
16
|
-
"ably": "2.17.1",
|
|
17
|
-
"buffer": "6.0.3",
|
|
18
|
-
"eventemitter3": "5.0.1",
|
|
19
|
-
"zod": "4.0.5"
|
|
20
|
-
};
|
|
9
|
+
var version = "1.23.0";
|
|
21
10
|
|
|
22
11
|
//#endregion
|
|
23
12
|
//#region src/client/core/getCore/getCore.ts
|
|
@@ -141,26 +130,6 @@ const setDefaultClient = (client) => {
|
|
|
141
130
|
const NONCE_POOL_EXPIRATION_TIME = 6e4 * 60 * 24;
|
|
142
131
|
const NONCE_POOL_SIZE = 5;
|
|
143
132
|
|
|
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
133
|
//#endregion
|
|
165
134
|
//#region src/utils/getPlatform/getPlatform.native.ts
|
|
166
135
|
/**
|
|
@@ -287,6 +256,41 @@ const getSessionKeys = (client) => {
|
|
|
287
256
|
return { publicKey };
|
|
288
257
|
};
|
|
289
258
|
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/generated/dependencyCatalog.ts
|
|
261
|
+
const dependencyCatalog = { "@dynamic-labs/sdk-api-core": "0.0.1083" };
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/constants.ts
|
|
265
|
+
const SDK_API_CORE_VERSION = dependencyCatalog["@dynamic-labs/sdk-api-core"];
|
|
266
|
+
const DYNAMIC_ICONIC_SPRITE_URL = "https://iconic.dynamic-static-assets.com/icons/sprite.svg";
|
|
267
|
+
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/modules/apiClient/constants.ts
|
|
270
|
+
const DYNAMIC_API_VERSION_HEADER = "x-dyn-api-version";
|
|
271
|
+
const DYNAMIC_REQUEST_ID_HEADER = "x-dyn-request-id";
|
|
272
|
+
const DYNAMIC_SDK_VERSION_HEADER = "x-dyn-version";
|
|
273
|
+
/**
|
|
274
|
+
* Reports *why* the SDK is logging the user out on the `revokeSession`
|
|
275
|
+
* (`/sdk/{env}/revoke`) request. The backend logs it so SDK-initiated session
|
|
276
|
+
* revocations are attributable in Datadog (e.g. `token-expired`,
|
|
277
|
+
* `keychain-key-missing`) instead of being inferred from downstream 401s.
|
|
278
|
+
*/
|
|
279
|
+
const DYNAMIC_LOGOUT_REASON_HEADER = "x-dyn-logout-reason";
|
|
280
|
+
const ELEVATED_ACCESS_TOKEN_HEADER = "x-dyn-elevated-access-token";
|
|
281
|
+
const MFA_TOKEN_HEADER = "x-mfa-auth-token";
|
|
282
|
+
const SESSION_PUBLIC_KEY_HEADER = "x-dyn-session-public-key";
|
|
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
|
+
|
|
290
294
|
//#endregion
|
|
291
295
|
//#region src/errors/APIError/APIError.ts
|
|
292
296
|
var APIError = class APIError extends BaseError {
|
|
@@ -458,6 +462,81 @@ const createConvertToApiErrorMiddleware = ({ errorMappers = [] }) => ({ post: as
|
|
|
458
462
|
return context.response;
|
|
459
463
|
} });
|
|
460
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/${SDK_API_CORE_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
|
+
|
|
461
540
|
//#endregion
|
|
462
541
|
//#region src/services/storage/createLocalStorageAdapter/createLocalStorageAdapter.native.ts
|
|
463
542
|
const NAMESPACE = "dynamic";
|
|
@@ -539,6 +618,85 @@ const updateNoncePoolStorage = async ({ update }, client) => {
|
|
|
539
618
|
return storedBeforeUpdate;
|
|
540
619
|
};
|
|
541
620
|
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
|
|
623
|
+
/**
|
|
624
|
+
* Fetches a batch of nonces from the API and appends them to the pool in
|
|
625
|
+
* storage.
|
|
626
|
+
*
|
|
627
|
+
* Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
|
|
628
|
+
* redirect). On iOS, a network request (like fetching a nonce) between a user
|
|
629
|
+
* action and a deeplink call will break the gesture chain, causing iOS to
|
|
630
|
+
* silently ignore the deeplink. By prefetching nonces ahead of time,
|
|
631
|
+
* `getNonce` can return from the stored pool without an interrupting network
|
|
632
|
+
* round-trip.
|
|
633
|
+
*
|
|
634
|
+
* New nonces are **appended** to the stored pool so that unconsumed entries
|
|
635
|
+
* are not discarded by a background refetch; an expired stored pool is
|
|
636
|
+
* replaced instead, since its nonces have already been evicted server-side.
|
|
637
|
+
*
|
|
638
|
+
* Concurrent refills are coalesced behind a single in-flight promise so that
|
|
639
|
+
* simultaneous callers share one `GET /nonces` round-trip instead of each
|
|
640
|
+
* issuing their own (which would inflate the pool and hammer the backend).
|
|
641
|
+
* @notInstrumented
|
|
642
|
+
*/
|
|
643
|
+
const fetchAndStoreNonces = async (client) => {
|
|
644
|
+
const core = getCore(client);
|
|
645
|
+
const inFlight = core.state.get().nonceFetchInFlight;
|
|
646
|
+
if (inFlight) return inFlight;
|
|
647
|
+
const { environmentId } = core;
|
|
648
|
+
const apiClient = createBaseApiClient({}, client);
|
|
649
|
+
const fetchPromise = (async () => {
|
|
650
|
+
const { nonces } = await apiClient.getNonces({
|
|
651
|
+
count: NONCE_POOL_SIZE,
|
|
652
|
+
environmentId
|
|
653
|
+
});
|
|
654
|
+
const expiration = Date.now() + NONCE_POOL_EXPIRATION_TIME;
|
|
655
|
+
await updateNoncePoolStorage({ update: (stored) => {
|
|
656
|
+
return {
|
|
657
|
+
expiration,
|
|
658
|
+
nonces: [...stored && stored.expiration > Date.now() ? stored.nonces : [], ...nonces]
|
|
659
|
+
};
|
|
660
|
+
} }, client);
|
|
661
|
+
})().finally(() => {
|
|
662
|
+
core.state.set({ nonceFetchInFlight: null });
|
|
663
|
+
});
|
|
664
|
+
core.state.set({ nonceFetchInFlight: fetchPromise });
|
|
665
|
+
return fetchPromise;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/utils/getSecureCookieAttribute/getSecureCookieAttribute.ts
|
|
670
|
+
/**
|
|
671
|
+
* Returns the cookie `Secure` attribute suffix (`'; Secure'`) when the current
|
|
672
|
+
* document is running in a secure context, or an empty string otherwise.
|
|
673
|
+
*
|
|
674
|
+
* The `Secure` attribute prevents the browser from ever transmitting the cookie
|
|
675
|
+
* over an unencrypted `http://` connection, which mitigates cleartext token
|
|
676
|
+
* capture (CWE-614). It is intentionally omitted on insecure/localhost dev,
|
|
677
|
+
* because browsers reject `Secure` cookies set over `http://` and that would
|
|
678
|
+
* silently break local testing.
|
|
679
|
+
*
|
|
680
|
+
* Used when building the Dynamic auth JWT cookie string so the attribute is
|
|
681
|
+
* applied consistently on both the write (sign-in/refresh) and clear (logout)
|
|
682
|
+
* paths.
|
|
683
|
+
*
|
|
684
|
+
* @notInstrumented
|
|
685
|
+
*/
|
|
686
|
+
const getSecureCookieAttribute = () => {
|
|
687
|
+
return Boolean(globalThis.window?.isSecureContext) || globalThis.location?.protocol === "https:" ? "; Secure" : "";
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/utils/setCookie/setCookie.ts
|
|
692
|
+
/**
|
|
693
|
+
* Sefelly sets the cookie in the browser.
|
|
694
|
+
* @notInstrumented
|
|
695
|
+
*/
|
|
696
|
+
const setCookie = (cookie) => {
|
|
697
|
+
document.cookie = cookie;
|
|
698
|
+
};
|
|
699
|
+
|
|
542
700
|
//#endregion
|
|
543
701
|
//#region src/utils/getNonce/getNonce.ts
|
|
544
702
|
/**
|
|
@@ -641,35 +799,6 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
|
|
|
641
799
|
} };
|
|
642
800
|
};
|
|
643
801
|
|
|
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
802
|
//#endregion
|
|
674
803
|
//#region src/modules/apiClient/createApiClient.ts
|
|
675
804
|
/**
|
|
@@ -679,120 +808,10 @@ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
|
|
|
679
808
|
* @notInstrumented
|
|
680
809
|
*/
|
|
681
810
|
const createApiClient = (options = {}, client) => {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
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;
|
|
811
|
+
return createBaseApiClient({
|
|
812
|
+
middleware: [createDeviceSignatureHeadersMiddleware(client)],
|
|
813
|
+
options
|
|
814
|
+
}, client);
|
|
796
815
|
};
|
|
797
816
|
|
|
798
817
|
//#endregion
|
|
@@ -1782,11 +1801,6 @@ const instrumentFunction = ({ fn, functionName, getCore: getCore$1, selectors })
|
|
|
1782
1801
|
return wrapped;
|
|
1783
1802
|
};
|
|
1784
1803
|
|
|
1785
|
-
//#endregion
|
|
1786
|
-
//#region src/constants.ts
|
|
1787
|
-
const SDK_API_CORE_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
|
|
1788
|
-
const DYNAMIC_ICONIC_SPRITE_URL = "https://iconic.dynamic-static-assets.com/icons/sprite.svg";
|
|
1789
|
-
|
|
1790
1804
|
//#endregion
|
|
1791
1805
|
//#region src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts
|
|
1792
1806
|
/**
|
|
@@ -2101,5 +2115,5 @@ var NativeModuleNotLinkedError = class extends BaseError {
|
|
|
2101
2115
|
};
|
|
2102
2116
|
|
|
2103
2117
|
//#endregion
|
|
2104
|
-
export {
|
|
2105
|
-
//# sourceMappingURL=NativeModuleNotLinkedError-
|
|
2118
|
+
export { UnauthorizedError as $, formatWalletProviderKey as A, onEvent as B, DYNAMIC_AUTH_COOKIE_NAME as C, name as Ct, createRuntimeServiceAccessKey as D, getWalletProviderRegistry as E, normalizeAddress as F, getDeviceSigner as G, createApiClient as H, splitWalletProviderKey as I, getSecureCookieAttribute as J, getNonce as K, InvalidWalletProviderKeyError as L, getChainFromVerifiedCredentialChain as M, CHAINS_INFO_MAP as N, NoWalletProviderFoundError as O, formatWalletAccountId as P, createLocalStorageAdapter as Q, emitEvent as R, extractSessionId as S, getCore as St, WalletProviderPriority as T, createDeviceSignatureHeadersMiddleware as U, onceEvent as V, getHeadersForNonceSignedByDeviceSigners as W, updateNoncePoolStorage as X, fetchAndStoreNonces as Y, createStorageKeySchema as Z, instrumentFunction as _, NONCE_POOL_SIZE as _t, InvalidParamError as a, APIError as at, getUserAgent as b, ClientNotFoundError as bt, findWaasWalletProviderByChain as c, DYNAMIC_ICONIC_SPRITE_URL as ct, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as d, isCookieEnabled as dt, SandboxMaximumThresholdReachedError as et, DYNAMIC_WAAS_METADATA as f, assertDefined as ft, emitWalletAccountsChangedEvent as g, getPlatform as gt, checkAndRaiseWalletAccountsChangedEvent as h, randomString as ht, parseElevatedAccessToken as i, InvalidExternalAuthError as it, normalizeWalletNameWithChain as j, getWalletAccounts as k, isWaasWalletProvider as l, SDK_API_CORE_VERSION as lt, isUserMissingMfaAuth as m, getElevatedAccessToken as mt, updateAuthFromVerifyResponse as n, MfaInvalidOtpError as nt, initializeWaasClientsForEagerRecovery as o, CLIENT_SDK_NAME as ot, getWalletProviders as p, ValueMustBeDefinedError as pt, setCookie as q, upsertElevatedAccessToken as r, LinkCredentialError as rt, isWaasWalletAccount as s, DYNAMIC_LOGOUT_REASON_HEADER as st, NativeModuleNotLinkedError as t, MfaRateLimitedError as tt, DEFAULT_WAAS_BASE_API_URL as u, getSessionKeys as ut, scrubParameters as v, getDefaultClient as vt, getWalletProviderFromWalletAccount as w, version as wt, getOperatingSystem as x, BaseError as xt, DEFAULT_PII_FIELDS as y, setDefaultClient as yt, offEvent as z };
|
|
2119
|
+
//# sourceMappingURL=NativeModuleNotLinkedError-DIpQjh_K.native.esm.js.map
|