@dynamic-labs-sdk/client 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{InvalidParamError-0w8-q2f3.cjs.js → InvalidParamError-6MugNXi3.cjs.js} +3 -3
- package/dist/{InvalidParamError-0w8-q2f3.cjs.js.map → InvalidParamError-6MugNXi3.cjs.js.map} +1 -1
- package/dist/{InvalidParamError-CGBIFNgP.esm.js → InvalidParamError-CnPeSjBW.esm.js} +2 -2
- package/dist/{InvalidParamError-CGBIFNgP.esm.js.map → InvalidParamError-CnPeSjBW.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-CT_IUD-3.esm.js → NotWaasWalletAccountError-B5QkZWrs.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-CT_IUD-3.esm.js.map → NotWaasWalletAccountError-B5QkZWrs.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-CyvI1KtC.cjs.js → NotWaasWalletAccountError-C204z_SH.cjs.js} +3 -3
- package/dist/{NotWaasWalletAccountError-CyvI1KtC.cjs.js.map → NotWaasWalletAccountError-C204z_SH.cjs.js.map} +1 -1
- package/dist/core.cjs.js +5 -5
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +5 -5
- package/dist/core.esm.js.map +1 -1
- package/dist/exports/core.d.ts +1 -1
- package/dist/exports/core.d.ts.map +1 -1
- package/dist/exports/index.d.ts +13 -4
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-KrwFxKlq.cjs.js → getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js} +23 -14
- package/dist/getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-C9PJejYH.esm.js → getNetworkProviderFromNetworkId-VEDzpV8Z.esm.js} +23 -14
- package/dist/getNetworkProviderFromNetworkId-VEDzpV8Z.esm.js.map +1 -0
- package/dist/{getSignedSessionId-Cqp6g3pY.cjs.js → getSignedSessionId-BZL8lFjp.cjs.js} +5 -7
- package/dist/getSignedSessionId-BZL8lFjp.cjs.js.map +1 -0
- package/dist/{getSignedSessionId-DhCbpycv.esm.js → getSignedSessionId-CgoBQlYG.esm.js} +5 -7
- package/dist/{getSignedSessionId-DhCbpycv.esm.js.map → getSignedSessionId-CgoBQlYG.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-BdoPoNic.esm.js → getVerifiedCredentialForWalletAccount-B58hODrW.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-BdoPoNic.esm.js.map → getVerifiedCredentialForWalletAccount-B58hODrW.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js → getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js} +3 -3
- package/dist/{getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js.map → getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js.map} +1 -1
- package/dist/index.cjs.js +162 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +160 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-cPUOtGku.cjs.js → isMfaRequiredForAction-D7amEpqp.cjs.js} +2 -2
- package/dist/{isMfaRequiredForAction-cPUOtGku.cjs.js.map → isMfaRequiredForAction-D7amEpqp.cjs.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-Vo0fCwzo.esm.js → isMfaRequiredForAction-Dkj_caxl.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-Vo0fCwzo.esm.js.map → isMfaRequiredForAction-Dkj_caxl.esm.js.map} +1 -1
- package/dist/modules/auth/events.d.ts +6 -2
- package/dist/modules/auth/events.d.ts.map +1 -1
- package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts +11 -0
- package/dist/modules/auth/handleSessionExpiration/handleSessionExpiration.d.ts.map +1 -0
- package/dist/modules/auth/handleSessionExpiration/index.d.ts +2 -0
- package/dist/modules/auth/handleSessionExpiration/index.d.ts.map +1 -0
- package/dist/modules/auth/logout/logout.d.ts +1 -1
- package/dist/modules/auth/logout/logout.d.ts.map +1 -1
- package/dist/modules/auth/logoutReason.d.ts +11 -0
- package/dist/modules/auth/logoutReason.d.ts.map +1 -0
- package/dist/modules/auth/performLogout/index.d.ts +2 -0
- package/dist/modules/auth/performLogout/index.d.ts.map +1 -0
- package/dist/modules/auth/performLogout/performLogout.d.ts +12 -0
- package/dist/modules/auth/performLogout/performLogout.d.ts.map +1 -0
- package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts +4 -1
- package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts.map +1 -1
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts +2 -2
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -1
- package/dist/modules/sessionKeys/getSignedSessionId/getSignedSessionId.d.ts.map +1 -1
- package/dist/modules/swap/constants.d.ts +2 -0
- package/dist/modules/swap/constants.d.ts.map +1 -0
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts +32 -0
- package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -0
- package/dist/modules/swap/executeSwapTransaction/index.d.ts +3 -0
- package/dist/modules/swap/executeSwapTransaction/index.d.ts.map +1 -0
- package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts +53 -0
- package/dist/modules/swap/getSwapQuote/getSwapQuote.d.ts.map +1 -0
- package/dist/modules/swap/getSwapQuote/index.d.ts +3 -0
- package/dist/modules/swap/getSwapQuote/index.d.ts.map +1 -0
- package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts +23 -0
- package/dist/modules/swap/getSwapStatus/getSwapStatus.d.ts.map +1 -0
- package/dist/modules/swap/getSwapStatus/index.d.ts +3 -0
- package/dist/modules/swap/getSwapStatus/index.d.ts.map +1 -0
- package/dist/modules/swap/swap.types.d.ts +14 -0
- package/dist/modules/swap/swap.types.d.ts.map +1 -0
- package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
- package/dist/modules/waas/waas.types.d.ts +4 -1
- package/dist/modules/waas/waas.types.d.ts.map +1 -1
- package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts +5 -2
- package/dist/modules/wallets/disconnectAndTerminateWalletProviders/disconnectAndTerminateWalletProviders.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/index.d.ts +1 -1
- package/dist/modules/wallets/walletProvider/index.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +17 -8
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
- package/dist/services/keychain/createIndexedDBKeychainService/createIndexedDBKeychainService.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs.js +4 -4
- package/dist/waas.esm.js +3 -3
- package/dist/waasCore.cjs.js +7 -6
- package/dist/waasCore.cjs.js.map +1 -1
- package/dist/waasCore.esm.js +6 -5
- package/dist/waasCore.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/getNetworkProviderFromNetworkId-C9PJejYH.esm.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-KrwFxKlq.cjs.js.map +0 -1
- package/dist/getSignedSessionId-Cqp6g3pY.cjs.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVerifiedCredentialForWalletAccount-Bffr91SM.cjs.js","names":["getDefaultClient","getCore","BaseError","WalletProviderEnum","getCore","getChainFromVerifiedCredentialChain","getChainFromVerifiedCredentialChain","walletAccountsMap: Map<string, WalletAccount>","JwtVerifiedCredentialFormatEnum","getDefaultClient","getCore","BaseError","getCore","getCore","DYNAMIC_WAAS_METADATA","DYNAMIC_WAAS_METADATA","WalletProviderEnum","DYNAMIC_WAAS_METADATA","InvalidParamError","getCore","newState: Partial<DynamicCoreState>","isCookieEnabled","walletProvider"],"sources":["../src/utils/setCookie/setCookie.ts","../src/modules/clientEvents/clientEvents.ts","../src/errors/InvalidWalletProviderKeyError.ts","../src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts","../src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts","../src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts","../src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts","../src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts","../src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts","../src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts","../src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts","../src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts","../src/modules/wallets/getWalletAccounts/getWalletAccounts.ts","../src/errors/NoWalletProviderFoundError.ts","../src/services/runtimeServices/createRuntimeServiceAccessKey/createRuntimeServiceAccessKey.ts","../src/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.ts","../src/modules/wallets/walletProviderRegistry/getWalletProviderRegistry/getWalletProviderRegistry.ts","../src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.ts","../src/modules/wallets/utils/getWalletProviderFromWalletAccount/getWalletProviderFromWalletAccount.ts","../src/modules/auth/consts.ts","../src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts","../src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts","../src/modules/wallets/getWalletProviders/getWalletProviders.ts","../src/modules/waas/isWaasWalletProvider/isWaasWalletProvider.ts","../src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts","../src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts","../src/modules/waas/restoreUserSharesForAllWalletAccounts/restoreUserSharesForAllWalletAccounts.ts","../src/modules/auth/decodeJwt/decodeJwt.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts","../src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts","../src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts","../src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts"],"sourcesContent":["/**\n * Sefelly sets the cookie in the browser.\n * @not-instrumented\n */\nexport const setCookie = (cookie: string) => {\n // eslint-disable-next-line no-restricted-globals\n document.cookie = cookie;\n};\n","import { getCore } from '../../client/core/getCore';\nimport { getDefaultClient } from '../../client/defaultClient';\nimport type { DynamicClient } from '../../client/types';\nimport type {\n DynamicEvents,\n EmitEventParams,\n OffEventParams,\n OnEventParams,\n OnceEventParams,\n} from './clientEvents.types';\n\n/**\n * Adds an event listener for Dynamic client events.\n *\n * This function allows you to listen for various events emitted by the Dynamic client,\n * such as authentication state changes, wallet connections, and more.\n *\n * @param params.event - The event name to listen for.\n * @param params.listener - The callback function to execute when the event is fired.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A function that can be called to remove the listener.\n * @instrumented\n */\nexport const onEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OnEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.on(event, listener);\n\n return () => {\n eventEmitter.off(event, listener);\n };\n};\n\n/**\n * Removes an event listener from Dynamic client events.\n *\n * This function unsubscribes a previously registered event listener\n * from the specified Dynamic client event.\n *\n * @param params.event - The event name to remove the listener from.\n * @param params.listener - The callback function to remove.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @instrumented\n */\nexport const offEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OffEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.off(event, listener);\n};\n\n/**\n * Adds a one-time event listener for Dynamic client events.\n *\n * This function listens for an event that will automatically remove itself\n * after being triggered once.\n *\n * @param params.event - The event name to listen for.\n * @param params.listener - The callback function to execute when the event is fired.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A function that can be called to remove the listener before it fires.\n * @instrumented\n */\nexport const onceEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OnceEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.once(event, listener);\n\n return () => {\n eventEmitter.off(event, listener);\n };\n};\n\n/**\n * Emits a Dynamic client event.\n *\n * This function triggers an event that will be received by all registered\n * listeners for the specified event type.\n *\n * @param params.event - The event name to emit.\n * @param params.args - The arguments to pass to event listeners.\n * @param client - The Dynamic client instance.\n * @not-instrumented\n */\nexport const emitEvent = <E extends keyof DynamicEvents>(\n { event, args }: EmitEventParams<E>,\n client: DynamicClient\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.emit(event, args);\n};\n","import { BaseError } from './base';\n\nexport class InvalidWalletProviderKeyError extends BaseError {\n constructor(value: string) {\n super({\n cause: null,\n code: 'invalid_wallet_provider_key',\n docsUrl: null,\n name: 'InvalidWalletProviderKeyError',\n shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`,\n });\n }\n}\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { InvalidWalletProviderKeyError } from '../../../../errors/InvalidWalletProviderKeyError';\n\ntype SplitWalletProviderKeyResult = {\n normalizedWalletNameWithChain: string;\n suffix: string | undefined;\n walletProviderType: WalletProviderEnum;\n};\n\n/** @not-instrumented */\nexport const splitWalletProviderKey = (\n walletProviderKey: string\n): SplitWalletProviderKeyResult => {\n const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] =\n walletProviderKey.split(':');\n\n if (\n !normalizedWalletNameWithChain ||\n !Object.values(WalletProviderEnum).includes(\n walletProviderType as WalletProviderEnum\n ) ||\n rest.length > 0\n ) {\n throw new InvalidWalletProviderKeyError(walletProviderKey);\n }\n\n return {\n normalizedWalletNameWithChain,\n suffix,\n walletProviderType: walletProviderType as WalletProviderEnum,\n };\n};\n","import type { Chain } from '../../../chain';\n\n/** @not-instrumented */\nexport const normalizeAddress = (address: string, chain: Chain) => {\n let normalizedAddress = address;\n\n if (normalizedAddress?.startsWith('0x')) {\n normalizedAddress = normalizedAddress.slice(2);\n }\n\n /**\n * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md\n * see also: https://github.com/ChainAgnostic/namespaces\n * note: no standard namespace currently exists for flow\n */\n const chainsThatRequireLowercaseAddress: Chain[] = ['EVM', 'FLOW'];\n\n normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain)\n ? normalizedAddress?.toLowerCase()\n : normalizedAddress;\n\n return normalizedAddress;\n};\n","import type { Chain } from '../../../chain';\nimport { splitWalletProviderKey } from '../../walletProvider/splitWalletProviderKey';\nimport { normalizeAddress } from '../normalizeAddress';\n\ntype CreateWalletAccountIdParams = {\n address: string;\n chain: Chain;\n walletProviderKey: string;\n};\n\n/** @not-instrumented */\nexport const formatWalletAccountId = ({\n address,\n chain,\n walletProviderKey,\n}: CreateWalletAccountIdParams): string => {\n const { normalizedWalletNameWithChain } =\n splitWalletProviderKey(walletProviderKey);\n\n const normalizedAddress = normalizeAddress(address, chain);\n\n return `${normalizedWalletNameWithChain}:${normalizedAddress}`;\n};\n","import type { UnverifiedWalletAccount } from '../../unverifiedWalletAccounts';\nimport type { WalletAccount } from '../../walletAccount';\nimport { formatWalletAccountId } from '../formatWalletAccountId';\n\ntype ConvertUnverifiedWalletAccountToWalletAccountParams = {\n unverifiedWalletAccount: UnverifiedWalletAccount;\n};\n\n/** @not-instrumented */\nexport const convertUnverifiedWalletAccountToWalletAccount = ({\n unverifiedWalletAccount,\n}: ConvertUnverifiedWalletAccountToWalletAccountParams): WalletAccount => ({\n address: unverifiedWalletAccount.address,\n addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,\n chain: unverifiedWalletAccount.chain,\n id: formatWalletAccountId({\n address: unverifiedWalletAccount.address,\n chain: unverifiedWalletAccount.chain,\n walletProviderKey: unverifiedWalletAccount.walletProviderKey,\n }),\n lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,\n verifiedCredentialId: null,\n walletProviderKey: unverifiedWalletAccount.walletProviderKey,\n});\n","import type { Chain } from '../../../chain';\n\ntype NormalizeWalletNameWithChainParams = {\n chain: Chain;\n displayName: string;\n};\n\n/**\n * Format the raw wallet name and chain to get the value we can use for\n * verified credentials' `walletName` field.\n * @not-instrumented\n */\nexport const normalizeWalletNameWithChain = ({\n displayName,\n chain,\n}: NormalizeWalletNameWithChainParams): string => {\n const sanitizedWalletName = displayName\n .replace(/[^a-zA-Z0-9]/g, '')\n .toLowerCase();\n\n const chainLowered = chain.toLocaleLowerCase();\n\n if (sanitizedWalletName.endsWith(chainLowered)) {\n return sanitizedWalletName;\n }\n\n return `${sanitizedWalletName}${chainLowered}`;\n};\n","import type { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { Chain } from '../../../chain';\nimport { normalizeWalletNameWithChain } from '../normalizeWalletNameWithChain';\n\ntype FormatWalletProviderKeyParams = {\n chain: Chain;\n displayName: string;\n suffix?: string;\n walletProviderType: WalletProviderEnum;\n};\n\n/**\n * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.\n *\n * The suffix is optional and can be used to add a uniquely identifying string to the key, which\n * might be necessary for some wallet providers (like Wallet Connect).\n *\n * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account\n * to not be able to find its wallet provider when connecting to a new device (it won't be possible\n * to determine the full key just from the Verified Credential data).\n * @not-instrumented\n */\nexport const formatWalletProviderKey = ({\n suffix,\n chain,\n displayName,\n walletProviderType,\n}: FormatWalletProviderKeyParams) => {\n const normalizedNameWithChain = normalizeWalletNameWithChain({\n chain,\n displayName,\n });\n\n return `${normalizedNameWithChain}:${walletProviderType}${\n suffix ? `:${suffix}` : ''\n }`;\n};\n","import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../../client/types';\nimport { assertDefined } from '../../../../../utils/assertDefined';\nimport { getChainFromVerifiedCredentialChain } from '../../../../../utils/getChainFromVerifiedCredentialChain';\nimport { formatWalletProviderKey } from '../../../utils/formatWalletProviderKey';\n\ntype GetWalletProviderKeyFromVerifiedCredentialParams = {\n verifiedCredential: JwtVerifiedCredential;\n};\n\n/** @not-instrumented */\nexport const getWalletProviderKeyFromVerifiedCredential = (\n { verifiedCredential }: GetWalletProviderKeyFromVerifiedCredentialParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const { walletProviderKeyMap } = core.state.get();\n\n const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];\n\n if (storedWalletProviderKey) {\n return { walletProviderKey: storedWalletProviderKey };\n }\n\n /**\n * We fallback to comprising the wallet provider key from walletName and walletProvider.\n *\n * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider\n * keys, so this won't be enough for them.\n * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider\n * and will require reconnection.\n * Read walletProvider.types.ts for more info.\n */\n assertDefined(\n verifiedCredential.walletName,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`\n );\n\n assertDefined(\n verifiedCredential.walletProvider,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`\n );\n\n assertDefined(\n verifiedCredential.chain,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`\n );\n\n /**\n * Historically, walletNames did not include the chain name as a suffix.\n * This piece of logic simply ensures we normalize any legacy walletNames to conform.\n */\n const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);\n\n const walletProviderKey = formatWalletProviderKey({\n chain,\n displayName: verifiedCredential.walletName,\n walletProviderType: verifiedCredential.walletProvider,\n });\n\n return { walletProviderKey };\n};\n","import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { getChainFromVerifiedCredentialChain } from '../../../../utils/getChainFromVerifiedCredentialChain';\nimport type { HardwareWalletVendor } from '../../hardwareWallet/hardwareWallet.types';\nimport type { WalletAccount } from '../../walletAccount';\nimport { getWalletProviderKeyFromVerifiedCredential } from '../../walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential';\nimport { formatWalletAccountId } from '../formatWalletAccountId';\n\ntype ConvertVerifiedCredentialToWalletAccountParams = {\n verifiedCredential: JwtVerifiedCredential;\n};\n\n/** @not-instrumented */\nexport const convertVerifiedCredentialToWalletAccount = (\n { verifiedCredential }: ConvertVerifiedCredentialToWalletAccountParams,\n client: DynamicClient\n): WalletAccount => {\n assertDefined(\n verifiedCredential.address,\n 'Missing address in verified credential'\n );\n assertDefined(\n verifiedCredential.chain,\n 'Missing chain in verified credential'\n );\n\n const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);\n\n const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential(\n {\n verifiedCredential,\n },\n client\n );\n\n const walletAccountId = formatWalletAccountId({\n address: verifiedCredential.address,\n chain,\n walletProviderKey,\n });\n\n return {\n address: verifiedCredential.address,\n addressesWithTypes: verifiedCredential.walletAdditionalAddresses,\n chain,\n hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet as\n | HardwareWalletVendor\n | undefined,\n id: walletAccountId,\n lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,\n verifiedCredentialId: verifiedCredential.id,\n walletProviderKey,\n };\n};\n","import type { SdkUser } from '@dynamic-labs/sdk-api-core';\nimport { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport type { UnverifiedWalletAccount } from '../../unverifiedWalletAccounts';\nimport { convertUnverifiedWalletAccountToWalletAccount } from '../../utils/convertUnverifiedWalletAccountToWalletAccount';\nimport { convertVerifiedCredentialToWalletAccount } from '../../utils/convertVerifiedCredentialToWalletAccount';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetWalletAccountsFromStateParams = {\n unverifiedWalletAccounts: UnverifiedWalletAccount[];\n user: SdkUser | null;\n};\n\n/** @not-instrumented */\nexport const getWalletAccountsFromState = (\n { unverifiedWalletAccounts, user }: GetWalletAccountsFromStateParams,\n client: DynamicClient\n): WalletAccount[] => {\n const walletAccountsMap: Map<string, WalletAccount> = new Map();\n\n /**\n * Handle the unverified wallet accounts before the user verified credentials\n * so the later verified wallet accounts can override the unverified wallet accounts\n */\n unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {\n const walletAccount = convertUnverifiedWalletAccountToWalletAccount({\n unverifiedWalletAccount,\n });\n\n walletAccountsMap.set(walletAccount.id, walletAccount);\n });\n\n /**\n * Handle user verified credentials\n */\n const verifiedCredentials = user?.verifiedCredentials ?? [];\n\n verifiedCredentials\n .filter(\n (verified) =>\n verified.format === JwtVerifiedCredentialFormatEnum.Blockchain\n )\n .forEach((verifiedWalletAccount) => {\n const walletAccount = convertVerifiedCredentialToWalletAccount(\n {\n verifiedCredential: verifiedWalletAccount,\n },\n client\n );\n\n walletAccountsMap.set(walletAccount.id, walletAccount);\n });\n\n return Array.from(walletAccountsMap.values());\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../walletAccount';\nimport { getWalletAccountsFromState } from './getWalletAccountsFromState';\n\n/**\n * Retrieves all wallet accounts associated with the current session.\n *\n * This function returns both verified and unverified wallet accounts,\n * combining data from user credentials and local unverified accounts.\n * You can differentiate between verified and unverified wallet accounts by\n * checking the `verifiedCredentialId` property.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An array of wallet accounts associated with the session.\n * @instrumented\n */\nexport const getWalletAccounts = (\n client = getDefaultClient()\n): WalletAccount[] => {\n const core = getCore(client);\n const { unverifiedWalletAccounts, user } = core.state.get();\n\n return getWalletAccountsFromState({ unverifiedWalletAccounts, user }, client);\n};\n","import { BaseError } from './base';\n\ntype NoWalletProviderFoundErrorParams = {\n walletProviderKey: string;\n};\n\nexport class NoWalletProviderFoundError extends BaseError {\n constructor({ walletProviderKey }: NoWalletProviderFoundErrorParams) {\n super({\n cause: null,\n code: 'no_wallet_provider_found_error',\n docsUrl: null,\n name: 'NoWalletProviderFoundError',\n shortMessage: `No wallet provider found with key: ${walletProviderKey}`,\n });\n }\n}\n","import type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { getCore } from '../../../client/core/getCore';\n\n/**\n * Creates a service accessor function that manages service instantiation and caching.\n * The returned function will either retrieve an existing service from the registry or\n * create a new one using the provided builder function.\n *\n * @template - The type of service to be created/accessed\n * @param key - Unique identifier for the service in the registry\n * @param builder - Function that creates the service instance when called with a DynamicClient\n * @instrumented\n */\nexport const createRuntimeServiceAccessKey =\n <T>(key: string, builder: (client: DynamicClient) => T) =>\n (client: DynamicClient): T => {\n const { runtimeServices } = getCore(client);\n\n const currentService = runtimeServices.getByKey<T>(key);\n\n if (currentService) {\n return currentService;\n }\n\n const service = builder(client);\n\n runtimeServices.register(key, service);\n\n return service;\n };\n","import type { DynamicClient } from '../../../../client/types';\nimport { emitEvent } from '../../../clientEvents';\nimport type { WalletProvider } from '../../walletProvider/walletProvider.types';\nimport type { WalletProviderRegistry } from '../walletProviderRegistry.types';\n\n/**\n * Creates a new wallet provider registry that manages wallet providers with priority-based registration.\n *\n * @returns The wallet provider registry instance\n *\n * @example\n * ```typescript\n * const registry = createWalletProviderRegistry();\n *\n * registry.register({\n * priority: WalletProviderPriority.WALLET_SDK,\n * walletProvider: myWalletProvider\n * });\n *\n * const provider = registry.getByKey('my-wallet-key');\n * const providers = registry.listProviders();\n * ```\n * @not-instrumented\n */\nexport const createWalletProviderRegistry = (\n client: DynamicClient\n): WalletProviderRegistry => {\n const registry = new Map<\n string,\n { priority: number; walletProvider: WalletProvider }\n >();\n\n return {\n getByKey: (key) => registry.get(key)?.walletProvider,\n listProviders: () =>\n Array.from(registry.values()).map((v) => v.walletProvider),\n register: (args) => {\n const existingEntry = registry.get(args.walletProvider.key);\n\n if (existingEntry) {\n if (existingEntry.priority < args.priority) {\n registry.set(args.walletProvider.key, args);\n\n emitEvent(\n {\n args: { walletProviderKey: args.walletProvider.key },\n event: 'walletProviderChanged',\n },\n client\n );\n }\n } else {\n registry.set(args.walletProvider.key, args);\n\n emitEvent(\n {\n args: { walletProvider: args.walletProvider },\n event: 'walletProviderRegistered',\n },\n client\n );\n\n emitEvent(\n {\n args: { walletProviderKey: args.walletProvider.key },\n event: 'walletProviderChanged',\n },\n client\n );\n }\n },\n unregister: (key) => {\n registry.delete(key);\n\n emitEvent(\n {\n args: { walletProviderKey: key },\n event: 'walletProviderUnregistered',\n },\n client\n );\n },\n };\n};\n","import { createRuntimeServiceAccessKey } from '../../../../services/runtimeServices';\nimport { createWalletProviderRegistry } from '../createWalletProviderRegistry';\n\n/**\n * This function provides access to a shared instance of the wallet provider registry.\n *\n * It ensures that the same registry instance is used throughout the client to maintaining\n * consistency of registered wallet providers across different parts of the codebase.\n *\n * @returns The wallet provider registry instance\n *\n * @example\n * ```typescript\n * // Get the registry instance\n * const registry = getWalletProviderRegistry();\n *\n * // Register a wallet provider\n * registry.register({\n * priority: WalletProviderPriority.WALLET_SDK,\n * walletProvider: myWalletProvider\n * });\n *\n * // Retrieve a specific provider\n * const provider = registry.getByKey('metamaskevm');\n * ```\n */\nexport const getWalletProviderRegistry = createRuntimeServiceAccessKey(\n 'walletProviderRegistry',\n (client) => createWalletProviderRegistry(client)\n);\n","import type { WalletProvider } from '../walletProvider/walletProvider.types';\n\nexport enum WalletProviderPriority {\n /**\n * Highest priority should be used by wallet providers that implement\n * the most reliable wallet integration.\n * example: The SDK provided by the wallet provider.\n */\n WALLET_SDK = 100,\n /**\n * Medium priority should be used by wallet providers that implement\n * a wallet integration via some reliable standard.\n * example: A wallet provider that uses EIP6963 announcement.\n */\n WALLET_SELF_ANNOUNCEMENT_STANDARD = 50,\n /**\n * Low priority should be used by wallet providers that implement\n * a wallet integration on a less reliable standard.\n * example: A wallet provider that uses window.ethereum, where the\n * window key can be overridden by other extensions.\n */\n WINDOW_INJECT = 20,\n}\n\nexport type WalletProviderRegistry = {\n /**\n * Retrieves a wallet provider by its key.\n * @param key - The key of the wallet provider.\n * @returns The wallet provider.\n */\n getByKey: (key: string) => WalletProvider | undefined;\n /**\n * Retrieves all wallet providers.\n * @returns The wallet providers.\n */\n listProviders: () => WalletProvider[];\n /**\n * Registers a wallet provider.\n * @param args - The arguments for the wallet provider.\n */\n register: (args: {\n priority: WalletProviderPriority;\n walletProvider: WalletProvider;\n }) => void;\n /**\n * Unregisters a wallet provider.\n * @param key - The key of the wallet provider.\n */\n unregister: (key: string) => void;\n};\n","import type { DynamicClient } from '../../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../../errors/NoWalletProviderFoundError';\nimport type { WalletAccount } from '../../walletAccount';\nimport { getWalletProviderRegistry } from '../../walletProviderRegistry';\n\ntype GetWalletProviderFromWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @instrumented */\nexport const getWalletProviderFromWalletAccount = (\n { walletAccount }: GetWalletProviderFromWalletAccountParams,\n client: DynamicClient\n) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = walletProviderRegistry.getByKey(\n walletAccount.walletProviderKey\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({\n walletProviderKey: walletAccount.walletProviderKey,\n });\n }\n\n return walletProvider;\n};\n","export const DYNAMIC_AUTH_COOKIE_NAME = 'DYNAMIC_JWT_TOKEN';\n","import type { DynamicClient } from '../../../client/types';\nimport { emitEvent } from '../../clientEvents';\nimport { getWalletAccounts } from '../getWalletAccounts';\n\n/**\n * Emits the `walletAccountsChanged` event.\n * @not-instrumented\n */\nexport const emitWalletAccountsChangedEvent = (client: DynamicClient): void => {\n const walletAccounts = getWalletAccounts(client);\n\n emitEvent(\n {\n args: { walletAccounts },\n event: 'walletAccountsChanged',\n },\n client\n );\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { emitWalletAccountsChangedEvent } from '../../../wallets/emitWalletAccountsChangedEvent';\nimport { getWalletAccountsFromState } from '../../../wallets/getWalletAccounts/getWalletAccountsFromState';\n\ntype CheckAndRaiseWalletAccountsChangedEventParams = {\n previousState: Readonly<DynamicCoreState>;\n};\n\n/** @not-instrumented */\nexport const checkAndRaiseWalletAccountsChangedEvent = (\n { previousState }: CheckAndRaiseWalletAccountsChangedEventParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const walletAccountsHashBefore = getWalletAccountsHash(previousState, client);\n\n const walletAccountsHashAfter = getWalletAccountsHash(\n core.state.get(),\n client\n );\n\n if (walletAccountsHashBefore !== walletAccountsHashAfter) {\n emitWalletAccountsChangedEvent(client);\n }\n};\n\nconst getWalletAccountsHash = (\n state: Readonly<DynamicCoreState>,\n client: DynamicClient\n) =>\n getWalletAccountsFromState(state, client)\n .map((walletAccount) => JSON.stringify(walletAccount))\n .sort()\n .join('-');\n","import type { DynamicClient } from '../../../client/types';\nimport { getWalletProviderRegistry } from '../walletProviderRegistry';\n\n/**\n * Get all available wallet providers to interact with internally.\n * @instrumented\n */\nexport const getWalletProviders = (client: DynamicClient) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n return walletProviderRegistry.listProviders();\n};\n","import type { WalletProvider } from '../../wallets/walletProvider';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport type { WaasWalletProvider } from '../waas.types';\n\n/** @not-instrumented */\nexport const isWaasWalletProvider = (\n walletProvider: WalletProvider\n): walletProvider is WaasWalletProvider => {\n return walletProvider.key.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { Chain } from '../../chain';\nimport { getWalletProviders } from '../../wallets/getWalletProviders';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport type { WaasWalletProvider } from '../waas.types';\n\ntype FindWaasWalletProviderByChainParams = {\n chain: Chain;\n};\n\n/** @not-instrumented */\nexport const findWaasWalletProviderByChain = (\n { chain }: FindWaasWalletProviderByChainParams,\n client: DynamicClient\n): WaasWalletProvider | null => {\n const providers = getWalletProviders(client);\n\n const waasProviderKey = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n const waasProvider = providers.find(\n (provider) => provider.key === waasProviderKey && provider.chain === chain\n );\n\n if (!waasProvider || !isWaasWalletProvider(waasProvider)) {\n return null;\n }\n\n return waasProvider;\n};\n","import type { WalletAccount } from '../../wallets/walletAccount';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\n\ntype IsWaasWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * This function determines whether the provided wallet account is a Dynamic\n * WaaS wallet account.\n *\n * @param params.walletAccount - The wallet account to check.\n * @returns True if the wallet account is a WaaS wallet account, false otherwise.\n * @not-instrumented\n */\nexport const isWaasWalletAccount = ({\n walletAccount,\n}: IsWaasWalletAccountParams): boolean => {\n return walletAccount.walletProviderKey.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain';\nimport { isWaasWalletAccount } from '../isWaasWalletAccount';\n\n/** @not-instrumented */\nexport const restoreUserSharesForAllWalletAccounts = async (\n client: DynamicClient\n) => {\n const walletAccounts = getWalletAccounts(client);\n\n const waasWalletAccounts = walletAccounts.filter((walletAccount) =>\n isWaasWalletAccount({ walletAccount })\n );\n\n await Promise.all(\n waasWalletAccounts.map(async (walletAccount) => {\n const provider = findWaasWalletProviderByChain(\n { chain: walletAccount.chain },\n client\n );\n\n /**\n * The environment might not have the embedded wallet extensions installed.\n * In that case there is no provider for the chain and we can skip restoring the user share.\n */\n if (!provider) return;\n\n return provider.restoreUserShareForWalletAccount({ walletAccount });\n })\n );\n};\n","import { InvalidParamError } from '../../../errors/InvalidParamError';\n\nexport type JwtPayload = {\n [key: string]: unknown;\n exp: number;\n iat: number;\n scope: string;\n singleUse?: boolean;\n sub: string;\n};\n\n/**\n * Decodes a JWT token and returns the full payload.\n *\n * This function extracts and returns the complete JWT payload including scopes,\n * expiration time, and other claims.\n *\n * @param jwt - The JWT token string.\n * @returns The decoded JWT payload object.\n * @throws InvalidParamError if the token is invalid or cannot be decoded.\n *\n * @example\n * ```typescript\n * const payload = decodeJwt(jwt);\n * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }\n * ```\n * @not-instrumented\n */\nexport const decodeJwt = (jwt: string): JwtPayload => {\n try {\n // JWT format: header.payload.signature\n const parts = jwt.split('.');\n if (parts.length !== 3) {\n throw new InvalidParamError('Invalid JWT format');\n }\n\n // Decode the payload (second part)\n // Base64URL decode: replace URL-safe characters and decode\n const base64Payload = parts[1].replaceAll('-', '+').replaceAll('_', '/');\n // Add padding if needed\n const paddedPayload =\n base64Payload + '='.repeat((4 - (base64Payload.length % 4)) % 4);\n const decodedPayload = atob(paddedPayload);\n const claims = JSON.parse(decodedPayload) as JwtPayload;\n\n return claims;\n } catch (error) {\n if (error instanceof InvalidParamError) {\n throw error;\n }\n throw new InvalidParamError(\n `Failed to decode JWT: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n};\n","/**\n * Normalizes scopes by deduplicating and sorting them.\n * This creates a canonical representation for comparison.\n *\n * @param scopes - Array of scope strings (may contain duplicates)\n * @returns Normalized, sorted array of unique scopes\n * @not-instrumented\n */\nexport const normalizeScopes = (scopes: string[]): string[] => {\n return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));\n};\n","import { decodeJwt } from '../../../decodeJwt';\nimport type { ParsedElevatedAccessToken } from '../elevatedAccessTokens.types';\nimport { normalizeScopes } from '../normalizeScopes';\n\n/**\n * Validates and parses an elevated access token from a JWT string.\n * Extracts scopes, expiration, and validates the token structure.\n *\n * Policy decisions:\n * - Tokens without scopes are rejected (returns null)\n * - Tokens with empty scopes array are rejected (returns null)\n * - Tokens without exp field are rejected (returns null)\n * - Expired tokens are rejected (returns null)\n *\n * @param token - JWT string containing the elevated access token\n * @param now - Current date for expiration validation (defaults to new Date())\n * @returns Parsed token data or null if token is invalid/expired\n * @not-instrumented\n */\nexport const parseElevatedAccessToken = (\n token: string,\n now: Date = new Date()\n): ParsedElevatedAccessToken | null => {\n const payload = decodeJwt(token);\n const rawScopeClaim = payload?.scope;\n const processedScopes = rawScopeClaim?.split(' ') ?? [];\n const filteredScopes = processedScopes.filter((s) => s.length > 0);\n const singleUse = payload.singleUse ?? false;\n\n // Reject tokens without scopes or with empty scopes\n if (!filteredScopes || filteredScopes.length === 0) {\n return null;\n }\n\n // Reject tokens without exp field\n if (!payload.exp) {\n return null;\n }\n\n // Convert exp (seconds) to Date (milliseconds)\n const expiresAt = new Date(payload.exp * 1000);\n\n // Reject expired tokens\n if (expiresAt <= now) {\n return null;\n }\n\n return {\n expiresAt,\n normalizedScopes: normalizeScopes(filteredScopes),\n scopes: filteredScopes,\n singleUse,\n token,\n };\n};\n","import type {\n ElevatedAccessToken,\n ParsedElevatedAccessToken,\n} from '../elevatedAccessTokens.types';\nimport { normalizeScopes } from '../normalizeScopes';\n\n/**\n * Upserts an elevated access token into the current tokens array.\n *\n * Policy: Only one token per normalized scope-set is allowed.\n * If a token with the same normalized scopes exists, it is replaced.\n * This ensures we don't accumulate multiple tokens for the same scope combination.\n *\n * @param currentTokens - Current array of elevated access tokens\n * @param newToken - New token to upsert\n * @returns Updated array of tokens with the new token upserted\n * @not-instrumented\n */\nexport const upsertElevatedAccessToken = ({\n currentTokens,\n newToken,\n}: {\n currentTokens: ElevatedAccessToken[];\n newToken: ParsedElevatedAccessToken;\n}): ElevatedAccessToken[] => {\n const newScopeKey = normalizeScopes(newToken.scopes).join(' ');\n\n // Remove any existing token with the same normalized scopes\n const filteredTokens = currentTokens.filter((existingToken) => {\n const existingScopeKey = normalizeScopes(existingToken.scopes).join(' ');\n return existingScopeKey !== newScopeKey;\n });\n\n // Add the new token\n return [\n ...filteredTokens,\n {\n expiresAt: newToken.expiresAt,\n scopes: newToken.scopes,\n singleUse: newToken.singleUse,\n token: newToken.token,\n },\n ];\n};\n","import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicCoreState } from '../../../client/core/types';\nimport type { DynamicClient } from '../../../client/types';\nimport { setCookie } from '../../../utils/setCookie';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { restoreUserSharesForAllWalletAccounts } from '../../waas/restoreUserSharesForAllWalletAccounts';\nimport { DYNAMIC_AUTH_COOKIE_NAME } from '../consts';\nimport { checkAndRaiseWalletAccountsChangedEvent } from './checkAndRaiseWalletAccountsChangedEvent';\nimport { parseElevatedAccessToken } from './elevatedAccessTokens/parseElevatedAccessToken';\nimport { upsertElevatedAccessToken } from './elevatedAccessTokens/upsertElevatedAccessToken';\n\ntype UpdateAuthFromVerifyResponseParams = {\n response: VerifyResponse;\n};\n\n/** @instrumented */\nexport const updateAuthFromVerifyResponse = (\n { response }: UpdateAuthFromVerifyResponseParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const previousState = { ...core.state.get() };\n\n const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } =\n response;\n\n // Expires at is in seconds, so we need to convert it to milliseconds\n const sessionExpiresAt = new Date(expiresAt * 1000);\n\n const newState: Partial<DynamicCoreState> = {\n legacyToken: jwt ?? null,\n sessionExpiresAt: sessionExpiresAt,\n token: minifiedJwt ?? null,\n user,\n };\n\n // only override the mfaToken if a new one is provided in the response\n if (mfaToken) {\n newState.mfaToken = mfaToken;\n }\n\n // Add elevated access token to the array if a new one is provided in the response\n // Policy: Only one token per normalized scope-set is allowed (old tokens are replaced)\n // Always preserve existing tokens to ensure they're synced to storage\n const currentTokens = core.state.get().elevatedAccessTokens || [];\n newState.elevatedAccessTokens = currentTokens;\n \n if (elevatedAccessToken) {\n const parsedToken = parseElevatedAccessToken(elevatedAccessToken);\n if (parsedToken) {\n newState.elevatedAccessTokens = upsertElevatedAccessToken({\n currentTokens,\n newToken: parsedToken,\n });\n }\n }\n\n core.state.set(newState);\n\n /**\n * For customers using a sandbox environment with cookies enabled, we need to set the cookie\n * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically\n * so customers can access the cookie from document.cookie consistently between sandbox and live environments.\n */\n if (minifiedJwt && isCookieEnabled(client)) {\n const expireDate = sessionExpiresAt.toUTCString();\n\n setCookie(\n `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`\n );\n }\n\n checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);\n\n // if the user is logging in, we should restore user shares\n // for all wallet accounts for performance reasons\n const isUserLoggingIn = !previousState.user && Boolean(newState.user);\n if (isUserLoggingIn) {\n void restoreUserSharesForAllWalletAccounts(client);\n }\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { getWalletProviders } from '../getWalletProviders';\n\ntype GetWalletProviderByKeyParams = {\n walletProviderKey: string;\n};\n\n/** @not-instrumented */\nexport const getWalletProviderByKey = (\n { walletProviderKey }: GetWalletProviderByKeyParams,\n client: DynamicClient\n) => {\n const walletProviders = getWalletProviders(client);\n\n const walletProvider = walletProviders.find(\n (walletProvider) => walletProvider.key === walletProviderKey\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({ walletProviderKey });\n }\n\n return walletProvider;\n};\n","import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetVerifiedCredentialForWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @instrumented */\nexport const getVerifiedCredentialForWalletAccount = (\n { walletAccount }: GetVerifiedCredentialForWalletAccountParams,\n client: DynamicClient\n) => {\n return client.user?.verifiedCredentials.find(\n (vc) => vc.id === walletAccount.verifiedCredentialId\n );\n};\n"],"mappings":";;;;;;;;;AAIA,MAAa,aAAa,WAAmB;AAE3C,UAAS,SAAS;;;;;;;;;;;;;;;;;ACiBpB,MAAa,WACX,EAAE,OAAO,YACT,SAASA,4CAAkB,KACxB;CACH,MAAM,EAAE,iBAAiBC,kCAAQ,OAAO;AAExC,cAAa,GAAG,OAAO,SAAS;AAEhC,cAAa;AACX,eAAa,IAAI,OAAO,SAAS;;;;;;;;;;;;;;AAerC,MAAa,YACX,EAAE,OAAO,YACT,SAASD,4CAAkB,KACxB;CACH,MAAM,EAAE,iBAAiBC,kCAAQ,OAAO;AAExC,cAAa,IAAI,OAAO,SAAS;;;;;;;;;;;;;;AAenC,MAAa,aACX,EAAE,OAAO,YACT,SAASD,4CAAkB,KACxB;CACH,MAAM,EAAE,iBAAiBC,kCAAQ,OAAO;AAExC,cAAa,KAAK,OAAO,SAAS;AAElC,cAAa;AACX,eAAa,IAAI,OAAO,SAAS;;;;;;;;;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ultClient","getCore","BaseError","WalletProviderEnum","getCore","getChainFromVerifiedCredentialChain","getChainFromVerifiedCredentialChain","walletAccountsMap: Map<string, WalletAccount>","JwtVerifiedCredentialFormatEnum","getDefaultClient","getCore","BaseError","getCore","getCore","DYNAMIC_WAAS_METADATA","DYNAMIC_WAAS_METADATA","WalletProviderEnum","DYNAMIC_WAAS_METADATA","InvalidParamError","getCore","newState: Partial<DynamicCoreState>","isCookieEnabled","walletProvider"],"sources":["../src/utils/setCookie/setCookie.ts","../src/modules/clientEvents/clientEvents.ts","../src/errors/InvalidWalletProviderKeyError.ts","../src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts","../src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts","../src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts","../src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts","../src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts","../src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts","../src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts","../src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts","../src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts","../src/modules/wallets/getWalletAccounts/getWalletAccounts.ts","../src/errors/NoWalletProviderFoundError.ts","../src/services/runtimeServices/createRuntimeServiceAccessKey/createRuntimeServiceAccessKey.ts","../src/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.ts","../src/modules/wallets/walletProviderRegistry/getWalletProviderRegistry/getWalletProviderRegistry.ts","../src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.ts","../src/modules/wallets/utils/getWalletProviderFromWalletAccount/getWalletProviderFromWalletAccount.ts","../src/modules/auth/consts.ts","../src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts","../src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts","../src/modules/wallets/getWalletProviders/getWalletProviders.ts","../src/modules/waas/isWaasWalletProvider/isWaasWalletProvider.ts","../src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts","../src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts","../src/modules/waas/restoreUserSharesForAllWalletAccounts/restoreUserSharesForAllWalletAccounts.ts","../src/modules/auth/decodeJwt/decodeJwt.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts","../src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts","../src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts","../src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts","../src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts"],"sourcesContent":["/**\n * Sefelly sets the cookie in the browser.\n * @not-instrumented\n */\nexport const setCookie = (cookie: string) => {\n // eslint-disable-next-line no-restricted-globals\n document.cookie = cookie;\n};\n","import { getCore } from '../../client/core/getCore';\nimport { getDefaultClient } from '../../client/defaultClient';\nimport type { DynamicClient } from '../../client/types';\nimport type {\n DynamicEvents,\n EmitEventParams,\n OffEventParams,\n OnEventParams,\n OnceEventParams,\n} from './clientEvents.types';\n\n/**\n * Adds an event listener for Dynamic client events.\n *\n * This function allows you to listen for various events emitted by the Dynamic client,\n * such as authentication state changes, wallet connections, and more.\n *\n * @param params.event - The event name to listen for.\n * @param params.listener - The callback function to execute when the event is fired.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A function that can be called to remove the listener.\n * @instrumented\n */\nexport const onEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OnEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.on(event, listener);\n\n return () => {\n eventEmitter.off(event, listener);\n };\n};\n\n/**\n * Removes an event listener from Dynamic client events.\n *\n * This function unsubscribes a previously registered event listener\n * from the specified Dynamic client event.\n *\n * @param params.event - The event name to remove the listener from.\n * @param params.listener - The callback function to remove.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @instrumented\n */\nexport const offEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OffEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.off(event, listener);\n};\n\n/**\n * Adds a one-time event listener for Dynamic client events.\n *\n * This function listens for an event that will automatically remove itself\n * after being triggered once.\n *\n * @param params.event - The event name to listen for.\n * @param params.listener - The callback function to execute when the event is fired.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A function that can be called to remove the listener before it fires.\n * @instrumented\n */\nexport const onceEvent = <E extends keyof DynamicEvents>(\n { event, listener }: OnceEventParams<E>,\n client = getDefaultClient()\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.once(event, listener);\n\n return () => {\n eventEmitter.off(event, listener);\n };\n};\n\n/**\n * Emits a Dynamic client event.\n *\n * This function triggers an event that will be received by all registered\n * listeners for the specified event type.\n *\n * @param params.event - The event name to emit.\n * @param params.args - The arguments to pass to event listeners.\n * @param client - The Dynamic client instance.\n * @not-instrumented\n */\nexport const emitEvent = <E extends keyof DynamicEvents>(\n { event, args }: EmitEventParams<E>,\n client: DynamicClient\n) => {\n const { eventEmitter } = getCore(client);\n\n eventEmitter.emit(event, args);\n};\n","import { BaseError } from './base';\n\nexport class InvalidWalletProviderKeyError extends BaseError {\n constructor(value: string) {\n super({\n cause: null,\n code: 'invalid_wallet_provider_key',\n docsUrl: null,\n name: 'InvalidWalletProviderKeyError',\n shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`,\n });\n }\n}\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { InvalidWalletProviderKeyError } from '../../../../errors/InvalidWalletProviderKeyError';\n\ntype SplitWalletProviderKeyResult = {\n normalizedWalletNameWithChain: string;\n suffix: string | undefined;\n walletProviderType: WalletProviderEnum;\n};\n\n/** @not-instrumented */\nexport const splitWalletProviderKey = (\n walletProviderKey: string\n): SplitWalletProviderKeyResult => {\n const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] =\n walletProviderKey.split(':');\n\n if (\n !normalizedWalletNameWithChain ||\n !Object.values(WalletProviderEnum).includes(\n walletProviderType as WalletProviderEnum\n ) ||\n rest.length > 0\n ) {\n throw new InvalidWalletProviderKeyError(walletProviderKey);\n }\n\n return {\n normalizedWalletNameWithChain,\n suffix,\n walletProviderType: walletProviderType as WalletProviderEnum,\n };\n};\n","import type { Chain } from '../../../chain';\n\n/** @not-instrumented */\nexport const normalizeAddress = (address: string, chain: Chain) => {\n let normalizedAddress = address;\n\n if (normalizedAddress?.startsWith('0x')) {\n normalizedAddress = normalizedAddress.slice(2);\n }\n\n /**\n * These are standard from CAIP-2: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md\n * see also: https://github.com/ChainAgnostic/namespaces\n * note: no standard namespace currently exists for flow\n */\n const chainsThatRequireLowercaseAddress: Chain[] = ['EVM', 'FLOW'];\n\n normalizedAddress = chainsThatRequireLowercaseAddress.includes(chain)\n ? normalizedAddress?.toLowerCase()\n : normalizedAddress;\n\n return normalizedAddress;\n};\n","import type { Chain } from '../../../chain';\nimport { splitWalletProviderKey } from '../../walletProvider/splitWalletProviderKey';\nimport { normalizeAddress } from '../normalizeAddress';\n\ntype CreateWalletAccountIdParams = {\n address: string;\n chain: Chain;\n walletProviderKey: string;\n};\n\n/** @not-instrumented */\nexport const formatWalletAccountId = ({\n address,\n chain,\n walletProviderKey,\n}: CreateWalletAccountIdParams): string => {\n const { normalizedWalletNameWithChain } =\n splitWalletProviderKey(walletProviderKey);\n\n const normalizedAddress = normalizeAddress(address, chain);\n\n return `${normalizedWalletNameWithChain}:${normalizedAddress}`;\n};\n","import type { UnverifiedWalletAccount } from '../../unverifiedWalletAccounts';\nimport type { WalletAccount } from '../../walletAccount';\nimport { formatWalletAccountId } from '../formatWalletAccountId';\n\ntype ConvertUnverifiedWalletAccountToWalletAccountParams = {\n unverifiedWalletAccount: UnverifiedWalletAccount;\n};\n\n/** @not-instrumented */\nexport const convertUnverifiedWalletAccountToWalletAccount = ({\n unverifiedWalletAccount,\n}: ConvertUnverifiedWalletAccountToWalletAccountParams): WalletAccount => ({\n address: unverifiedWalletAccount.address,\n addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,\n chain: unverifiedWalletAccount.chain,\n id: formatWalletAccountId({\n address: unverifiedWalletAccount.address,\n chain: unverifiedWalletAccount.chain,\n walletProviderKey: unverifiedWalletAccount.walletProviderKey,\n }),\n lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,\n verifiedCredentialId: null,\n walletProviderKey: unverifiedWalletAccount.walletProviderKey,\n});\n","import type { Chain } from '../../../chain';\n\ntype NormalizeWalletNameWithChainParams = {\n chain: Chain;\n displayName: string;\n};\n\n/**\n * Format the raw wallet name and chain to get the value we can use for\n * verified credentials' `walletName` field.\n * @not-instrumented\n */\nexport const normalizeWalletNameWithChain = ({\n displayName,\n chain,\n}: NormalizeWalletNameWithChainParams): string => {\n const sanitizedWalletName = displayName\n .replace(/[^a-zA-Z0-9]/g, '')\n .toLowerCase();\n\n const chainLowered = chain.toLocaleLowerCase();\n\n if (sanitizedWalletName.endsWith(chainLowered)) {\n return sanitizedWalletName;\n }\n\n return `${sanitizedWalletName}${chainLowered}`;\n};\n","import type { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { Chain } from '../../../chain';\nimport { normalizeWalletNameWithChain } from '../normalizeWalletNameWithChain';\n\ntype FormatWalletProviderKeyParams = {\n chain: Chain;\n displayName: string;\n suffix?: string;\n walletProviderType: WalletProviderEnum;\n};\n\n/**\n * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.\n *\n * The suffix is optional and can be used to add a uniquely identifying string to the key, which\n * might be necessary for some wallet providers (like Wallet Connect).\n *\n * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account\n * to not be able to find its wallet provider when connecting to a new device (it won't be possible\n * to determine the full key just from the Verified Credential data).\n * @not-instrumented\n */\nexport const formatWalletProviderKey = ({\n suffix,\n chain,\n displayName,\n walletProviderType,\n}: FormatWalletProviderKeyParams) => {\n const normalizedNameWithChain = normalizeWalletNameWithChain({\n chain,\n displayName,\n });\n\n return `${normalizedNameWithChain}:${walletProviderType}${\n suffix ? `:${suffix}` : ''\n }`;\n};\n","import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../../client/types';\nimport { assertDefined } from '../../../../../utils/assertDefined';\nimport { getChainFromVerifiedCredentialChain } from '../../../../../utils/getChainFromVerifiedCredentialChain';\nimport { formatWalletProviderKey } from '../../../utils/formatWalletProviderKey';\n\ntype GetWalletProviderKeyFromVerifiedCredentialParams = {\n verifiedCredential: JwtVerifiedCredential;\n};\n\n/** @not-instrumented */\nexport const getWalletProviderKeyFromVerifiedCredential = (\n { verifiedCredential }: GetWalletProviderKeyFromVerifiedCredentialParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const { walletProviderKeyMap } = core.state.get();\n\n const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];\n\n if (storedWalletProviderKey) {\n return { walletProviderKey: storedWalletProviderKey };\n }\n\n /**\n * We fallback to comprising the wallet provider key from walletName and walletProvider.\n *\n * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider\n * keys, so this won't be enough for them.\n * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider\n * and will require reconnection.\n * Read walletProvider.types.ts for more info.\n */\n assertDefined(\n verifiedCredential.walletName,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`\n );\n\n assertDefined(\n verifiedCredential.walletProvider,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`\n );\n\n assertDefined(\n verifiedCredential.chain,\n `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`\n );\n\n /**\n * Historically, walletNames did not include the chain name as a suffix.\n * This piece of logic simply ensures we normalize any legacy walletNames to conform.\n */\n const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);\n\n const walletProviderKey = formatWalletProviderKey({\n chain,\n displayName: verifiedCredential.walletName,\n walletProviderType: verifiedCredential.walletProvider,\n });\n\n return { walletProviderKey };\n};\n","import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport { assertDefined } from '../../../../utils/assertDefined';\nimport { getChainFromVerifiedCredentialChain } from '../../../../utils/getChainFromVerifiedCredentialChain';\nimport type { HardwareWalletVendor } from '../../hardwareWallet/hardwareWallet.types';\nimport type { WalletAccount } from '../../walletAccount';\nimport { getWalletProviderKeyFromVerifiedCredential } from '../../walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential';\nimport { formatWalletAccountId } from '../formatWalletAccountId';\n\ntype ConvertVerifiedCredentialToWalletAccountParams = {\n verifiedCredential: JwtVerifiedCredential;\n};\n\n/** @not-instrumented */\nexport const convertVerifiedCredentialToWalletAccount = (\n { verifiedCredential }: ConvertVerifiedCredentialToWalletAccountParams,\n client: DynamicClient\n): WalletAccount => {\n assertDefined(\n verifiedCredential.address,\n 'Missing address in verified credential'\n );\n assertDefined(\n verifiedCredential.chain,\n 'Missing chain in verified credential'\n );\n\n const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);\n\n const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential(\n {\n verifiedCredential,\n },\n client\n );\n\n const walletAccountId = formatWalletAccountId({\n address: verifiedCredential.address,\n chain,\n walletProviderKey,\n });\n\n return {\n address: verifiedCredential.address,\n addressesWithTypes: verifiedCredential.walletAdditionalAddresses,\n chain,\n hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet as\n | HardwareWalletVendor\n | undefined,\n id: walletAccountId,\n lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,\n verifiedCredentialId: verifiedCredential.id,\n walletProviderKey,\n };\n};\n","import type { SdkUser } from '@dynamic-labs/sdk-api-core';\nimport { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types';\nimport type { UnverifiedWalletAccount } from '../../unverifiedWalletAccounts';\nimport { convertUnverifiedWalletAccountToWalletAccount } from '../../utils/convertUnverifiedWalletAccountToWalletAccount';\nimport { convertVerifiedCredentialToWalletAccount } from '../../utils/convertVerifiedCredentialToWalletAccount';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetWalletAccountsFromStateParams = {\n unverifiedWalletAccounts: UnverifiedWalletAccount[];\n user: SdkUser | null;\n};\n\n/** @not-instrumented */\nexport const getWalletAccountsFromState = (\n { unverifiedWalletAccounts, user }: GetWalletAccountsFromStateParams,\n client: DynamicClient\n): WalletAccount[] => {\n const walletAccountsMap: Map<string, WalletAccount> = new Map();\n\n /**\n * Handle the unverified wallet accounts before the user verified credentials\n * so the later verified wallet accounts can override the unverified wallet accounts\n */\n unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {\n const walletAccount = convertUnverifiedWalletAccountToWalletAccount({\n unverifiedWalletAccount,\n });\n\n walletAccountsMap.set(walletAccount.id, walletAccount);\n });\n\n /**\n * Handle user verified credentials\n */\n const verifiedCredentials = user?.verifiedCredentials ?? [];\n\n verifiedCredentials\n .filter(\n (verified) =>\n verified.format === JwtVerifiedCredentialFormatEnum.Blockchain\n )\n .forEach((verifiedWalletAccount) => {\n const walletAccount = convertVerifiedCredentialToWalletAccount(\n {\n verifiedCredential: verifiedWalletAccount,\n },\n client\n );\n\n walletAccountsMap.set(walletAccount.id, walletAccount);\n });\n\n return Array.from(walletAccountsMap.values());\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport type { WalletAccount } from '../walletAccount';\nimport { getWalletAccountsFromState } from './getWalletAccountsFromState';\n\n/**\n * Retrieves all wallet accounts associated with the current session.\n *\n * This function returns both verified and unverified wallet accounts,\n * combining data from user credentials and local unverified accounts.\n * You can differentiate between verified and unverified wallet accounts by\n * checking the `verifiedCredentialId` property.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns An array of wallet accounts associated with the session.\n * @instrumented\n */\nexport const getWalletAccounts = (\n client = getDefaultClient()\n): WalletAccount[] => {\n const core = getCore(client);\n const { unverifiedWalletAccounts, user } = core.state.get();\n\n return getWalletAccountsFromState({ unverifiedWalletAccounts, user }, client);\n};\n","import { BaseError } from './base';\n\ntype NoWalletProviderFoundErrorParams = {\n walletProviderKey: string;\n};\n\nexport class NoWalletProviderFoundError extends BaseError {\n constructor({ walletProviderKey }: NoWalletProviderFoundErrorParams) {\n super({\n cause: null,\n code: 'no_wallet_provider_found_error',\n docsUrl: null,\n name: 'NoWalletProviderFoundError',\n shortMessage: `No wallet provider found with key: ${walletProviderKey}`,\n });\n }\n}\n","import type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { getCore } from '../../../client/core/getCore';\n\n/**\n * Creates a service accessor function that manages service instantiation and caching.\n * The returned function will either retrieve an existing service from the registry or\n * create a new one using the provided builder function.\n *\n * @template - The type of service to be created/accessed\n * @param key - Unique identifier for the service in the registry\n * @param builder - Function that creates the service instance when called with a DynamicClient\n * @instrumented\n */\nexport const createRuntimeServiceAccessKey =\n <T>(key: string, builder: (client: DynamicClient) => T) =>\n (client: DynamicClient): T => {\n const { runtimeServices } = getCore(client);\n\n const currentService = runtimeServices.getByKey<T>(key);\n\n if (currentService) {\n return currentService;\n }\n\n const service = builder(client);\n\n runtimeServices.register(key, service);\n\n return service;\n };\n","import type { DynamicClient } from '../../../../client/types';\nimport { emitEvent } from '../../../clientEvents';\nimport type { WalletProvider } from '../../walletProvider/walletProvider.types';\nimport type { WalletProviderRegistry } from '../walletProviderRegistry.types';\n\n/**\n * Creates a new wallet provider registry that manages wallet providers with priority-based registration.\n *\n * @returns The wallet provider registry instance\n *\n * @example\n * ```typescript\n * const registry = createWalletProviderRegistry();\n *\n * registry.register({\n * priority: WalletProviderPriority.WALLET_SDK,\n * walletProvider: myWalletProvider\n * });\n *\n * const provider = registry.getByKey('my-wallet-key');\n * const providers = registry.listProviders();\n * ```\n * @not-instrumented\n */\nexport const createWalletProviderRegistry = (\n client: DynamicClient\n): WalletProviderRegistry => {\n const registry = new Map<\n string,\n { priority: number; walletProvider: WalletProvider }\n >();\n\n return {\n getByKey: (key) => registry.get(key)?.walletProvider,\n listProviders: () =>\n Array.from(registry.values()).map((v) => v.walletProvider),\n register: (args) => {\n const existingEntry = registry.get(args.walletProvider.key);\n\n if (existingEntry) {\n if (existingEntry.priority < args.priority) {\n registry.set(args.walletProvider.key, args);\n\n emitEvent(\n {\n args: { walletProviderKey: args.walletProvider.key },\n event: 'walletProviderChanged',\n },\n client\n );\n }\n } else {\n registry.set(args.walletProvider.key, args);\n\n emitEvent(\n {\n args: { walletProvider: args.walletProvider },\n event: 'walletProviderRegistered',\n },\n client\n );\n\n emitEvent(\n {\n args: { walletProviderKey: args.walletProvider.key },\n event: 'walletProviderChanged',\n },\n client\n );\n }\n },\n unregister: (key) => {\n registry.delete(key);\n\n emitEvent(\n {\n args: { walletProviderKey: key },\n event: 'walletProviderUnregistered',\n },\n client\n );\n },\n };\n};\n","import { createRuntimeServiceAccessKey } from '../../../../services/runtimeServices';\nimport { createWalletProviderRegistry } from '../createWalletProviderRegistry';\n\n/**\n * This function provides access to a shared instance of the wallet provider registry.\n *\n * It ensures that the same registry instance is used throughout the client to maintaining\n * consistency of registered wallet providers across different parts of the codebase.\n *\n * @returns The wallet provider registry instance\n *\n * @example\n * ```typescript\n * // Get the registry instance\n * const registry = getWalletProviderRegistry();\n *\n * // Register a wallet provider\n * registry.register({\n * priority: WalletProviderPriority.WALLET_SDK,\n * walletProvider: myWalletProvider\n * });\n *\n * // Retrieve a specific provider\n * const provider = registry.getByKey('metamaskevm');\n * ```\n */\nexport const getWalletProviderRegistry = createRuntimeServiceAccessKey(\n 'walletProviderRegistry',\n (client) => createWalletProviderRegistry(client)\n);\n","import type { WalletProvider } from '../walletProvider/walletProvider.types';\n\nexport enum WalletProviderPriority {\n /**\n * Highest priority should be used by wallet providers that implement\n * the most reliable wallet integration.\n * example: The SDK provided by the wallet provider.\n */\n WALLET_SDK = 100,\n /**\n * Medium priority should be used by wallet providers that implement\n * a wallet integration via some reliable standard.\n * example: A wallet provider that uses EIP6963 announcement.\n */\n WALLET_SELF_ANNOUNCEMENT_STANDARD = 50,\n /**\n * Low priority should be used by wallet providers that implement\n * a wallet integration on a less reliable standard.\n * example: A wallet provider that uses window.ethereum, where the\n * window key can be overridden by other extensions.\n */\n WINDOW_INJECT = 20,\n}\n\nexport type WalletProviderRegistry = {\n /**\n * Retrieves a wallet provider by its key.\n * @param key - The key of the wallet provider.\n * @returns The wallet provider.\n */\n getByKey: (key: string) => WalletProvider | undefined;\n /**\n * Retrieves all wallet providers.\n * @returns The wallet providers.\n */\n listProviders: () => WalletProvider[];\n /**\n * Registers a wallet provider.\n * @param args - The arguments for the wallet provider.\n */\n register: (args: {\n priority: WalletProviderPriority;\n walletProvider: WalletProvider;\n }) => void;\n /**\n * Unregisters a wallet provider.\n * @param key - The key of the wallet provider.\n */\n unregister: (key: string) => void;\n};\n","import type { DynamicClient } from '../../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../../errors/NoWalletProviderFoundError';\nimport type { WalletAccount } from '../../walletAccount';\nimport { getWalletProviderRegistry } from '../../walletProviderRegistry';\n\ntype GetWalletProviderFromWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @instrumented */\nexport const getWalletProviderFromWalletAccount = (\n { walletAccount }: GetWalletProviderFromWalletAccountParams,\n client: DynamicClient\n) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n const walletProvider = walletProviderRegistry.getByKey(\n walletAccount.walletProviderKey\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({\n walletProviderKey: walletAccount.walletProviderKey,\n });\n }\n\n return walletProvider;\n};\n","export const DYNAMIC_AUTH_COOKIE_NAME = 'DYNAMIC_JWT_TOKEN';\n","import type { DynamicClient } from '../../../client/types';\nimport { emitEvent } from '../../clientEvents';\nimport { getWalletAccounts } from '../getWalletAccounts';\n\n/**\n * Emits the `walletAccountsChanged` event.\n * @not-instrumented\n */\nexport const emitWalletAccountsChangedEvent = (client: DynamicClient): void => {\n const walletAccounts = getWalletAccounts(client);\n\n emitEvent(\n {\n args: { walletAccounts },\n event: 'walletAccountsChanged',\n },\n client\n );\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { emitWalletAccountsChangedEvent } from '../../../wallets/emitWalletAccountsChangedEvent';\nimport { getWalletAccountsFromState } from '../../../wallets/getWalletAccounts/getWalletAccountsFromState';\n\ntype CheckAndRaiseWalletAccountsChangedEventParams = {\n previousState: Readonly<DynamicCoreState>;\n};\n\n/** @not-instrumented */\nexport const checkAndRaiseWalletAccountsChangedEvent = (\n { previousState }: CheckAndRaiseWalletAccountsChangedEventParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const walletAccountsHashBefore = getWalletAccountsHash(previousState, client);\n\n const walletAccountsHashAfter = getWalletAccountsHash(\n core.state.get(),\n client\n );\n\n if (walletAccountsHashBefore !== walletAccountsHashAfter) {\n emitWalletAccountsChangedEvent(client);\n }\n};\n\nconst getWalletAccountsHash = (\n state: Readonly<DynamicCoreState>,\n client: DynamicClient\n) =>\n getWalletAccountsFromState(state, client)\n .map((walletAccount) => JSON.stringify(walletAccount))\n .sort()\n .join('-');\n","import type { DynamicClient } from '../../../client/types';\nimport { getWalletProviderRegistry } from '../walletProviderRegistry';\n\n/**\n * Get all available wallet providers to interact with internally.\n * @instrumented\n */\nexport const getWalletProviders = (client: DynamicClient) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n return walletProviderRegistry.listProviders();\n};\n","import type { WalletProvider } from '../../wallets/walletProvider';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport type { WaasWalletProvider } from '../waas.types';\n\n/** @not-instrumented */\nexport const isWaasWalletProvider = (\n walletProvider: WalletProvider\n): walletProvider is WaasWalletProvider => {\n return walletProvider.key.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import { WalletProviderEnum } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { Chain } from '../../chain';\nimport { getWalletProviders } from '../../wallets/getWalletProviders';\nimport { formatWalletProviderKey } from '../../wallets/utils/formatWalletProviderKey';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport type { WaasWalletProvider } from '../waas.types';\n\ntype FindWaasWalletProviderByChainParams = {\n chain: Chain;\n};\n\n/** @not-instrumented */\nexport const findWaasWalletProviderByChain = (\n { chain }: FindWaasWalletProviderByChainParams,\n client: DynamicClient\n): WaasWalletProvider | null => {\n const providers = getWalletProviders(client);\n\n const waasProviderKey = formatWalletProviderKey({\n chain,\n displayName: DYNAMIC_WAAS_METADATA.displayName,\n walletProviderType: WalletProviderEnum.EmbeddedWallet,\n });\n\n const waasProvider = providers.find(\n (provider) => provider.key === waasProviderKey && provider.chain === chain\n );\n\n if (!waasProvider || !isWaasWalletProvider(waasProvider)) {\n return null;\n }\n\n return waasProvider;\n};\n","import type { WalletAccount } from '../../wallets/walletAccount';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\n\ntype IsWaasWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/**\n * This function determines whether the provided wallet account is a Dynamic\n * WaaS wallet account.\n *\n * @param params.walletAccount - The wallet account to check.\n * @returns True if the wallet account is a WaaS wallet account, false otherwise.\n * @not-instrumented\n */\nexport const isWaasWalletAccount = ({\n walletAccount,\n}: IsWaasWalletAccountParams): boolean => {\n return walletAccount.walletProviderKey.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain';\nimport { isWaasWalletAccount } from '../isWaasWalletAccount';\n\n/** @not-instrumented */\nexport const restoreUserSharesForAllWalletAccounts = async (\n client: DynamicClient\n) => {\n const walletAccounts = getWalletAccounts(client);\n\n const waasWalletAccounts = walletAccounts.filter((walletAccount) =>\n isWaasWalletAccount({ walletAccount })\n );\n\n await Promise.all(\n waasWalletAccounts.map(async (walletAccount) => {\n const provider = findWaasWalletProviderByChain(\n { chain: walletAccount.chain },\n client\n );\n\n /**\n * The environment might not have the embedded wallet extensions installed.\n * In that case there is no provider for the chain and we can skip restoring the user share.\n */\n if (!provider) return;\n\n return provider.restoreUserShareForWalletAccount({ walletAccount });\n })\n );\n};\n","import { InvalidParamError } from '../../../errors/InvalidParamError';\n\nexport type JwtPayload = {\n [key: string]: unknown;\n exp: number;\n iat: number;\n scope: string;\n singleUse?: boolean;\n sub: string;\n};\n\n/**\n * Decodes a JWT token and returns the full payload.\n *\n * This function extracts and returns the complete JWT payload including scopes,\n * expiration time, and other claims.\n *\n * @param jwt - The JWT token string.\n * @returns The decoded JWT payload object.\n * @throws InvalidParamError if the token is invalid or cannot be decoded.\n *\n * @example\n * ```typescript\n * const payload = decodeJwt(jwt);\n * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }\n * ```\n * @not-instrumented\n */\nexport const decodeJwt = (jwt: string): JwtPayload => {\n try {\n // JWT format: header.payload.signature\n const parts = jwt.split('.');\n if (parts.length !== 3) {\n throw new InvalidParamError('Invalid JWT format');\n }\n\n // Decode the payload (second part)\n // Base64URL decode: replace URL-safe characters and decode\n const base64Payload = parts[1].replaceAll('-', '+').replaceAll('_', '/');\n // Add padding if needed\n const paddedPayload =\n base64Payload + '='.repeat((4 - (base64Payload.length % 4)) % 4);\n const decodedPayload = atob(paddedPayload);\n const claims = JSON.parse(decodedPayload) as JwtPayload;\n\n return claims;\n } catch (error) {\n if (error instanceof InvalidParamError) {\n throw error;\n }\n throw new InvalidParamError(\n `Failed to decode JWT: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n};\n","/**\n * Normalizes scopes by deduplicating and sorting them.\n * This creates a canonical representation for comparison.\n *\n * @param scopes - Array of scope strings (may contain duplicates)\n * @returns Normalized, sorted array of unique scopes\n * @not-instrumented\n */\nexport const normalizeScopes = (scopes: string[]): string[] => {\n return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));\n};\n","import { decodeJwt } from '../../../decodeJwt';\nimport type { ParsedElevatedAccessToken } from '../elevatedAccessTokens.types';\nimport { normalizeScopes } from '../normalizeScopes';\n\n/**\n * Validates and parses an elevated access token from a JWT string.\n * Extracts scopes, expiration, and validates the token structure.\n *\n * Policy decisions:\n * - Tokens without scopes are rejected (returns null)\n * - Tokens with empty scopes array are rejected (returns null)\n * - Tokens without exp field are rejected (returns null)\n * - Expired tokens are rejected (returns null)\n *\n * @param token - JWT string containing the elevated access token\n * @param now - Current date for expiration validation (defaults to new Date())\n * @returns Parsed token data or null if token is invalid/expired\n * @not-instrumented\n */\nexport const parseElevatedAccessToken = (\n token: string,\n now: Date = new Date()\n): ParsedElevatedAccessToken | null => {\n const payload = decodeJwt(token);\n const rawScopeClaim = payload?.scope;\n const processedScopes = rawScopeClaim?.split(' ') ?? [];\n const filteredScopes = processedScopes.filter((s) => s.length > 0);\n const singleUse = payload.singleUse ?? false;\n\n // Reject tokens without scopes or with empty scopes\n if (!filteredScopes || filteredScopes.length === 0) {\n return null;\n }\n\n // Reject tokens without exp field\n if (!payload.exp) {\n return null;\n }\n\n // Convert exp (seconds) to Date (milliseconds)\n const expiresAt = new Date(payload.exp * 1000);\n\n // Reject expired tokens\n if (expiresAt <= now) {\n return null;\n }\n\n return {\n expiresAt,\n normalizedScopes: normalizeScopes(filteredScopes),\n scopes: filteredScopes,\n singleUse,\n token,\n };\n};\n","import type {\n ElevatedAccessToken,\n ParsedElevatedAccessToken,\n} from '../elevatedAccessTokens.types';\nimport { normalizeScopes } from '../normalizeScopes';\n\n/**\n * Upserts an elevated access token into the current tokens array.\n *\n * Policy: Only one token per normalized scope-set is allowed.\n * If a token with the same normalized scopes exists, it is replaced.\n * This ensures we don't accumulate multiple tokens for the same scope combination.\n *\n * @param currentTokens - Current array of elevated access tokens\n * @param newToken - New token to upsert\n * @returns Updated array of tokens with the new token upserted\n * @not-instrumented\n */\nexport const upsertElevatedAccessToken = ({\n currentTokens,\n newToken,\n}: {\n currentTokens: ElevatedAccessToken[];\n newToken: ParsedElevatedAccessToken;\n}): ElevatedAccessToken[] => {\n const newScopeKey = normalizeScopes(newToken.scopes).join(' ');\n\n // Remove any existing token with the same normalized scopes\n const filteredTokens = currentTokens.filter((existingToken) => {\n const existingScopeKey = normalizeScopes(existingToken.scopes).join(' ');\n return existingScopeKey !== newScopeKey;\n });\n\n // Add the new token\n return [\n ...filteredTokens,\n {\n expiresAt: newToken.expiresAt,\n scopes: newToken.scopes,\n singleUse: newToken.singleUse,\n token: newToken.token,\n },\n ];\n};\n","import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicCoreState } from '../../../client/core/types';\nimport type { DynamicClient } from '../../../client/types';\nimport { setCookie } from '../../../utils/setCookie';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { restoreUserSharesForAllWalletAccounts } from '../../waas/restoreUserSharesForAllWalletAccounts';\nimport { DYNAMIC_AUTH_COOKIE_NAME } from '../consts';\nimport { checkAndRaiseWalletAccountsChangedEvent } from './checkAndRaiseWalletAccountsChangedEvent';\nimport { parseElevatedAccessToken } from './elevatedAccessTokens/parseElevatedAccessToken';\nimport { upsertElevatedAccessToken } from './elevatedAccessTokens/upsertElevatedAccessToken';\n\ntype UpdateAuthFromVerifyResponseParams = {\n response: VerifyResponse;\n};\n\n/** @instrumented */\nexport const updateAuthFromVerifyResponse = (\n { response }: UpdateAuthFromVerifyResponseParams,\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const previousState = { ...core.state.get() };\n\n const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } =\n response;\n\n // Expires at is in seconds, so we need to convert it to milliseconds\n const sessionExpiresAt = new Date(expiresAt * 1000);\n\n const newState: Partial<DynamicCoreState> = {\n legacyToken: jwt ?? null,\n sessionExpiresAt: sessionExpiresAt,\n token: minifiedJwt ?? null,\n user,\n };\n\n // only override the mfaToken if a new one is provided in the response\n if (mfaToken) {\n newState.mfaToken = mfaToken;\n }\n\n // Add elevated access token to the array if a new one is provided in the response\n // Policy: Only one token per normalized scope-set is allowed (old tokens are replaced)\n // Always preserve existing tokens to ensure they're synced to storage\n const currentTokens = core.state.get().elevatedAccessTokens || [];\n newState.elevatedAccessTokens = currentTokens;\n \n if (elevatedAccessToken) {\n const parsedToken = parseElevatedAccessToken(elevatedAccessToken);\n if (parsedToken) {\n newState.elevatedAccessTokens = upsertElevatedAccessToken({\n currentTokens,\n newToken: parsedToken,\n });\n }\n }\n\n core.state.set(newState);\n\n /**\n * For customers using a sandbox environment with cookies enabled, we need to set the cookie\n * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically\n * so customers can access the cookie from document.cookie consistently between sandbox and live environments.\n */\n if (minifiedJwt && isCookieEnabled(client)) {\n const expireDate = sessionExpiresAt.toUTCString();\n\n setCookie(\n `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`\n );\n }\n\n checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);\n\n // if the user is logging in, we should restore user shares\n // for all wallet accounts for performance reasons\n const isUserLoggingIn = !previousState.user && Boolean(newState.user);\n if (isUserLoggingIn) {\n void restoreUserSharesForAllWalletAccounts(client);\n }\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { getWalletProviders } from '../getWalletProviders';\n\ntype GetWalletProviderByKeyParams = {\n walletProviderKey: string;\n};\n\n/** @not-instrumented */\nexport const getWalletProviderByKey = (\n { walletProviderKey }: GetWalletProviderByKeyParams,\n client: DynamicClient\n) => {\n const walletProviders = getWalletProviders(client);\n\n const walletProvider = walletProviders.find(\n (walletProvider) => walletProvider.key === walletProviderKey\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({ walletProviderKey });\n }\n\n return walletProvider;\n};\n","import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetVerifiedCredentialForWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @instrumented */\nexport const getVerifiedCredentialForWalletAccount = (\n { walletAccount }: GetVerifiedCredentialForWalletAccountParams,\n client: DynamicClient\n) => {\n return client.user?.verifiedCredentials.find(\n (vc) => vc.id === walletAccount.verifiedCredentialId\n );\n};\n"],"mappings":";;;;;;;;;AAIA,MAAa,aAAa,WAAmB;AAE3C,UAAS,SAAS;;;;;;;;;;;;;;;;;ACiBpB,MAAa,WACX,EAAE,OAAO,YACT,SAASA,4CAAkB,KACxB;CACH,MAAM,EAAE,iBAAiBC,kCAAQ,OAAO;AAExC,cAAa,GAAG,OAAO,SAAS;AAEhC,cAAa;AACX,eAAa,IAAI,OAAO,SAAS;;;;;;;;;;;;;;AAerC,MAAa,YACX,EAAE,OAAO,YACT,SAASD,4CAAkB,KACxB;CACH,MAAM,EAAE,iBAAiBC,kCAAQ,O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,2BAA2B,EAAE,mBAAmB,CAAC;AAG7D,QAAO;;;;;;ACfT,MAAa,yCACX,EAAE,iBACF,WACG;AACH,QAAO,OAAO,MAAM,oBAAoB,MACrC,OAAO,GAAG,OAAO,cAAc,qBACjC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
2
|
-
const require_InvalidParamError = require('./InvalidParamError-
|
|
3
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-
|
|
5
|
-
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-CoAKJyXQ.cjs.js');
|
|
2
|
+
const require_InvalidParamError = require('./InvalidParamError-6MugNXi3.cjs.js');
|
|
3
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-Zu778J_y.cjs.js');
|
|
4
|
+
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-C204z_SH.cjs.js');
|
|
5
|
+
const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-D7amEpqp.cjs.js');
|
|
6
6
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
7
7
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
8
8
|
let zod_mini = require("zod/mini");
|
|
@@ -175,11 +175,11 @@ const getAvailableWalletProvidersFromWalletAccounts = (client) => {
|
|
|
175
175
|
* Disconnect and terminate each wallet provider, if available.
|
|
176
176
|
* @not-instrumented
|
|
177
177
|
*/
|
|
178
|
-
const disconnectAndTerminateWalletProviders = async (client) => {
|
|
178
|
+
const disconnectAndTerminateWalletProviders = async ({ reason }, client) => {
|
|
179
179
|
const core = require_InvalidParamError.getCore(client);
|
|
180
180
|
const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
|
|
181
181
|
await Promise.all(walletProviders.map(async (walletProvider) => {
|
|
182
|
-
if (walletProvider.terminate) await walletProvider.terminate();
|
|
182
|
+
if (walletProvider.terminate) await walletProvider.terminate({ reason });
|
|
183
183
|
if (walletProvider.disconnect) try {
|
|
184
184
|
await walletProvider.disconnect();
|
|
185
185
|
} catch (err) {
|
|
@@ -189,18 +189,17 @@ const disconnectAndTerminateWalletProviders = async (client) => {
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
|
-
//#region src/modules/auth/
|
|
192
|
+
//#region src/modules/auth/performLogout/performLogout.ts
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
194
|
+
* Shared logout implementation that revokes the session, clears auth state,
|
|
195
|
+
* terminates wallet providers, and emits the logout event with the given reason.
|
|
195
196
|
*
|
|
196
|
-
* @
|
|
197
|
-
* @returns A promise that resolves when the logout process is complete.
|
|
198
|
-
* @instrumented
|
|
197
|
+
* @not-instrumented
|
|
199
198
|
*/
|
|
200
|
-
const
|
|
199
|
+
const performLogout = async ({ reason }, client) => {
|
|
201
200
|
const core = require_InvalidParamError.getCore(client);
|
|
202
201
|
core.logger.debug("[logout] Logging out...");
|
|
203
|
-
await disconnectAndTerminateWalletProviders(client);
|
|
202
|
+
await disconnectAndTerminateWalletProviders({ reason }, client);
|
|
204
203
|
if (client.user !== null) {
|
|
205
204
|
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
206
205
|
try {
|
|
@@ -226,11 +225,28 @@ const logout = async (client = require_InvalidParamError.getDefaultClient()) =>
|
|
|
226
225
|
unverifiedWalletAccounts: [],
|
|
227
226
|
user: null
|
|
228
227
|
});
|
|
229
|
-
require_getVerifiedCredentialForWalletAccount.emitEvent({
|
|
228
|
+
require_getVerifiedCredentialForWalletAccount.emitEvent({
|
|
229
|
+
args: { reason },
|
|
230
|
+
event: "logout"
|
|
231
|
+
}, client);
|
|
230
232
|
fetchProjectSettings(client);
|
|
231
233
|
require_getNetworkProviderFromNetworkId.generateSessionKeys(client);
|
|
232
234
|
};
|
|
233
235
|
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/modules/auth/handleSessionExpiration/handleSessionExpiration.ts
|
|
238
|
+
/**
|
|
239
|
+
* Logs out due to session expiry with a token-expired reason,
|
|
240
|
+
* allowing downstream providers to decide their own cleanup behavior.
|
|
241
|
+
*
|
|
242
|
+
* @param client - The Dynamic client instance.
|
|
243
|
+
* @returns A promise that resolves when the logout process is complete.
|
|
244
|
+
* @instrumented
|
|
245
|
+
*/
|
|
246
|
+
const handleSessionExpiration = async (client) => {
|
|
247
|
+
return performLogout({ reason: "token-expired" }, client);
|
|
248
|
+
};
|
|
249
|
+
|
|
234
250
|
//#endregion
|
|
235
251
|
//#region src/modules/auth/initializeAuth/setLongTimeout/setLongTimeout.ts
|
|
236
252
|
/**
|
|
@@ -271,7 +287,7 @@ const initializeAuth = (client) => {
|
|
|
271
287
|
const now = /* @__PURE__ */ new Date();
|
|
272
288
|
const timeUntilExpiration = expiration.getTime() - now.getTime();
|
|
273
289
|
if (timeUntilExpiration <= 0) {
|
|
274
|
-
|
|
290
|
+
handleSessionExpiration(client);
|
|
275
291
|
return;
|
|
276
292
|
}
|
|
277
293
|
clearExpirationTimeout = setLongTimeout(checkExpiration, timeUntilExpiration);
|
|
@@ -280,6 +296,19 @@ const initializeAuth = (client) => {
|
|
|
280
296
|
checkExpiration();
|
|
281
297
|
};
|
|
282
298
|
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/modules/auth/logout/logout.ts
|
|
301
|
+
/**
|
|
302
|
+
* Logs out the current user and clears all authentication data.
|
|
303
|
+
*
|
|
304
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
305
|
+
* @returns A promise that resolves when the logout process is complete.
|
|
306
|
+
* @instrumented
|
|
307
|
+
*/
|
|
308
|
+
const logout = async (client = require_InvalidParamError.getDefaultClient()) => {
|
|
309
|
+
return performLogout({ reason: "user-intent" }, client);
|
|
310
|
+
};
|
|
311
|
+
|
|
283
312
|
//#endregion
|
|
284
313
|
//#region src/modules/crossTabEventSync/setupCrossTabEventSync/setupCrossTabEventSync.ts
|
|
285
314
|
/**
|
|
@@ -2018,13 +2047,14 @@ const authenticateWithSocial = async ({ provider, redirectUrl }, client = requir
|
|
|
2018
2047
|
* and completes the user authentication with the social provider.
|
|
2019
2048
|
*
|
|
2020
2049
|
* @param params.url - The callback URL containing OAuth response parameters.
|
|
2050
|
+
* @param [params.requestedScopes] - Optional scopes to request an elevated access token when verifying (linking) a social account.
|
|
2021
2051
|
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2022
2052
|
* @returns A promise that resolves to the authenticated user or null.
|
|
2023
2053
|
* @throws MissingSocialUrlParamError If required OAuth parameters are missing.
|
|
2024
2054
|
* @throws InvalidRedirectStorageStateError If the stored state doesn't match.
|
|
2025
2055
|
* @instrumented
|
|
2026
2056
|
*/
|
|
2027
|
-
const completeSocialAuthentication = async ({ url }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2057
|
+
const completeSocialAuthentication = async ({ url, requestedScopes }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2028
2058
|
const core = require_InvalidParamError.getCore(client);
|
|
2029
2059
|
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
2030
2060
|
await core.initTrack.waitForAll();
|
|
@@ -2043,6 +2073,7 @@ const completeSocialAuthentication = async ({ url }, client = require_InvalidPar
|
|
|
2043
2073
|
oauthRequest: {
|
|
2044
2074
|
code: dynamicOauthCode,
|
|
2045
2075
|
codeVerifier,
|
|
2076
|
+
requestedScopes,
|
|
2046
2077
|
state: dynamicOauthState
|
|
2047
2078
|
},
|
|
2048
2079
|
providerType: provider
|
|
@@ -2396,6 +2427,43 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2396
2427
|
});
|
|
2397
2428
|
}
|
|
2398
2429
|
|
|
2430
|
+
//#endregion
|
|
2431
|
+
//#region src/modules/swap/constants.ts
|
|
2432
|
+
const SWAP_SUPPORTED_CHAINS = [
|
|
2433
|
+
"BTC",
|
|
2434
|
+
"EVM",
|
|
2435
|
+
"SOL",
|
|
2436
|
+
"SUI",
|
|
2437
|
+
"TRON"
|
|
2438
|
+
];
|
|
2439
|
+
|
|
2440
|
+
//#endregion
|
|
2441
|
+
//#region src/modules/swap/executeSwapTransaction/executeSwapTransaction.ts
|
|
2442
|
+
/**
|
|
2443
|
+
* Executes a swap transaction
|
|
2444
|
+
*
|
|
2445
|
+
* @param params ExecuteSwapTransactionParams - The parameters for the swap transaction.
|
|
2446
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
2447
|
+
* @returns The transaction hash.
|
|
2448
|
+
* @instrumented
|
|
2449
|
+
*/
|
|
2450
|
+
const executeSwapTransaction = async ({ walletAccount, signingPayload, onStepChange }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2451
|
+
if (!SWAP_SUPPORTED_CHAINS.includes(walletAccount.chain)) throw new require_InvalidParamError.InvalidParamError(`Chain ${walletAccount.chain} is not supported for swap transactions`);
|
|
2452
|
+
const walletProvider = require_getVerifiedCredentialForWalletAccount.getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
2453
|
+
assertWalletProviderMethodDefined(walletProvider, "executeSwapTransaction");
|
|
2454
|
+
const requiredNetworkId = signingPayload.chainId;
|
|
2455
|
+
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
2456
|
+
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2457
|
+
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2458
|
+
}
|
|
2459
|
+
const { transactionHash } = await walletProvider.executeSwapTransaction({
|
|
2460
|
+
onStepChange,
|
|
2461
|
+
signingPayload,
|
|
2462
|
+
walletAccount
|
|
2463
|
+
});
|
|
2464
|
+
return { transactionHash };
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2399
2467
|
//#endregion
|
|
2400
2468
|
//#region src/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.ts
|
|
2401
2469
|
/**
|
|
@@ -2404,7 +2472,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2404
2472
|
* Orchestrates the full submission flow:
|
|
2405
2473
|
* 1. Calls prepareCheckoutTransaction to advance to signing state and lock the quote
|
|
2406
2474
|
* 2. Ensures the wallet is on the correct network for the transaction
|
|
2407
|
-
* 3. Delegates on-chain signing to the wallet provider's
|
|
2475
|
+
* 3. Delegates on-chain signing to the wallet provider's executeSwapTransaction method
|
|
2408
2476
|
* 4. Calls broadcastCheckoutTransaction with the resulting txHash
|
|
2409
2477
|
*
|
|
2410
2478
|
* @param params SubmitCheckoutTransactionParams - The transaction ID, wallet account, and optional step callback.
|
|
@@ -2415,14 +2483,7 @@ function assertWalletProviderMethodDefined(walletProvider, methodName) {
|
|
|
2415
2483
|
const submitCheckoutTransaction = async ({ onStepChange, transactionId, walletAccount }, client = require_InvalidParamError.getDefaultClient()) => {
|
|
2416
2484
|
const prepared = await prepareCheckoutTransaction({ transactionId }, client);
|
|
2417
2485
|
require_InvalidParamError.assertDefined(prepared.signingPayload, "No signing payload returned from prepare — quote may be missing transaction data");
|
|
2418
|
-
const
|
|
2419
|
-
assertWalletProviderMethodDefined(walletProvider, "executeCheckoutTransaction");
|
|
2420
|
-
const requiredNetworkId = prepared.signingPayload.chainId;
|
|
2421
|
-
if (requiredNetworkId && walletProvider.switchActiveNetwork) {
|
|
2422
|
-
const { networkId: activeNetworkId } = await walletProvider.getActiveNetworkId();
|
|
2423
|
-
if (activeNetworkId !== requiredNetworkId) await walletProvider.switchActiveNetwork({ networkId: requiredNetworkId });
|
|
2424
|
-
}
|
|
2425
|
-
const { transactionHash } = await walletProvider.executeCheckoutTransaction({
|
|
2486
|
+
const { transactionHash } = await executeSwapTransaction({
|
|
2426
2487
|
onStepChange,
|
|
2427
2488
|
signingPayload: prepared.signingPayload,
|
|
2428
2489
|
walletAccount
|
|
@@ -4680,6 +4741,78 @@ const verifyOTP = async ({ otpVerification, verificationToken, requestedScopes }
|
|
|
4680
4741
|
return response;
|
|
4681
4742
|
};
|
|
4682
4743
|
|
|
4744
|
+
//#endregion
|
|
4745
|
+
//#region src/modules/swap/getSwapQuote/getSwapQuote.ts
|
|
4746
|
+
/**
|
|
4747
|
+
* Gets a swap quote
|
|
4748
|
+
*
|
|
4749
|
+
* @param params GetSwapQuoteParams - The parameters for the swap quote.
|
|
4750
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4751
|
+
* @returns The swap quote details. Use the `signingPayload` field to get the transaction data for the wallet to sign.
|
|
4752
|
+
* @instrumented
|
|
4753
|
+
*/
|
|
4754
|
+
const getSwapQuote = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4755
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4756
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
4757
|
+
if (!params.from.amount && !params.to.amount) throw new require_InvalidParamError.InvalidParamError("Either from.amount or to.amount is required");
|
|
4758
|
+
if (params.from.amount && params.to.amount) throw new require_InvalidParamError.InvalidParamError("Only one of from.amount or to.amount is allowed");
|
|
4759
|
+
return await apiClient.swapQuote({
|
|
4760
|
+
environmentId: core.environmentId,
|
|
4761
|
+
swapQuoteRequest: {
|
|
4762
|
+
from: {
|
|
4763
|
+
...params.from,
|
|
4764
|
+
chainId: params.from.networkId,
|
|
4765
|
+
chainName: params.from.chain
|
|
4766
|
+
},
|
|
4767
|
+
maxPriceImpact: params.maxPriceImpact,
|
|
4768
|
+
order: params.order,
|
|
4769
|
+
slippage: params.slippage,
|
|
4770
|
+
to: {
|
|
4771
|
+
...params.to,
|
|
4772
|
+
chainId: params.to.networkId,
|
|
4773
|
+
chainName: params.to.chain
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
});
|
|
4777
|
+
};
|
|
4778
|
+
|
|
4779
|
+
//#endregion
|
|
4780
|
+
//#region src/modules/swap/getSwapStatus/getSwapStatus.ts
|
|
4781
|
+
/**
|
|
4782
|
+
* Gets the status of a swap
|
|
4783
|
+
*
|
|
4784
|
+
* @param params GetSwapStatusParams - The parameters for the swap status.
|
|
4785
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
4786
|
+
* @returns The swap status.
|
|
4787
|
+
* @instrumented
|
|
4788
|
+
*/
|
|
4789
|
+
const getSwapStatus = async (params, client = require_InvalidParamError.getDefaultClient()) => {
|
|
4790
|
+
const core = require_InvalidParamError.getCore(client);
|
|
4791
|
+
const apiClient = require_InvalidParamError.createApiClient({}, client);
|
|
4792
|
+
let from;
|
|
4793
|
+
if (params.from) from = {
|
|
4794
|
+
chainId: params.from.networkId,
|
|
4795
|
+
chainName: params.from.chain
|
|
4796
|
+
};
|
|
4797
|
+
let to;
|
|
4798
|
+
if (params.to) to = {
|
|
4799
|
+
chainId: params.to.networkId,
|
|
4800
|
+
chainName: params.to.chain
|
|
4801
|
+
};
|
|
4802
|
+
const response = await apiClient.swapStatus({
|
|
4803
|
+
environmentId: core.environmentId,
|
|
4804
|
+
swapStatusRequest: {
|
|
4805
|
+
from,
|
|
4806
|
+
to,
|
|
4807
|
+
txHash: params.txHash
|
|
4808
|
+
}
|
|
4809
|
+
});
|
|
4810
|
+
return {
|
|
4811
|
+
status: response.status,
|
|
4812
|
+
substatus: response.substatus
|
|
4813
|
+
};
|
|
4814
|
+
};
|
|
4815
|
+
|
|
4683
4816
|
//#endregion
|
|
4684
4817
|
//#region src/modules/user/deleteUser/deleteUser.ts
|
|
4685
4818
|
/**
|
|
@@ -5700,6 +5833,7 @@ exports.deletePasskey = deletePasskey;
|
|
|
5700
5833
|
exports.deleteUser = deleteUser;
|
|
5701
5834
|
exports.detectDeviceRegistrationRedirect = detectDeviceRegistrationRedirect;
|
|
5702
5835
|
exports.detectOAuthRedirect = detectOAuthRedirect;
|
|
5836
|
+
exports.executeSwapTransaction = executeSwapTransaction;
|
|
5703
5837
|
exports.fetchProjectSettings = fetchProjectSettings;
|
|
5704
5838
|
exports.getActiveNetworkData = getActiveNetworkData;
|
|
5705
5839
|
exports.getActiveNetworkId = getActiveNetworkId;
|
|
@@ -5726,6 +5860,8 @@ exports.getOwnerWalletAccountForSmartWalletAccount = getOwnerWalletAccountForSma
|
|
|
5726
5860
|
exports.getPasskeys = getPasskeys;
|
|
5727
5861
|
exports.getPrimaryWalletAccount = getPrimaryWalletAccount;
|
|
5728
5862
|
exports.getRegisteredDevices = getRegisteredDevices;
|
|
5863
|
+
exports.getSwapQuote = getSwapQuote;
|
|
5864
|
+
exports.getSwapStatus = getSwapStatus;
|
|
5729
5865
|
exports.getTransactionHistory = getTransactionHistory;
|
|
5730
5866
|
exports.getUserSocialAccounts = getUserSocialAccounts;
|
|
5731
5867
|
exports.getWalletAccountAddressByType = getWalletAccountAddressByType;
|