@dynamic-labs-sdk/client 1.16.1 → 1.17.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.
Files changed (110) hide show
  1. package/dist/core.cjs +53 -53
  2. package/dist/core.cjs.map +1 -1
  3. package/dist/core.esm.js +5 -5
  4. package/dist/core.native.esm.js +5 -5
  5. package/dist/exports/waas.d.ts +2 -1
  6. package/dist/exports/waas.d.ts.map +1 -1
  7. package/dist/exports/waasCore.d.ts +3 -2
  8. package/dist/exports/waasCore.d.ts.map +1 -1
  9. package/dist/{getNetworkProviderFromNetworkId-BPeOK1Xx.esm.js → getNetworkProviderFromNetworkId-BVVs3arj.esm.js} +2 -3
  10. package/dist/{getNetworkProviderFromNetworkId-BPeOK1Xx.esm.js.map → getNetworkProviderFromNetworkId-BVVs3arj.esm.js.map} +1 -1
  11. package/dist/{getNetworkProviderFromNetworkId-D79icjmX.native.esm.js → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js} +3 -4
  12. package/dist/{getNetworkProviderFromNetworkId-D79icjmX.native.esm.js.map → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js.map} +1 -1
  13. package/dist/{getNetworkProviderFromNetworkId-BHxkTbiJ.cjs → getNetworkProviderFromNetworkId-DzzocxRc.cjs} +43 -44
  14. package/dist/{getNetworkProviderFromNetworkId-BHxkTbiJ.cjs.map → getNetworkProviderFromNetworkId-DzzocxRc.cjs.map} +1 -1
  15. package/dist/{getSignedSessionId-DzjHW7Rw.esm.js → getSignedSessionId-Bnuz2Aqc.esm.js} +3 -3
  16. package/dist/{getSignedSessionId-DzjHW7Rw.esm.js.map → getSignedSessionId-Bnuz2Aqc.esm.js.map} +1 -1
  17. package/dist/{getSignedSessionId-BjSUL8Br.cjs → getSignedSessionId-Dx0qQLMP.cjs} +11 -11
  18. package/dist/{getSignedSessionId-BjSUL8Br.cjs.map → getSignedSessionId-Dx0qQLMP.cjs.map} +1 -1
  19. package/dist/{getSignedSessionId-Dh4Df1mY.native.esm.js → getSignedSessionId-Pc_5wscD.native.esm.js} +3 -3
  20. package/dist/{getSignedSessionId-Dh4Df1mY.native.esm.js.map → getSignedSessionId-Pc_5wscD.native.esm.js.map} +1 -1
  21. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js +20 -0
  22. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js.map +1 -0
  23. package/dist/getWalletProviderByKey-BLWcueTR.cjs +31 -0
  24. package/dist/getWalletProviderByKey-BLWcueTR.cjs.map +1 -0
  25. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js +20 -0
  26. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js.map +1 -0
  27. package/dist/index.cjs +539 -540
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.esm.js +6 -7
  30. package/dist/index.esm.js.map +1 -1
  31. package/dist/index.native.esm.js +6 -7
  32. package/dist/index.native.esm.js.map +1 -1
  33. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs +88 -0
  34. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs.map +1 -0
  35. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js +70 -0
  36. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js.map +1 -0
  37. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js +70 -0
  38. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js.map +1 -0
  39. package/dist/{isMfaRequiredForAction-CkX6CfJf.esm.js → isMfaRequiredForAction-B7wNkqQf.esm.js} +2 -2
  40. package/dist/{isMfaRequiredForAction-CkX6CfJf.esm.js.map → isMfaRequiredForAction-B7wNkqQf.esm.js.map} +1 -1
  41. package/dist/{isMfaRequiredForAction-CBW-d9C6.native.esm.js → isMfaRequiredForAction-CJ9qbBUz.native.esm.js} +2 -2
  42. package/dist/{isMfaRequiredForAction-CBW-d9C6.native.esm.js.map → isMfaRequiredForAction-CJ9qbBUz.native.esm.js.map} +1 -1
  43. package/dist/{isMfaRequiredForAction-3fWX5MEF.cjs → isMfaRequiredForAction-CaNdGc-m.cjs} +29 -29
  44. package/dist/{isMfaRequiredForAction-3fWX5MEF.cjs.map → isMfaRequiredForAction-CaNdGc-m.cjs.map} +1 -1
  45. package/dist/{isUserOnboardingComplete-C4_b3pDb.esm.js → isUserOnboardingComplete-CGz-9Iyw.esm.js} +3 -3
  46. package/dist/{isUserOnboardingComplete-C4_b3pDb.esm.js.map → isUserOnboardingComplete-CGz-9Iyw.esm.js.map} +1 -1
  47. package/dist/{isUserOnboardingComplete-m6E6GbB0.native.esm.js → isUserOnboardingComplete-FRAIuxdi.native.esm.js} +3 -3
  48. package/dist/{isUserOnboardingComplete-m6E6GbB0.native.esm.js.map → isUserOnboardingComplete-FRAIuxdi.native.esm.js.map} +1 -1
  49. package/dist/{isUserOnboardingComplete-D0JrQGvR.cjs → isUserOnboardingComplete-w1IkCC_p.cjs} +13 -13
  50. package/dist/{isUserOnboardingComplete-D0JrQGvR.cjs.map → isUserOnboardingComplete-w1IkCC_p.cjs.map} +1 -1
  51. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js +65 -0
  52. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js.map +1 -0
  53. package/dist/migrateFromFireblocks-CjQWJPZW.cjs +82 -0
  54. package/dist/migrateFromFireblocks-CjQWJPZW.cjs.map +1 -0
  55. package/dist/migrateFromFireblocks-DXs3odF_.esm.js +65 -0
  56. package/dist/migrateFromFireblocks-DXs3odF_.esm.js.map +1 -0
  57. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  58. package/dist/modules/waas/migrateFromFireblocks/index.d.ts +2 -0
  59. package/dist/modules/waas/migrateFromFireblocks/index.d.ts.map +1 -0
  60. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts +52 -0
  61. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts.map +1 -0
  62. package/dist/modules/waas/waas.types.d.ts +9 -1
  63. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  64. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  65. package/dist/{InvalidParamError-PQ2Xen_o.esm.js → updateAuthFromVerifyResponse-BdokPJ21.esm.js} +237 -3
  66. package/dist/updateAuthFromVerifyResponse-BdokPJ21.esm.js.map +1 -0
  67. package/dist/{InvalidParamError-DCpeZMBr.cjs → updateAuthFromVerifyResponse-CUnvs5Af.cjs} +291 -9
  68. package/dist/updateAuthFromVerifyResponse-CUnvs5Af.cjs.map +1 -0
  69. package/dist/{InvalidParamError-5AXtm6Zp.native.esm.js → updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js} +457 -4
  70. package/dist/updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js.map +1 -0
  71. package/dist/waas.cjs +53 -67
  72. package/dist/waas.cjs.map +1 -1
  73. package/dist/waas.esm.js +5 -20
  74. package/dist/waas.esm.js.map +1 -1
  75. package/dist/waas.native.esm.js +5 -20
  76. package/dist/waas.native.esm.js.map +1 -1
  77. package/dist/waasCore.cjs +40 -23
  78. package/dist/waasCore.cjs.map +1 -1
  79. package/dist/waasCore.esm.js +23 -7
  80. package/dist/waasCore.esm.js.map +1 -1
  81. package/dist/waasCore.native.esm.js +23 -7
  82. package/dist/waasCore.native.esm.js.map +1 -1
  83. package/package.json +2 -2
  84. package/dist/InvalidParamError-5AXtm6Zp.native.esm.js.map +0 -1
  85. package/dist/InvalidParamError-DCpeZMBr.cjs.map +0 -1
  86. package/dist/InvalidParamError-PQ2Xen_o.esm.js.map +0 -1
  87. package/dist/getWaasWalletProviderFromWalletAccount-BxyUZBpT.cjs +0 -19
  88. package/dist/getWaasWalletProviderFromWalletAccount-BxyUZBpT.cjs.map +0 -1
  89. package/dist/getWaasWalletProviderFromWalletAccount-Ca0SiNEz.native.esm.js +0 -14
  90. package/dist/getWaasWalletProviderFromWalletAccount-Ca0SiNEz.native.esm.js.map +0 -1
  91. package/dist/getWaasWalletProviderFromWalletAccount-CupLo7EC.esm.js +0 -14
  92. package/dist/getWaasWalletProviderFromWalletAccount-CupLo7EC.esm.js.map +0 -1
  93. package/dist/getWalletProviderByKey-B6vtKHJy.esm.js +0 -255
  94. package/dist/getWalletProviderByKey-B6vtKHJy.esm.js.map +0 -1
  95. package/dist/getWalletProviderByKey-DIFBlGlR.cjs +0 -321
  96. package/dist/getWalletProviderByKey-DIFBlGlR.cjs.map +0 -1
  97. package/dist/getWalletProviderByKey-Dh2qnBmw.native.esm.js +0 -474
  98. package/dist/getWalletProviderByKey-Dh2qnBmw.native.esm.js.map +0 -1
  99. package/dist/isDynamicWaasEnabled-A8Humh0r.cjs +0 -49
  100. package/dist/isDynamicWaasEnabled-A8Humh0r.cjs.map +0 -1
  101. package/dist/isDynamicWaasEnabled-BmWqrgz1.esm.js +0 -37
  102. package/dist/isDynamicWaasEnabled-BmWqrgz1.esm.js.map +0 -1
  103. package/dist/isDynamicWaasEnabled-Djp4QuBw.native.esm.js +0 -37
  104. package/dist/isDynamicWaasEnabled-Djp4QuBw.native.esm.js.map +0 -1
  105. package/dist/refreshAuth-BKeW1dSq.cjs +0 -43
  106. package/dist/refreshAuth-BKeW1dSq.cjs.map +0 -1
  107. package/dist/refreshAuth-Cykyxvpz.native.esm.js +0 -38
  108. package/dist/refreshAuth-Cykyxvpz.native.esm.js.map +0 -1
  109. package/dist/refreshAuth-LzA2xxNC.esm.js +0 -38
  110. package/dist/refreshAuth-LzA2xxNC.esm.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletProviderByKey-DIFBlGlR.cjs","names":["getWalletAccounts","getCore","getWalletAccountsFromState","getWalletProviderRegistry","formatWalletProviderKey","DYNAMIC_WAAS_METADATA","WalletProviderEnum","isWaasWalletProvider","DYNAMIC_WAAS_METADATA","isUserMissingMfaAuth","getWalletAccounts","InvalidParamError","getCore","newState: Partial<DynamicCoreState>","isCookieEnabled","DYNAMIC_AUTH_COOKIE_NAME","walletProvider","NoWalletProviderFoundError"],"sources":["../src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts","../src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts","../src/modules/wallets/getWalletProviders/getWalletProviders.ts","../src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts","../src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts","../src/modules/waas/initializeWaasClientsForEagerRecovery/initializeWaasClientsForEagerRecovery.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/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts","../src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts"],"sourcesContent":["import type { DynamicClient } from '../../../client/types';\nimport { emitEvent } from '../../clientEvents';\nimport { getWalletAccounts } from '../getWalletAccounts';\n\n/**\n * Emits the `walletAccountsChanged` event.\n * @notInstrumented\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/** @notInstrumented */\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\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 * @notInstrumented\n */\nexport const getWalletProviders = (client: DynamicClient) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n return walletProviderRegistry.listProviders();\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/** @notInstrumented */\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 * @notInstrumented\n */\nexport const isWaasWalletAccount = ({\n walletAccount,\n}: IsWaasWalletAccountParams): boolean => {\n return walletAccount.walletProviderKey.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain';\nimport { isWaasWalletAccount } from '../isWaasWalletAccount';\n\n/**\n * On login, boots the WaaS client once per chain so the SDK eagerly recovers\n * key shares itself (the `eagerlyRecoverKeyShares` capability) instead of the\n * host looping per wallet. Booting calls `initialize()`, which sends the auth\n * token the iframe needs to self-recover.\n *\n * @notInstrumented\n */\nexport const initializeWaasClientsForEagerRecovery = async (\n client: DynamicClient\n): Promise<void> => {\n /**\n * Booting triggers recovery, which fails if the user is missing the MFA auth.\n * This early return avoids attempting a call we know will fail and just adds\n * noise to the logs.\n */\n if (isUserMissingMfaAuth(client)) {\n return;\n }\n\n const waasChains = new Set(\n getWalletAccounts(client)\n .filter((walletAccount) => isWaasWalletAccount({ walletAccount }))\n .map((walletAccount) => walletAccount.chain)\n );\n\n await Promise.all(\n [...waasChains].map(async (chain) => {\n const provider = findWaasWalletProviderByChain({ chain }, client);\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 nothing to boot.\n */\n if (!provider) return;\n\n try {\n await provider.getWaasClient();\n } catch (error) {\n getCore(client).logger.warn(\n '[initializeWaasClientsForEagerRecovery] failed to boot waas client',\n error\n );\n }\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\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\nexport type ParseElevatedAccessTokenOptions = {\n /** JWT string containing the elevated access token. */\n token: string;\n};\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 * @returns Parsed token data or null if token is invalid/expired\n * @notInstrumented\n */\nexport const parseElevatedAccessToken = ({\n token,\n}: ParseElevatedAccessTokenOptions): 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 <= new Date()) {\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 * @notInstrumented\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 { initializeWaasClientsForEagerRecovery } from '../../waas/initializeWaasClientsForEagerRecovery';\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/** @notInstrumented */\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({\n token: elevatedAccessToken,\n });\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, boot the waas client(s) so the SDK eagerly\n // recovers key shares for all wallet accounts\n const isUserLoggingIn = !previousState.user && Boolean(newState.user);\n if (isUserLoggingIn) {\n void initializeWaasClientsForEagerRecovery(client);\n }\n};\n","import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetVerifiedCredentialForWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\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","import type { DynamicClient } from '../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { getWalletProviders } from '../getWalletProviders';\n\ntype GetWalletProviderByKeyParams = {\n walletProviderKey: string;\n};\n\n/** @notInstrumented */\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"],"mappings":";;;;;;;;;AAQA,MAAa,kCAAkC,WAAgC;AAG7E,qCACE;EACE,MAAM,EAAE,gBAJWA,4CAAkB,OAAO,EAIpB;EACxB,OAAO;EACR,EACD,OACD;;;;;;ACPH,MAAa,2CACX,EAAE,iBACF,WACG;CACH,MAAM,OAAOC,kCAAQ,OAAO;AAS5B,KAPiC,sBAAsB,eAAe,OAAO,KAE7C,sBAC9B,KAAK,MAAM,KAAK,EAChB,OACD,CAGC,gCAA+B,OAAO;;AAM1C,MAAM,yBACJ,OACA,WAEAC,qDAA2B,OAAO,OAAO,CACtC,KAAK,kBAAkB,KAAK,UAAU,cAAc,CAAC,CACrD,MAAM,CACN,KAAK,IAAI;;;;;;;;AC9Bd,MAAa,sBAAsB,WAA0B;AAG3D,QAF+BC,oDAA0B,OAAO,CAElC,eAAe;;;;;;ACK/C,MAAa,iCACX,EAAE,SACF,WAC8B;CAC9B,MAAM,YAAY,mBAAmB,OAAO;CAE5C,MAAM,kBAAkBC,kDAAwB;EAC9C;EACA,aAAaC,gDAAsB;EACnC,oBAAoBC,8CAAmB;EACxC,CAAC;CAEF,MAAM,eAAe,UAAU,MAC5B,aAAa,SAAS,QAAQ,mBAAmB,SAAS,UAAU,MACtE;AAED,KAAI,CAAC,gBAAgB,CAACC,+CAAqB,aAAa,CACtD,QAAO;AAGT,QAAO;;;;;;;;;;;;;ACpBT,MAAa,uBAAuB,EAClC,oBACwC;AACxC,QAAO,cAAc,kBAAkB,SACrCC,gDAAsB,qBACvB;;;;;;;;;;;;;ACLH,MAAa,wCAAwC,OACnD,WACkB;;;;;;AAMlB,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AgB,OAAO,CAGxC,qCACE,GAAGC,mDAAyB,GAAG,YAAY,YAH1B,iBAAiB,aAAa,CAGmB,wBACnE;AAGH,yCAAwC,EAAE,eAAe,EAAE,OAAO;AAKlE,KADwB,CAAC,cAAc,QAAQ,QAAQ,SAAS,KAAK,CAEnE,CAAK,sCAAsC,OAAO;;;;;;AC3EtD,MAAa,yCACX,EAAE,iBACF,WACG;AACH,QAAO,OAAO,MAAM,oBAAoB,MACrC,OAAO,GAAG,OAAO,cAAc,qBACjC;;;;;;ACLH,MAAa,0BACX,EAAE,qBACF,WACG;CAGH,MAAM,iBAFkB,mBAAmB,OAAO,CAEX,MACpC,qBAAmBC,iBAAe,QAAQ,kBAC5C;AAED,KAAI,CAAC,eACH,OAAM,IAAIC,qDAA2B,EAAE,mBAAmB,CAAC;AAG7D,QAAO"}
@@ -1,474 +0,0 @@
1
- import { $ as getCore, C as emitEvent, H as assertDefined, Q as BaseError, V as isCookieEnabled, Y as getDefaultClient, a as DYNAMIC_WAAS_METADATA, b as NoWalletProviderFoundError, n as isWaasWalletProvider, o as isUserMissingMfaAuth, t as InvalidParamError, v as getWalletProviderRegistry, x as getChainFromVerifiedCredentialChain } from "./InvalidParamError-5AXtm6Zp.native.esm.js";
2
- import { JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
3
-
4
- //#region src/utils/setCookie/setCookie.ts
5
- /**
6
- * Sefelly sets the cookie in the browser.
7
- * @notInstrumented
8
- */
9
- const setCookie = (cookie) => {
10
- document.cookie = cookie;
11
- };
12
-
13
- //#endregion
14
- //#region src/errors/InvalidWalletProviderKeyError.ts
15
- var InvalidWalletProviderKeyError = class extends BaseError {
16
- constructor(value) {
17
- super({
18
- cause: null,
19
- code: "invalid_wallet_provider_key",
20
- docsUrl: null,
21
- name: "InvalidWalletProviderKeyError",
22
- shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`
23
- });
24
- }
25
- };
26
-
27
- //#endregion
28
- //#region src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts
29
- /** @notInstrumented */
30
- const splitWalletProviderKey = (walletProviderKey) => {
31
- const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] = walletProviderKey.split(":");
32
- if (!normalizedWalletNameWithChain || !Object.values(WalletProviderEnum).includes(walletProviderType) || rest.length > 0) throw new InvalidWalletProviderKeyError(walletProviderKey);
33
- return {
34
- normalizedWalletNameWithChain,
35
- suffix,
36
- walletProviderType
37
- };
38
- };
39
-
40
- //#endregion
41
- //#region src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts
42
- /** @notInstrumented */
43
- const normalizeAddress = ({ address, chain }) => {
44
- let normalizedAddress = address;
45
- if (normalizedAddress?.startsWith("0x")) normalizedAddress = normalizedAddress.slice(2);
46
- normalizedAddress = ["EVM", "FLOW"].includes(chain) ? normalizedAddress?.toLowerCase() : normalizedAddress;
47
- return normalizedAddress;
48
- };
49
-
50
- //#endregion
51
- //#region src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts
52
- /** @notInstrumented */
53
- const formatWalletAccountId = ({ address, chain, walletProviderKey }) => {
54
- const { normalizedWalletNameWithChain } = splitWalletProviderKey(walletProviderKey);
55
- return `${normalizedWalletNameWithChain}:${normalizeAddress({
56
- address,
57
- chain
58
- })}`;
59
- };
60
-
61
- //#endregion
62
- //#region src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts
63
- /** @notInstrumented */
64
- const convertUnverifiedWalletAccountToWalletAccount = ({ unverifiedWalletAccount }) => ({
65
- address: unverifiedWalletAccount.address,
66
- addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,
67
- chain: unverifiedWalletAccount.chain,
68
- id: formatWalletAccountId({
69
- address: unverifiedWalletAccount.address,
70
- chain: unverifiedWalletAccount.chain,
71
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
72
- }),
73
- lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
74
- verifiedCredentialId: null,
75
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
76
- });
77
-
78
- //#endregion
79
- //#region src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts
80
- /**
81
- * Format the raw wallet name and chain to get the value we can use for
82
- * verified credentials' `walletName` field.
83
- * @notInstrumented
84
- */
85
- const normalizeWalletNameWithChain = ({ displayName, chain }) => {
86
- const sanitizedWalletName = displayName.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
87
- const chainLowered = chain.toLocaleLowerCase();
88
- if (sanitizedWalletName.endsWith(chainLowered)) return sanitizedWalletName;
89
- return `${sanitizedWalletName}${chainLowered}`;
90
- };
91
-
92
- //#endregion
93
- //#region src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts
94
- /**
95
- * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.
96
- *
97
- * The suffix is optional and can be used to add a uniquely identifying string to the key, which
98
- * might be necessary for some wallet providers (like Wallet Connect).
99
- *
100
- * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account
101
- * to not be able to find its wallet provider when connecting to a new device (it won't be possible
102
- * to determine the full key just from the Verified Credential data).
103
- * @notInstrumented
104
- */
105
- const formatWalletProviderKey = ({ suffix, chain, displayName, walletProviderType }) => {
106
- return `${normalizeWalletNameWithChain({
107
- chain,
108
- displayName
109
- })}:${walletProviderType}${suffix ? `:${suffix}` : ""}`;
110
- };
111
-
112
- //#endregion
113
- //#region src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts
114
- /** @notInstrumented */
115
- const getWalletProviderKeyFromVerifiedCredential = ({ verifiedCredential }, client) => {
116
- const { walletProviderKeyMap } = getCore(client).state.get();
117
- const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];
118
- if (storedWalletProviderKey) return { walletProviderKey: storedWalletProviderKey };
119
- /**
120
- * We fallback to comprising the wallet provider key from walletName and walletProvider.
121
- *
122
- * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider
123
- * keys, so this won't be enough for them.
124
- * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider
125
- * and will require reconnection.
126
- * Read walletProvider.types.ts for more info.
127
- */
128
- assertDefined(verifiedCredential.walletName, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`);
129
- assertDefined(verifiedCredential.walletProvider, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`);
130
- assertDefined(verifiedCredential.chain, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`);
131
- return { walletProviderKey: formatWalletProviderKey({
132
- chain: getChainFromVerifiedCredentialChain(verifiedCredential.chain),
133
- displayName: verifiedCredential.walletName,
134
- walletProviderType: verifiedCredential.walletProvider
135
- }) };
136
- };
137
-
138
- //#endregion
139
- //#region src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts
140
- /** @notInstrumented */
141
- const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client) => {
142
- assertDefined(verifiedCredential.address, "Missing address in verified credential");
143
- assertDefined(verifiedCredential.chain, "Missing chain in verified credential");
144
- const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);
145
- const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential({ verifiedCredential }, client);
146
- const walletAccountId = formatWalletAccountId({
147
- address: verifiedCredential.address,
148
- chain,
149
- walletProviderKey
150
- });
151
- return {
152
- address: verifiedCredential.address,
153
- addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
154
- chain,
155
- hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
156
- id: walletAccountId,
157
- lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,
158
- verifiedCredentialId: verifiedCredential.id,
159
- walletProviderKey
160
- };
161
- };
162
-
163
- //#endregion
164
- //#region src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts
165
- /** @notInstrumented */
166
- const getWalletAccountsFromState = ({ unverifiedWalletAccounts, user }, client) => {
167
- const walletAccountsMap = /* @__PURE__ */ new Map();
168
- /**
169
- * Handle the unverified wallet accounts before the user verified credentials
170
- * so the later verified wallet accounts can override the unverified wallet accounts
171
- */
172
- unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {
173
- const walletAccount = convertUnverifiedWalletAccountToWalletAccount({ unverifiedWalletAccount });
174
- walletAccountsMap.set(walletAccount.id, walletAccount);
175
- });
176
- (user?.verifiedCredentials ?? []).filter((verified) => verified.format === JwtVerifiedCredentialFormatEnum.Blockchain).forEach((verifiedWalletAccount) => {
177
- try {
178
- const walletAccount = convertVerifiedCredentialToWalletAccount({ verifiedCredential: verifiedWalletAccount }, client);
179
- walletAccountsMap.set(walletAccount.id, walletAccount);
180
- } catch (error) {
181
- /**
182
- * A verified credential can be missing the data required to resolve its
183
- * wallet provider (e.g. a legacy credential without a walletName). Skip
184
- * it instead of throwing so a single unconvertible credential does not
185
- * abort the whole mapping — which, during client initialization, would
186
- * otherwise fail init and leave the app stuck loading. The wallet stays
187
- * absent until the user reconnects it.
188
- */
189
- getCore(client).logger.debug(`Skipping verified credential ${verifiedWalletAccount.id}: unable to convert to wallet account`, error);
190
- }
191
- });
192
- return Array.from(walletAccountsMap.values());
193
- };
194
-
195
- //#endregion
196
- //#region src/modules/wallets/getWalletAccounts/getWalletAccounts.ts
197
- /**
198
- * Retrieves all wallet accounts associated with the current session.
199
- *
200
- * This function returns both verified and unverified wallet accounts,
201
- * combining data from user credentials and local unverified accounts.
202
- * You can differentiate between verified and unverified wallet accounts by
203
- * checking the `verifiedCredentialId` property.
204
- *
205
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
206
- * @returns An array of wallet accounts associated with the session.
207
- * @notInstrumented
208
- * @hook Exposed as a hook so consumers get the reactive list of wallet accounts.
209
- */
210
- const getWalletAccounts = (client = getDefaultClient()) => {
211
- const { unverifiedWalletAccounts, user } = getCore(client).state.get();
212
- return getWalletAccountsFromState({
213
- unverifiedWalletAccounts,
214
- user
215
- }, client);
216
- };
217
-
218
- //#endregion
219
- //#region src/modules/auth/consts.ts
220
- const DYNAMIC_AUTH_COOKIE_NAME = "DYNAMIC_JWT_TOKEN";
221
-
222
- //#endregion
223
- //#region src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts
224
- /**
225
- * Emits the `walletAccountsChanged` event.
226
- * @notInstrumented
227
- */
228
- const emitWalletAccountsChangedEvent = (client) => {
229
- emitEvent({
230
- args: { walletAccounts: getWalletAccounts(client) },
231
- event: "walletAccountsChanged"
232
- }, client);
233
- };
234
-
235
- //#endregion
236
- //#region src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts
237
- /** @notInstrumented */
238
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client) => {
239
- const core = getCore(client);
240
- if (getWalletAccountsHash(previousState, client) !== getWalletAccountsHash(core.state.get(), client)) emitWalletAccountsChangedEvent(client);
241
- };
242
- const getWalletAccountsHash = (state, client) => getWalletAccountsFromState(state, client).map((walletAccount) => JSON.stringify(walletAccount)).sort().join("-");
243
-
244
- //#endregion
245
- //#region src/modules/wallets/getWalletProviders/getWalletProviders.ts
246
- /**
247
- * Get all available wallet providers to interact with internally.
248
- * @notInstrumented
249
- */
250
- const getWalletProviders = (client) => {
251
- return getWalletProviderRegistry(client).listProviders();
252
- };
253
-
254
- //#endregion
255
- //#region src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts
256
- /** @notInstrumented */
257
- const findWaasWalletProviderByChain = ({ chain }, client) => {
258
- const providers = getWalletProviders(client);
259
- const waasProviderKey = formatWalletProviderKey({
260
- chain,
261
- displayName: DYNAMIC_WAAS_METADATA.displayName,
262
- walletProviderType: WalletProviderEnum.EmbeddedWallet
263
- });
264
- const waasProvider = providers.find((provider) => provider.key === waasProviderKey && provider.chain === chain);
265
- if (!waasProvider || !isWaasWalletProvider(waasProvider)) return null;
266
- return waasProvider;
267
- };
268
-
269
- //#endregion
270
- //#region src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts
271
- /**
272
- * This function determines whether the provided wallet account is a Dynamic
273
- * WaaS wallet account.
274
- *
275
- * @param params.walletAccount - The wallet account to check.
276
- * @returns True if the wallet account is a WaaS wallet account, false otherwise.
277
- * @notInstrumented
278
- */
279
- const isWaasWalletAccount = ({ walletAccount }) => {
280
- return walletAccount.walletProviderKey.includes(DYNAMIC_WAAS_METADATA.normalizedWalletName);
281
- };
282
-
283
- //#endregion
284
- //#region src/modules/waas/initializeWaasClientsForEagerRecovery/initializeWaasClientsForEagerRecovery.ts
285
- /**
286
- * On login, boots the WaaS client once per chain so the SDK eagerly recovers
287
- * key shares itself (the `eagerlyRecoverKeyShares` capability) instead of the
288
- * host looping per wallet. Booting calls `initialize()`, which sends the auth
289
- * token the iframe needs to self-recover.
290
- *
291
- * @notInstrumented
292
- */
293
- const initializeWaasClientsForEagerRecovery = async (client) => {
294
- /**
295
- * Booting triggers recovery, which fails if the user is missing the MFA auth.
296
- * This early return avoids attempting a call we know will fail and just adds
297
- * noise to the logs.
298
- */
299
- if (isUserMissingMfaAuth(client)) return;
300
- const waasChains = new Set(getWalletAccounts(client).filter((walletAccount) => isWaasWalletAccount({ walletAccount })).map((walletAccount) => walletAccount.chain));
301
- await Promise.all([...waasChains].map(async (chain) => {
302
- const provider = findWaasWalletProviderByChain({ chain }, client);
303
- /**
304
- * The environment might not have the embedded wallet extensions installed.
305
- * In that case there is no provider for the chain and nothing to boot.
306
- */
307
- if (!provider) return;
308
- try {
309
- await provider.getWaasClient();
310
- } catch (error) {
311
- getCore(client).logger.warn("[initializeWaasClientsForEagerRecovery] failed to boot waas client", error);
312
- }
313
- }));
314
- };
315
-
316
- //#endregion
317
- //#region src/modules/auth/decodeJwt/decodeJwt.ts
318
- /**
319
- * Decodes a JWT token and returns the full payload.
320
- *
321
- * This function extracts and returns the complete JWT payload including scopes,
322
- * expiration time, and other claims.
323
- *
324
- * @param jwt - The JWT token string.
325
- * @returns The decoded JWT payload object.
326
- * @throws InvalidParamError if the token is invalid or cannot be decoded.
327
- *
328
- * @example
329
- * ```typescript
330
- * const payload = decodeJwt(jwt);
331
- * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }
332
- * ```
333
- * @notInstrumented
334
- */
335
- const decodeJwt = (jwt) => {
336
- try {
337
- const parts = jwt.split(".");
338
- if (parts.length !== 3) throw new InvalidParamError("Invalid JWT format");
339
- const base64Payload = parts[1].replaceAll("-", "+").replaceAll("_", "/");
340
- const paddedPayload = base64Payload + "=".repeat((4 - base64Payload.length % 4) % 4);
341
- const decodedPayload = atob(paddedPayload);
342
- return JSON.parse(decodedPayload);
343
- } catch (error) {
344
- if (error instanceof InvalidParamError) throw error;
345
- throw new InvalidParamError(`Failed to decode JWT: ${error instanceof Error ? error.message : String(error)}`);
346
- }
347
- };
348
-
349
- //#endregion
350
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts
351
- /**
352
- * Normalizes scopes by deduplicating and sorting them.
353
- * This creates a canonical representation for comparison.
354
- *
355
- * @param scopes - Array of scope strings (may contain duplicates)
356
- * @returns Normalized, sorted array of unique scopes
357
- * @notInstrumented
358
- */
359
- const normalizeScopes = (scopes) => {
360
- return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));
361
- };
362
-
363
- //#endregion
364
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts
365
- /**
366
- * Validates and parses an elevated access token from a JWT string.
367
- * Extracts scopes, expiration, and validates the token structure.
368
- *
369
- * Policy decisions:
370
- * - Tokens without scopes are rejected (returns null)
371
- * - Tokens with empty scopes array are rejected (returns null)
372
- * - Tokens without exp field are rejected (returns null)
373
- * - Expired tokens are rejected (returns null)
374
- *
375
- * @returns Parsed token data or null if token is invalid/expired
376
- * @notInstrumented
377
- */
378
- const parseElevatedAccessToken = ({ token }) => {
379
- const payload = decodeJwt(token);
380
- const filteredScopes = ((payload?.scope)?.split(" ") ?? []).filter((s) => s.length > 0);
381
- const singleUse = payload.singleUse ?? false;
382
- if (!filteredScopes || filteredScopes.length === 0) return null;
383
- if (!payload.exp) return null;
384
- const expiresAt = /* @__PURE__ */ new Date(payload.exp * 1e3);
385
- if (expiresAt <= /* @__PURE__ */ new Date()) return null;
386
- return {
387
- expiresAt,
388
- normalizedScopes: normalizeScopes(filteredScopes),
389
- scopes: filteredScopes,
390
- singleUse,
391
- token
392
- };
393
- };
394
-
395
- //#endregion
396
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts
397
- /**
398
- * Upserts an elevated access token into the current tokens array.
399
- *
400
- * Policy: Only one token per normalized scope-set is allowed.
401
- * If a token with the same normalized scopes exists, it is replaced.
402
- * This ensures we don't accumulate multiple tokens for the same scope combination.
403
- *
404
- * @param currentTokens - Current array of elevated access tokens
405
- * @param newToken - New token to upsert
406
- * @returns Updated array of tokens with the new token upserted
407
- * @notInstrumented
408
- */
409
- const upsertElevatedAccessToken = ({ currentTokens, newToken }) => {
410
- const newScopeKey = normalizeScopes(newToken.scopes).join(" ");
411
- return [...currentTokens.filter((existingToken) => {
412
- return normalizeScopes(existingToken.scopes).join(" ") !== newScopeKey;
413
- }), {
414
- expiresAt: newToken.expiresAt,
415
- scopes: newToken.scopes,
416
- singleUse: newToken.singleUse,
417
- token: newToken.token
418
- }];
419
- };
420
-
421
- //#endregion
422
- //#region src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts
423
- /** @notInstrumented */
424
- const updateAuthFromVerifyResponse = ({ response }, client) => {
425
- const core = getCore(client);
426
- const previousState = { ...core.state.get() };
427
- const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } = response;
428
- const sessionExpiresAt = /* @__PURE__ */ new Date(expiresAt * 1e3);
429
- const newState = {
430
- legacyToken: jwt ?? null,
431
- sessionExpiresAt,
432
- token: minifiedJwt ?? null,
433
- user
434
- };
435
- if (mfaToken) newState.mfaToken = mfaToken;
436
- const currentTokens = core.state.get().elevatedAccessTokens || [];
437
- newState.elevatedAccessTokens = currentTokens;
438
- if (elevatedAccessToken) {
439
- const parsedToken = parseElevatedAccessToken({ token: elevatedAccessToken });
440
- if (parsedToken) newState.elevatedAccessTokens = upsertElevatedAccessToken({
441
- currentTokens,
442
- newToken: parsedToken
443
- });
444
- }
445
- core.state.set(newState);
446
- /**
447
- * For customers using a sandbox environment with cookies enabled, we need to set the cookie
448
- * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically
449
- * so customers can access the cookie from document.cookie consistently between sandbox and live environments.
450
- */
451
- if (minifiedJwt && isCookieEnabled(client)) setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${sessionExpiresAt.toUTCString()}; path=/; SameSite=Lax`);
452
- checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
453
- if (!previousState.user && Boolean(newState.user)) initializeWaasClientsForEagerRecovery(client);
454
- };
455
-
456
- //#endregion
457
- //#region src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts
458
- /** @notInstrumented */
459
- const getVerifiedCredentialForWalletAccount = ({ walletAccount }, client) => {
460
- return client.user?.verifiedCredentials.find((vc) => vc.id === walletAccount.verifiedCredentialId);
461
- };
462
-
463
- //#endregion
464
- //#region src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts
465
- /** @notInstrumented */
466
- const getWalletProviderByKey = ({ walletProviderKey }, client) => {
467
- const walletProvider = getWalletProviders(client).find((walletProvider$1) => walletProvider$1.key === walletProviderKey);
468
- if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey });
469
- return walletProvider;
470
- };
471
-
472
- //#endregion
473
- export { normalizeAddress as _, parseElevatedAccessToken as a, setCookie as b, findWaasWalletProviderByChain as c, emitWalletAccountsChangedEvent as d, DYNAMIC_AUTH_COOKIE_NAME as f, formatWalletAccountId as g, normalizeWalletNameWithChain as h, upsertElevatedAccessToken as i, getWalletProviders as l, formatWalletProviderKey as m, getVerifiedCredentialForWalletAccount as n, initializeWaasClientsForEagerRecovery as o, getWalletAccounts as p, updateAuthFromVerifyResponse as r, isWaasWalletAccount as s, getWalletProviderByKey as t, checkAndRaiseWalletAccountsChangedEvent as u, splitWalletProviderKey as v, InvalidWalletProviderKeyError as y };
474
- //# sourceMappingURL=getWalletProviderByKey-Dh2qnBmw.native.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletProviderByKey-Dh2qnBmw.native.esm.js","names":["walletAccountsMap: Map<string, WalletAccount>","newState: Partial<DynamicCoreState>","walletProvider"],"sources":["../src/utils/setCookie/setCookie.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/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/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts","../src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts","../src/modules/waas/initializeWaasClientsForEagerRecovery/initializeWaasClientsForEagerRecovery.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/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts","../src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts"],"sourcesContent":["/**\n * Sefelly sets the cookie in the browser.\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\nexport const setCookie = (cookie: string) => {\n // eslint-disable-next-line no-restricted-globals\n document.cookie = cookie;\n};\n","import { BaseError } from './base';\n\nexport class InvalidWalletProviderKeyError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\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/** @notInstrumented */\n// eslint-disable-next-line custom-rules/require-single-object-param\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\nexport type NormalizeAddressOptions = {\n /** The raw address to normalize. */\n address: string;\n\n /** The chain the address belongs to. */\n chain: Chain;\n};\n\n/** @notInstrumented */\nexport const normalizeAddress = ({ address, chain }: NormalizeAddressOptions) => {\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/** @notInstrumented */\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/** @notInstrumented */\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 * @notInstrumented\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 * @notInstrumented\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/** @notInstrumented */\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/** @notInstrumented */\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 { getCore } from '../../../../client/core/getCore';\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/** @notInstrumented */\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 try {\n const walletAccount = convertVerifiedCredentialToWalletAccount(\n {\n verifiedCredential: verifiedWalletAccount,\n },\n client\n );\n\n walletAccountsMap.set(walletAccount.id, walletAccount);\n } catch (error) {\n /**\n * A verified credential can be missing the data required to resolve its\n * wallet provider (e.g. a legacy credential without a walletName). Skip\n * it instead of throwing so a single unconvertible credential does not\n * abort the whole mapping — which, during client initialization, would\n * otherwise fail init and leave the app stuck loading. The wallet stays\n * absent until the user reconnects it.\n */\n getCore(client).logger.debug(\n `Skipping verified credential ${verifiedWalletAccount.id}: unable to convert to wallet account`,\n error\n );\n }\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 * @notInstrumented\n * @hook Exposed as a hook so consumers get the reactive list of wallet accounts.\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","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 * @notInstrumented\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/** @notInstrumented */\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\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 * @notInstrumented\n */\nexport const getWalletProviders = (client: DynamicClient) => {\n const walletProviderRegistry = getWalletProviderRegistry(client);\n\n return walletProviderRegistry.listProviders();\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/** @notInstrumented */\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 * @notInstrumented\n */\nexport const isWaasWalletAccount = ({\n walletAccount,\n}: IsWaasWalletAccountParams): boolean => {\n return walletAccount.walletProviderKey.includes(\n DYNAMIC_WAAS_METADATA.normalizedWalletName\n );\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\nimport { findWaasWalletProviderByChain } from '../findWaasWalletProviderByChain';\nimport { isWaasWalletAccount } from '../isWaasWalletAccount';\n\n/**\n * On login, boots the WaaS client once per chain so the SDK eagerly recovers\n * key shares itself (the `eagerlyRecoverKeyShares` capability) instead of the\n * host looping per wallet. Booting calls `initialize()`, which sends the auth\n * token the iframe needs to self-recover.\n *\n * @notInstrumented\n */\nexport const initializeWaasClientsForEagerRecovery = async (\n client: DynamicClient\n): Promise<void> => {\n /**\n * Booting triggers recovery, which fails if the user is missing the MFA auth.\n * This early return avoids attempting a call we know will fail and just adds\n * noise to the logs.\n */\n if (isUserMissingMfaAuth(client)) {\n return;\n }\n\n const waasChains = new Set(\n getWalletAccounts(client)\n .filter((walletAccount) => isWaasWalletAccount({ walletAccount }))\n .map((walletAccount) => walletAccount.chain)\n );\n\n await Promise.all(\n [...waasChains].map(async (chain) => {\n const provider = findWaasWalletProviderByChain({ chain }, client);\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 nothing to boot.\n */\n if (!provider) return;\n\n try {\n await provider.getWaasClient();\n } catch (error) {\n getCore(client).logger.warn(\n '[initializeWaasClientsForEagerRecovery] failed to boot waas client',\n error\n );\n }\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\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 * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param\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\nexport type ParseElevatedAccessTokenOptions = {\n /** JWT string containing the elevated access token. */\n token: string;\n};\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 * @returns Parsed token data or null if token is invalid/expired\n * @notInstrumented\n */\nexport const parseElevatedAccessToken = ({\n token,\n}: ParseElevatedAccessTokenOptions): 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 <= new Date()) {\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 * @notInstrumented\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 { initializeWaasClientsForEagerRecovery } from '../../waas/initializeWaasClientsForEagerRecovery';\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/** @notInstrumented */\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({\n token: elevatedAccessToken,\n });\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, boot the waas client(s) so the SDK eagerly\n // recovers key shares for all wallet accounts\n const isUserLoggingIn = !previousState.user && Boolean(newState.user);\n if (isUserLoggingIn) {\n void initializeWaasClientsForEagerRecovery(client);\n }\n};\n","import type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetVerifiedCredentialForWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\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","import type { DynamicClient } from '../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { getWalletProviders } from '../getWalletProviders';\n\ntype GetWalletProviderByKeyParams = {\n walletProviderKey: string;\n};\n\n/** @notInstrumented */\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"],"mappings":";;;;;;;;AAKA,MAAa,aAAa,WAAmB;AAE3C,UAAS,SAAS;;;;;ACLpB,IAAa,gCAAb,cAAmD,UAAU;CAE3D,YAAY,OAAe;AACzB,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,gCAAgC,MAAM;GACrD,CAAC;;;;;;;ACCN,MAAa,0BACX,sBACiC;CACjC,MAAM,CAAC,+BAA+B,oBAAoB,QAAQ,GAAG,QACnE,kBAAkB,MAAM,IAAI;AAE9B,KACE,CAAC,iCACD,CAAC,OAAO,OAAO,mBAAmB,CAAC,SACjC,mBACD,IACD,KAAK,SAAS,EAEd,OAAM,IAAI,8BAA8B,kBAAkB;AAG5D,QAAO;EACL;EACA;EACoB;EACrB;;;;;;ACrBH,MAAa,oBAAoB,EAAE,SAAS,YAAqC;CAC/E,IAAI,oBAAoB;AAExB,KAAI,mBAAmB,WAAW,KAAK,CACrC,qBAAoB,kBAAkB,MAAM,EAAE;AAUhD,qBAFmD,CAAC,OAAO,OAAO,CAEZ,SAAS,MAAM,GACjE,mBAAmB,aAAa,GAChC;AAEJ,QAAO;;;;;;AClBT,MAAa,yBAAyB,EACpC,SACA,OACA,wBACyC;CACzC,MAAM,EAAE,kCACN,uBAAuB,kBAAkB;AAI3C,QAAO,GAAG,8BAA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