@dynamic-labs-sdk/client 1.16.0 → 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 (112) hide show
  1. package/dist/core.cjs +53 -53
  2. package/dist/core.cjs.map +1 -1
  3. package/dist/core.esm.js +7 -7
  4. package/dist/core.esm.js.map +1 -1
  5. package/dist/core.native.esm.js +5 -5
  6. package/dist/exports/waas.d.ts +2 -1
  7. package/dist/exports/waas.d.ts.map +1 -1
  8. package/dist/exports/waasCore.d.ts +3 -2
  9. package/dist/exports/waasCore.d.ts.map +1 -1
  10. package/dist/{getNetworkProviderFromNetworkId-CregkqLB.esm.js → getNetworkProviderFromNetworkId-BVVs3arj.esm.js} +6 -7
  11. package/dist/getNetworkProviderFromNetworkId-BVVs3arj.esm.js.map +1 -0
  12. package/dist/{getNetworkProviderFromNetworkId-BURAkmc3.native.esm.js → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js} +3 -4
  13. package/dist/{getNetworkProviderFromNetworkId-BURAkmc3.native.esm.js.map → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js.map} +1 -1
  14. package/dist/{getNetworkProviderFromNetworkId-BpvoqbEH.cjs → getNetworkProviderFromNetworkId-DzzocxRc.cjs} +43 -44
  15. package/dist/{getNetworkProviderFromNetworkId-BpvoqbEH.cjs.map → getNetworkProviderFromNetworkId-DzzocxRc.cjs.map} +1 -1
  16. package/dist/{getSignedSessionId-Czpvp58E.esm.js → getSignedSessionId-Bnuz2Aqc.esm.js} +3 -3
  17. package/dist/{getSignedSessionId-Czpvp58E.esm.js.map → getSignedSessionId-Bnuz2Aqc.esm.js.map} +1 -1
  18. package/dist/{getSignedSessionId-C98wdvMw.cjs → getSignedSessionId-Dx0qQLMP.cjs} +11 -11
  19. package/dist/{getSignedSessionId-C98wdvMw.cjs.map → getSignedSessionId-Dx0qQLMP.cjs.map} +1 -1
  20. package/dist/{getSignedSessionId-upC71vLP.native.esm.js → getSignedSessionId-Pc_5wscD.native.esm.js} +3 -3
  21. package/dist/{getSignedSessionId-upC71vLP.native.esm.js.map → getSignedSessionId-Pc_5wscD.native.esm.js.map} +1 -1
  22. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js +20 -0
  23. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js.map +1 -0
  24. package/dist/getWalletProviderByKey-BLWcueTR.cjs +31 -0
  25. package/dist/getWalletProviderByKey-BLWcueTR.cjs.map +1 -0
  26. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js +20 -0
  27. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js.map +1 -0
  28. package/dist/index.cjs +539 -540
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.esm.js +9 -10
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/index.native.esm.js +6 -7
  33. package/dist/index.native.esm.js.map +1 -1
  34. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs +88 -0
  35. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs.map +1 -0
  36. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js +70 -0
  37. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js.map +1 -0
  38. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js +70 -0
  39. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js.map +1 -0
  40. package/dist/{isMfaRequiredForAction-CgVdSGRA.esm.js → isMfaRequiredForAction-B7wNkqQf.esm.js} +2 -2
  41. package/dist/{isMfaRequiredForAction-CgVdSGRA.esm.js.map → isMfaRequiredForAction-B7wNkqQf.esm.js.map} +1 -1
  42. package/dist/{isMfaRequiredForAction-juTvf3Pl.native.esm.js → isMfaRequiredForAction-CJ9qbBUz.native.esm.js} +2 -2
  43. package/dist/{isMfaRequiredForAction-juTvf3Pl.native.esm.js.map → isMfaRequiredForAction-CJ9qbBUz.native.esm.js.map} +1 -1
  44. package/dist/{isMfaRequiredForAction-DECknr5q.cjs → isMfaRequiredForAction-CaNdGc-m.cjs} +29 -29
  45. package/dist/{isMfaRequiredForAction-DECknr5q.cjs.map → isMfaRequiredForAction-CaNdGc-m.cjs.map} +1 -1
  46. package/dist/{isUserOnboardingComplete-DFrrp61b.esm.js → isUserOnboardingComplete-CGz-9Iyw.esm.js} +3 -3
  47. package/dist/{isUserOnboardingComplete-DFrrp61b.esm.js.map → isUserOnboardingComplete-CGz-9Iyw.esm.js.map} +1 -1
  48. package/dist/{isUserOnboardingComplete-Dtr1_Mi4.native.esm.js → isUserOnboardingComplete-FRAIuxdi.native.esm.js} +3 -3
  49. package/dist/{isUserOnboardingComplete-Dtr1_Mi4.native.esm.js.map → isUserOnboardingComplete-FRAIuxdi.native.esm.js.map} +1 -1
  50. package/dist/{isUserOnboardingComplete-DvCQh8Dj.cjs → isUserOnboardingComplete-w1IkCC_p.cjs} +13 -13
  51. package/dist/{isUserOnboardingComplete-DvCQh8Dj.cjs.map → isUserOnboardingComplete-w1IkCC_p.cjs.map} +1 -1
  52. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js +65 -0
  53. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js.map +1 -0
  54. package/dist/migrateFromFireblocks-CjQWJPZW.cjs +82 -0
  55. package/dist/migrateFromFireblocks-CjQWJPZW.cjs.map +1 -0
  56. package/dist/migrateFromFireblocks-DXs3odF_.esm.js +65 -0
  57. package/dist/migrateFromFireblocks-DXs3odF_.esm.js.map +1 -0
  58. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  59. package/dist/modules/waas/migrateFromFireblocks/index.d.ts +2 -0
  60. package/dist/modules/waas/migrateFromFireblocks/index.d.ts.map +1 -0
  61. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts +52 -0
  62. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts.map +1 -0
  63. package/dist/modules/waas/waas.types.d.ts +9 -1
  64. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  65. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  66. package/dist/{InvalidParamError-Dn_riAvL.esm.js → updateAuthFromVerifyResponse-BdokPJ21.esm.js} +237 -3
  67. package/dist/updateAuthFromVerifyResponse-BdokPJ21.esm.js.map +1 -0
  68. package/dist/{InvalidParamError-DHriGGNI.cjs → updateAuthFromVerifyResponse-CUnvs5Af.cjs} +291 -9
  69. package/dist/updateAuthFromVerifyResponse-CUnvs5Af.cjs.map +1 -0
  70. package/dist/{InvalidParamError-DYezznCD.native.esm.js → updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js} +457 -4
  71. package/dist/updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js.map +1 -0
  72. package/dist/waas.cjs +53 -67
  73. package/dist/waas.cjs.map +1 -1
  74. package/dist/waas.esm.js +5 -20
  75. package/dist/waas.esm.js.map +1 -1
  76. package/dist/waas.native.esm.js +5 -20
  77. package/dist/waas.native.esm.js.map +1 -1
  78. package/dist/waasCore.cjs +40 -23
  79. package/dist/waasCore.cjs.map +1 -1
  80. package/dist/waasCore.esm.js +23 -7
  81. package/dist/waasCore.esm.js.map +1 -1
  82. package/dist/waasCore.native.esm.js +23 -7
  83. package/dist/waasCore.native.esm.js.map +1 -1
  84. package/package.json +2 -2
  85. package/dist/InvalidParamError-DHriGGNI.cjs.map +0 -1
  86. package/dist/InvalidParamError-DYezznCD.native.esm.js.map +0 -1
  87. package/dist/InvalidParamError-Dn_riAvL.esm.js.map +0 -1
  88. package/dist/getNetworkProviderFromNetworkId-CregkqLB.esm.js.map +0 -1
  89. package/dist/getWaasWalletProviderFromWalletAccount-BrskhuL8.cjs +0 -19
  90. package/dist/getWaasWalletProviderFromWalletAccount-BrskhuL8.cjs.map +0 -1
  91. package/dist/getWaasWalletProviderFromWalletAccount-DHKga3uH.native.esm.js +0 -14
  92. package/dist/getWaasWalletProviderFromWalletAccount-DHKga3uH.native.esm.js.map +0 -1
  93. package/dist/getWaasWalletProviderFromWalletAccount-Dc6QvHVt.esm.js +0 -14
  94. package/dist/getWaasWalletProviderFromWalletAccount-Dc6QvHVt.esm.js.map +0 -1
  95. package/dist/getWalletProviderByKey-DDNCUbUe.cjs +0 -321
  96. package/dist/getWalletProviderByKey-DDNCUbUe.cjs.map +0 -1
  97. package/dist/getWalletProviderByKey-DTi6MhKt.esm.js +0 -255
  98. package/dist/getWalletProviderByKey-DTi6MhKt.esm.js.map +0 -1
  99. package/dist/getWalletProviderByKey-OYhHm11_.native.esm.js +0 -474
  100. package/dist/getWalletProviderByKey-OYhHm11_.native.esm.js.map +0 -1
  101. package/dist/isDynamicWaasEnabled-Bj3v8LZ_.cjs +0 -49
  102. package/dist/isDynamicWaasEnabled-Bj3v8LZ_.cjs.map +0 -1
  103. package/dist/isDynamicWaasEnabled-CuSe2RO1.esm.js +0 -37
  104. package/dist/isDynamicWaasEnabled-CuSe2RO1.esm.js.map +0 -1
  105. package/dist/isDynamicWaasEnabled-CvD8_c7H.native.esm.js +0 -37
  106. package/dist/isDynamicWaasEnabled-CvD8_c7H.native.esm.js.map +0 -1
  107. package/dist/refreshAuth-CKHkaRJo.native.esm.js +0 -38
  108. package/dist/refreshAuth-CKHkaRJo.native.esm.js.map +0 -1
  109. package/dist/refreshAuth-Q5fxSi3Z.esm.js +0 -38
  110. package/dist/refreshAuth-Q5fxSi3Z.esm.js.map +0 -1
  111. package/dist/refreshAuth-oycoOXtD.cjs +0 -43
  112. package/dist/refreshAuth-oycoOXtD.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletProviderByKey-DDNCUbUe.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;;;;;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AeC,0CAAgB,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,255 +0,0 @@
