@dynamic-labs-sdk/client 0.16.1 → 0.16.3
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/{InvalidParamError-BPKi-2Me.esm.js → InvalidParamError-BVx-qvip.esm.js} +8 -3
- package/dist/{InvalidParamError-BPKi-2Me.esm.js.map → InvalidParamError-BVx-qvip.esm.js.map} +1 -1
- package/dist/{InvalidParamError-DxdJ-Vjr.cjs.js → InvalidParamError-DgN3p6L7.cjs.js} +8 -3
- package/dist/{InvalidParamError-DxdJ-Vjr.cjs.js.map → InvalidParamError-DgN3p6L7.cjs.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-674h4R9F.esm.js → NotWaasWalletAccountError-Cf9lQuha.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-674h4R9F.esm.js.map → NotWaasWalletAccountError-Cf9lQuha.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-CC0TnXFG.cjs.js → NotWaasWalletAccountError-D-U7HAdA.cjs.js} +3 -3
- package/dist/{NotWaasWalletAccountError-CC0TnXFG.cjs.js.map → NotWaasWalletAccountError-D-U7HAdA.cjs.js.map} +1 -1
- package/dist/client/core/createCore/createCore.d.ts.map +1 -1
- package/dist/client/types/DynamicClientConfig.d.ts +2 -0
- package/dist/client/types/DynamicClientConfig.d.ts.map +1 -1
- package/dist/core.cjs.js +5 -5
- package/dist/core.esm.js +5 -5
- package/dist/{getNetworkProviderFromNetworkId-4aliEYIC.cjs.js → getNetworkProviderFromNetworkId-B3Q8FbYk.cjs.js} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-4aliEYIC.cjs.js.map → getNetworkProviderFromNetworkId-B3Q8FbYk.cjs.js.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DMgQWVbk.esm.js → getNetworkProviderFromNetworkId-Dxgklnpy.esm.js} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-DMgQWVbk.esm.js.map → getNetworkProviderFromNetworkId-Dxgklnpy.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-lflDyi6Y.cjs.js → getSignedSessionId-CHghEuS-.cjs.js} +3 -3
- package/dist/{getSignedSessionId-lflDyi6Y.cjs.js.map → getSignedSessionId-CHghEuS-.cjs.js.map} +1 -1
- package/dist/{getSignedSessionId-QONqJpzq.esm.js → getSignedSessionId-DyHvgJWx.esm.js} +3 -3
- package/dist/{getSignedSessionId-QONqJpzq.esm.js.map → getSignedSessionId-DyHvgJWx.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-9U3-GhOF.esm.js → getVerifiedCredentialForWalletAccount-BNiAI52Z.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-9U3-GhOF.esm.js.map → getVerifiedCredentialForWalletAccount-BNiAI52Z.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-BdVRoKMM.cjs.js → getVerifiedCredentialForWalletAccount-CrCYutAz.cjs.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-BdVRoKMM.cjs.js.map → getVerifiedCredentialForWalletAccount-CrCYutAz.cjs.js.map} +1 -1
- package/dist/index.cjs.js +13 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-Du4D8WDp.cjs.js → isMfaRequiredForAction-C3HCyv2s.cjs.js} +2 -2
- package/dist/{isMfaRequiredForAction-Du4D8WDp.cjs.js.map → isMfaRequiredForAction-C3HCyv2s.cjs.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-BMf88hKI.esm.js → isMfaRequiredForAction-cHOlNJRm.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-BMf88hKI.esm.js.map → isMfaRequiredForAction-cHOlNJRm.esm.js.map} +1 -1
- package/dist/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.d.ts +5 -3
- package/dist/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.d.ts.map +1 -1
- package/dist/modules/wallets/constants.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs.js +3 -3
- package/dist/waas.esm.js +3 -3
- package/dist/waasCore.cjs.js +3 -3
- package/dist/waasCore.esm.js +3 -3
- package/package.json +3 -3
|
@@ -4,11 +4,11 @@ import * as z from "zod/mini";
|
|
|
4
4
|
|
|
5
5
|
//#region package.json
|
|
6
6
|
var name = "@dynamic-labs-sdk/client";
|
|
7
|
-
var version = "0.16.
|
|
7
|
+
var version = "0.16.3";
|
|
8
8
|
var dependencies = {
|
|
9
9
|
"@dynamic-labs-sdk/assert-package-version": "workspace:*",
|
|
10
10
|
"@dynamic-labs-wallet/browser-wallet-client": "0.0.286",
|
|
11
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
11
|
+
"@dynamic-labs/sdk-api-core": "0.0.900",
|
|
12
12
|
"@simplewebauthn/browser": "13.1.0",
|
|
13
13
|
"ably": "2.17.1",
|
|
14
14
|
"buffer": "6.0.3",
|
|
@@ -716,6 +716,11 @@ const CHAINS_INFO_MAP = {
|
|
|
716
716
|
blockchainName: "Sui",
|
|
717
717
|
verifiedCredentialChainName: "sui"
|
|
718
718
|
},
|
|
719
|
+
TEMPO: {
|
|
720
|
+
apiChainName: "tempo",
|
|
721
|
+
blockchainName: "Tempo",
|
|
722
|
+
verifiedCredentialChainName: "tempo"
|
|
723
|
+
},
|
|
719
724
|
TON: {
|
|
720
725
|
apiChainName: "ton",
|
|
721
726
|
blockchainName: "TON",
|
|
@@ -767,4 +772,4 @@ var InvalidParamError = class extends BaseError {
|
|
|
767
772
|
|
|
768
773
|
//#endregion
|
|
769
774
|
export { randomString as A, version as B, InvalidExternalAuthError as C, isCookieEnabled as D, getBuffer as E, setDefaultClient as F, ClientNotFoundError as I, BaseError as L, DYNAMIC_SDK_API_VERSION as M, NONCE_POOL_SIZE as N, assertDefined as O, getDefaultClient as P, getCore as R, LinkCredentialError as S, getSessionKeys as T, p256Sign as _, DYNAMIC_ICONIC_SPRITE_URL as a, MfaRateLimitedError as b, CHAINS_INFO_MAP as c, UnauthorizedError as d, createDeviceSignatureHeadersMiddleware as f, createStorageKeySchema as g, p256Keygen as h, DYNAMIC_WAAS_METADATA as i, CLIENT_SDK_NAME as j, ValueMustBeDefinedError as k, fetchAndStoreNonces as l, getDeviceSigner as m, DEFAULT_WAAS_BASE_API_URL as n, SDK_API_CORE_VERSION as o, getHeadersForNonceSignedByDeviceSigners as p, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as r, getChainFromVerifiedCredentialChain as s, InvalidParamError as t, createApiClient as u, getNonce as v, APIError as w, MfaInvalidOtpError as x, SandboxMaximumThresholdReachedError as y, name as z };
|
|
770
|
-
//# sourceMappingURL=InvalidParamError-
|
|
775
|
+
//# sourceMappingURL=InvalidParamError-BVx-qvip.esm.js.map
|
package/dist/{InvalidParamError-BPKi-2Me.esm.js.map → InvalidParamError-BVx-qvip.esm.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidParamError-BPKi-2Me.esm.js","names":["defaultClient: DynamicClient | null","BufferPolyfill","clientErrorMapper: ErrorMapper","errorToThrow: Error","cause: Error | null","settings: ISettings","CHAINS_INFO_MAP: Record<Chain, ChainInfo>","chain"],"sources":["../package.json","../src/client/core/getCore/getCore.ts","../src/errors/base/BaseError.ts","../src/errors/ClientNotFoundError.ts","../src/client/defaultClient/defaultClient.ts","../src/utils/getNonce/constants.ts","../src/modules/apiClient/constants.ts","../src/utils/randomString/randomString.ts","../src/errors/ValueMustBeDefinedError.ts","../src/utils/assertDefined/assertDefined.ts","../src/modules/projectSettings/isCookieEnabled/isCookieEnabled.ts","../src/utils/getBuffer/getBuffer.ts","../src/modules/sessionKeys/getSessionKeys/getSessionKeys.ts","../src/errors/APIError/APIError.ts","../src/errors/InvalidExternalAuthError.ts","../src/errors/LinkCredentialError.ts","../src/errors/MfaInvalidOtpError.ts","../src/errors/MfaRateLimitedError.ts","../src/errors/SandboxMaximumThresholdReachedError.ts","../src/modules/apiClient/utils/clientErrorMapper/clientErrorMapper.ts","../src/modules/apiClient/utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware.ts","../src/utils/getNonce/getNonce.ts","../src/utils/bufferToHex/bufferToHex.ts","../src/utils/p256Sign/p256Sign.ts","../src/services/storage/createStorageKeySchema/createStorageKeySchema.ts","../src/utils/base64UrlDecode/base64UrlDecode.ts","../src/utils/compressRawPublicKey/compressRawPublicKey.ts","../src/utils/p256Keygen/p256Keygen.ts","../src/modules/deviceRegistration/getDeviceSigner/deviceSigningKeys.schema.ts","../src/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.ts","../src/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.ts","../src/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.ts","../src/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.ts","../src/errors/UnauthorizedError.ts","../src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts","../src/modules/apiClient/createApiClient.ts","../src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts","../src/modules/wallets/constants.ts","../src/utils/getChainFromVerifiedCredentialChain/getChainFromVerifiedCredentialChain.ts","../src/constants.ts","../src/modules/waas/constants.ts","../src/errors/InvalidParamError.ts"],"sourcesContent":["","import type { DynamicClient } from '../../types';\nimport type { DynamicCore } from '../types';\n\nexport const getCore = (client: DynamicClient): DynamicCore => {\n // @ts-expect-error - this was hidden from the public API\n return client.__core;\n};\n","import { version } from '../../../package.json';\n\nexport type BaseErrorParameters = {\n /** The underlying error that caused this error, if any */\n cause: Error | null;\n /** The error unique code */\n code: string;\n /** Additional detailed information about the error */\n details?: string;\n /** URL to relevant documentation for this error */\n docsUrl: string | null;\n /** Array of additional contextual messages to be displayed */\n metaMessages?: string[];\n /** Custom name for the error. Defaults to 'BaseError' if not provided */\n name: string;\n /** A brief, human-readable description of the error */\n shortMessage: string;\n};\n\nconst getDetails = ({ details, cause }: BaseErrorParameters) => {\n if (cause instanceof BaseError) {\n return cause.details;\n }\n\n if (cause?.message) {\n return cause.message;\n }\n\n return details;\n};\n\n/**\n * Formats the error message with all available information\n */\nconst formatMessage = ({\n shortMessage,\n details,\n docsUrl,\n metaMessages,\n}: BaseErrorParameters) => {\n return [\n '[Dynamic JS SDK]',\n shortMessage,\n '',\n ...(metaMessages ? [...metaMessages, ''] : []),\n ...(docsUrl ? [`Docs: ${docsUrl}`] : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: ${version}`,\n `Timestamp: ${new Date().toISOString()}`,\n ].join('\\n');\n};\n\n/**\n * Base error class that provides structured error handling with detailed information\n */\nexport abstract class BaseError extends Error {\n /** The error unique code */\n code: string;\n details: string | undefined;\n private readonly formattedMessage: string | undefined;\n override name = 'BaseError';\n override cause: BaseError | Error | undefined;\n\n constructor(args: BaseErrorParameters) {\n const details = getDetails(args);\n const formattedMessage = formatMessage({ ...args, details });\n super(\n args.shortMessage ?? formattedMessage,\n args.cause ? { cause: args.cause } : undefined\n );\n\n this.formattedMessage = formattedMessage;\n this.details = details;\n this.name = args.name ?? this.name;\n this.cause = args.cause ?? this.cause;\n this.code = args.code;\n }\n\n /**\n * Walks the cause chain of the error and returns the root error\n */\n walk(): Error | undefined {\n const cause = this.cause;\n\n if (cause instanceof BaseError) {\n return cause.walk();\n }\n\n return cause;\n }\n\n override toString() {\n return this.formattedMessage;\n }\n}\n","import { BaseError } from './base';\n\nexport class ClientNotFoundError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'client_not_found_error',\n docsUrl: null,\n name: 'ClientNotFoundError',\n shortMessage:\n 'No Dynamic client has been created yet. Make sure you have called createDynamicClient() first.',\n });\n }\n}\n","import { ClientNotFoundError } from '../../errors/ClientNotFoundError';\nimport { getCore } from '../core/getCore';\nimport type { DynamicClient } from '../types';\n\nlet defaultClient: DynamicClient | null = null;\nlet numOfInitializedClients = 0;\n\n/**\n * Returns the DynamicClient instance that was initialized with createDynamicClient.\n *\n * If more than one instance of DynamicClient was initialized, you should not use this function.\n * Instead, you should pass the client instance you stored to the function that needs it.\n */\nexport const getDefaultClient = (): DynamicClient => {\n if (!defaultClient) {\n throw new ClientNotFoundError();\n }\n\n if (numOfInitializedClients > 1) {\n const core = getCore(defaultClient);\n core.logger.debug(\n 'Multiple instances of DynamicClient found. If you are only using one client (recommended), make sure you are not calling ' +\n '\"createDynamicClient\" multiple times. If you are using multiple clients, make sure you are passing which client to use as ' +\n 'the last param of all Dynamic functions.'\n );\n }\n\n return defaultClient;\n};\n\nexport const setDefaultClient = (client: DynamicClient) => {\n defaultClient = client;\n numOfInitializedClients++;\n};\n","export const NONCE_POOL_EXPIRATION_TIME = 60000 * 60 * 24;\n\nexport const NONCE_POOL_SIZE = 5;\n","import { dependencies } from '../../../package.json';\n\nexport const DYNAMIC_API_VERSION_HEADER = 'x-dyn-api-version';\n\nexport const DYNAMIC_REQUEST_ID_HEADER = 'x-dyn-request-id';\n\nexport const DYNAMIC_SDK_VERSION_HEADER = 'x-dyn-version';\n\nexport const MFA_TOKEN_HEADER = 'x-mfa-auth-token';\n\nexport const SESSION_PUBLIC_KEY_HEADER = 'x-dyn-session-public-key';\n\nexport const DYNAMIC_SDK_API_VERSION =\n dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const CLIENT_SDK_NAME = 'ClientSDK';\n","const DEFAULT_CHARS =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\ntype RandomStringParams = {\n chars?: string;\n length: number;\n};\n\nexport const randomString = ({ chars = DEFAULT_CHARS, length }: RandomStringParams) => {\n const bytes = new Uint8Array(length);\n crypto.getRandomValues(bytes);\n\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n return result;\n};\n","import { BaseError } from './base';\n\nexport class ValueMustBeDefinedError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'value_must_be_defined_error',\n docsUrl: null,\n name: 'ValueMustBeDefined',\n shortMessage: message,\n });\n }\n}\n","/* eslint-disable func-style -- javascript requires this to be a function */\n\nimport { ValueMustBeDefinedError } from './../../errors/ValueMustBeDefinedError';\n\n/**\n * Asserts that a value is not null or undefined, throwing an error if it is.\n * This function acts as a type guard, narrowing the type to exclude null and undefined.\n *\n * @template T - The type of the value being checked\n * @param value - The value to check for null or undefined\n * @param message - The error message to throw if the value is null or undefined\n * @throws Throws an error with the provided message if value is null or undefined\n * @example\n * ```typescript\n * const maybeString: string | null = getValue();\n * assertDefined(maybeString, 'String value is required');\n * // maybeString is now typed as string (null is excluded)\n * ```\n */\nexport function assertDefined<T>(\n value: T,\n message: string\n): asserts value is Exclude<NonNullable<T>, void> {\n if (value === null || value === undefined) {\n throw new ValueMustBeDefinedError(message);\n }\n}\n","import { AuthStorageEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Returns true if the client is using Dynamic cookies or a BYO JWT cookie.\n */\nexport const isCookieEnabled = (client: DynamicClient): boolean => {\n assertDefined(client.projectSettings, 'Project settings are not defined');\n\n const securitySettings = client.projectSettings.security;\n\n if (!securitySettings) return false;\n\n // client uses Dynamic cookies\n const dynamicCookiesEnabled = (securitySettings.auth?.storage || []).includes(\n AuthStorageEnum.Cookie\n );\n\n // BYO JWT client puts their non-Dynamic JWT in a cookie\n const byoJwtCookieEnabled = Boolean(\n securitySettings.externalAuth?.cookieName\n );\n\n // should return true for both of these scenarios\n // because we also need to do `credentials: true` in api.ts when\n // a byo jwt client sets their named cookie for their jwt and\n // needs to send it to our backend\n return dynamicCookiesEnabled || byoJwtCookieEnabled;\n};\n","/* eslint-disable no-restricted-globals */\nimport { Buffer as BufferPolyfill } from 'buffer';\n\nexport const getBuffer = () =>\n typeof Buffer !== 'undefined' ? Buffer : BufferPolyfill;\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { getBuffer } from '../../../utils/getBuffer';\nimport type { SessionKeys } from '../sessionKeys.types';\n\nexport const getSessionKeys = (client: DynamicClient) => {\n const core = getCore(client);\n\n const encodedKeys = core.state.get().sessionKeys;\n\n if (!encodedKeys) {\n return undefined;\n }\n\n try {\n const decodedKeys: SessionKeys = JSON.parse(\n getBuffer().from(encodedKeys, 'base64').toString()\n );\n\n return decodedKeys;\n } catch (error) {\n core.logger.error('Error decoding session keys', error);\n return undefined;\n }\n};\n","import { BaseError } from '../base';\n\nexport class APIError extends BaseError {\n status: number;\n\n constructor(message: string, code: string, status: number) {\n super({\n cause: null,\n code,\n docsUrl: null,\n name: 'APIError',\n shortMessage: message,\n });\n\n this.status = status;\n }\n\n static async fromResponse(response: Response) {\n try {\n const errorBody = await response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n const errorCode =\n 'code' in errorBody && typeof errorBody.code === 'string'\n ? errorBody.code\n : 'unknown_error';\n\n return new APIError(errorBody.error, errorCode, response.status);\n }\n\n return null;\n } catch {\n return null;\n }\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class InvalidExternalAuthError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'invalid_external_auth_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/external-auth/third-party-auth-overview',\n name: 'InvalidExternalAuthError',\n shortMessage: 'Error authenticating with external JWT',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class LinkCredentialError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'link_credential_error',\n docsUrl: null,\n name: 'LinkCredentialError',\n shortMessage:\n 'The credential you are trying to link is associated with another account and cannot be reassigned.',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaInvalidOtpError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_invalid_otp_error',\n docsUrl: null,\n name: 'MfaInvalidOtpError',\n shortMessage: 'Invalid OTP',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaRateLimitedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_rate_limited_error',\n docsUrl: null,\n name: 'MfaRateLimitedError',\n shortMessage: 'Rate limited',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class SandboxMaximumThresholdReachedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'sandbox_maximum_threshold_reached_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/developer-dashboard/sandbox-vs-live#sandbox-vs-live',\n name: 'SandboxMaximumThresholdReachedError',\n shortMessage:\n 'Your sandbox environment has reached the maximum MAU. Please use a live environment for production traffic.',\n });\n }\n}\n","import { APIError } from '../../../../errors/APIError';\nimport { InvalidExternalAuthError } from '../../../../errors/InvalidExternalAuthError';\nimport { LinkCredentialError } from '../../../../errors/LinkCredentialError';\nimport { MfaInvalidOtpError } from '../../../../errors/MfaInvalidOtpError';\nimport { MfaRateLimitedError } from '../../../../errors/MfaRateLimitedError';\nimport { SandboxMaximumThresholdReachedError } from '../../../../errors/SandboxMaximumThresholdReachedError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\n/**\n * Default error mapper for the client that handles common API error codes.\n *\n * This mapper transforms specific API error codes into more specific error types:\n * - `mfa_invalid_code` → `MfaInvalidOtpError`\n * - `mfa_rate_limited` → `MfaRateLimitedError`\n *\n * @param error - The error to be mapped\n * @returns A transformed error if the error code matches a known pattern, or null if no transformation is needed\n *\n * @example\n * ```typescript\n * // This will be automatically applied to all API errors\n * const apiClient = createApiClient({}, client);\n *\n * // The clientErrorMapper will automatically convert mfa_invalid_code errors\n * // to MfaInvalidOtpError instances\n * ```\n */\nexport const clientErrorMapper: ErrorMapper = (error) => {\n if (error instanceof APIError) {\n if (error.code === 'mfa_invalid_code') {\n return new MfaInvalidOtpError({ cause: error });\n }\n\n if (error.code === 'mfa_rate_limited') {\n return new MfaRateLimitedError({ cause: error });\n }\n\n if (error.code === 'invalid_external_auth') {\n return new InvalidExternalAuthError({ cause: error });\n }\n\n if (error.code === 'sandbox_maximum_threshold_reached') {\n return new SandboxMaximumThresholdReachedError({ cause: error });\n }\n\n if (\n error.code === 'merge_accounts_invalid' ||\n error.code === 'reassign_wallet_error'\n ) {\n return new LinkCredentialError({ cause: error });\n }\n }\n\n return null;\n};\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { APIError } from '../../../../errors/APIError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\ntype CreateConvertToApiErrorMiddlewareOptions = {\n errorMappers?: ErrorMapper[];\n};\n\n/**\n * Creates middleware that converts HTTP error responses to APIError instances\n * and optionally applies custom error mappers to transform them into specific error types.\n *\n * @param options.errorMappers - Array of error mappers to apply to API errors\n * @returns A middleware function that handles error conversion and mapping\n */\nexport const createConvertToApiErrorMiddleware = ({\n errorMappers = [],\n}: CreateConvertToApiErrorMiddlewareOptions): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status >= 400) {\n const apiError = await APIError.fromResponse(context.response);\n\n if (apiError) {\n let errorToThrow: Error = apiError;\n\n for (const mapper of errorMappers) {\n const newError = mapper(apiError);\n\n if (newError) {\n errorToThrow = newError;\n break;\n }\n }\n\n throw errorToThrow;\n }\n }\n\n return context.response;\n },\n});\n","import { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { fetchAndStoreNonces } from './fetchAndStoreNonces/fetchAndStoreNonces';\n\n/**\n * Returns a nonce for wallet ownership verification.\n *\n * Pops the first nonce from the prefetched pool. When the pool is running low\n * (≤1 remaining after pop) a background refetch is triggered. If the pool is\n * empty, nonces are fetched on-demand before returning.\n */\nexport const getNonce = async (\n client: DynamicClient\n): Promise<string> => {\n const core = getCore(client);\n const pool = core.state.get().prefetchedNonces;\n\n if (pool.length > 0) {\n const [nonce, ...remaining] = pool;\n\n core.state.set({ prefetchedNonces: remaining });\n\n if (remaining.length <= 1) {\n void fetchAndStoreNonces(client);\n }\n\n return nonce;\n }\n\n await fetchAndStoreNonces(client);\n\n return getNonce(client);\n};\n","/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { bufferToHex } from '../bufferToHex';\n\ntype P256SignParams = {\n message: string;\n privateKeyJwk: JsonWebKey;\n};\n\nexport const p256Sign = async ({ privateKeyJwk, message }: P256SignParams) => {\n const privateKey = await crypto.subtle.importKey(\n 'jwk',\n privateKeyJwk,\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n false,\n ['sign']\n );\n\n const signature = await crypto.subtle.sign(\n {\n hash: 'SHA-256',\n name: 'ECDSA',\n },\n privateKey,\n new TextEncoder().encode(message)\n );\n\n return bufferToHex(signature);\n};\n","import type * as z from 'zod/mini';\n\nimport type { StorageKeySchema } from '../storage.types';\n\nexport const createStorageKeySchema = <T>(params: {\n key: string;\n schema: z.ZodMiniType<T>;\n}): StorageKeySchema<T> => {\n return params;\n};\n","/**\n * Takes a base64url-encoded string (e.g. \"nMueRPiAm51YXEjRtka8S_8Ura3HaqbmqDqMJCZmvkM\")\n * and return the corresponding bytes, as an array buffer.\n */\nexport const base64UrlDecode = (s?: string) => {\n // Go from base64url encoding to base64 encoding\n s = s?.replace(/-/g, '+').replace(/_/g, '/') || '';\n // use `atob` to decode base64\n return Uint8Array.from(atob(s), (c) => c.charCodeAt(0));\n};\n","/**\n * Accepts a public key array buffer, and returns a buffer with the compressed version of the public key\n */\nexport const compressRawPublicKey = (rawPublicKey: ArrayBuffer) => {\n const rawPublicKeyBytes = new Uint8Array(rawPublicKey);\n const len = rawPublicKeyBytes.byteLength;\n\n // Drop the y coordinate\n const compressedBytes = rawPublicKeyBytes.slice(0, (1 + len) >>> 1);\n\n // Encode the parity of `y` in first bit\n compressedBytes[0] = 0x2 | (rawPublicKeyBytes[len - 1] & 0x01);\n return compressedBytes.buffer;\n};\n","import { base64UrlDecode } from '../base64UrlDecode';\nimport { bufferToHex } from '../bufferToHex';\nimport { compressRawPublicKey } from '../compressRawPublicKey';\n\nexport const p256Keygen = async () => {\n // Create a new P-256 keypair\n const p256Keypair = await crypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n true,\n ['sign', 'verify']\n );\n\n // Export the raw public key. By default this will export in uncompressed format\n const rawPublicKey = await crypto.subtle.exportKey(\n 'raw',\n p256Keypair.publicKey\n );\n\n // We need to export with JWK format because exporting EC private keys with \"raw\" isn't supported\n const privateKeyJwk = await crypto.subtle.exportKey(\n 'jwk',\n p256Keypair.privateKey\n );\n\n const compressedPublicKeyBuffer = compressRawPublicKey(rawPublicKey);\n\n const privateKeyBuffer = base64UrlDecode(privateKeyJwk.d);\n\n return {\n private: bufferToHex(privateKeyBuffer),\n privateJwk: privateKeyJwk,\n public: bufferToHex(compressedPublicKeyBuffer),\n };\n};\n","import * as z from 'zod/mini';\n\nexport const deviceSigningKeysSchema = z.object({\n privateJwk: z.custom<JsonWebKey>(),\n privateKey: z.string(),\n publicKey: z.string(),\n});\n","import type * as z from 'zod/mini';\n\nimport { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createStorageKeySchema } from '../../../../services/storage';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { p256Keygen } from '../../../../utils/p256Keygen';\nimport { deviceSigningKeysSchema } from '../deviceSigningKeys.schema';\n\n/**\n * On web we want to auto create the device signing keys for each user.\n * And the user device signing keys should never be deleted.\n */\nexport const getOrCreateEnvironmentDeviceSigningKeys = async (\n client: DynamicClient\n): Promise<z.infer<typeof deviceSigningKeysSchema>> => {\n const { storage, environmentId } = getCore(client);\n\n assertDefined(environmentId, 'Environment ID is required');\n\n const environmentDeviceSigningKeysStorageKeySchema = createStorageKeySchema({\n key: `user_device_signing_keys_${environmentId}`,\n schema: deviceSigningKeysSchema,\n });\n\n const deviceSigningKeys = await storage.getItem(\n environmentDeviceSigningKeysStorageKeySchema\n );\n\n if (deviceSigningKeys) {\n return deviceSigningKeys;\n }\n\n const {\n public: publicKey,\n private: privateKey,\n privateJwk,\n } = await p256Keygen();\n\n await storage.setItem(environmentDeviceSigningKeysStorageKeySchema, {\n privateJwk,\n privateKey,\n publicKey,\n });\n\n return {\n privateJwk,\n privateKey,\n publicKey,\n };\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport type { DeviceSigner } from '../../../services/deviceSigner';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getOrCreateEnvironmentDeviceSigningKeys } from './getOrCreateEnvironmentDeviceSigningKeys';\n\nexport const getDeviceSigner = async (\n client: DynamicClient\n): Promise<DeviceSigner> => {\n const { deviceSigner } = getCore(client);\n\n /**\n * If the device signer is available, it should handle the device signing\n * This is used for mobile devices with secure enclave.\n */\n if (deviceSigner) {\n return deviceSigner;\n }\n\n /**\n * For web devices we want to auto create one PK per user id.\n */\n const environmentDeviceSigningKeys =\n await getOrCreateEnvironmentDeviceSigningKeys(client);\n\n return {\n getPublicKey: async () => environmentDeviceSigningKeys.publicKey,\n sign: (payload: string) =>\n p256Sign({\n message: payload,\n privateKeyJwk: environmentDeviceSigningKeys.privateJwk,\n }),\n };\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getNonce } from '../../../utils/getNonce';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { getDeviceSigner } from '../getDeviceSigner';\n\nexport const getHeadersForNonceSignedByDeviceSigners = async (\n client: DynamicClient\n): Promise<Record<string, string>> => {\n const { projectSettings } = client;\n\n assertDefined(projectSettings, 'Project settings not found');\n\n /**\n * For cookie based environments, the device registration is handled\n * by settings the cookie in the browser.\n * Then we dont need to provide the headers\n */\n if (isCookieEnabled(client)) {\n return {};\n }\n\n const deviceSigner = await getDeviceSigner(client);\n\n const nonce = await getNonce(client);\n\n const signedNonce = await deviceSigner.sign(nonce);\n const publicKey = await deviceSigner.getPublicKey();\n\n return {\n 'x-dynamic-device-nonce': nonce,\n 'x-dynamic-device-publickey': publicKey,\n 'x-dynamic-device-signed-nonce': signedNonce,\n };\n};\n","import type { Middleware } from '@dynamic-labs/sdk-api-core';\nimport { isDeviceNonceSignatureRequiredForUrl } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { getHeadersForNonceSignedByDeviceSigners } from '../../../deviceRegistration/getHeadersForNonceSignedByDeviceSigners';\nimport { isCookieEnabled } from '../../../projectSettings/isCookieEnabled';\n\nexport const createDeviceSignatureHeadersMiddleware = (\n client: DynamicClient\n): Middleware => {\n return {\n pre: async (context) => {\n /**\n * The signed nonce is not required for cookie based environments.\n */\n if (\n isDeviceNonceSignatureRequiredForUrl(context.url) &&\n !isCookieEnabled(client)\n ) {\n const deviceSignerHeaders = await getHeadersForNonceSignedByDeviceSigners(\n client\n );\n\n return {\n init: {\n ...context.init,\n headers: {\n ...context.init.headers,\n ...deviceSignerHeaders,\n },\n },\n url: context.url,\n };\n }\n\n return;\n },\n };\n};\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class UnauthorizedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'unauthorized_error',\n docsUrl: null,\n name: 'UnauthorizedError',\n shortMessage: 'Unauthorized',\n });\n }\n}\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { UnauthorizedError } from '../../../../errors/UnauthorizedError';\n\nexport const createUnauthorizedMiddleware = (): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status === 401) {\n let cause: Error | null = null;\n\n try {\n const errorBody = await context.response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n // eslint-disable-next-line no-restricted-syntax\n cause = new Error(errorBody.error);\n }\n } catch {\n // Response body isn't valid JSON — proceed without a cause\n }\n\n throw new UnauthorizedError({ cause });\n }\n\n return context.response;\n },\n});\n","import { Configuration, SDKApi } from '@dynamic-labs/sdk-api-core';\n\nimport { version } from '../../../package.json';\nimport { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { randomString } from '../../utils/randomString';\nimport { isCookieEnabled } from '../projectSettings/isCookieEnabled';\nimport { getSessionKeys } from '../sessionKeys/getSessionKeys';\nimport type { CreateApiClientOptions } from './apiClient.types';\nimport {\n CLIENT_SDK_NAME,\n DYNAMIC_API_VERSION_HEADER,\n DYNAMIC_REQUEST_ID_HEADER,\n DYNAMIC_SDK_API_VERSION,\n DYNAMIC_SDK_VERSION_HEADER,\n MFA_TOKEN_HEADER,\n SESSION_PUBLIC_KEY_HEADER,\n} from './constants';\nimport { clientErrorMapper } from './utils/clientErrorMapper';\nimport { createConvertToApiErrorMiddleware } from './utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware';\nimport { createDeviceSignatureHeadersMiddleware } from './utils/deviceSignatureHeadersMiddleware';\nimport { createUnauthorizedMiddleware } from './utils/unauthorizedMiddleware/createUnauthorizedMiddleware';\n\ntype ISettings = {\n basePath: string;\n credentials?: 'include';\n headers: {\n Authorization?: string;\n 'Content-Type': string;\n [DYNAMIC_API_VERSION_HEADER]: string;\n [DYNAMIC_REQUEST_ID_HEADER]: string;\n [DYNAMIC_SDK_VERSION_HEADER]: string;\n [MFA_TOKEN_HEADER]?: string;\n [SESSION_PUBLIC_KEY_HEADER]?: string;\n };\n};\n\n/**\n * Returns a new instance of the SDK API client.\n *\n * This is not meant for storing, as it is very light we can create it whenever needed.\n */\nexport const createApiClient = (\n options: CreateApiClientOptions = {},\n client: DynamicClient\n) => {\n const core = getCore(client);\n const coreState = core.state.get();\n\n const settings: ISettings = {\n basePath: core.apiBaseUrl,\n headers: {\n 'Content-Type': 'application/json',\n [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,\n [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),\n [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,\n ...core.getApiHeaders(),\n ...options.headers,\n },\n };\n\n if (client.token) {\n settings.headers.Authorization = `Bearer ${client.token}`;\n }\n\n if (client.projectSettings && isCookieEnabled(client)) {\n settings.credentials = 'include';\n }\n\n if (options.includeMfaToken && coreState.mfaToken) {\n settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;\n }\n\n const sessionPublicKey = getSessionKeys(client)?.publicKey;\n\n // This check is required to avoid overriding the session public key header\n // that is set by any of our other SDKs using the Dynamic Client SDK.\n const isSessionPublicKeyHeaderPresent =\n settings.headers[SESSION_PUBLIC_KEY_HEADER] !== undefined;\n\n if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) {\n settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;\n }\n\n return new SDKApi(\n new Configuration({\n ...settings,\n fetchApi: core.fetch,\n middleware: [\n createDeviceSignatureHeadersMiddleware(client),\n createConvertToApiErrorMiddleware({\n errorMappers: [...(options.errorMappers || []), clientErrorMapper],\n }),\n createUnauthorizedMiddleware(),\n ],\n })\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { createApiClient } from '../../../modules/apiClient';\nimport { NONCE_POOL_EXPIRATION_TIME, NONCE_POOL_SIZE } from '../constants';\n\n/**\n * Fetches a batch of nonces from the API.\n *\n * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom\n * redirect). On iOS, a network request (like fetching a nonce) between a user\n * action and a deeplink call will break the gesture chain, causing iOS to\n * silently ignore the deeplink. By prefetching nonces ahead of time,\n * `getNonce` can return synchronously from cache and the deeplink fires\n * without an interrupting network round-trip.\n */\nexport const fetchAndStoreNonces = async (\n client: DynamicClient\n): Promise<void> => {\n const core = getCore(client);\n\n const { environmentId } = core;\n\n const apiClient = createApiClient({}, client);\n\n const { nonces } = await apiClient.getNonces({\n count: NONCE_POOL_SIZE,\n environmentId,\n });\n\n core.state.set({\n prefetchedNonces: nonces,\n prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME,\n });\n};\n","import type { Chain } from '../chain';\n\ntype ChainInfo = {\n apiChainName: string;\n blockchainName: string;\n verifiedCredentialChainName: string;\n waasChainNameOverride?: string;\n};\n\nexport const CHAINS_INFO_MAP: Record<Chain, ChainInfo> = {\n ALEO: {\n apiChainName: 'aleo',\n blockchainName: 'Aleo',\n verifiedCredentialChainName: 'aleo',\n },\n ALGO: {\n apiChainName: 'algo',\n blockchainName: 'Algorand',\n verifiedCredentialChainName: 'algorand',\n },\n APTOS: {\n apiChainName: 'aptos',\n blockchainName: 'Aptos',\n verifiedCredentialChainName: 'aptos',\n },\n BTC: {\n apiChainName: 'bitcoin',\n blockchainName: 'Bitcoin',\n verifiedCredentialChainName: 'bip122',\n },\n COSMOS: {\n apiChainName: 'cosmos',\n blockchainName: 'Cosmos',\n verifiedCredentialChainName: 'cosmos',\n },\n ECLIPSE: {\n apiChainName: 'eclipse',\n blockchainName: 'Eclipse',\n verifiedCredentialChainName: 'eclipse',\n },\n EVM: {\n apiChainName: 'evm',\n // eslint-disable-next-line custom-rules/ban-ethereum-eth-terms\n blockchainName: 'Ethereum',\n verifiedCredentialChainName: 'eip155',\n },\n FLOW: {\n apiChainName: 'flow',\n blockchainName: 'Flow',\n verifiedCredentialChainName: 'flow',\n },\n SOL: {\n apiChainName: 'solana',\n blockchainName: 'Solana',\n verifiedCredentialChainName: 'solana',\n waasChainNameOverride: 'SVM',\n },\n SPARK: {\n apiChainName: 'spark',\n blockchainName: 'Spark',\n verifiedCredentialChainName: 'spark',\n },\n STARK: {\n apiChainName: 'starknet',\n blockchainName: 'Starknet',\n verifiedCredentialChainName: 'starknet',\n },\n STELLAR: {\n apiChainName: 'stellar',\n blockchainName: 'Stellar',\n verifiedCredentialChainName: 'stellar',\n },\n SUI: {\n apiChainName: 'sui',\n blockchainName: 'Sui',\n verifiedCredentialChainName: 'sui',\n },\n TON: {\n apiChainName: 'ton',\n blockchainName: 'TON',\n verifiedCredentialChainName: 'ton',\n },\n TRON: {\n apiChainName: 'tron',\n blockchainName: 'Tron',\n verifiedCredentialChainName: 'tron',\n },\n};\n","import type { Chain } from '../../modules/chain';\nimport { CHAINS_INFO_MAP } from '../../modules/wallets/constants';\nimport { assertDefined } from '../assertDefined';\n\nexport const getChainFromVerifiedCredentialChain = (\n verifiedCredentialChain: string\n): Chain => {\n const chains = Object.keys(CHAINS_INFO_MAP) as Chain[];\n\n const chain = chains.find(\n (chain) =>\n CHAINS_INFO_MAP[chain].verifiedCredentialChainName ===\n verifiedCredentialChain\n );\n\n assertDefined(chain, `Unknown chain: ${verifiedCredentialChain}`);\n\n return chain;\n};\n","import { dependencies } from '../package.json';\n\nexport const SDK_API_CORE_VERSION = dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const DYNAMIC_ICONIC_SPRITE_URL =\n 'https://iconic.dynamic-static-assets.com/icons/sprite.svg';\n","import { DYNAMIC_ICONIC_SPRITE_URL } from '../../constants';\n\nexport const DEFAULT_WAAS_BASE_API_URL = 'https://app.dynamicauth.com';\nexport const DEFAULT_WAAS_BASE_MPC_RELAY_API_URL =\n 'https://relay.dynamicauth.com';\n\nexport const DYNAMIC_WAAS_METADATA = {\n displayName: 'Dynamic WaaS',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#dynamicwaas`,\n normalizedWalletName: 'dynamicwaas',\n};\n","import { BaseError } from './base';\n\nexport class InvalidParamError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'invalid_param_error',\n docsUrl: null,\n name: 'InvalidParamError',\n shortMessage: message,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;ACGA,MAAa,WAAW,WAAuC;AAE7D,QAAO,OAAO;;;;;ACchB,MAAM,cAAc,EAAE,SAAS,YAAiC;AAC9D,KAAI,iBAAiB,UACnB,QAAO,MAAM;AAGf,KAAI,OAAO,QACT,QAAO,MAAM;AAGf,QAAO;;;;;AAMT,MAAM,iBAAiB,EACrB,cACA,SACA,SACA,mBACyB;AACzB,QAAO;EACL;EACA;EACA;EACA,GAAI,eAAe,CAAC,GAAG,cAAc,GAAG,GAAG,EAAE;EAC7C,GAAI,UAAU,CAAC,SAAS,UAAU,GAAG,EAAE;EACvC,GAAI,UAAU,CAAC,YAAY,UAAU,GAAG,EAAE;EAC1C,YAAY;EACZ,+BAAc,IAAI,MAAM,EAAC,aAAa;EACvC,CAAC,KAAK,KAAK;;;;;AAMd,IAAsB,YAAtB,MAAsB,kBAAkB,MAAM;;CAE5C;CACA;CACA,AAAiB;CACjB,AAAS,OAAO;CAChB,AAAS;CAET,YAAY,MAA2B;EACrC,MAAM,UAAU,WAAW,KAAK;EAChC,MAAM,mBAAmB,cAAc;GAAE,GAAG;GAAM;GAAS,CAAC;AAC5D,QACE,KAAK,gBAAgB,kBACrB,KAAK,QAAQ,EAAE,OAAO,KAAK,OAAO,GAAG,OACtC;AAED,OAAK,mBAAmB;AACxB,OAAK,UAAU;AACf,OAAK,OAAO,KAAK,QAAQ,KAAK;AAC9B,OAAK,QAAQ,KAAK,SAAS,KAAK;AAChC,OAAK,OAAO,KAAK;;;;;CAMnB,OAA0B;EACxB,MAAM,QAAQ,KAAK;AAEnB,MAAI,iBAAiB,UACnB,QAAO,MAAM,MAAM;AAGrB,SAAO;;CAGT,AAAS,WAAW;AAClB,SAAO,KAAK;;;;;;AC1FhB,IAAa,sB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Error-BVx-qvip.esm.js","names":["defaultClient: DynamicClient | null","BufferPolyfill","clientErrorMapper: ErrorMapper","errorToThrow: Error","cause: Error | null","settings: ISettings","CHAINS_INFO_MAP: Record<Chain, ChainInfo>","chain"],"sources":["../package.json","../src/client/core/getCore/getCore.ts","../src/errors/base/BaseError.ts","../src/errors/ClientNotFoundError.ts","../src/client/defaultClient/defaultClient.ts","../src/utils/getNonce/constants.ts","../src/modules/apiClient/constants.ts","../src/utils/randomString/randomString.ts","../src/errors/ValueMustBeDefinedError.ts","../src/utils/assertDefined/assertDefined.ts","../src/modules/projectSettings/isCookieEnabled/isCookieEnabled.ts","../src/utils/getBuffer/getBuffer.ts","../src/modules/sessionKeys/getSessionKeys/getSessionKeys.ts","../src/errors/APIError/APIError.ts","../src/errors/InvalidExternalAuthError.ts","../src/errors/LinkCredentialError.ts","../src/errors/MfaInvalidOtpError.ts","../src/errors/MfaRateLimitedError.ts","../src/errors/SandboxMaximumThresholdReachedError.ts","../src/modules/apiClient/utils/clientErrorMapper/clientErrorMapper.ts","../src/modules/apiClient/utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware.ts","../src/utils/getNonce/getNonce.ts","../src/utils/bufferToHex/bufferToHex.ts","../src/utils/p256Sign/p256Sign.ts","../src/services/storage/createStorageKeySchema/createStorageKeySchema.ts","../src/utils/base64UrlDecode/base64UrlDecode.ts","../src/utils/compressRawPublicKey/compressRawPublicKey.ts","../src/utils/p256Keygen/p256Keygen.ts","../src/modules/deviceRegistration/getDeviceSigner/deviceSigningKeys.schema.ts","../src/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.ts","../src/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.ts","../src/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.ts","../src/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.ts","../src/errors/UnauthorizedError.ts","../src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts","../src/modules/apiClient/createApiClient.ts","../src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts","../src/modules/wallets/constants.ts","../src/utils/getChainFromVerifiedCredentialChain/getChainFromVerifiedCredentialChain.ts","../src/constants.ts","../src/modules/waas/constants.ts","../src/errors/InvalidParamError.ts"],"sourcesContent":["","import type { DynamicClient } from '../../types';\nimport type { DynamicCore } from '../types';\n\nexport const getCore = (client: DynamicClient): DynamicCore => {\n // @ts-expect-error - this was hidden from the public API\n return client.__core;\n};\n","import { version } from '../../../package.json';\n\nexport type BaseErrorParameters = {\n /** The underlying error that caused this error, if any */\n cause: Error | null;\n /** The error unique code */\n code: string;\n /** Additional detailed information about the error */\n details?: string;\n /** URL to relevant documentation for this error */\n docsUrl: string | null;\n /** Array of additional contextual messages to be displayed */\n metaMessages?: string[];\n /** Custom name for the error. Defaults to 'BaseError' if not provided */\n name: string;\n /** A brief, human-readable description of the error */\n shortMessage: string;\n};\n\nconst getDetails = ({ details, cause }: BaseErrorParameters) => {\n if (cause instanceof BaseError) {\n return cause.details;\n }\n\n if (cause?.message) {\n return cause.message;\n }\n\n return details;\n};\n\n/**\n * Formats the error message with all available information\n */\nconst formatMessage = ({\n shortMessage,\n details,\n docsUrl,\n metaMessages,\n}: BaseErrorParameters) => {\n return [\n '[Dynamic JS SDK]',\n shortMessage,\n '',\n ...(metaMessages ? [...metaMessages, ''] : []),\n ...(docsUrl ? [`Docs: ${docsUrl}`] : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: ${version}`,\n `Timestamp: ${new Date().toISOString()}`,\n ].join('\\n');\n};\n\n/**\n * Base error class that provides structured error handling with detailed information\n */\nexport abstract class BaseError extends Error {\n /** The error unique code */\n code: string;\n details: string | undefined;\n private readonly formattedMessage: string | undefined;\n override name = 'BaseError';\n override cause: BaseError | Error | undefined;\n\n constructor(args: BaseErrorParameters) {\n const details = getDetails(args);\n const formattedMessage = formatMessage({ ...args, details });\n super(\n args.shortMessage ?? formattedMessage,\n args.cause ? { cause: args.cause } : undefined\n );\n\n this.formattedMessage = formattedMessage;\n this.details = details;\n this.name = args.name ?? this.name;\n this.cause = args.cause ?? this.cause;\n this.code = args.code;\n }\n\n /**\n * Walks the cause chain of the error and returns the root error\n */\n walk(): Error | undefined {\n const cause = this.cause;\n\n if (cause instanceof BaseError) {\n return cause.walk();\n }\n\n return cause;\n }\n\n override toString() {\n return this.formattedMessage;\n }\n}\n","import { BaseError } from './base';\n\nexport class ClientNotFoundError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'client_not_found_error',\n docsUrl: null,\n name: 'ClientNotFoundError',\n shortMessage:\n 'No Dynamic client has been created yet. Make sure you have called createDynamicClient() first.',\n });\n }\n}\n","import { ClientNotFoundError } from '../../errors/ClientNotFoundError';\nimport { getCore } from '../core/getCore';\nimport type { DynamicClient } from '../types';\n\nlet defaultClient: DynamicClient | null = null;\nlet numOfInitializedClients = 0;\n\n/**\n * Returns the DynamicClient instance that was initialized with createDynamicClient.\n *\n * If more than one instance of DynamicClient was initialized, you should not use this function.\n * Instead, you should pass the client instance you stored to the function that needs it.\n */\nexport const getDefaultClient = (): DynamicClient => {\n if (!defaultClient) {\n throw new ClientNotFoundError();\n }\n\n if (numOfInitializedClients > 1) {\n const core = getCore(defaultClient);\n core.logger.debug(\n 'Multiple instances of DynamicClient found. If you are only using one client (recommended), make sure you are not calling ' +\n '\"createDynamicClient\" multiple times. If you are using multiple clients, make sure you are passing which client to use as ' +\n 'the last param of all Dynamic functions.'\n );\n }\n\n return defaultClient;\n};\n\nexport const setDefaultClient = (client: DynamicClient) => {\n defaultClient = client;\n numOfInitializedClients++;\n};\n","export const NONCE_POOL_EXPIRATION_TIME = 60000 * 60 * 24;\n\nexport const NONCE_POOL_SIZE = 5;\n","import { dependencies } from '../../../package.json';\n\nexport const DYNAMIC_API_VERSION_HEADER = 'x-dyn-api-version';\n\nexport const DYNAMIC_REQUEST_ID_HEADER = 'x-dyn-request-id';\n\nexport const DYNAMIC_SDK_VERSION_HEADER = 'x-dyn-version';\n\nexport const MFA_TOKEN_HEADER = 'x-mfa-auth-token';\n\nexport const SESSION_PUBLIC_KEY_HEADER = 'x-dyn-session-public-key';\n\nexport const DYNAMIC_SDK_API_VERSION =\n dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const CLIENT_SDK_NAME = 'ClientSDK';\n","const DEFAULT_CHARS =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\ntype RandomStringParams = {\n chars?: string;\n length: number;\n};\n\nexport const randomString = ({ chars = DEFAULT_CHARS, length }: RandomStringParams) => {\n const bytes = new Uint8Array(length);\n crypto.getRandomValues(bytes);\n\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n return result;\n};\n","import { BaseError } from './base';\n\nexport class ValueMustBeDefinedError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'value_must_be_defined_error',\n docsUrl: null,\n name: 'ValueMustBeDefined',\n shortMessage: message,\n });\n }\n}\n","/* eslint-disable func-style -- javascript requires this to be a function */\n\nimport { ValueMustBeDefinedError } from './../../errors/ValueMustBeDefinedError';\n\n/**\n * Asserts that a value is not null or undefined, throwing an error if it is.\n * This function acts as a type guard, narrowing the type to exclude null and undefined.\n *\n * @template T - The type of the value being checked\n * @param value - The value to check for null or undefined\n * @param message - The error message to throw if the value is null or undefined\n * @throws Throws an error with the provided message if value is null or undefined\n * @example\n * ```typescript\n * const maybeString: string | null = getValue();\n * assertDefined(maybeString, 'String value is required');\n * // maybeString is now typed as string (null is excluded)\n * ```\n */\nexport function assertDefined<T>(\n value: T,\n message: string\n): asserts value is Exclude<NonNullable<T>, void> {\n if (value === null || value === undefined) {\n throw new ValueMustBeDefinedError(message);\n }\n}\n","import { AuthStorageEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Returns true if the client is using Dynamic cookies or a BYO JWT cookie.\n */\nexport const isCookieEnabled = (client: DynamicClient): boolean => {\n assertDefined(client.projectSettings, 'Project settings are not defined');\n\n const securitySettings = client.projectSettings.security;\n\n if (!securitySettings) return false;\n\n // client uses Dynamic cookies\n const dynamicCookiesEnabled = (securitySettings.auth?.storage || []).includes(\n AuthStorageEnum.Cookie\n );\n\n // BYO JWT client puts their non-Dynamic JWT in a cookie\n const byoJwtCookieEnabled = Boolean(\n securitySettings.externalAuth?.cookieName\n );\n\n // should return true for both of these scenarios\n // because we also need to do `credentials: true` in api.ts when\n // a byo jwt client sets their named cookie for their jwt and\n // needs to send it to our backend\n return dynamicCookiesEnabled || byoJwtCookieEnabled;\n};\n","/* eslint-disable no-restricted-globals */\nimport { Buffer as BufferPolyfill } from 'buffer';\n\nexport const getBuffer = () =>\n typeof Buffer !== 'undefined' ? Buffer : BufferPolyfill;\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { getBuffer } from '../../../utils/getBuffer';\nimport type { SessionKeys } from '../sessionKeys.types';\n\nexport const getSessionKeys = (client: DynamicClient) => {\n const core = getCore(client);\n\n const encodedKeys = core.state.get().sessionKeys;\n\n if (!encodedKeys) {\n return undefined;\n }\n\n try {\n const decodedKeys: SessionKeys = JSON.parse(\n getBuffer().from(encodedKeys, 'base64').toString()\n );\n\n return decodedKeys;\n } catch (error) {\n core.logger.error('Error decoding session keys', error);\n return undefined;\n }\n};\n","import { BaseError } from '../base';\n\nexport class APIError extends BaseError {\n status: number;\n\n constructor(message: string, code: string, status: number) {\n super({\n cause: null,\n code,\n docsUrl: null,\n name: 'APIError',\n shortMessage: message,\n });\n\n this.status = status;\n }\n\n static async fromResponse(response: Response) {\n try {\n const errorBody = await response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n const errorCode =\n 'code' in errorBody && typeof errorBody.code === 'string'\n ? errorBody.code\n : 'unknown_error';\n\n return new APIError(errorBody.error, errorCode, response.status);\n }\n\n return null;\n } catch {\n return null;\n }\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class InvalidExternalAuthError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'invalid_external_auth_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/external-auth/third-party-auth-overview',\n name: 'InvalidExternalAuthError',\n shortMessage: 'Error authenticating with external JWT',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class LinkCredentialError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'link_credential_error',\n docsUrl: null,\n name: 'LinkCredentialError',\n shortMessage:\n 'The credential you are trying to link is associated with another account and cannot be reassigned.',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaInvalidOtpError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_invalid_otp_error',\n docsUrl: null,\n name: 'MfaInvalidOtpError',\n shortMessage: 'Invalid OTP',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaRateLimitedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_rate_limited_error',\n docsUrl: null,\n name: 'MfaRateLimitedError',\n shortMessage: 'Rate limited',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class SandboxMaximumThresholdReachedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'sandbox_maximum_threshold_reached_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/developer-dashboard/sandbox-vs-live#sandbox-vs-live',\n name: 'SandboxMaximumThresholdReachedError',\n shortMessage:\n 'Your sandbox environment has reached the maximum MAU. Please use a live environment for production traffic.',\n });\n }\n}\n","import { APIError } from '../../../../errors/APIError';\nimport { InvalidExternalAuthError } from '../../../../errors/InvalidExternalAuthError';\nimport { LinkCredentialError } from '../../../../errors/LinkCredentialError';\nimport { MfaInvalidOtpError } from '../../../../errors/MfaInvalidOtpError';\nimport { MfaRateLimitedError } from '../../../../errors/MfaRateLimitedError';\nimport { SandboxMaximumThresholdReachedError } from '../../../../errors/SandboxMaximumThresholdReachedError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\n/**\n * Default error mapper for the client that handles common API error codes.\n *\n * This mapper transforms specific API error codes into more specific error types:\n * - `mfa_invalid_code` → `MfaInvalidOtpError`\n * - `mfa_rate_limited` → `MfaRateLimitedError`\n *\n * @param error - The error to be mapped\n * @returns A transformed error if the error code matches a known pattern, or null if no transformation is needed\n *\n * @example\n * ```typescript\n * // This will be automatically applied to all API errors\n * const apiClient = createApiClient({}, client);\n *\n * // The clientErrorMapper will automatically convert mfa_invalid_code errors\n * // to MfaInvalidOtpError instances\n * ```\n */\nexport const clientErrorMapper: ErrorMapper = (error) => {\n if (error instanceof APIError) {\n if (error.code === 'mfa_invalid_code') {\n return new MfaInvalidOtpError({ cause: error });\n }\n\n if (error.code === 'mfa_rate_limited') {\n return new MfaRateLimitedError({ cause: error });\n }\n\n if (error.code === 'invalid_external_auth') {\n return new InvalidExternalAuthError({ cause: error });\n }\n\n if (error.code === 'sandbox_maximum_threshold_reached') {\n return new SandboxMaximumThresholdReachedError({ cause: error });\n }\n\n if (\n error.code === 'merge_accounts_invalid' ||\n error.code === 'reassign_wallet_error'\n ) {\n return new LinkCredentialError({ cause: error });\n }\n }\n\n return null;\n};\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { APIError } from '../../../../errors/APIError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\ntype CreateConvertToApiErrorMiddlewareOptions = {\n errorMappers?: ErrorMapper[];\n};\n\n/**\n * Creates middleware that converts HTTP error responses to APIError instances\n * and optionally applies custom error mappers to transform them into specific error types.\n *\n * @param options.errorMappers - Array of error mappers to apply to API errors\n * @returns A middleware function that handles error conversion and mapping\n */\nexport const createConvertToApiErrorMiddleware = ({\n errorMappers = [],\n}: CreateConvertToApiErrorMiddlewareOptions): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status >= 400) {\n const apiError = await APIError.fromResponse(context.response);\n\n if (apiError) {\n let errorToThrow: Error = apiError;\n\n for (const mapper of errorMappers) {\n const newError = mapper(apiError);\n\n if (newError) {\n errorToThrow = newError;\n break;\n }\n }\n\n throw errorToThrow;\n }\n }\n\n return context.response;\n },\n});\n","import { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { fetchAndStoreNonces } from './fetchAndStoreNonces/fetchAndStoreNonces';\n\n/**\n * Returns a nonce for wallet ownership verification.\n *\n * Pops the first nonce from the prefetched pool. When the pool is running low\n * (≤1 remaining after pop) a background refetch is triggered. If the pool is\n * empty, nonces are fetched on-demand before returning.\n */\nexport const getNonce = async (\n client: DynamicClient\n): Promise<string> => {\n const core = getCore(client);\n const pool = core.state.get().prefetchedNonces;\n\n if (pool.length > 0) {\n const [nonce, ...remaining] = pool;\n\n core.state.set({ prefetchedNonces: remaining });\n\n if (remaining.length <= 1) {\n void fetchAndStoreNonces(client);\n }\n\n return nonce;\n }\n\n await fetchAndStoreNonces(client);\n\n return getNonce(client);\n};\n","/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { bufferToHex } from '../bufferToHex';\n\ntype P256SignParams = {\n message: string;\n privateKeyJwk: JsonWebKey;\n};\n\nexport const p256Sign = async ({ privateKeyJwk, message }: P256SignParams) => {\n const privateKey = await crypto.subtle.importKey(\n 'jwk',\n privateKeyJwk,\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n false,\n ['sign']\n );\n\n const signature = await crypto.subtle.sign(\n {\n hash: 'SHA-256',\n name: 'ECDSA',\n },\n privateKey,\n new TextEncoder().encode(message)\n );\n\n return bufferToHex(signature);\n};\n","import type * as z from 'zod/mini';\n\nimport type { StorageKeySchema } from '../storage.types';\n\nexport const createStorageKeySchema = <T>(params: {\n key: string;\n schema: z.ZodMiniType<T>;\n}): StorageKeySchema<T> => {\n return params;\n};\n","/**\n * Takes a base64url-encoded string (e.g. \"nMueRPiAm51YXEjRtka8S_8Ura3HaqbmqDqMJCZmvkM\")\n * and return the corresponding bytes, as an array buffer.\n */\nexport const base64UrlDecode = (s?: string) => {\n // Go from base64url encoding to base64 encoding\n s = s?.replace(/-/g, '+').replace(/_/g, '/') || '';\n // use `atob` to decode base64\n return Uint8Array.from(atob(s), (c) => c.charCodeAt(0));\n};\n","/**\n * Accepts a public key array buffer, and returns a buffer with the compressed version of the public key\n */\nexport const compressRawPublicKey = (rawPublicKey: ArrayBuffer) => {\n const rawPublicKeyBytes = new Uint8Array(rawPublicKey);\n const len = rawPublicKeyBytes.byteLength;\n\n // Drop the y coordinate\n const compressedBytes = rawPublicKeyBytes.slice(0, (1 + len) >>> 1);\n\n // Encode the parity of `y` in first bit\n compressedBytes[0] = 0x2 | (rawPublicKeyBytes[len - 1] & 0x01);\n return compressedBytes.buffer;\n};\n","import { base64UrlDecode } from '../base64UrlDecode';\nimport { bufferToHex } from '../bufferToHex';\nimport { compressRawPublicKey } from '../compressRawPublicKey';\n\nexport const p256Keygen = async () => {\n // Create a new P-256 keypair\n const p256Keypair = await crypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n true,\n ['sign', 'verify']\n );\n\n // Export the raw public key. By default this will export in uncompressed format\n const rawPublicKey = await crypto.subtle.exportKey(\n 'raw',\n p256Keypair.publicKey\n );\n\n // We need to export with JWK format because exporting EC private keys with \"raw\" isn't supported\n const privateKeyJwk = await crypto.subtle.exportKey(\n 'jwk',\n p256Keypair.privateKey\n );\n\n const compressedPublicKeyBuffer = compressRawPublicKey(rawPublicKey);\n\n const privateKeyBuffer = base64UrlDecode(privateKeyJwk.d);\n\n return {\n private: bufferToHex(privateKeyBuffer),\n privateJwk: privateKeyJwk,\n public: bufferToHex(compressedPublicKeyBuffer),\n };\n};\n","import * as z from 'zod/mini';\n\nexport const deviceSigningKeysSchema = z.object({\n privateJwk: z.custom<JsonWebKey>(),\n privateKey: z.string(),\n publicKey: z.string(),\n});\n","import type * as z from 'zod/mini';\n\nimport { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createStorageKeySchema } from '../../../../services/storage';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { p256Keygen } from '../../../../utils/p256Keygen';\nimport { deviceSigningKeysSchema } from '../deviceSigningKeys.schema';\n\n/**\n * On web we want to auto create the device signing keys for each user.\n * And the user device signing keys should never be deleted.\n */\nexport const getOrCreateEnvironmentDeviceSigningKeys = async (\n client: DynamicClient\n): Promise<z.infer<typeof deviceSigningKeysSchema>> => {\n const { storage, environmentId } = getCore(client);\n\n assertDefined(environmentId, 'Environment ID is required');\n\n const environmentDeviceSigningKeysStorageKeySchema = createStorageKeySchema({\n key: `user_device_signing_keys_${environmentId}`,\n schema: deviceSigningKeysSchema,\n });\n\n const deviceSigningKeys = await storage.getItem(\n environmentDeviceSigningKeysStorageKeySchema\n );\n\n if (deviceSigningKeys) {\n return deviceSigningKeys;\n }\n\n const {\n public: publicKey,\n private: privateKey,\n privateJwk,\n } = await p256Keygen();\n\n await storage.setItem(environmentDeviceSigningKeysStorageKeySchema, {\n privateJwk,\n privateKey,\n publicKey,\n });\n\n return {\n privateJwk,\n privateKey,\n publicKey,\n };\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport type { DeviceSigner } from '../../../services/deviceSigner';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getOrCreateEnvironmentDeviceSigningKeys } from './getOrCreateEnvironmentDeviceSigningKeys';\n\nexport const getDeviceSigner = async (\n client: DynamicClient\n): Promise<DeviceSigner> => {\n const { deviceSigner } = getCore(client);\n\n /**\n * If the device signer is available, it should handle the device signing\n * This is used for mobile devices with secure enclave.\n */\n if (deviceSigner) {\n return deviceSigner;\n }\n\n /**\n * For web devices we want to auto create one PK per user id.\n */\n const environmentDeviceSigningKeys =\n await getOrCreateEnvironmentDeviceSigningKeys(client);\n\n return {\n getPublicKey: async () => environmentDeviceSigningKeys.publicKey,\n sign: (payload: string) =>\n p256Sign({\n message: payload,\n privateKeyJwk: environmentDeviceSigningKeys.privateJwk,\n }),\n };\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getNonce } from '../../../utils/getNonce';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { getDeviceSigner } from '../getDeviceSigner';\n\nexport const getHeadersForNonceSignedByDeviceSigners = async (\n client: DynamicClient\n): Promise<Record<string, string>> => {\n const { projectSettings } = client;\n\n assertDefined(projectSettings, 'Project settings not found');\n\n /**\n * For cookie based environments, the device registration is handled\n * by settings the cookie in the browser.\n * Then we dont need to provide the headers\n */\n if (isCookieEnabled(client)) {\n return {};\n }\n\n const deviceSigner = await getDeviceSigner(client);\n\n const nonce = await getNonce(client);\n\n const signedNonce = await deviceSigner.sign(nonce);\n const publicKey = await deviceSigner.getPublicKey();\n\n return {\n 'x-dynamic-device-nonce': nonce,\n 'x-dynamic-device-publickey': publicKey,\n 'x-dynamic-device-signed-nonce': signedNonce,\n };\n};\n","import type { Middleware } from '@dynamic-labs/sdk-api-core';\nimport { isDeviceNonceSignatureRequiredForUrl } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { getHeadersForNonceSignedByDeviceSigners } from '../../../deviceRegistration/getHeadersForNonceSignedByDeviceSigners';\nimport { isCookieEnabled } from '../../../projectSettings/isCookieEnabled';\n\nexport const createDeviceSignatureHeadersMiddleware = (\n client: DynamicClient\n): Middleware => {\n return {\n pre: async (context) => {\n /**\n * The signed nonce is not required for cookie based environments.\n */\n if (\n isDeviceNonceSignatureRequiredForUrl(context.url) &&\n !isCookieEnabled(client)\n ) {\n const deviceSignerHeaders = await getHeadersForNonceSignedByDeviceSigners(\n client\n );\n\n return {\n init: {\n ...context.init,\n headers: {\n ...context.init.headers,\n ...deviceSignerHeaders,\n },\n },\n url: context.url,\n };\n }\n\n return;\n },\n };\n};\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class UnauthorizedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'unauthorized_error',\n docsUrl: null,\n name: 'UnauthorizedError',\n shortMessage: 'Unauthorized',\n });\n }\n}\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { UnauthorizedError } from '../../../../errors/UnauthorizedError';\n\nexport const createUnauthorizedMiddleware = (): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status === 401) {\n let cause: Error | null = null;\n\n try {\n const errorBody = await context.response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n // eslint-disable-next-line no-restricted-syntax\n cause = new Error(errorBody.error);\n }\n } catch {\n // Response body isn't valid JSON — proceed without a cause\n }\n\n throw new UnauthorizedError({ cause });\n }\n\n return context.response;\n },\n});\n","import { Configuration, SDKApi } from '@dynamic-labs/sdk-api-core';\n\nimport { version } from '../../../package.json';\nimport { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { randomString } from '../../utils/randomString';\nimport { isCookieEnabled } from '../projectSettings/isCookieEnabled';\nimport { getSessionKeys } from '../sessionKeys/getSessionKeys';\nimport type { CreateApiClientOptions } from './apiClient.types';\nimport {\n CLIENT_SDK_NAME,\n DYNAMIC_API_VERSION_HEADER,\n DYNAMIC_REQUEST_ID_HEADER,\n DYNAMIC_SDK_API_VERSION,\n DYNAMIC_SDK_VERSION_HEADER,\n MFA_TOKEN_HEADER,\n SESSION_PUBLIC_KEY_HEADER,\n} from './constants';\nimport { clientErrorMapper } from './utils/clientErrorMapper';\nimport { createConvertToApiErrorMiddleware } from './utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware';\nimport { createDeviceSignatureHeadersMiddleware } from './utils/deviceSignatureHeadersMiddleware';\nimport { createUnauthorizedMiddleware } from './utils/unauthorizedMiddleware/createUnauthorizedMiddleware';\n\ntype ISettings = {\n basePath: string;\n credentials?: 'include';\n headers: {\n Authorization?: string;\n 'Content-Type': string;\n [DYNAMIC_API_VERSION_HEADER]: string;\n [DYNAMIC_REQUEST_ID_HEADER]: string;\n [DYNAMIC_SDK_VERSION_HEADER]: string;\n [MFA_TOKEN_HEADER]?: string;\n [SESSION_PUBLIC_KEY_HEADER]?: string;\n };\n};\n\n/**\n * Returns a new instance of the SDK API client.\n *\n * This is not meant for storing, as it is very light we can create it whenever needed.\n */\nexport const createApiClient = (\n options: CreateApiClientOptions = {},\n client: DynamicClient\n) => {\n const core = getCore(client);\n const coreState = core.state.get();\n\n const settings: ISettings = {\n basePath: core.apiBaseUrl,\n headers: {\n 'Content-Type': 'application/json',\n [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,\n [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),\n [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,\n ...core.getApiHeaders(),\n ...options.headers,\n },\n };\n\n if (client.token) {\n settings.headers.Authorization = `Bearer ${client.token}`;\n }\n\n if (client.projectSettings && isCookieEnabled(client)) {\n settings.credentials = 'include';\n }\n\n if (options.includeMfaToken && coreState.mfaToken) {\n settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;\n }\n\n const sessionPublicKey = getSessionKeys(client)?.publicKey;\n\n // This check is required to avoid overriding the session public key header\n // that is set by any of our other SDKs using the Dynamic Client SDK.\n const isSessionPublicKeyHeaderPresent =\n settings.headers[SESSION_PUBLIC_KEY_HEADER] !== undefined;\n\n if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) {\n settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;\n }\n\n return new SDKApi(\n new Configuration({\n ...settings,\n fetchApi: core.fetch,\n middleware: [\n createDeviceSignatureHeadersMiddleware(client),\n createConvertToApiErrorMiddleware({\n errorMappers: [...(options.errorMappers || []), clientErrorMapper],\n }),\n createUnauthorizedMiddleware(),\n ],\n })\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { createApiClient } from '../../../modules/apiClient';\nimport { NONCE_POOL_EXPIRATION_TIME, NONCE_POOL_SIZE } from '../constants';\n\n/**\n * Fetches a batch of nonces from the API.\n *\n * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom\n * redirect). On iOS, a network request (like fetching a nonce) between a user\n * action and a deeplink call will break the gesture chain, causing iOS to\n * silently ignore the deeplink. By prefetching nonces ahead of time,\n * `getNonce` can return synchronously from cache and the deeplink fires\n * without an interrupting network round-trip.\n */\nexport const fetchAndStoreNonces = async (\n client: DynamicClient\n): Promise<void> => {\n const core = getCore(client);\n\n const { environmentId } = core;\n\n const apiClient = createApiClient({}, client);\n\n const { nonces } = await apiClient.getNonces({\n count: NONCE_POOL_SIZE,\n environmentId,\n });\n\n core.state.set({\n prefetchedNonces: nonces,\n prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME,\n });\n};\n","import type { Chain } from '../chain';\n\ntype ChainInfo = {\n apiChainName: string;\n blockchainName: string;\n verifiedCredentialChainName: string;\n waasChainNameOverride?: string;\n};\n\nexport const CHAINS_INFO_MAP: Record<Chain, ChainInfo> = {\n ALEO: {\n apiChainName: 'aleo',\n blockchainName: 'Aleo',\n verifiedCredentialChainName: 'aleo',\n },\n ALGO: {\n apiChainName: 'algo',\n blockchainName: 'Algorand',\n verifiedCredentialChainName: 'algorand',\n },\n APTOS: {\n apiChainName: 'aptos',\n blockchainName: 'Aptos',\n verifiedCredentialChainName: 'aptos',\n },\n BTC: {\n apiChainName: 'bitcoin',\n blockchainName: 'Bitcoin',\n verifiedCredentialChainName: 'bip122',\n },\n COSMOS: {\n apiChainName: 'cosmos',\n blockchainName: 'Cosmos',\n verifiedCredentialChainName: 'cosmos',\n },\n ECLIPSE: {\n apiChainName: 'eclipse',\n blockchainName: 'Eclipse',\n verifiedCredentialChainName: 'eclipse',\n },\n EVM: {\n apiChainName: 'evm',\n // eslint-disable-next-line custom-rules/ban-ethereum-eth-terms\n blockchainName: 'Ethereum',\n verifiedCredentialChainName: 'eip155',\n },\n FLOW: {\n apiChainName: 'flow',\n blockchainName: 'Flow',\n verifiedCredentialChainName: 'flow',\n },\n SOL: {\n apiChainName: 'solana',\n blockchainName: 'Solana',\n verifiedCredentialChainName: 'solana',\n waasChainNameOverride: 'SVM',\n },\n SPARK: {\n apiChainName: 'spark',\n blockchainName: 'Spark',\n verifiedCredentialChainName: 'spark',\n },\n STARK: {\n apiChainName: 'starknet',\n blockchainName: 'Starknet',\n verifiedCredentialChainName: 'starknet',\n },\n STELLAR: {\n apiChainName: 'stellar',\n blockchainName: 'Stellar',\n verifiedCredentialChainName: 'stellar',\n },\n SUI: {\n apiChainName: 'sui',\n blockchainName: 'Sui',\n verifiedCredentialChainName: 'sui',\n },\n TEMPO: {\n apiChainName: 'tempo',\n blockchainName: 'Tempo',\n verifiedCredentialChainName: 'tempo',\n },\n TON: {\n apiChainName: 'ton',\n blockchainName: 'TON',\n verifiedCredentialChainName: 'ton',\n },\n TRON: {\n apiChainName: 'tron',\n blockchainName: 'Tron',\n verifiedCredentialChainName: 'tron',\n },\n};\n","import type { Chain } from '../../modules/chain';\nimport { CHAINS_INFO_MAP } from '../../modules/wallets/constants';\nimport { assertDefined } from '../assertDefined';\n\nexport const getChainFromVerifiedCredentialChain = (\n verifiedCredentialChain: string\n): Chain => {\n const chains = Object.keys(CHAINS_INFO_MAP) as Chain[];\n\n const chain = chains.find(\n (chain) =>\n CHAINS_INFO_MAP[chain].verifiedCredentialChainName ===\n verifiedCredentialChain\n );\n\n assertDefined(chain, `Unknown chain: ${verifiedCredentialChain}`);\n\n return chain;\n};\n","import { dependencies } from '../package.json';\n\nexport const SDK_API_CORE_VERSION = dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const DYNAMIC_ICONIC_SPRITE_URL =\n 'https://iconic.dynamic-static-assets.com/icons/sprite.svg';\n","import { DYNAMIC_ICONIC_SPRITE_URL } from '../../constants';\n\nexport const DEFAULT_WAAS_BASE_API_URL = 'https://app.dynamicauth.com';\nexport const DEFAULT_WAAS_BASE_MPC_RELAY_API_URL =\n 'https://relay.dynamicauth.com';\n\nexport const DYNAMIC_WAAS_METADATA = {\n displayName: 'Dynamic WaaS',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#dynamicwaas`,\n normalizedWalletName: 'dynamicwaas',\n};\n","import { BaseError } from './base';\n\nexport class InvalidParamError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'invalid_param_error',\n docsUrl: null,\n name: 'InvalidParamError',\n shortMessage: message,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;ACGA,MAAa,WAAW,WAAuC;AAE7D,QAAO,OAAO;;;;;ACchB,MAAM,cAAc,EAAE,SAAS,YAAiC;AAC9D,KAAI,iBAAiB,UACnB,QAAO,MAAM;AAGf,KAAI,OAAO,QACT,QAAO,MAAM;AAGf,QAAO;;;;;AAMT,MAAM,iBAAiB,EACrB,cACA,SACA,SACA,mBACyB;AACzB,QAAO;EACL;EACA;EACA;EACA,GAAI,eAAe,CAAC,GAAG,cAAc,GAAG,GAAG,EAAE;EAC7C,GAAI,UAAU,CAAC,SAAS,UAAU,GAAG,EAAE;EACvC,GAAI,UAAU,CAAC,YAAY,UAAU,GAAG,EAAE;EAC1C,YAAY;EACZ,+BAAc,IAAI,MAAM,EAAC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CACD,OAAO;EACL,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,MAAM;EACJ,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACF;;;;ACxFD,MAAa,uCACX,4BACU;CAGV,MAAM,QAFS,OAAO,KAAK,gBAAgB,CAEtB,MAClB,YACC,gBAAgBC,SAAO,gCACvB,wBACH;AAED,eAAc,OAAO,kBAAkB,0BAA0B;AAEjE,QAAO;;;;;ACfT,MAAa,uBAAuB,aAAa;AAEjD,MAAa,4BACX;;;;ACHF,MAAa,4BAA4B;AACzC,MAAa,sCACX;AAEF,MAAa,wBAAwB;CACnC,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;;;;ACRD,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,SAAiB;AAC3B,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC"}
|
|
@@ -32,11 +32,11 @@ zod_mini = __toESM(zod_mini);
|
|
|
32
32
|
|
|
33
33
|
//#region package.json
|
|
34
34
|
var name = "@dynamic-labs-sdk/client";
|
|
35
|
-
var version = "0.16.
|
|
35
|
+
var version = "0.16.3";
|
|
36
36
|
var dependencies = {
|
|
37
37
|
"@dynamic-labs-sdk/assert-package-version": "workspace:*",
|
|
38
38
|
"@dynamic-labs-wallet/browser-wallet-client": "0.0.286",
|
|
39
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
39
|
+
"@dynamic-labs/sdk-api-core": "0.0.900",
|
|
40
40
|
"@simplewebauthn/browser": "13.1.0",
|
|
41
41
|
"ably": "2.17.1",
|
|
42
42
|
"buffer": "6.0.3",
|
|
@@ -744,6 +744,11 @@ const CHAINS_INFO_MAP = {
|
|
|
744
744
|
blockchainName: "Sui",
|
|
745
745
|
verifiedCredentialChainName: "sui"
|
|
746
746
|
},
|
|
747
|
+
TEMPO: {
|
|
748
|
+
apiChainName: "tempo",
|
|
749
|
+
blockchainName: "Tempo",
|
|
750
|
+
verifiedCredentialChainName: "tempo"
|
|
751
|
+
},
|
|
747
752
|
TON: {
|
|
748
753
|
apiChainName: "ton",
|
|
749
754
|
blockchainName: "TON",
|
|
@@ -1040,4 +1045,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
1040
1045
|
return version;
|
|
1041
1046
|
}
|
|
1042
1047
|
});
|
|
1043
|
-
//# sourceMappingURL=InvalidParamError-
|
|
1048
|
+
//# sourceMappingURL=InvalidParamError-DgN3p6L7.cjs.js.map
|
package/dist/{InvalidParamError-DxdJ-Vjr.cjs.js.map → InvalidParamError-DgN3p6L7.cjs.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidParamError-DxdJ-Vjr.cjs.js","names":["defaultClient: DynamicClient | null","AuthStorageEnum","BufferPolyfill","clientErrorMapper: ErrorMapper","errorToThrow: Error","buffer","z","cause: Error | null","settings: ISettings","SDKApi","Configuration","CHAINS_INFO_MAP: Record<Chain, ChainInfo>","chain"],"sources":["../package.json","../src/client/core/getCore/getCore.ts","../src/errors/base/BaseError.ts","../src/errors/ClientNotFoundError.ts","../src/client/defaultClient/defaultClient.ts","../src/utils/getNonce/constants.ts","../src/modules/apiClient/constants.ts","../src/utils/randomString/randomString.ts","../src/errors/ValueMustBeDefinedError.ts","../src/utils/assertDefined/assertDefined.ts","../src/modules/projectSettings/isCookieEnabled/isCookieEnabled.ts","../src/utils/getBuffer/getBuffer.ts","../src/modules/sessionKeys/getSessionKeys/getSessionKeys.ts","../src/errors/APIError/APIError.ts","../src/errors/InvalidExternalAuthError.ts","../src/errors/LinkCredentialError.ts","../src/errors/MfaInvalidOtpError.ts","../src/errors/MfaRateLimitedError.ts","../src/errors/SandboxMaximumThresholdReachedError.ts","../src/modules/apiClient/utils/clientErrorMapper/clientErrorMapper.ts","../src/modules/apiClient/utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware.ts","../src/utils/getNonce/getNonce.ts","../src/utils/bufferToHex/bufferToHex.ts","../src/utils/p256Sign/p256Sign.ts","../src/services/storage/createStorageKeySchema/createStorageKeySchema.ts","../src/utils/base64UrlDecode/base64UrlDecode.ts","../src/utils/compressRawPublicKey/compressRawPublicKey.ts","../src/utils/p256Keygen/p256Keygen.ts","../src/modules/deviceRegistration/getDeviceSigner/deviceSigningKeys.schema.ts","../src/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.ts","../src/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.ts","../src/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.ts","../src/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.ts","../src/errors/UnauthorizedError.ts","../src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts","../src/modules/apiClient/createApiClient.ts","../src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts","../src/modules/wallets/constants.ts","../src/utils/getChainFromVerifiedCredentialChain/getChainFromVerifiedCredentialChain.ts","../src/constants.ts","../src/modules/waas/constants.ts","../src/errors/InvalidParamError.ts"],"sourcesContent":["","import type { DynamicClient } from '../../types';\nimport type { DynamicCore } from '../types';\n\nexport const getCore = (client: DynamicClient): DynamicCore => {\n // @ts-expect-error - this was hidden from the public API\n return client.__core;\n};\n","import { version } from '../../../package.json';\n\nexport type BaseErrorParameters = {\n /** The underlying error that caused this error, if any */\n cause: Error | null;\n /** The error unique code */\n code: string;\n /** Additional detailed information about the error */\n details?: string;\n /** URL to relevant documentation for this error */\n docsUrl: string | null;\n /** Array of additional contextual messages to be displayed */\n metaMessages?: string[];\n /** Custom name for the error. Defaults to 'BaseError' if not provided */\n name: string;\n /** A brief, human-readable description of the error */\n shortMessage: string;\n};\n\nconst getDetails = ({ details, cause }: BaseErrorParameters) => {\n if (cause instanceof BaseError) {\n return cause.details;\n }\n\n if (cause?.message) {\n return cause.message;\n }\n\n return details;\n};\n\n/**\n * Formats the error message with all available information\n */\nconst formatMessage = ({\n shortMessage,\n details,\n docsUrl,\n metaMessages,\n}: BaseErrorParameters) => {\n return [\n '[Dynamic JS SDK]',\n shortMessage,\n '',\n ...(metaMessages ? [...metaMessages, ''] : []),\n ...(docsUrl ? [`Docs: ${docsUrl}`] : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: ${version}`,\n `Timestamp: ${new Date().toISOString()}`,\n ].join('\\n');\n};\n\n/**\n * Base error class that provides structured error handling with detailed information\n */\nexport abstract class BaseError extends Error {\n /** The error unique code */\n code: string;\n details: string | undefined;\n private readonly formattedMessage: string | undefined;\n override name = 'BaseError';\n override cause: BaseError | Error | undefined;\n\n constructor(args: BaseErrorParameters) {\n const details = getDetails(args);\n const formattedMessage = formatMessage({ ...args, details });\n super(\n args.shortMessage ?? formattedMessage,\n args.cause ? { cause: args.cause } : undefined\n );\n\n this.formattedMessage = formattedMessage;\n this.details = details;\n this.name = args.name ?? this.name;\n this.cause = args.cause ?? this.cause;\n this.code = args.code;\n }\n\n /**\n * Walks the cause chain of the error and returns the root error\n */\n walk(): Error | undefined {\n const cause = this.cause;\n\n if (cause instanceof BaseError) {\n return cause.walk();\n }\n\n return cause;\n }\n\n override toString() {\n return this.formattedMessage;\n }\n}\n","import { BaseError } from './base';\n\nexport class ClientNotFoundError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'client_not_found_error',\n docsUrl: null,\n name: 'ClientNotFoundError',\n shortMessage:\n 'No Dynamic client has been created yet. Make sure you have called createDynamicClient() first.',\n });\n }\n}\n","import { ClientNotFoundError } from '../../errors/ClientNotFoundError';\nimport { getCore } from '../core/getCore';\nimport type { DynamicClient } from '../types';\n\nlet defaultClient: DynamicClient | null = null;\nlet numOfInitializedClients = 0;\n\n/**\n * Returns the DynamicClient instance that was initialized with createDynamicClient.\n *\n * If more than one instance of DynamicClient was initialized, you should not use this function.\n * Instead, you should pass the client instance you stored to the function that needs it.\n */\nexport const getDefaultClient = (): DynamicClient => {\n if (!defaultClient) {\n throw new ClientNotFoundError();\n }\n\n if (numOfInitializedClients > 1) {\n const core = getCore(defaultClient);\n core.logger.debug(\n 'Multiple instances of DynamicClient found. If you are only using one client (recommended), make sure you are not calling ' +\n '\"createDynamicClient\" multiple times. If you are using multiple clients, make sure you are passing which client to use as ' +\n 'the last param of all Dynamic functions.'\n );\n }\n\n return defaultClient;\n};\n\nexport const setDefaultClient = (client: DynamicClient) => {\n defaultClient = client;\n numOfInitializedClients++;\n};\n","export const NONCE_POOL_EXPIRATION_TIME = 60000 * 60 * 24;\n\nexport const NONCE_POOL_SIZE = 5;\n","import { dependencies } from '../../../package.json';\n\nexport const DYNAMIC_API_VERSION_HEADER = 'x-dyn-api-version';\n\nexport const DYNAMIC_REQUEST_ID_HEADER = 'x-dyn-request-id';\n\nexport const DYNAMIC_SDK_VERSION_HEADER = 'x-dyn-version';\n\nexport const MFA_TOKEN_HEADER = 'x-mfa-auth-token';\n\nexport const SESSION_PUBLIC_KEY_HEADER = 'x-dyn-session-public-key';\n\nexport const DYNAMIC_SDK_API_VERSION =\n dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const CLIENT_SDK_NAME = 'ClientSDK';\n","const DEFAULT_CHARS =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\ntype RandomStringParams = {\n chars?: string;\n length: number;\n};\n\nexport const randomString = ({ chars = DEFAULT_CHARS, length }: RandomStringParams) => {\n const bytes = new Uint8Array(length);\n crypto.getRandomValues(bytes);\n\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n return result;\n};\n","import { BaseError } from './base';\n\nexport class ValueMustBeDefinedError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'value_must_be_defined_error',\n docsUrl: null,\n name: 'ValueMustBeDefined',\n shortMessage: message,\n });\n }\n}\n","/* eslint-disable func-style -- javascript requires this to be a function */\n\nimport { ValueMustBeDefinedError } from './../../errors/ValueMustBeDefinedError';\n\n/**\n * Asserts that a value is not null or undefined, throwing an error if it is.\n * This function acts as a type guard, narrowing the type to exclude null and undefined.\n *\n * @template T - The type of the value being checked\n * @param value - The value to check for null or undefined\n * @param message - The error message to throw if the value is null or undefined\n * @throws Throws an error with the provided message if value is null or undefined\n * @example\n * ```typescript\n * const maybeString: string | null = getValue();\n * assertDefined(maybeString, 'String value is required');\n * // maybeString is now typed as string (null is excluded)\n * ```\n */\nexport function assertDefined<T>(\n value: T,\n message: string\n): asserts value is Exclude<NonNullable<T>, void> {\n if (value === null || value === undefined) {\n throw new ValueMustBeDefinedError(message);\n }\n}\n","import { AuthStorageEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Returns true if the client is using Dynamic cookies or a BYO JWT cookie.\n */\nexport const isCookieEnabled = (client: DynamicClient): boolean => {\n assertDefined(client.projectSettings, 'Project settings are not defined');\n\n const securitySettings = client.projectSettings.security;\n\n if (!securitySettings) return false;\n\n // client uses Dynamic cookies\n const dynamicCookiesEnabled = (securitySettings.auth?.storage || []).includes(\n AuthStorageEnum.Cookie\n );\n\n // BYO JWT client puts their non-Dynamic JWT in a cookie\n const byoJwtCookieEnabled = Boolean(\n securitySettings.externalAuth?.cookieName\n );\n\n // should return true for both of these scenarios\n // because we also need to do `credentials: true` in api.ts when\n // a byo jwt client sets their named cookie for their jwt and\n // needs to send it to our backend\n return dynamicCookiesEnabled || byoJwtCookieEnabled;\n};\n","/* eslint-disable no-restricted-globals */\nimport { Buffer as BufferPolyfill } from 'buffer';\n\nexport const getBuffer = () =>\n typeof Buffer !== 'undefined' ? Buffer : BufferPolyfill;\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { getBuffer } from '../../../utils/getBuffer';\nimport type { SessionKeys } from '../sessionKeys.types';\n\nexport const getSessionKeys = (client: DynamicClient) => {\n const core = getCore(client);\n\n const encodedKeys = core.state.get().sessionKeys;\n\n if (!encodedKeys) {\n return undefined;\n }\n\n try {\n const decodedKeys: SessionKeys = JSON.parse(\n getBuffer().from(encodedKeys, 'base64').toString()\n );\n\n return decodedKeys;\n } catch (error) {\n core.logger.error('Error decoding session keys', error);\n return undefined;\n }\n};\n","import { BaseError } from '../base';\n\nexport class APIError extends BaseError {\n status: number;\n\n constructor(message: string, code: string, status: number) {\n super({\n cause: null,\n code,\n docsUrl: null,\n name: 'APIError',\n shortMessage: message,\n });\n\n this.status = status;\n }\n\n static async fromResponse(response: Response) {\n try {\n const errorBody = await response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n const errorCode =\n 'code' in errorBody && typeof errorBody.code === 'string'\n ? errorBody.code\n : 'unknown_error';\n\n return new APIError(errorBody.error, errorCode, response.status);\n }\n\n return null;\n } catch {\n return null;\n }\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class InvalidExternalAuthError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'invalid_external_auth_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/external-auth/third-party-auth-overview',\n name: 'InvalidExternalAuthError',\n shortMessage: 'Error authenticating with external JWT',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class LinkCredentialError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'link_credential_error',\n docsUrl: null,\n name: 'LinkCredentialError',\n shortMessage:\n 'The credential you are trying to link is associated with another account and cannot be reassigned.',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaInvalidOtpError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_invalid_otp_error',\n docsUrl: null,\n name: 'MfaInvalidOtpError',\n shortMessage: 'Invalid OTP',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaRateLimitedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_rate_limited_error',\n docsUrl: null,\n name: 'MfaRateLimitedError',\n shortMessage: 'Rate limited',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class SandboxMaximumThresholdReachedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'sandbox_maximum_threshold_reached_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/developer-dashboard/sandbox-vs-live#sandbox-vs-live',\n name: 'SandboxMaximumThresholdReachedError',\n shortMessage:\n 'Your sandbox environment has reached the maximum MAU. Please use a live environment for production traffic.',\n });\n }\n}\n","import { APIError } from '../../../../errors/APIError';\nimport { InvalidExternalAuthError } from '../../../../errors/InvalidExternalAuthError';\nimport { LinkCredentialError } from '../../../../errors/LinkCredentialError';\nimport { MfaInvalidOtpError } from '../../../../errors/MfaInvalidOtpError';\nimport { MfaRateLimitedError } from '../../../../errors/MfaRateLimitedError';\nimport { SandboxMaximumThresholdReachedError } from '../../../../errors/SandboxMaximumThresholdReachedError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\n/**\n * Default error mapper for the client that handles common API error codes.\n *\n * This mapper transforms specific API error codes into more specific error types:\n * - `mfa_invalid_code` → `MfaInvalidOtpError`\n * - `mfa_rate_limited` → `MfaRateLimitedError`\n *\n * @param error - The error to be mapped\n * @returns A transformed error if the error code matches a known pattern, or null if no transformation is needed\n *\n * @example\n * ```typescript\n * // This will be automatically applied to all API errors\n * const apiClient = createApiClient({}, client);\n *\n * // The clientErrorMapper will automatically convert mfa_invalid_code errors\n * // to MfaInvalidOtpError instances\n * ```\n */\nexport const clientErrorMapper: ErrorMapper = (error) => {\n if (error instanceof APIError) {\n if (error.code === 'mfa_invalid_code') {\n return new MfaInvalidOtpError({ cause: error });\n }\n\n if (error.code === 'mfa_rate_limited') {\n return new MfaRateLimitedError({ cause: error });\n }\n\n if (error.code === 'invalid_external_auth') {\n return new InvalidExternalAuthError({ cause: error });\n }\n\n if (error.code === 'sandbox_maximum_threshold_reached') {\n return new SandboxMaximumThresholdReachedError({ cause: error });\n }\n\n if (\n error.code === 'merge_accounts_invalid' ||\n error.code === 'reassign_wallet_error'\n ) {\n return new LinkCredentialError({ cause: error });\n }\n }\n\n return null;\n};\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { APIError } from '../../../../errors/APIError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\ntype CreateConvertToApiErrorMiddlewareOptions = {\n errorMappers?: ErrorMapper[];\n};\n\n/**\n * Creates middleware that converts HTTP error responses to APIError instances\n * and optionally applies custom error mappers to transform them into specific error types.\n *\n * @param options.errorMappers - Array of error mappers to apply to API errors\n * @returns A middleware function that handles error conversion and mapping\n */\nexport const createConvertToApiErrorMiddleware = ({\n errorMappers = [],\n}: CreateConvertToApiErrorMiddlewareOptions): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status >= 400) {\n const apiError = await APIError.fromResponse(context.response);\n\n if (apiError) {\n let errorToThrow: Error = apiError;\n\n for (const mapper of errorMappers) {\n const newError = mapper(apiError);\n\n if (newError) {\n errorToThrow = newError;\n break;\n }\n }\n\n throw errorToThrow;\n }\n }\n\n return context.response;\n },\n});\n","import { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { fetchAndStoreNonces } from './fetchAndStoreNonces/fetchAndStoreNonces';\n\n/**\n * Returns a nonce for wallet ownership verification.\n *\n * Pops the first nonce from the prefetched pool. When the pool is running low\n * (≤1 remaining after pop) a background refetch is triggered. If the pool is\n * empty, nonces are fetched on-demand before returning.\n */\nexport const getNonce = async (\n client: DynamicClient\n): Promise<string> => {\n const core = getCore(client);\n const pool = core.state.get().prefetchedNonces;\n\n if (pool.length > 0) {\n const [nonce, ...remaining] = pool;\n\n core.state.set({ prefetchedNonces: remaining });\n\n if (remaining.length <= 1) {\n void fetchAndStoreNonces(client);\n }\n\n return nonce;\n }\n\n await fetchAndStoreNonces(client);\n\n return getNonce(client);\n};\n","/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { bufferToHex } from '../bufferToHex';\n\ntype P256SignParams = {\n message: string;\n privateKeyJwk: JsonWebKey;\n};\n\nexport const p256Sign = async ({ privateKeyJwk, message }: P256SignParams) => {\n const privateKey = await crypto.subtle.importKey(\n 'jwk',\n privateKeyJwk,\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n false,\n ['sign']\n );\n\n const signature = await crypto.subtle.sign(\n {\n hash: 'SHA-256',\n name: 'ECDSA',\n },\n privateKey,\n new TextEncoder().encode(message)\n );\n\n return bufferToHex(signature);\n};\n","import type * as z from 'zod/mini';\n\nimport type { StorageKeySchema } from '../storage.types';\n\nexport const createStorageKeySchema = <T>(params: {\n key: string;\n schema: z.ZodMiniType<T>;\n}): StorageKeySchema<T> => {\n return params;\n};\n","/**\n * Takes a base64url-encoded string (e.g. \"nMueRPiAm51YXEjRtka8S_8Ura3HaqbmqDqMJCZmvkM\")\n * and return the corresponding bytes, as an array buffer.\n */\nexport const base64UrlDecode = (s?: string) => {\n // Go from base64url encoding to base64 encoding\n s = s?.replace(/-/g, '+').replace(/_/g, '/') || '';\n // use `atob` to decode base64\n return Uint8Array.from(atob(s), (c) => c.charCodeAt(0));\n};\n","/**\n * Accepts a public key array buffer, and returns a buffer with the compressed version of the public key\n */\nexport const compressRawPublicKey = (rawPublicKey: ArrayBuffer) => {\n const rawPublicKeyBytes = new Uint8Array(rawPublicKey);\n const len = rawPublicKeyBytes.byteLength;\n\n // Drop the y coordinate\n const compressedBytes = rawPublicKeyBytes.slice(0, (1 + len) >>> 1);\n\n // Encode the parity of `y` in first bit\n compressedBytes[0] = 0x2 | (rawPublicKeyBytes[len - 1] & 0x01);\n return compressedBytes.buffer;\n};\n","import { base64UrlDecode } from '../base64UrlDecode';\nimport { bufferToHex } from '../bufferToHex';\nimport { compressRawPublicKey } from '../compressRawPublicKey';\n\nexport const p256Keygen = async () => {\n // Create a new P-256 keypair\n const p256Keypair = await crypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n true,\n ['sign', 'verify']\n );\n\n // Export the raw public key. By default this will export in uncompressed format\n const rawPublicKey = await crypto.subtle.exportKey(\n 'raw',\n p256Keypair.publicKey\n );\n\n // We need to export with JWK format because exporting EC private keys with \"raw\" isn't supported\n const privateKeyJwk = await crypto.subtle.exportKey(\n 'jwk',\n p256Keypair.privateKey\n );\n\n const compressedPublicKeyBuffer = compressRawPublicKey(rawPublicKey);\n\n const privateKeyBuffer = base64UrlDecode(privateKeyJwk.d);\n\n return {\n private: bufferToHex(privateKeyBuffer),\n privateJwk: privateKeyJwk,\n public: bufferToHex(compressedPublicKeyBuffer),\n };\n};\n","import * as z from 'zod/mini';\n\nexport const deviceSigningKeysSchema = z.object({\n privateJwk: z.custom<JsonWebKey>(),\n privateKey: z.string(),\n publicKey: z.string(),\n});\n","import type * as z from 'zod/mini';\n\nimport { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createStorageKeySchema } from '../../../../services/storage';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { p256Keygen } from '../../../../utils/p256Keygen';\nimport { deviceSigningKeysSchema } from '../deviceSigningKeys.schema';\n\n/**\n * On web we want to auto create the device signing keys for each user.\n * And the user device signing keys should never be deleted.\n */\nexport const getOrCreateEnvironmentDeviceSigningKeys = async (\n client: DynamicClient\n): Promise<z.infer<typeof deviceSigningKeysSchema>> => {\n const { storage, environmentId } = getCore(client);\n\n assertDefined(environmentId, 'Environment ID is required');\n\n const environmentDeviceSigningKeysStorageKeySchema = createStorageKeySchema({\n key: `user_device_signing_keys_${environmentId}`,\n schema: deviceSigningKeysSchema,\n });\n\n const deviceSigningKeys = await storage.getItem(\n environmentDeviceSigningKeysStorageKeySchema\n );\n\n if (deviceSigningKeys) {\n return deviceSigningKeys;\n }\n\n const {\n public: publicKey,\n private: privateKey,\n privateJwk,\n } = await p256Keygen();\n\n await storage.setItem(environmentDeviceSigningKeysStorageKeySchema, {\n privateJwk,\n privateKey,\n publicKey,\n });\n\n return {\n privateJwk,\n privateKey,\n publicKey,\n };\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport type { DeviceSigner } from '../../../services/deviceSigner';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getOrCreateEnvironmentDeviceSigningKeys } from './getOrCreateEnvironmentDeviceSigningKeys';\n\nexport const getDeviceSigner = async (\n client: DynamicClient\n): Promise<DeviceSigner> => {\n const { deviceSigner } = getCore(client);\n\n /**\n * If the device signer is available, it should handle the device signing\n * This is used for mobile devices with secure enclave.\n */\n if (deviceSigner) {\n return deviceSigner;\n }\n\n /**\n * For web devices we want to auto create one PK per user id.\n */\n const environmentDeviceSigningKeys =\n await getOrCreateEnvironmentDeviceSigningKeys(client);\n\n return {\n getPublicKey: async () => environmentDeviceSigningKeys.publicKey,\n sign: (payload: string) =>\n p256Sign({\n message: payload,\n privateKeyJwk: environmentDeviceSigningKeys.privateJwk,\n }),\n };\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getNonce } from '../../../utils/getNonce';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { getDeviceSigner } from '../getDeviceSigner';\n\nexport const getHeadersForNonceSignedByDeviceSigners = async (\n client: DynamicClient\n): Promise<Record<string, string>> => {\n const { projectSettings } = client;\n\n assertDefined(projectSettings, 'Project settings not found');\n\n /**\n * For cookie based environments, the device registration is handled\n * by settings the cookie in the browser.\n * Then we dont need to provide the headers\n */\n if (isCookieEnabled(client)) {\n return {};\n }\n\n const deviceSigner = await getDeviceSigner(client);\n\n const nonce = await getNonce(client);\n\n const signedNonce = await deviceSigner.sign(nonce);\n const publicKey = await deviceSigner.getPublicKey();\n\n return {\n 'x-dynamic-device-nonce': nonce,\n 'x-dynamic-device-publickey': publicKey,\n 'x-dynamic-device-signed-nonce': signedNonce,\n };\n};\n","import type { Middleware } from '@dynamic-labs/sdk-api-core';\nimport { isDeviceNonceSignatureRequiredForUrl } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { getHeadersForNonceSignedByDeviceSigners } from '../../../deviceRegistration/getHeadersForNonceSignedByDeviceSigners';\nimport { isCookieEnabled } from '../../../projectSettings/isCookieEnabled';\n\nexport const createDeviceSignatureHeadersMiddleware = (\n client: DynamicClient\n): Middleware => {\n return {\n pre: async (context) => {\n /**\n * The signed nonce is not required for cookie based environments.\n */\n if (\n isDeviceNonceSignatureRequiredForUrl(context.url) &&\n !isCookieEnabled(client)\n ) {\n const deviceSignerHeaders = await getHeadersForNonceSignedByDeviceSigners(\n client\n );\n\n return {\n init: {\n ...context.init,\n headers: {\n ...context.init.headers,\n ...deviceSignerHeaders,\n },\n },\n url: context.url,\n };\n }\n\n return;\n },\n };\n};\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class UnauthorizedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'unauthorized_error',\n docsUrl: null,\n name: 'UnauthorizedError',\n shortMessage: 'Unauthorized',\n });\n }\n}\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { UnauthorizedError } from '../../../../errors/UnauthorizedError';\n\nexport const createUnauthorizedMiddleware = (): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status === 401) {\n let cause: Error | null = null;\n\n try {\n const errorBody = await context.response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n // eslint-disable-next-line no-restricted-syntax\n cause = new Error(errorBody.error);\n }\n } catch {\n // Response body isn't valid JSON — proceed without a cause\n }\n\n throw new UnauthorizedError({ cause });\n }\n\n return context.response;\n },\n});\n","import { Configuration, SDKApi } from '@dynamic-labs/sdk-api-core';\n\nimport { version } from '../../../package.json';\nimport { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { randomString } from '../../utils/randomString';\nimport { isCookieEnabled } from '../projectSettings/isCookieEnabled';\nimport { getSessionKeys } from '../sessionKeys/getSessionKeys';\nimport type { CreateApiClientOptions } from './apiClient.types';\nimport {\n CLIENT_SDK_NAME,\n DYNAMIC_API_VERSION_HEADER,\n DYNAMIC_REQUEST_ID_HEADER,\n DYNAMIC_SDK_API_VERSION,\n DYNAMIC_SDK_VERSION_HEADER,\n MFA_TOKEN_HEADER,\n SESSION_PUBLIC_KEY_HEADER,\n} from './constants';\nimport { clientErrorMapper } from './utils/clientErrorMapper';\nimport { createConvertToApiErrorMiddleware } from './utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware';\nimport { createDeviceSignatureHeadersMiddleware } from './utils/deviceSignatureHeadersMiddleware';\nimport { createUnauthorizedMiddleware } from './utils/unauthorizedMiddleware/createUnauthorizedMiddleware';\n\ntype ISettings = {\n basePath: string;\n credentials?: 'include';\n headers: {\n Authorization?: string;\n 'Content-Type': string;\n [DYNAMIC_API_VERSION_HEADER]: string;\n [DYNAMIC_REQUEST_ID_HEADER]: string;\n [DYNAMIC_SDK_VERSION_HEADER]: string;\n [MFA_TOKEN_HEADER]?: string;\n [SESSION_PUBLIC_KEY_HEADER]?: string;\n };\n};\n\n/**\n * Returns a new instance of the SDK API client.\n *\n * This is not meant for storing, as it is very light we can create it whenever needed.\n */\nexport const createApiClient = (\n options: CreateApiClientOptions = {},\n client: DynamicClient\n) => {\n const core = getCore(client);\n const coreState = core.state.get();\n\n const settings: ISettings = {\n basePath: core.apiBaseUrl,\n headers: {\n 'Content-Type': 'application/json',\n [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,\n [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),\n [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,\n ...core.getApiHeaders(),\n ...options.headers,\n },\n };\n\n if (client.token) {\n settings.headers.Authorization = `Bearer ${client.token}`;\n }\n\n if (client.projectSettings && isCookieEnabled(client)) {\n settings.credentials = 'include';\n }\n\n if (options.includeMfaToken && coreState.mfaToken) {\n settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;\n }\n\n const sessionPublicKey = getSessionKeys(client)?.publicKey;\n\n // This check is required to avoid overriding the session public key header\n // that is set by any of our other SDKs using the Dynamic Client SDK.\n const isSessionPublicKeyHeaderPresent =\n settings.headers[SESSION_PUBLIC_KEY_HEADER] !== undefined;\n\n if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) {\n settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;\n }\n\n return new SDKApi(\n new Configuration({\n ...settings,\n fetchApi: core.fetch,\n middleware: [\n createDeviceSignatureHeadersMiddleware(client),\n createConvertToApiErrorMiddleware({\n errorMappers: [...(options.errorMappers || []), clientErrorMapper],\n }),\n createUnauthorizedMiddleware(),\n ],\n })\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { createApiClient } from '../../../modules/apiClient';\nimport { NONCE_POOL_EXPIRATION_TIME, NONCE_POOL_SIZE } from '../constants';\n\n/**\n * Fetches a batch of nonces from the API.\n *\n * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom\n * redirect). On iOS, a network request (like fetching a nonce) between a user\n * action and a deeplink call will break the gesture chain, causing iOS to\n * silently ignore the deeplink. By prefetching nonces ahead of time,\n * `getNonce` can return synchronously from cache and the deeplink fires\n * without an interrupting network round-trip.\n */\nexport const fetchAndStoreNonces = async (\n client: DynamicClient\n): Promise<void> => {\n const core = getCore(client);\n\n const { environmentId } = core;\n\n const apiClient = createApiClient({}, client);\n\n const { nonces } = await apiClient.getNonces({\n count: NONCE_POOL_SIZE,\n environmentId,\n });\n\n core.state.set({\n prefetchedNonces: nonces,\n prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME,\n });\n};\n","import type { Chain } from '../chain';\n\ntype ChainInfo = {\n apiChainName: string;\n blockchainName: string;\n verifiedCredentialChainName: string;\n waasChainNameOverride?: string;\n};\n\nexport const CHAINS_INFO_MAP: Record<Chain, ChainInfo> = {\n ALEO: {\n apiChainName: 'aleo',\n blockchainName: 'Aleo',\n verifiedCredentialChainName: 'aleo',\n },\n ALGO: {\n apiChainName: 'algo',\n blockchainName: 'Algorand',\n verifiedCredentialChainName: 'algorand',\n },\n APTOS: {\n apiChainName: 'aptos',\n blockchainName: 'Aptos',\n verifiedCredentialChainName: 'aptos',\n },\n BTC: {\n apiChainName: 'bitcoin',\n blockchainName: 'Bitcoin',\n verifiedCredentialChainName: 'bip122',\n },\n COSMOS: {\n apiChainName: 'cosmos',\n blockchainName: 'Cosmos',\n verifiedCredentialChainName: 'cosmos',\n },\n ECLIPSE: {\n apiChainName: 'eclipse',\n blockchainName: 'Eclipse',\n verifiedCredentialChainName: 'eclipse',\n },\n EVM: {\n apiChainName: 'evm',\n // eslint-disable-next-line custom-rules/ban-ethereum-eth-terms\n blockchainName: 'Ethereum',\n verifiedCredentialChainName: 'eip155',\n },\n FLOW: {\n apiChainName: 'flow',\n blockchainName: 'Flow',\n verifiedCredentialChainName: 'flow',\n },\n SOL: {\n apiChainName: 'solana',\n blockchainName: 'Solana',\n verifiedCredentialChainName: 'solana',\n waasChainNameOverride: 'SVM',\n },\n SPARK: {\n apiChainName: 'spark',\n blockchainName: 'Spark',\n verifiedCredentialChainName: 'spark',\n },\n STARK: {\n apiChainName: 'starknet',\n blockchainName: 'Starknet',\n verifiedCredentialChainName: 'starknet',\n },\n STELLAR: {\n apiChainName: 'stellar',\n blockchainName: 'Stellar',\n verifiedCredentialChainName: 'stellar',\n },\n SUI: {\n apiChainName: 'sui',\n blockchainName: 'Sui',\n verifiedCredentialChainName: 'sui',\n },\n TON: {\n apiChainName: 'ton',\n blockchainName: 'TON',\n verifiedCredentialChainName: 'ton',\n },\n TRON: {\n apiChainName: 'tron',\n blockchainName: 'Tron',\n verifiedCredentialChainName: 'tron',\n },\n};\n","import type { Chain } from '../../modules/chain';\nimport { CHAINS_INFO_MAP } from '../../modules/wallets/constants';\nimport { assertDefined } from '../assertDefined';\n\nexport const getChainFromVerifiedCredentialChain = (\n verifiedCredentialChain: string\n): Chain => {\n const chains = Object.keys(CHAINS_INFO_MAP) as Chain[];\n\n const chain = chains.find(\n (chain) =>\n CHAINS_INFO_MAP[chain].verifiedCredentialChainName ===\n verifiedCredentialChain\n );\n\n assertDefined(chain, `Unknown chain: ${verifiedCredentialChain}`);\n\n return chain;\n};\n","import { dependencies } from '../package.json';\n\nexport const SDK_API_CORE_VERSION = dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const DYNAMIC_ICONIC_SPRITE_URL =\n 'https://iconic.dynamic-static-assets.com/icons/sprite.svg';\n","import { DYNAMIC_ICONIC_SPRITE_URL } from '../../constants';\n\nexport const DEFAULT_WAAS_BASE_API_URL = 'https://app.dynamicauth.com';\nexport const DEFAULT_WAAS_BASE_MPC_RELAY_API_URL =\n 'https://relay.dynamicauth.com';\n\nexport const DYNAMIC_WAAS_METADATA = {\n displayName: 'Dynamic WaaS',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#dynamicwaas`,\n normalizedWalletName: 'dynamicwaas',\n};\n","import { BaseError } from './base';\n\nexport class InvalidParamError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'invalid_param_error',\n docsUrl: null,\n name: 'InvalidParamError',\n shortMessage: message,\n });\n }\n}\n"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AQ;EACN,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,SAAS;EACP,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EAEd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,MAAM;EACJ,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC7B,uBAAuB;EACxB;CACD,OAAO;EACL,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,OAAO;EACL,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,SAAS;EACP,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,MAAM;EACJ,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACF;;;;ACnFD,MAAa,uCACX,4BACU;CAGV,MAAM,QAFS,OAAO,KAAK,gBAAgB,CAEtB,MAClB,YACC,gBAAgBC,SAAO,gCACvB,wBACH;AAED,eAAc,OAAO,kBAAkB,0BAA0B;AAEjE,QAAO;;;;;ACfT,MAAa,uBAAuB,aAAa;AAEjD,MAAa,4BACX;;;;ACHF,MAAa,4BAA4B;AACzC,MAAa,sCACX;AAEF,MAAa,wBAAwB;CACnC,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;;;;ACRD,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,SAAiB;AAC3B,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"InvalidParamError-DgN3p6L7.cjs.js","names":["defaultClient: DynamicClient | null","AuthStorageEnum","BufferPolyfill","clientErrorMapper: ErrorMapper","errorToThrow: Error","buffer","z","cause: Error | null","settings: ISettings","SDKApi","Configuration","CHAINS_INFO_MAP: Record<Chain, ChainInfo>","chain"],"sources":["../package.json","../src/client/core/getCore/getCore.ts","../src/errors/base/BaseError.ts","../src/errors/ClientNotFoundError.ts","../src/client/defaultClient/defaultClient.ts","../src/utils/getNonce/constants.ts","../src/modules/apiClient/constants.ts","../src/utils/randomString/randomString.ts","../src/errors/ValueMustBeDefinedError.ts","../src/utils/assertDefined/assertDefined.ts","../src/modules/projectSettings/isCookieEnabled/isCookieEnabled.ts","../src/utils/getBuffer/getBuffer.ts","../src/modules/sessionKeys/getSessionKeys/getSessionKeys.ts","../src/errors/APIError/APIError.ts","../src/errors/InvalidExternalAuthError.ts","../src/errors/LinkCredentialError.ts","../src/errors/MfaInvalidOtpError.ts","../src/errors/MfaRateLimitedError.ts","../src/errors/SandboxMaximumThresholdReachedError.ts","../src/modules/apiClient/utils/clientErrorMapper/clientErrorMapper.ts","../src/modules/apiClient/utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware.ts","../src/utils/getNonce/getNonce.ts","../src/utils/bufferToHex/bufferToHex.ts","../src/utils/p256Sign/p256Sign.ts","../src/services/storage/createStorageKeySchema/createStorageKeySchema.ts","../src/utils/base64UrlDecode/base64UrlDecode.ts","../src/utils/compressRawPublicKey/compressRawPublicKey.ts","../src/utils/p256Keygen/p256Keygen.ts","../src/modules/deviceRegistration/getDeviceSigner/deviceSigningKeys.schema.ts","../src/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.ts","../src/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.ts","../src/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.ts","../src/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.ts","../src/errors/UnauthorizedError.ts","../src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts","../src/modules/apiClient/createApiClient.ts","../src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts","../src/modules/wallets/constants.ts","../src/utils/getChainFromVerifiedCredentialChain/getChainFromVerifiedCredentialChain.ts","../src/constants.ts","../src/modules/waas/constants.ts","../src/errors/InvalidParamError.ts"],"sourcesContent":["","import type { DynamicClient } from '../../types';\nimport type { DynamicCore } from '../types';\n\nexport const getCore = (client: DynamicClient): DynamicCore => {\n // @ts-expect-error - this was hidden from the public API\n return client.__core;\n};\n","import { version } from '../../../package.json';\n\nexport type BaseErrorParameters = {\n /** The underlying error that caused this error, if any */\n cause: Error | null;\n /** The error unique code */\n code: string;\n /** Additional detailed information about the error */\n details?: string;\n /** URL to relevant documentation for this error */\n docsUrl: string | null;\n /** Array of additional contextual messages to be displayed */\n metaMessages?: string[];\n /** Custom name for the error. Defaults to 'BaseError' if not provided */\n name: string;\n /** A brief, human-readable description of the error */\n shortMessage: string;\n};\n\nconst getDetails = ({ details, cause }: BaseErrorParameters) => {\n if (cause instanceof BaseError) {\n return cause.details;\n }\n\n if (cause?.message) {\n return cause.message;\n }\n\n return details;\n};\n\n/**\n * Formats the error message with all available information\n */\nconst formatMessage = ({\n shortMessage,\n details,\n docsUrl,\n metaMessages,\n}: BaseErrorParameters) => {\n return [\n '[Dynamic JS SDK]',\n shortMessage,\n '',\n ...(metaMessages ? [...metaMessages, ''] : []),\n ...(docsUrl ? [`Docs: ${docsUrl}`] : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: ${version}`,\n `Timestamp: ${new Date().toISOString()}`,\n ].join('\\n');\n};\n\n/**\n * Base error class that provides structured error handling with detailed information\n */\nexport abstract class BaseError extends Error {\n /** The error unique code */\n code: string;\n details: string | undefined;\n private readonly formattedMessage: string | undefined;\n override name = 'BaseError';\n override cause: BaseError | Error | undefined;\n\n constructor(args: BaseErrorParameters) {\n const details = getDetails(args);\n const formattedMessage = formatMessage({ ...args, details });\n super(\n args.shortMessage ?? formattedMessage,\n args.cause ? { cause: args.cause } : undefined\n );\n\n this.formattedMessage = formattedMessage;\n this.details = details;\n this.name = args.name ?? this.name;\n this.cause = args.cause ?? this.cause;\n this.code = args.code;\n }\n\n /**\n * Walks the cause chain of the error and returns the root error\n */\n walk(): Error | undefined {\n const cause = this.cause;\n\n if (cause instanceof BaseError) {\n return cause.walk();\n }\n\n return cause;\n }\n\n override toString() {\n return this.formattedMessage;\n }\n}\n","import { BaseError } from './base';\n\nexport class ClientNotFoundError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'client_not_found_error',\n docsUrl: null,\n name: 'ClientNotFoundError',\n shortMessage:\n 'No Dynamic client has been created yet. Make sure you have called createDynamicClient() first.',\n });\n }\n}\n","import { ClientNotFoundError } from '../../errors/ClientNotFoundError';\nimport { getCore } from '../core/getCore';\nimport type { DynamicClient } from '../types';\n\nlet defaultClient: DynamicClient | null = null;\nlet numOfInitializedClients = 0;\n\n/**\n * Returns the DynamicClient instance that was initialized with createDynamicClient.\n *\n * If more than one instance of DynamicClient was initialized, you should not use this function.\n * Instead, you should pass the client instance you stored to the function that needs it.\n */\nexport const getDefaultClient = (): DynamicClient => {\n if (!defaultClient) {\n throw new ClientNotFoundError();\n }\n\n if (numOfInitializedClients > 1) {\n const core = getCore(defaultClient);\n core.logger.debug(\n 'Multiple instances of DynamicClient found. If you are only using one client (recommended), make sure you are not calling ' +\n '\"createDynamicClient\" multiple times. If you are using multiple clients, make sure you are passing which client to use as ' +\n 'the last param of all Dynamic functions.'\n );\n }\n\n return defaultClient;\n};\n\nexport const setDefaultClient = (client: DynamicClient) => {\n defaultClient = client;\n numOfInitializedClients++;\n};\n","export const NONCE_POOL_EXPIRATION_TIME = 60000 * 60 * 24;\n\nexport const NONCE_POOL_SIZE = 5;\n","import { dependencies } from '../../../package.json';\n\nexport const DYNAMIC_API_VERSION_HEADER = 'x-dyn-api-version';\n\nexport const DYNAMIC_REQUEST_ID_HEADER = 'x-dyn-request-id';\n\nexport const DYNAMIC_SDK_VERSION_HEADER = 'x-dyn-version';\n\nexport const MFA_TOKEN_HEADER = 'x-mfa-auth-token';\n\nexport const SESSION_PUBLIC_KEY_HEADER = 'x-dyn-session-public-key';\n\nexport const DYNAMIC_SDK_API_VERSION =\n dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const CLIENT_SDK_NAME = 'ClientSDK';\n","const DEFAULT_CHARS =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n\ntype RandomStringParams = {\n chars?: string;\n length: number;\n};\n\nexport const randomString = ({ chars = DEFAULT_CHARS, length }: RandomStringParams) => {\n const bytes = new Uint8Array(length);\n crypto.getRandomValues(bytes);\n\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n return result;\n};\n","import { BaseError } from './base';\n\nexport class ValueMustBeDefinedError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'value_must_be_defined_error',\n docsUrl: null,\n name: 'ValueMustBeDefined',\n shortMessage: message,\n });\n }\n}\n","/* eslint-disable func-style -- javascript requires this to be a function */\n\nimport { ValueMustBeDefinedError } from './../../errors/ValueMustBeDefinedError';\n\n/**\n * Asserts that a value is not null or undefined, throwing an error if it is.\n * This function acts as a type guard, narrowing the type to exclude null and undefined.\n *\n * @template T - The type of the value being checked\n * @param value - The value to check for null or undefined\n * @param message - The error message to throw if the value is null or undefined\n * @throws Throws an error with the provided message if value is null or undefined\n * @example\n * ```typescript\n * const maybeString: string | null = getValue();\n * assertDefined(maybeString, 'String value is required');\n * // maybeString is now typed as string (null is excluded)\n * ```\n */\nexport function assertDefined<T>(\n value: T,\n message: string\n): asserts value is Exclude<NonNullable<T>, void> {\n if (value === null || value === undefined) {\n throw new ValueMustBeDefinedError(message);\n }\n}\n","import { AuthStorageEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Returns true if the client is using Dynamic cookies or a BYO JWT cookie.\n */\nexport const isCookieEnabled = (client: DynamicClient): boolean => {\n assertDefined(client.projectSettings, 'Project settings are not defined');\n\n const securitySettings = client.projectSettings.security;\n\n if (!securitySettings) return false;\n\n // client uses Dynamic cookies\n const dynamicCookiesEnabled = (securitySettings.auth?.storage || []).includes(\n AuthStorageEnum.Cookie\n );\n\n // BYO JWT client puts their non-Dynamic JWT in a cookie\n const byoJwtCookieEnabled = Boolean(\n securitySettings.externalAuth?.cookieName\n );\n\n // should return true for both of these scenarios\n // because we also need to do `credentials: true` in api.ts when\n // a byo jwt client sets their named cookie for their jwt and\n // needs to send it to our backend\n return dynamicCookiesEnabled || byoJwtCookieEnabled;\n};\n","/* eslint-disable no-restricted-globals */\nimport { Buffer as BufferPolyfill } from 'buffer';\n\nexport const getBuffer = () =>\n typeof Buffer !== 'undefined' ? Buffer : BufferPolyfill;\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { getBuffer } from '../../../utils/getBuffer';\nimport type { SessionKeys } from '../sessionKeys.types';\n\nexport const getSessionKeys = (client: DynamicClient) => {\n const core = getCore(client);\n\n const encodedKeys = core.state.get().sessionKeys;\n\n if (!encodedKeys) {\n return undefined;\n }\n\n try {\n const decodedKeys: SessionKeys = JSON.parse(\n getBuffer().from(encodedKeys, 'base64').toString()\n );\n\n return decodedKeys;\n } catch (error) {\n core.logger.error('Error decoding session keys', error);\n return undefined;\n }\n};\n","import { BaseError } from '../base';\n\nexport class APIError extends BaseError {\n status: number;\n\n constructor(message: string, code: string, status: number) {\n super({\n cause: null,\n code,\n docsUrl: null,\n name: 'APIError',\n shortMessage: message,\n });\n\n this.status = status;\n }\n\n static async fromResponse(response: Response) {\n try {\n const errorBody = await response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n const errorCode =\n 'code' in errorBody && typeof errorBody.code === 'string'\n ? errorBody.code\n : 'unknown_error';\n\n return new APIError(errorBody.error, errorCode, response.status);\n }\n\n return null;\n } catch {\n return null;\n }\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class InvalidExternalAuthError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'invalid_external_auth_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/external-auth/third-party-auth-overview',\n name: 'InvalidExternalAuthError',\n shortMessage: 'Error authenticating with external JWT',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class LinkCredentialError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'link_credential_error',\n docsUrl: null,\n name: 'LinkCredentialError',\n shortMessage:\n 'The credential you are trying to link is associated with another account and cannot be reassigned.',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaInvalidOtpError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_invalid_otp_error',\n docsUrl: null,\n name: 'MfaInvalidOtpError',\n shortMessage: 'Invalid OTP',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class MfaRateLimitedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'mfa_rate_limited_error',\n docsUrl: null,\n name: 'MfaRateLimitedError',\n shortMessage: 'Rate limited',\n });\n }\n}\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class SandboxMaximumThresholdReachedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'sandbox_maximum_threshold_reached_error',\n docsUrl:\n 'https://www.dynamic.xyz/docs/developer-dashboard/sandbox-vs-live#sandbox-vs-live',\n name: 'SandboxMaximumThresholdReachedError',\n shortMessage:\n 'Your sandbox environment has reached the maximum MAU. Please use a live environment for production traffic.',\n });\n }\n}\n","import { APIError } from '../../../../errors/APIError';\nimport { InvalidExternalAuthError } from '../../../../errors/InvalidExternalAuthError';\nimport { LinkCredentialError } from '../../../../errors/LinkCredentialError';\nimport { MfaInvalidOtpError } from '../../../../errors/MfaInvalidOtpError';\nimport { MfaRateLimitedError } from '../../../../errors/MfaRateLimitedError';\nimport { SandboxMaximumThresholdReachedError } from '../../../../errors/SandboxMaximumThresholdReachedError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\n/**\n * Default error mapper for the client that handles common API error codes.\n *\n * This mapper transforms specific API error codes into more specific error types:\n * - `mfa_invalid_code` → `MfaInvalidOtpError`\n * - `mfa_rate_limited` → `MfaRateLimitedError`\n *\n * @param error - The error to be mapped\n * @returns A transformed error if the error code matches a known pattern, or null if no transformation is needed\n *\n * @example\n * ```typescript\n * // This will be automatically applied to all API errors\n * const apiClient = createApiClient({}, client);\n *\n * // The clientErrorMapper will automatically convert mfa_invalid_code errors\n * // to MfaInvalidOtpError instances\n * ```\n */\nexport const clientErrorMapper: ErrorMapper = (error) => {\n if (error instanceof APIError) {\n if (error.code === 'mfa_invalid_code') {\n return new MfaInvalidOtpError({ cause: error });\n }\n\n if (error.code === 'mfa_rate_limited') {\n return new MfaRateLimitedError({ cause: error });\n }\n\n if (error.code === 'invalid_external_auth') {\n return new InvalidExternalAuthError({ cause: error });\n }\n\n if (error.code === 'sandbox_maximum_threshold_reached') {\n return new SandboxMaximumThresholdReachedError({ cause: error });\n }\n\n if (\n error.code === 'merge_accounts_invalid' ||\n error.code === 'reassign_wallet_error'\n ) {\n return new LinkCredentialError({ cause: error });\n }\n }\n\n return null;\n};\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { APIError } from '../../../../errors/APIError';\nimport type { ErrorMapper } from '../../apiClient.types';\n\ntype CreateConvertToApiErrorMiddlewareOptions = {\n errorMappers?: ErrorMapper[];\n};\n\n/**\n * Creates middleware that converts HTTP error responses to APIError instances\n * and optionally applies custom error mappers to transform them into specific error types.\n *\n * @param options.errorMappers - Array of error mappers to apply to API errors\n * @returns A middleware function that handles error conversion and mapping\n */\nexport const createConvertToApiErrorMiddleware = ({\n errorMappers = [],\n}: CreateConvertToApiErrorMiddlewareOptions): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status >= 400) {\n const apiError = await APIError.fromResponse(context.response);\n\n if (apiError) {\n let errorToThrow: Error = apiError;\n\n for (const mapper of errorMappers) {\n const newError = mapper(apiError);\n\n if (newError) {\n errorToThrow = newError;\n break;\n }\n }\n\n throw errorToThrow;\n }\n }\n\n return context.response;\n },\n});\n","import { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { fetchAndStoreNonces } from './fetchAndStoreNonces/fetchAndStoreNonces';\n\n/**\n * Returns a nonce for wallet ownership verification.\n *\n * Pops the first nonce from the prefetched pool. When the pool is running low\n * (≤1 remaining after pop) a background refetch is triggered. If the pool is\n * empty, nonces are fetched on-demand before returning.\n */\nexport const getNonce = async (\n client: DynamicClient\n): Promise<string> => {\n const core = getCore(client);\n const pool = core.state.get().prefetchedNonces;\n\n if (pool.length > 0) {\n const [nonce, ...remaining] = pool;\n\n core.state.set({ prefetchedNonces: remaining });\n\n if (remaining.length <= 1) {\n void fetchAndStoreNonces(client);\n }\n\n return nonce;\n }\n\n await fetchAndStoreNonces(client);\n\n return getNonce(client);\n};\n","/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { bufferToHex } from '../bufferToHex';\n\ntype P256SignParams = {\n message: string;\n privateKeyJwk: JsonWebKey;\n};\n\nexport const p256Sign = async ({ privateKeyJwk, message }: P256SignParams) => {\n const privateKey = await crypto.subtle.importKey(\n 'jwk',\n privateKeyJwk,\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n false,\n ['sign']\n );\n\n const signature = await crypto.subtle.sign(\n {\n hash: 'SHA-256',\n name: 'ECDSA',\n },\n privateKey,\n new TextEncoder().encode(message)\n );\n\n return bufferToHex(signature);\n};\n","import type * as z from 'zod/mini';\n\nimport type { StorageKeySchema } from '../storage.types';\n\nexport const createStorageKeySchema = <T>(params: {\n key: string;\n schema: z.ZodMiniType<T>;\n}): StorageKeySchema<T> => {\n return params;\n};\n","/**\n * Takes a base64url-encoded string (e.g. \"nMueRPiAm51YXEjRtka8S_8Ura3HaqbmqDqMJCZmvkM\")\n * and return the corresponding bytes, as an array buffer.\n */\nexport const base64UrlDecode = (s?: string) => {\n // Go from base64url encoding to base64 encoding\n s = s?.replace(/-/g, '+').replace(/_/g, '/') || '';\n // use `atob` to decode base64\n return Uint8Array.from(atob(s), (c) => c.charCodeAt(0));\n};\n","/**\n * Accepts a public key array buffer, and returns a buffer with the compressed version of the public key\n */\nexport const compressRawPublicKey = (rawPublicKey: ArrayBuffer) => {\n const rawPublicKeyBytes = new Uint8Array(rawPublicKey);\n const len = rawPublicKeyBytes.byteLength;\n\n // Drop the y coordinate\n const compressedBytes = rawPublicKeyBytes.slice(0, (1 + len) >>> 1);\n\n // Encode the parity of `y` in first bit\n compressedBytes[0] = 0x2 | (rawPublicKeyBytes[len - 1] & 0x01);\n return compressedBytes.buffer;\n};\n","import { base64UrlDecode } from '../base64UrlDecode';\nimport { bufferToHex } from '../bufferToHex';\nimport { compressRawPublicKey } from '../compressRawPublicKey';\n\nexport const p256Keygen = async () => {\n // Create a new P-256 keypair\n const p256Keypair = await crypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n true,\n ['sign', 'verify']\n );\n\n // Export the raw public key. By default this will export in uncompressed format\n const rawPublicKey = await crypto.subtle.exportKey(\n 'raw',\n p256Keypair.publicKey\n );\n\n // We need to export with JWK format because exporting EC private keys with \"raw\" isn't supported\n const privateKeyJwk = await crypto.subtle.exportKey(\n 'jwk',\n p256Keypair.privateKey\n );\n\n const compressedPublicKeyBuffer = compressRawPublicKey(rawPublicKey);\n\n const privateKeyBuffer = base64UrlDecode(privateKeyJwk.d);\n\n return {\n private: bufferToHex(privateKeyBuffer),\n privateJwk: privateKeyJwk,\n public: bufferToHex(compressedPublicKeyBuffer),\n };\n};\n","import * as z from 'zod/mini';\n\nexport const deviceSigningKeysSchema = z.object({\n privateJwk: z.custom<JsonWebKey>(),\n privateKey: z.string(),\n publicKey: z.string(),\n});\n","import type * as z from 'zod/mini';\n\nimport { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { createStorageKeySchema } from '../../../../services/storage';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { p256Keygen } from '../../../../utils/p256Keygen';\nimport { deviceSigningKeysSchema } from '../deviceSigningKeys.schema';\n\n/**\n * On web we want to auto create the device signing keys for each user.\n * And the user device signing keys should never be deleted.\n */\nexport const getOrCreateEnvironmentDeviceSigningKeys = async (\n client: DynamicClient\n): Promise<z.infer<typeof deviceSigningKeysSchema>> => {\n const { storage, environmentId } = getCore(client);\n\n assertDefined(environmentId, 'Environment ID is required');\n\n const environmentDeviceSigningKeysStorageKeySchema = createStorageKeySchema({\n key: `user_device_signing_keys_${environmentId}`,\n schema: deviceSigningKeysSchema,\n });\n\n const deviceSigningKeys = await storage.getItem(\n environmentDeviceSigningKeysStorageKeySchema\n );\n\n if (deviceSigningKeys) {\n return deviceSigningKeys;\n }\n\n const {\n public: publicKey,\n private: privateKey,\n privateJwk,\n } = await p256Keygen();\n\n await storage.setItem(environmentDeviceSigningKeysStorageKeySchema, {\n privateJwk,\n privateKey,\n publicKey,\n });\n\n return {\n privateJwk,\n privateKey,\n publicKey,\n };\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport type { DeviceSigner } from '../../../services/deviceSigner';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getOrCreateEnvironmentDeviceSigningKeys } from './getOrCreateEnvironmentDeviceSigningKeys';\n\nexport const getDeviceSigner = async (\n client: DynamicClient\n): Promise<DeviceSigner> => {\n const { deviceSigner } = getCore(client);\n\n /**\n * If the device signer is available, it should handle the device signing\n * This is used for mobile devices with secure enclave.\n */\n if (deviceSigner) {\n return deviceSigner;\n }\n\n /**\n * For web devices we want to auto create one PK per user id.\n */\n const environmentDeviceSigningKeys =\n await getOrCreateEnvironmentDeviceSigningKeys(client);\n\n return {\n getPublicKey: async () => environmentDeviceSigningKeys.publicKey,\n sign: (payload: string) =>\n p256Sign({\n message: payload,\n privateKeyJwk: environmentDeviceSigningKeys.privateJwk,\n }),\n };\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { getNonce } from '../../../utils/getNonce';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { getDeviceSigner } from '../getDeviceSigner';\n\nexport const getHeadersForNonceSignedByDeviceSigners = async (\n client: DynamicClient\n): Promise<Record<string, string>> => {\n const { projectSettings } = client;\n\n assertDefined(projectSettings, 'Project settings not found');\n\n /**\n * For cookie based environments, the device registration is handled\n * by settings the cookie in the browser.\n * Then we dont need to provide the headers\n */\n if (isCookieEnabled(client)) {\n return {};\n }\n\n const deviceSigner = await getDeviceSigner(client);\n\n const nonce = await getNonce(client);\n\n const signedNonce = await deviceSigner.sign(nonce);\n const publicKey = await deviceSigner.getPublicKey();\n\n return {\n 'x-dynamic-device-nonce': nonce,\n 'x-dynamic-device-publickey': publicKey,\n 'x-dynamic-device-signed-nonce': signedNonce,\n };\n};\n","import type { Middleware } from '@dynamic-labs/sdk-api-core';\nimport { isDeviceNonceSignatureRequiredForUrl } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { getHeadersForNonceSignedByDeviceSigners } from '../../../deviceRegistration/getHeadersForNonceSignedByDeviceSigners';\nimport { isCookieEnabled } from '../../../projectSettings/isCookieEnabled';\n\nexport const createDeviceSignatureHeadersMiddleware = (\n client: DynamicClient\n): Middleware => {\n return {\n pre: async (context) => {\n /**\n * The signed nonce is not required for cookie based environments.\n */\n if (\n isDeviceNonceSignatureRequiredForUrl(context.url) &&\n !isCookieEnabled(client)\n ) {\n const deviceSignerHeaders = await getHeadersForNonceSignedByDeviceSigners(\n client\n );\n\n return {\n init: {\n ...context.init,\n headers: {\n ...context.init.headers,\n ...deviceSignerHeaders,\n },\n },\n url: context.url,\n };\n }\n\n return;\n },\n };\n};\n","import { BaseError, type BaseErrorParameters } from './base';\n\nexport class UnauthorizedError extends BaseError {\n constructor({ cause }: Pick<BaseErrorParameters, 'cause'>) {\n super({\n cause,\n code: 'unauthorized_error',\n docsUrl: null,\n name: 'UnauthorizedError',\n shortMessage: 'Unauthorized',\n });\n }\n}\n","import type { Middleware, ResponseContext } from '@dynamic-labs/sdk-api-core';\n\nimport { UnauthorizedError } from '../../../../errors/UnauthorizedError';\n\nexport const createUnauthorizedMiddleware = (): Middleware => ({\n post: async (context: ResponseContext) => {\n if (context.response.status === 401) {\n let cause: Error | null = null;\n\n try {\n const errorBody = await context.response.clone().json();\n\n if (\n errorBody &&\n 'error' in errorBody &&\n typeof errorBody.error === 'string'\n ) {\n // eslint-disable-next-line no-restricted-syntax\n cause = new Error(errorBody.error);\n }\n } catch {\n // Response body isn't valid JSON — proceed without a cause\n }\n\n throw new UnauthorizedError({ cause });\n }\n\n return context.response;\n },\n});\n","import { Configuration, SDKApi } from '@dynamic-labs/sdk-api-core';\n\nimport { version } from '../../../package.json';\nimport { getCore } from '../../client/core/getCore';\nimport type { DynamicClient } from '../../client/types';\nimport { randomString } from '../../utils/randomString';\nimport { isCookieEnabled } from '../projectSettings/isCookieEnabled';\nimport { getSessionKeys } from '../sessionKeys/getSessionKeys';\nimport type { CreateApiClientOptions } from './apiClient.types';\nimport {\n CLIENT_SDK_NAME,\n DYNAMIC_API_VERSION_HEADER,\n DYNAMIC_REQUEST_ID_HEADER,\n DYNAMIC_SDK_API_VERSION,\n DYNAMIC_SDK_VERSION_HEADER,\n MFA_TOKEN_HEADER,\n SESSION_PUBLIC_KEY_HEADER,\n} from './constants';\nimport { clientErrorMapper } from './utils/clientErrorMapper';\nimport { createConvertToApiErrorMiddleware } from './utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware';\nimport { createDeviceSignatureHeadersMiddleware } from './utils/deviceSignatureHeadersMiddleware';\nimport { createUnauthorizedMiddleware } from './utils/unauthorizedMiddleware/createUnauthorizedMiddleware';\n\ntype ISettings = {\n basePath: string;\n credentials?: 'include';\n headers: {\n Authorization?: string;\n 'Content-Type': string;\n [DYNAMIC_API_VERSION_HEADER]: string;\n [DYNAMIC_REQUEST_ID_HEADER]: string;\n [DYNAMIC_SDK_VERSION_HEADER]: string;\n [MFA_TOKEN_HEADER]?: string;\n [SESSION_PUBLIC_KEY_HEADER]?: string;\n };\n};\n\n/**\n * Returns a new instance of the SDK API client.\n *\n * This is not meant for storing, as it is very light we can create it whenever needed.\n */\nexport const createApiClient = (\n options: CreateApiClientOptions = {},\n client: DynamicClient\n) => {\n const core = getCore(client);\n const coreState = core.state.get();\n\n const settings: ISettings = {\n basePath: core.apiBaseUrl,\n headers: {\n 'Content-Type': 'application/json',\n [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,\n [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),\n [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,\n ...core.getApiHeaders(),\n ...options.headers,\n },\n };\n\n if (client.token) {\n settings.headers.Authorization = `Bearer ${client.token}`;\n }\n\n if (client.projectSettings && isCookieEnabled(client)) {\n settings.credentials = 'include';\n }\n\n if (options.includeMfaToken && coreState.mfaToken) {\n settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;\n }\n\n const sessionPublicKey = getSessionKeys(client)?.publicKey;\n\n // This check is required to avoid overriding the session public key header\n // that is set by any of our other SDKs using the Dynamic Client SDK.\n const isSessionPublicKeyHeaderPresent =\n settings.headers[SESSION_PUBLIC_KEY_HEADER] !== undefined;\n\n if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) {\n settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;\n }\n\n return new SDKApi(\n new Configuration({\n ...settings,\n fetchApi: core.fetch,\n middleware: [\n createDeviceSignatureHeadersMiddleware(client),\n createConvertToApiErrorMiddleware({\n errorMappers: [...(options.errorMappers || []), clientErrorMapper],\n }),\n createUnauthorizedMiddleware(),\n ],\n })\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { createApiClient } from '../../../modules/apiClient';\nimport { NONCE_POOL_EXPIRATION_TIME, NONCE_POOL_SIZE } from '../constants';\n\n/**\n * Fetches a batch of nonces from the API.\n *\n * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom\n * redirect). On iOS, a network request (like fetching a nonce) between a user\n * action and a deeplink call will break the gesture chain, causing iOS to\n * silently ignore the deeplink. By prefetching nonces ahead of time,\n * `getNonce` can return synchronously from cache and the deeplink fires\n * without an interrupting network round-trip.\n */\nexport const fetchAndStoreNonces = async (\n client: DynamicClient\n): Promise<void> => {\n const core = getCore(client);\n\n const { environmentId } = core;\n\n const apiClient = createApiClient({}, client);\n\n const { nonces } = await apiClient.getNonces({\n count: NONCE_POOL_SIZE,\n environmentId,\n });\n\n core.state.set({\n prefetchedNonces: nonces,\n prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME,\n });\n};\n","import type { Chain } from '../chain';\n\ntype ChainInfo = {\n apiChainName: string;\n blockchainName: string;\n verifiedCredentialChainName: string;\n waasChainNameOverride?: string;\n};\n\nexport const CHAINS_INFO_MAP: Record<Chain, ChainInfo> = {\n ALEO: {\n apiChainName: 'aleo',\n blockchainName: 'Aleo',\n verifiedCredentialChainName: 'aleo',\n },\n ALGO: {\n apiChainName: 'algo',\n blockchainName: 'Algorand',\n verifiedCredentialChainName: 'algorand',\n },\n APTOS: {\n apiChainName: 'aptos',\n blockchainName: 'Aptos',\n verifiedCredentialChainName: 'aptos',\n },\n BTC: {\n apiChainName: 'bitcoin',\n blockchainName: 'Bitcoin',\n verifiedCredentialChainName: 'bip122',\n },\n COSMOS: {\n apiChainName: 'cosmos',\n blockchainName: 'Cosmos',\n verifiedCredentialChainName: 'cosmos',\n },\n ECLIPSE: {\n apiChainName: 'eclipse',\n blockchainName: 'Eclipse',\n verifiedCredentialChainName: 'eclipse',\n },\n EVM: {\n apiChainName: 'evm',\n // eslint-disable-next-line custom-rules/ban-ethereum-eth-terms\n blockchainName: 'Ethereum',\n verifiedCredentialChainName: 'eip155',\n },\n FLOW: {\n apiChainName: 'flow',\n blockchainName: 'Flow',\n verifiedCredentialChainName: 'flow',\n },\n SOL: {\n apiChainName: 'solana',\n blockchainName: 'Solana',\n verifiedCredentialChainName: 'solana',\n waasChainNameOverride: 'SVM',\n },\n SPARK: {\n apiChainName: 'spark',\n blockchainName: 'Spark',\n verifiedCredentialChainName: 'spark',\n },\n STARK: {\n apiChainName: 'starknet',\n blockchainName: 'Starknet',\n verifiedCredentialChainName: 'starknet',\n },\n STELLAR: {\n apiChainName: 'stellar',\n blockchainName: 'Stellar',\n verifiedCredentialChainName: 'stellar',\n },\n SUI: {\n apiChainName: 'sui',\n blockchainName: 'Sui',\n verifiedCredentialChainName: 'sui',\n },\n TEMPO: {\n apiChainName: 'tempo',\n blockchainName: 'Tempo',\n verifiedCredentialChainName: 'tempo',\n },\n TON: {\n apiChainName: 'ton',\n blockchainName: 'TON',\n verifiedCredentialChainName: 'ton',\n },\n TRON: {\n apiChainName: 'tron',\n blockchainName: 'Tron',\n verifiedCredentialChainName: 'tron',\n },\n};\n","import type { Chain } from '../../modules/chain';\nimport { CHAINS_INFO_MAP } from '../../modules/wallets/constants';\nimport { assertDefined } from '../assertDefined';\n\nexport const getChainFromVerifiedCredentialChain = (\n verifiedCredentialChain: string\n): Chain => {\n const chains = Object.keys(CHAINS_INFO_MAP) as Chain[];\n\n const chain = chains.find(\n (chain) =>\n CHAINS_INFO_MAP[chain].verifiedCredentialChainName ===\n verifiedCredentialChain\n );\n\n assertDefined(chain, `Unknown chain: ${verifiedCredentialChain}`);\n\n return chain;\n};\n","import { dependencies } from '../package.json';\n\nexport const SDK_API_CORE_VERSION = dependencies['@dynamic-labs/sdk-api-core'];\n\nexport const DYNAMIC_ICONIC_SPRITE_URL =\n 'https://iconic.dynamic-static-assets.com/icons/sprite.svg';\n","import { DYNAMIC_ICONIC_SPRITE_URL } from '../../constants';\n\nexport const DEFAULT_WAAS_BASE_API_URL = 'https://app.dynamicauth.com';\nexport const DEFAULT_WAAS_BASE_MPC_RELAY_API_URL =\n 'https://relay.dynamicauth.com';\n\nexport const DYNAMIC_WAAS_METADATA = {\n displayName: 'Dynamic WaaS',\n icon: `${DYNAMIC_ICONIC_SPRITE_URL}#dynamicwaas`,\n normalizedWalletName: 'dynamicwaas',\n};\n","import { BaseError } from './base';\n\nexport class InvalidParamError extends BaseError {\n constructor(message: string) {\n super({\n cause: null,\n code: 'invalid_param_error',\n docsUrl: null,\n name: 'InvalidParamError',\n shortMessage: message,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGA,MAAa,WAAW,WAAuC;AAE7D,QAAO,OAAO;;;;;ACchB,MAAM,cAAc,EAAE,SAAS,YAAiC;AAC9D,KAAI,iBAAiB,UACnB,QAAO,MAAM;AAGf,KAAI,OAAO,QACT,QAAO,MAAM;AAGf,QAAO;;;;;AAMT,MAAM,iBAAiB,EACrB,cACA,SACA,SACA,mBACyB;AACzB,QAAO;EACL;EACA;EACA;EACA,GAAI,eAAe,CAAC,GAAG,cAAc,GAAG,GAAG,EAAE;EAC7C,GAAI,UAAU,CAAC,SAAS,UAAU,GAAG,EAAE;EACvC,GAAI,UAAU,CAAC,YAAY,UAAU,GAAG,EAAE;EAC1C,YAAY;EACZ,+BAAc,IAAI,MAAM,EAAC,aAAa;EACvC,CAAC,KAA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,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,KAAK;EACH,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACD,MAAM;EACJ,cAAc;EACd,gBAAgB;EAChB,6BAA6B;EAC9B;CACF;;;;ACxFD,MAAa,uCACX,4BACU;CAGV,MAAM,QAFS,OAAO,KAAK,gBAAgB,CAEtB,MAClB,YACC,gBAAgBC,SAAO,gCACvB,wBACH;AAED,eAAc,OAAO,kBAAkB,0BAA0B;AAEjE,QAAO;;;;;ACfT,MAAa,uBAAuB,aAAa;AAEjD,MAAa,4BACX;;;;ACHF,MAAa,4BAA4B;AACzC,MAAa,sCACX;AAEF,MAAa,wBAAwB;CACnC,aAAa;CACb,MAAM,GAAG,0BAA0B;CACnC,sBAAsB;CACvB;;;;ACRD,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,SAAiB;AAC3B,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC"}
|
package/dist/{NotWaasWalletAccountError-674h4R9F.esm.js → NotWaasWalletAccountError-Cf9lQuha.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as BaseError, P as getDefaultClient, R as getCore, u as createApiClient } from "./InvalidParamError-
|
|
2
|
-
import { r as updateAuthFromVerifyResponse } from "./getVerifiedCredentialForWalletAccount-
|
|
1
|
+
import { L as BaseError, P as getDefaultClient, R as getCore, u as createApiClient } from "./InvalidParamError-BVx-qvip.esm.js";
|
|
2
|
+
import { r as updateAuthFromVerifyResponse } from "./getVerifiedCredentialForWalletAccount-BNiAI52Z.esm.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/user/refreshAuth/refreshAuth.ts
|
|
5
5
|
/**
|
|
@@ -34,4 +34,4 @@ var NotWaasWalletAccountError = class extends BaseError {
|
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
36
|
export { refreshAuth as n, NotWaasWalletAccountError as t };
|
|
37
|
-
//# sourceMappingURL=NotWaasWalletAccountError-
|
|
37
|
+
//# sourceMappingURL=NotWaasWalletAccountError-Cf9lQuha.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotWaasWalletAccountError-
|
|
1
|
+
{"version":3,"file":"NotWaasWalletAccountError-Cf9lQuha.esm.js","names":[],"sources":["../src/modules/user/refreshAuth/refreshAuth.ts","../src/errors/NotWaasWalletAccountError.ts"],"sourcesContent":["import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport { updateAuthFromVerifyResponse } from '../../auth/updateAuthFromVerifyResponse';\n\n/**\n * Refreshes the current user's data from the server.\n *\n * This function fetches the latest user information and token from the backend\n * updating the local user and token states with any changes.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the verify response.\n */\nexport const refreshAuth = async (\n client = getDefaultClient()\n): Promise<VerifyResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const response = await apiClient.refreshAuth({\n environmentId: core.environmentId,\n });\n\n updateAuthFromVerifyResponse({ response }, client);\n\n return response;\n};\n","import { BaseError } from './base';\n\ntype NotWaasWalletAccountErrorParams = {\n walletAddress: string;\n};\n\nexport class NotWaasWalletAccountError extends BaseError {\n constructor({ walletAddress }: NotWaasWalletAccountErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_account_error',\n docsUrl: null,\n name: 'NotWaasWalletAccountError',\n shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,cAAc,OACzB,SAAS,kBAAkB,KACC;CAC5B,MAAM,OAAO,QAAQ,OAAO;CAG5B,MAAM,WAAW,MAFC,gBAAgB,EAAE,EAAE,OAAO,CAEZ,YAAY,EAC3C,eAAe,KAAK,eACrB,CAAC;AAEF,8BAA6B,EAAE,UAAU,EAAE,OAAO;AAElD,QAAO;;;;;ACtBT,IAAa,4BAAb,cAA+C,UAAU;CACvD,YAAY,EAAE,iBAAkD;AAC9D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,kBAAkB,cAAc;GAC/C,CAAC"}
|
package/dist/{NotWaasWalletAccountError-CC0TnXFG.cjs.js → NotWaasWalletAccountError-D-U7HAdA.cjs.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_InvalidParamError = require('./InvalidParamError-
|
|
2
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
1
|
+
const require_InvalidParamError = require('./InvalidParamError-DgN3p6L7.cjs.js');
|
|
2
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-CrCYutAz.cjs.js');
|
|
3
3
|
|
|
4
4
|
//#region src/modules/user/refreshAuth/refreshAuth.ts
|
|
5
5
|
/**
|
|
@@ -45,4 +45,4 @@ Object.defineProperty(exports, 'refreshAuth', {
|
|
|
45
45
|
return refreshAuth;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
//# sourceMappingURL=NotWaasWalletAccountError-
|
|
48
|
+
//# sourceMappingURL=NotWaasWalletAccountError-D-U7HAdA.cjs.js.map
|