1
- import { C as getWalletAccountsFromState, I as setCookie, M as emitEvent, S as getWalletAccounts, Z as isCookieEnabled, a as DYNAMIC_WAAS_METADATA, g as DYNAMIC_AUTH_COOKIE_NAME, lt as getCore, n as isWaasWalletProvider, o as isUserMissingMfaAuth, t as InvalidParamError, w as formatWalletProviderKey, x as NoWalletProviderFoundError, y as getWalletProviderRegistry } from "./InvalidParamError-Dn_riAvL.esm.js";
2
- import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
3
-
4
- //#region src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts
5
- /**
6
- * Emits the `walletAccountsChanged` event.
7
- * @notInstrumented
8
- */
9
- const emitWalletAccountsChangedEvent = (client) => {
10
- emitEvent({
11
- args: { walletAccounts: getWalletAccounts(client) },
12
- event: "walletAccountsChanged"
13
- }, client);
14
- };
15
-
16
- //#endregion
17
- //#region src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts
18
- /** @notInstrumented */
19
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client) => {
20
- const core = getCore(client);
21
- if (getWalletAccountsHash(previousState, client) !== getWalletAccountsHash(core.state.get(), client)) emitWalletAccountsChangedEvent(client);
22
- };
23
- const getWalletAccountsHash = (state, client) => getWalletAccountsFromState(state, client).map((walletAccount) => JSON.stringify(walletAccount)).sort().join("-");
24
-
25
- //#endregion
26
- //#region src/modules/wallets/getWalletProviders/getWalletProviders.ts
27
- /**
28
- * Get all available wallet providers to interact with internally.
29
- * @notInstrumented
30
- */
31
- const getWalletProviders = (client) => {
32
- return getWalletProviderRegistry(client).listProviders();
33
- };
34
-
35
- //#endregion
36
- //#region src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts
37
- /** @notInstrumented */
38
- const findWaasWalletProviderByChain = ({ chain }, client) => {
39
- const providers = getWalletProviders(client);
40
- const waasProviderKey = formatWalletProviderKey({
41
- chain,
42
- displayName: DYNAMIC_WAAS_METADATA.displayName,
43
- walletProviderType: WalletProviderEnum.EmbeddedWallet
44
- });
45
- const waasProvider = providers.find((provider) => provider.key === waasProviderKey && provider.chain === chain);
46
- if (!waasProvider || !isWaasWalletProvider(waasProvider)) return null;
47
- return waasProvider;
48
- };
49
-
50
- //#endregion
51
- //#region src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts
52
- /**
53
- * This function determines whether the provided wallet account is a Dynamic
54
- * WaaS wallet account.
55
- *
56
- * @param params.walletAccount - The wallet account to check.
57
- * @returns True if the wallet account is a WaaS wallet account, false otherwise.
58
- * @notInstrumented
59
- */
60
- const isWaasWalletAccount = ({ walletAccount }) => {
61
- return walletAccount.walletProviderKey.includes(DYNAMIC_WAAS_METADATA.normalizedWalletName);
62
- };
63
-
64
- //#endregion
65
- //#region src/modules/waas/initializeWaasClientsForEagerRecovery/initializeWaasClientsForEagerRecovery.ts
66
- /**
67
- * On login, boots the WaaS client once per chain so the SDK eagerly recovers
68
- * key shares itself (the `eagerlyRecoverKeyShares` capability) instead of the
69
- * host looping per wallet. Booting calls `initialize()`, which sends the auth
70
- * token the iframe needs to self-recover.
71
- *
72
- * @notInstrumented
73
- */
74
- const initializeWaasClientsForEagerRecovery = async (client) => {
75
- /**
76
- * Booting triggers recovery, which fails if the user is missing the MFA auth.
77
- * This early return avoids attempting a call we know will fail and just adds
78
- * noise to the logs.
79
- */
80
- if (isUserMissingMfaAuth(client)) return;
81
- const waasChains = new Set(getWalletAccounts(client).filter((walletAccount) => isWaasWalletAccount({ walletAccount })).map((walletAccount) => walletAccount.chain));
82
- await Promise.all([...waasChains].map(async (chain) => {
83
- const provider = findWaasWalletProviderByChain({ chain }, client);
84
- /**
85
- * The environment might not have the embedded wallet extensions installed.
86
- * In that case there is no provider for the chain and nothing to boot.
87
- */
88
- if (!provider) return;
89
- try {
90
- await provider.getWaasClient();
91
- } catch (error) {
92
- getCore(client).logger.warn("[initializeWaasClientsForEagerRecovery] failed to boot waas client", error);
93
- }
94
- }));
95
- };
96
-
97
- //#endregion
98
- //#region src/modules/auth/decodeJwt/decodeJwt.ts
99
- /**
100
- * Decodes a JWT token and returns the full payload.
101
- *
102
- * This function extracts and returns the complete JWT payload including scopes,
103
- * expiration time, and other claims.
104
- *
105
- * @param jwt - The JWT token string.
106
- * @returns The decoded JWT payload object.
107
- * @throws InvalidParamError if the token is invalid or cannot be decoded.
108
- *
109
- * @example
110
- * ```typescript
111
- * const payload = decodeJwt(jwt);
112
- * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }
113
- * ```
114
- * @notInstrumented
115
- */
116
- const decodeJwt = (jwt) => {
117
- try {
118
- const parts = jwt.split(".");
119
- if (parts.length !== 3) throw new InvalidParamError("Invalid JWT format");
120
- const base64Payload = parts[1].replaceAll("-", "+").replaceAll("_", "/");
121
- const paddedPayload = base64Payload + "=".repeat((4 - base64Payload.length % 4) % 4);
122
- const decodedPayload = atob(paddedPayload);
123
- return JSON.parse(decodedPayload);
124
- } catch (error) {
125
- if (error instanceof InvalidParamError) throw error;
126
- throw new InvalidParamError(`Failed to decode JWT: ${error instanceof Error ? error.message : String(error)}`);
127
- }
128
- };
129
-
130
- //#endregion
131
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts
132
- /**
133
- * Normalizes scopes by deduplicating and sorting them.
134
- * This creates a canonical representation for comparison.
135
- *
136
- * @param scopes - Array of scope strings (may contain duplicates)
137
- * @returns Normalized, sorted array of unique scopes
138
- * @notInstrumented
139
- */
140
- const normalizeScopes = (scopes) => {
141
- return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));
142
- };
143
-
144
- //#endregion
145
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts
146
- /**
147
- * Validates and parses an elevated access token from a JWT string.
148
- * Extracts scopes, expiration, and validates the token structure.
149
- *
150
- * Policy decisions:
151
- * - Tokens without scopes are rejected (returns null)
152
- * - Tokens with empty scopes array are rejected (returns null)
153
- * - Tokens without exp field are rejected (returns null)
154
- * - Expired tokens are rejected (returns null)
155
- *
156
- * @returns Parsed token data or null if token is invalid/expired
157
- * @notInstrumented
158
- */
159
- const parseElevatedAccessToken = ({ token }) => {
160
- const payload = decodeJwt(token);
161
- const filteredScopes = ((payload?.scope)?.split(" ") ?? []).filter((s) => s.length > 0);
162
- const singleUse = payload.singleUse ?? false;
163
- if (!filteredScopes || filteredScopes.length === 0) return null;
164
- if (!payload.exp) return null;
165
- const expiresAt = /* @__PURE__ */ new Date(payload.exp * 1e3);
166
- if (expiresAt <= /* @__PURE__ */ new Date()) return null;
167
- return {
168
- expiresAt,
169
- normalizedScopes: normalizeScopes(filteredScopes),
170
- scopes: filteredScopes,
171
- singleUse,
172
- token
173
- };
174
- };
175
-
176
- //#endregion
177
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts
178
- /**
179
- * Upserts an elevated access token into the current tokens array.
180
- *
181
- * Policy: Only one token per normalized scope-set is allowed.
182
- * If a token with the same normalized scopes exists, it is replaced.
183
- * This ensures we don't accumulate multiple tokens for the same scope combination.
184
- *
185
- * @param currentTokens - Current array of elevated access tokens
186
- * @param newToken - New token to upsert
187
- * @returns Updated array of tokens with the new token upserted
188
- * @notInstrumented
189
- */
190
- const upsertElevatedAccessToken = ({ currentTokens, newToken }) => {
191
- const newScopeKey = normalizeScopes(newToken.scopes).join(" ");
192
- return [...currentTokens.filter((existingToken) => {
193
- return normalizeScopes(existingToken.scopes).join(" ") !== newScopeKey;
194
- }), {
195
- expiresAt: newToken.expiresAt,
196
- scopes: newToken.scopes,
197
- singleUse: newToken.singleUse,
198
- token: newToken.token
199
- }];
200
- };
201
-
202
- //#endregion
203
- //#region src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts
204
- /** @notInstrumented */
205
- const updateAuthFromVerifyResponse = ({ response }, client) => {
206
- const core = getCore(client);
207
- const previousState = { ...core.state.get() };
208
- const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } = response;
209
- const sessionExpiresAt = /* @__PURE__ */ new Date(expiresAt * 1e3);
210
- const newState = {
211
- legacyToken: jwt ?? null,
212
- sessionExpiresAt,
213
- token: minifiedJwt ?? null,
214
- user
215
- };
216
- if (mfaToken) newState.mfaToken = mfaToken;
217
- const currentTokens = core.state.get().elevatedAccessTokens || [];
218
- newState.elevatedAccessTokens = currentTokens;
219
- if (elevatedAccessToken) {
220
- const parsedToken = parseElevatedAccessToken({ token: elevatedAccessToken });
221
- if (parsedToken) newState.elevatedAccessTokens = upsertElevatedAccessToken({
222
- currentTokens,
223
- newToken: parsedToken
224
- });
225
- }
226
- core.state.set(newState);
227
- /**
228
- * For customers using a sandbox environment with cookies enabled, we need to set the cookie
229
- * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically
230
- * so customers can access the cookie from document.cookie consistently between sandbox and live environments.
231
- */
232
- if (minifiedJwt && isCookieEnabled(client)) setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${sessionExpiresAt.toUTCString()}; path=/; SameSite=Lax`);
233
- checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
234
- if (!previousState.user && Boolean(newState.user)) initializeWaasClientsForEagerRecovery(client);
235
- };
236
-
237
- //#endregion
238
- //#region src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts
239
- /** @notInstrumented */
240
- const getVerifiedCredentialForWalletAccount = ({ walletAccount }, client) => {
241
- return client.user?.verifiedCredentials.find((vc) => vc.id === walletAccount.verifiedCredentialId);
242
- };
243
-
244
- //#endregion
245
- //#region src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts
246
- /** @notInstrumented */
247
- const getWalletProviderByKey = ({ walletProviderKey }, client) => {
248
- const walletProvider = getWalletProviders(client).find((walletProvider$1) => walletProvider$1.key === walletProviderKey);
249
- if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey });
250
- return walletProvider;
251
- };
252
-
253
- //#endregion
254
- export { parseElevatedAccessToken as a, findWaasWalletProviderByChain as c, emitWalletAccountsChangedEvent as d, upsertElevatedAccessToken as i, getWalletProviders as l, getVerifiedCredentialForWalletAccount as n, initializeWaasClientsForEagerRecovery as o, updateAuthFromVerifyResponse as r, isWaasWalletAccount as s, getWalletProviderByKey as t, checkAndRaiseWalletAccountsChangedEvent as u };
255
- //# sourceMappingURL=getWalletProviderByKey-DTi6MhKt.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletProviderByKey-DTi6MhKt.esm.js","names":["newState: Partial<DynamicCoreState>","walletProvider"],"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 wal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