@dynamic-labs-sdk/client 1.16.1 → 1.17.1

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 (121) 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/index.d.ts +2 -2
  6. package/dist/exports/index.d.ts.map +1 -1
  7. package/dist/exports/waas.d.ts +2 -1
  8. package/dist/exports/waas.d.ts.map +1 -1
  9. package/dist/exports/waasCore.d.ts +3 -2
  10. package/dist/exports/waasCore.d.ts.map +1 -1
  11. package/dist/{getNetworkProviderFromNetworkId-D79icjmX.native.esm.js → getNetworkProviderFromNetworkId-Bfg-NkNJ.native.esm.js} +12 -4
  12. package/dist/getNetworkProviderFromNetworkId-Bfg-NkNJ.native.esm.js.map +1 -0
  13. package/dist/{getNetworkProviderFromNetworkId-BHxkTbiJ.cjs → getNetworkProviderFromNetworkId-CS4r9hi7.cjs} +43 -44
  14. package/dist/{getNetworkProviderFromNetworkId-BHxkTbiJ.cjs.map → getNetworkProviderFromNetworkId-CS4r9hi7.cjs.map} +1 -1
  15. package/dist/{getNetworkProviderFromNetworkId-BPeOK1Xx.esm.js → getNetworkProviderFromNetworkId-pknqqhk1.esm.js} +2 -3
  16. package/dist/{getNetworkProviderFromNetworkId-BPeOK1Xx.esm.js.map → getNetworkProviderFromNetworkId-pknqqhk1.esm.js.map} +1 -1
  17. package/dist/{getSignedSessionId-DzjHW7Rw.esm.js → getSignedSessionId-CUw7LJ35.esm.js} +3 -3
  18. package/dist/{getSignedSessionId-DzjHW7Rw.esm.js.map → getSignedSessionId-CUw7LJ35.esm.js.map} +1 -1
  19. package/dist/{getSignedSessionId-Dh4Df1mY.native.esm.js → getSignedSessionId-Cl3PEqa8.native.esm.js} +3 -3
  20. package/dist/{getSignedSessionId-Dh4Df1mY.native.esm.js.map → getSignedSessionId-Cl3PEqa8.native.esm.js.map} +1 -1
  21. package/dist/{getSignedSessionId-BjSUL8Br.cjs → getSignedSessionId-cMGkmojJ.cjs} +11 -11
  22. package/dist/{getSignedSessionId-BjSUL8Br.cjs.map → getSignedSessionId-cMGkmojJ.cjs.map} +1 -1
  23. package/dist/getWalletProviderByKey-24co0tBE.native.esm.js +20 -0
  24. package/dist/getWalletProviderByKey-24co0tBE.native.esm.js.map +1 -0
  25. package/dist/getWalletProviderByKey-CP9Te5Sz.cjs +31 -0
  26. package/dist/getWalletProviderByKey-CP9Te5Sz.cjs.map +1 -0
  27. package/dist/getWalletProviderByKey-lQVfIGFi.esm.js +20 -0
  28. package/dist/getWalletProviderByKey-lQVfIGFi.esm.js.map +1 -0
  29. package/dist/index.cjs +560 -541
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.esm.js +29 -28
  32. package/dist/index.esm.js.map +1 -1
  33. package/dist/index.native.esm.js +29 -28
  34. package/dist/index.native.esm.js.map +1 -1
  35. package/dist/isDynamicWaasEnabled-BXe0VyI4.native.esm.js +70 -0
  36. package/dist/isDynamicWaasEnabled-BXe0VyI4.native.esm.js.map +1 -0
  37. package/dist/isDynamicWaasEnabled-BYaqAOml.esm.js +70 -0
  38. package/dist/isDynamicWaasEnabled-BYaqAOml.esm.js.map +1 -0
  39. package/dist/isDynamicWaasEnabled-BwP1oowd.cjs +88 -0
  40. package/dist/isDynamicWaasEnabled-BwP1oowd.cjs.map +1 -0
  41. package/dist/{isMfaRequiredForAction-3fWX5MEF.cjs → isMfaRequiredForAction-Btejc5g3.cjs} +38 -29
  42. package/dist/isMfaRequiredForAction-Btejc5g3.cjs.map +1 -0
  43. package/dist/{isMfaRequiredForAction-CkX6CfJf.esm.js → isMfaRequiredForAction-CqEcCTIe.esm.js} +11 -2
  44. package/dist/isMfaRequiredForAction-CqEcCTIe.esm.js.map +1 -0
  45. package/dist/{isMfaRequiredForAction-CBW-d9C6.native.esm.js → isMfaRequiredForAction-Demz9zlH.native.esm.js} +2 -2
  46. package/dist/{isMfaRequiredForAction-CBW-d9C6.native.esm.js.map → isMfaRequiredForAction-Demz9zlH.native.esm.js.map} +1 -1
  47. package/dist/{isUserOnboardingComplete-D0JrQGvR.cjs → isUserOnboardingComplete-C86NDY7I.cjs} +13 -13
  48. package/dist/{isUserOnboardingComplete-D0JrQGvR.cjs.map → isUserOnboardingComplete-C86NDY7I.cjs.map} +1 -1
  49. package/dist/{isUserOnboardingComplete-C4_b3pDb.esm.js → isUserOnboardingComplete-CBrAH0ZF.esm.js} +3 -3
  50. package/dist/{isUserOnboardingComplete-C4_b3pDb.esm.js.map → isUserOnboardingComplete-CBrAH0ZF.esm.js.map} +1 -1
  51. package/dist/{isUserOnboardingComplete-m6E6GbB0.native.esm.js → isUserOnboardingComplete-Cr-YTpcU.native.esm.js} +3 -3
  52. package/dist/{isUserOnboardingComplete-m6E6GbB0.native.esm.js.map → isUserOnboardingComplete-Cr-YTpcU.native.esm.js.map} +1 -1
  53. package/dist/migrateFromFireblocks-B_q8Oawb.cjs +82 -0
  54. package/dist/migrateFromFireblocks-B_q8Oawb.cjs.map +1 -0
  55. package/dist/migrateFromFireblocks-Bbx2wHZD.esm.js +65 -0
  56. package/dist/migrateFromFireblocks-Bbx2wHZD.esm.js.map +1 -0
  57. package/dist/migrateFromFireblocks-D-J6-gRo.native.esm.js +65 -0
  58. package/dist/migrateFromFireblocks-D-J6-gRo.native.esm.js.map +1 -0
  59. package/dist/modules/flow/attachFlowSource/attachFlowSource.d.ts.map +1 -1
  60. package/dist/modules/sessionKeys/generateSessionKeys/generateSessionKeys.d.ts.map +1 -1
  61. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  62. package/dist/modules/waas/migrateFromFireblocks/index.d.ts +2 -0
  63. package/dist/modules/waas/migrateFromFireblocks/index.d.ts.map +1 -0
  64. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts +52 -0
  65. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts.map +1 -0
  66. package/dist/modules/waas/waas.types.d.ts +9 -1
  67. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  68. package/dist/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts +1 -1
  69. package/dist/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts.map +1 -1
  70. package/dist/modules/wallets/walletProviderRegistry/events.d.ts +2 -1
  71. package/dist/modules/wallets/walletProviderRegistry/events.d.ts.map +1 -1
  72. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  73. package/dist/{InvalidParamError-DCpeZMBr.cjs → updateAuthFromVerifyResponse-CElYpi97.cjs} +291 -9
  74. package/dist/updateAuthFromVerifyResponse-CElYpi97.cjs.map +1 -0
  75. package/dist/{InvalidParamError-5AXtm6Zp.native.esm.js → updateAuthFromVerifyResponse-D1w-Aw9P.native.esm.js} +457 -4
  76. package/dist/updateAuthFromVerifyResponse-D1w-Aw9P.native.esm.js.map +1 -0
  77. package/dist/{InvalidParamError-PQ2Xen_o.esm.js → updateAuthFromVerifyResponse-azIi_3FB.esm.js} +237 -3
  78. package/dist/updateAuthFromVerifyResponse-azIi_3FB.esm.js.map +1 -0
  79. package/dist/waas.cjs +53 -67
  80. package/dist/waas.cjs.map +1 -1
  81. package/dist/waas.esm.js +5 -20
  82. package/dist/waas.esm.js.map +1 -1
  83. package/dist/waas.native.esm.js +5 -20
  84. package/dist/waas.native.esm.js.map +1 -1
  85. package/dist/waasCore.cjs +40 -23
  86. package/dist/waasCore.cjs.map +1 -1
  87. package/dist/waasCore.esm.js +23 -7
  88. package/dist/waasCore.esm.js.map +1 -1
  89. package/dist/waasCore.native.esm.js +23 -7
  90. package/dist/waasCore.native.esm.js.map +1 -1
  91. package/package.json +3 -3
  92. package/dist/InvalidParamError-5AXtm6Zp.native.esm.js.map +0 -1
  93. package/dist/InvalidParamError-DCpeZMBr.cjs.map +0 -1
  94. package/dist/InvalidParamError-PQ2Xen_o.esm.js.map +0 -1
  95. package/dist/getNetworkProviderFromNetworkId-D79icjmX.native.esm.js.map +0 -1
  96. package/dist/getWaasWalletProviderFromWalletAccount-BxyUZBpT.cjs +0 -19
  97. package/dist/getWaasWalletProviderFromWalletAccount-BxyUZBpT.cjs.map +0 -1
  98. package/dist/getWaasWalletProviderFromWalletAccount-Ca0SiNEz.native.esm.js +0 -14
  99. package/dist/getWaasWalletProviderFromWalletAccount-Ca0SiNEz.native.esm.js.map +0 -1
  100. package/dist/getWaasWalletProviderFromWalletAccount-CupLo7EC.esm.js +0 -14
  101. package/dist/getWaasWalletProviderFromWalletAccount-CupLo7EC.esm.js.map +0 -1
  102. package/dist/getWalletProviderByKey-B6vtKHJy.esm.js +0 -255
  103. package/dist/getWalletProviderByKey-B6vtKHJy.esm.js.map +0 -1
  104. package/dist/getWalletProviderByKey-DIFBlGlR.cjs +0 -321
  105. package/dist/getWalletProviderByKey-DIFBlGlR.cjs.map +0 -1
  106. package/dist/getWalletProviderByKey-Dh2qnBmw.native.esm.js +0 -474
  107. package/dist/getWalletProviderByKey-Dh2qnBmw.native.esm.js.map +0 -1
  108. package/dist/isDynamicWaasEnabled-A8Humh0r.cjs +0 -49
  109. package/dist/isDynamicWaasEnabled-A8Humh0r.cjs.map +0 -1
  110. package/dist/isDynamicWaasEnabled-BmWqrgz1.esm.js +0 -37
  111. package/dist/isDynamicWaasEnabled-BmWqrgz1.esm.js.map +0 -1
  112. package/dist/isDynamicWaasEnabled-Djp4QuBw.native.esm.js +0 -37
  113. package/dist/isDynamicWaasEnabled-Djp4QuBw.native.esm.js.map +0 -1
  114. package/dist/isMfaRequiredForAction-3fWX5MEF.cjs.map +0 -1
  115. package/dist/isMfaRequiredForAction-CkX6CfJf.esm.js.map +0 -1
  116. package/dist/refreshAuth-BKeW1dSq.cjs +0 -43
  117. package/dist/refreshAuth-BKeW1dSq.cjs.map +0 -1
  118. package/dist/refreshAuth-Cykyxvpz.native.esm.js +0 -38
  119. package/dist/refreshAuth-Cykyxvpz.native.esm.js.map +0 -1
  120. package/dist/refreshAuth-LzA2xxNC.esm.js +0 -38
  121. package/dist/refreshAuth-LzA2xxNC.esm.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"getWalletProviderByKey-B6vtKHJy.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 walletProvider;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,kCAAkC,WAAgC;AAG7E,WACE;EACE,MAAM,EAAE,gBAJW,kBAAkB,OAAO,EAIpB;EACxB,OAAO;EACR,EACD,OACD;;;;;;ACPH,MAAa,2CACX,EAAE,iBACF,WACG;CACH,MAAM,OAAO,QAAQ,OAAO;AAS5B,KAPiC,sBAAsB,eAAe,OAAO,KAE7C,sBAC9B,KAAK,MAAM,KAAK,EAChB,OACD,CAGC,gCAA+B,OAAO;;AAM1C,MAAM,yBACJ,OACA,WAEA,2BAA2B,OAAO,OAAO,CACtC,KAAK,kBAAkB,KAAK,UAAU,cAAc,CAAC,CACrD,MAAM,CACN,KAAK,IAAI;;;;;;;;AC9Bd,MAAa,sBAAsB,WAA0B;AAG3D,QAF+B,0BAA0B,OAAO,CAElC,eAAe;;;;;;ACK/C,MAAa,iCACX,EAAE,SACF,WAC8B;CAC9B,MAAM,YAAY,mBAAmB,OAAO;CAE5C,MAAM,kBAAkB,wBAAwB;EAC9C;EACA,aAAa,sBAAsB;EACnC,oBAAoB,mBAAmB;EACxC,CAAC;CAEF,MAAM,eAAe,UAAU,MAC5B,aAAa,SAAS,QAAQ,mBAAmB,SAAS,UAAU,MACtE;AAED,KAAI,CAAC,gBAAgB,CAAC,qBAAqB,aAAa,CACtD,QAAO;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BAAyB,EAC3C,OAAO,qBACR,CAAC;AACF,MAAI,YACF,UAAS,uBAAuB,0BAA0B;GACxD;GACA,UAAU;GACX,CAAC;;AAIN,MAAK,MAAM,IAAI,SAAS;;;;;;AAOxB,KAAI,eAAe,gBAAgB,OAAO,CAGxC,WACE,GAAG,yBAAyB,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,IAAI,2BAA2B,EAAE,mBAAmB,CAAC;AAG7D,QAAO"}
@@ -1,321 +0,0 @@
1
- const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-3fWX5MEF.cjs');
2
- const require_InvalidParamError = require('./InvalidParamError-DCpeZMBr.cjs');
3
- let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
4
-
5
- //#region src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts
6
- /**
7
- * Emits the `walletAccountsChanged` event.
8
- * @notInstrumented
9
- */
10
- const emitWalletAccountsChangedEvent = (client) => {
11
- require_InvalidParamError.emitEvent({
12
- args: { walletAccounts: require_InvalidParamError.getWalletAccounts(client) },
13
- event: "walletAccountsChanged"
14
- }, client);
15
- };
16
-
17
- //#endregion
18
- //#region src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts
19
- /** @notInstrumented */
20
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client) => {
21
- const core = require_InvalidParamError.getCore(client);
22
- if (getWalletAccountsHash(previousState, client) !== getWalletAccountsHash(core.state.get(), client)) emitWalletAccountsChangedEvent(client);
23
- };
24
- const getWalletAccountsHash = (state, client) => require_InvalidParamError.getWalletAccountsFromState(state, client).map((walletAccount) => JSON.stringify(walletAccount)).sort().join("-");
25
-
26
- //#endregion
27
- //#region src/modules/wallets/getWalletProviders/getWalletProviders.ts
28
- /**
29
- * Get all available wallet providers to interact with internally.
30
- * @notInstrumented
31
- */
32
- const getWalletProviders = (client) => {
33
- return require_InvalidParamError.getWalletProviderRegistry(client).listProviders();
34
- };
35
-
36
- //#endregion
37
- //#region src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts
38
- /** @notInstrumented */
39
- const findWaasWalletProviderByChain = ({ chain }, client) => {
40
- const providers = getWalletProviders(client);
41
- const waasProviderKey = require_InvalidParamError.formatWalletProviderKey({
42
- chain,
43
- displayName: require_InvalidParamError.DYNAMIC_WAAS_METADATA.displayName,
44
- walletProviderType: _dynamic_labs_sdk_api_core.WalletProviderEnum.EmbeddedWallet
45
- });
46
- const waasProvider = providers.find((provider) => provider.key === waasProviderKey && provider.chain === chain);
47
- if (!waasProvider || !require_InvalidParamError.isWaasWalletProvider(waasProvider)) return null;
48
- return waasProvider;
49
- };
50
-
51
- //#endregion
52
- //#region src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts
53
- /**
54
- * This function determines whether the provided wallet account is a Dynamic
55
- * WaaS wallet account.
56
- *
57
- * @param params.walletAccount - The wallet account to check.
58
- * @returns True if the wallet account is a WaaS wallet account, false otherwise.
59
- * @notInstrumented
60
- */
61
- const isWaasWalletAccount = ({ walletAccount }) => {
62
- return walletAccount.walletProviderKey.includes(require_InvalidParamError.DYNAMIC_WAAS_METADATA.normalizedWalletName);
63
- };
64
-
65
- //#endregion
66
- //#region src/modules/waas/initializeWaasClientsForEagerRecovery/initializeWaasClientsForEagerRecovery.ts
67
- /**
68
- * On login, boots the WaaS client once per chain so the SDK eagerly recovers
69
- * key shares itself (the `eagerlyRecoverKeyShares` capability) instead of the
70
- * host looping per wallet. Booting calls `initialize()`, which sends the auth
71
- * token the iframe needs to self-recover.
72
- *
73
- * @notInstrumented
74
- */
75
- const initializeWaasClientsForEagerRecovery = async (client) => {
76
- /**
77
- * Booting triggers recovery, which fails if the user is missing the MFA auth.
78
- * This early return avoids attempting a call we know will fail and just adds
79
- * noise to the logs.
80
- */
81
- if (require_InvalidParamError.isUserMissingMfaAuth(client)) return;
82
- const waasChains = new Set(require_InvalidParamError.getWalletAccounts(client).filter((walletAccount) => isWaasWalletAccount({ walletAccount })).map((walletAccount) => walletAccount.chain));
83
- await Promise.all([...waasChains].map(async (chain) => {
84
- const provider = findWaasWalletProviderByChain({ chain }, client);
85
- /**
86
- * The environment might not have the embedded wallet extensions installed.
87
- * In that case there is no provider for the chain and nothing to boot.
88
- */
89
- if (!provider) return;
90
- try {
91
- await provider.getWaasClient();
92
- } catch (error) {
93
- require_InvalidParamError.getCore(client).logger.warn("[initializeWaasClientsForEagerRecovery] failed to boot waas client", error);
94
- }
95
- }));
96
- };
97
-
98
- //#endregion
99
- //#region src/modules/auth/decodeJwt/decodeJwt.ts
100
- /**
101
- * Decodes a JWT token and returns the full payload.
102
- *
103
- * This function extracts and returns the complete JWT payload including scopes,
104
- * expiration time, and other claims.
105
- *
106
- * @param jwt - The JWT token string.
107
- * @returns The decoded JWT payload object.
108
- * @throws InvalidParamError if the token is invalid or cannot be decoded.
109
- *
110
- * @example
111
- * ```typescript
112
- * const payload = decodeJwt(jwt);
113
- * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }
114
- * ```
115
- * @notInstrumented
116
- */
117
- const decodeJwt = (jwt) => {
118
- try {
119
- const parts = jwt.split(".");
120
- if (parts.length !== 3) throw new require_InvalidParamError.InvalidParamError("Invalid JWT format");
121
- const base64Payload = parts[1].replaceAll("-", "+").replaceAll("_", "/");
122
- const paddedPayload = base64Payload + "=".repeat((4 - base64Payload.length % 4) % 4);
123
- const decodedPayload = atob(paddedPayload);
124
- return JSON.parse(decodedPayload);
125
- } catch (error) {
126
- if (error instanceof require_InvalidParamError.InvalidParamError) throw error;
127
- throw new require_InvalidParamError.InvalidParamError(`Failed to decode JWT: ${error instanceof Error ? error.message : String(error)}`);
128
- }
129
- };
130
-
131
- //#endregion
132
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts
133
- /**
134
- * Normalizes scopes by deduplicating and sorting them.
135
- * This creates a canonical representation for comparison.
136
- *
137
- * @param scopes - Array of scope strings (may contain duplicates)
138
- * @returns Normalized, sorted array of unique scopes
139
- * @notInstrumented
140
- */
141
- const normalizeScopes = (scopes) => {
142
- return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));
143
- };
144
-
145
- //#endregion
146
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts
147
- /**
148
- * Validates and parses an elevated access token from a JWT string.
149
- * Extracts scopes, expiration, and validates the token structure.
150
- *
151
- * Policy decisions:
152
- * - Tokens without scopes are rejected (returns null)
153
- * - Tokens with empty scopes array are rejected (returns null)
154
- * - Tokens without exp field are rejected (returns null)
155
- * - Expired tokens are rejected (returns null)
156
- *
157
- * @returns Parsed token data or null if token is invalid/expired
158
- * @notInstrumented
159
- */
160
- const parseElevatedAccessToken = ({ token }) => {
161
- const payload = decodeJwt(token);
162
- const filteredScopes = ((payload?.scope)?.split(" ") ?? []).filter((s) => s.length > 0);
163
- const singleUse = payload.singleUse ?? false;
164
- if (!filteredScopes || filteredScopes.length === 0) return null;
165
- if (!payload.exp) return null;
166
- const expiresAt = /* @__PURE__ */ new Date(payload.exp * 1e3);
167
- if (expiresAt <= /* @__PURE__ */ new Date()) return null;
168
- return {
169
- expiresAt,
170
- normalizedScopes: normalizeScopes(filteredScopes),
171
- scopes: filteredScopes,
172
- singleUse,
173
- token
174
- };
175
- };
176
-
177
- //#endregion
178
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts
179
- /**
180
- * Upserts an elevated access token into the current tokens array.
181
- *
182
- * Policy: Only one token per normalized scope-set is allowed.
183
- * If a token with the same normalized scopes exists, it is replaced.
184
- * This ensures we don't accumulate multiple tokens for the same scope combination.
185
- *
186
- * @param currentTokens - Current array of elevated access tokens
187
- * @param newToken - New token to upsert
188
- * @returns Updated array of tokens with the new token upserted
189
- * @notInstrumented
190
- */
191
- const upsertElevatedAccessToken = ({ currentTokens, newToken }) => {
192
- const newScopeKey = normalizeScopes(newToken.scopes).join(" ");
193
- return [...currentTokens.filter((existingToken) => {
194
- return normalizeScopes(existingToken.scopes).join(" ") !== newScopeKey;
195
- }), {
196
- expiresAt: newToken.expiresAt,
197
- scopes: newToken.scopes,
198
- singleUse: newToken.singleUse,
199
- token: newToken.token
200
- }];
201
- };
202
-
203
- //#endregion
204
- //#region src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts
205
- /** @notInstrumented */
206
- const updateAuthFromVerifyResponse = ({ response }, client) => {
207
- const core = require_InvalidParamError.getCore(client);
208
- const previousState = { ...core.state.get() };
209
- const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } = response;
210
- const sessionExpiresAt = /* @__PURE__ */ new Date(expiresAt * 1e3);
211
- const newState = {
212
- legacyToken: jwt ?? null,
213
- sessionExpiresAt,
214
- token: minifiedJwt ?? null,
215
- user
216
- };
217
- if (mfaToken) newState.mfaToken = mfaToken;
218
- const currentTokens = core.state.get().elevatedAccessTokens || [];
219
- newState.elevatedAccessTokens = currentTokens;
220
- if (elevatedAccessToken) {
221
- const parsedToken = parseElevatedAccessToken({ token: elevatedAccessToken });
222
- if (parsedToken) newState.elevatedAccessTokens = upsertElevatedAccessToken({
223
- currentTokens,
224
- newToken: parsedToken
225
- });
226
- }
227
- core.state.set(newState);
228
- /**
229
- * For customers using a sandbox environment with cookies enabled, we need to set the cookie
230
- * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically
231
- * so customers can access the cookie from document.cookie consistently between sandbox and live environments.
232
- */
233
- if (minifiedJwt && require_InvalidParamError.isCookieEnabled(client)) require_InvalidParamError.setCookie(`${require_InvalidParamError.DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${sessionExpiresAt.toUTCString()}; path=/; SameSite=Lax`);
234
- checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
235
- if (!previousState.user && Boolean(newState.user)) initializeWaasClientsForEagerRecovery(client);
236
- };
237
-
238
- //#endregion
239
- //#region src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts
240
- /** @notInstrumented */
241
- const getVerifiedCredentialForWalletAccount = ({ walletAccount }, client) => {
242
- return client.user?.verifiedCredentials.find((vc) => vc.id === walletAccount.verifiedCredentialId);
243
- };
244
-
245
- //#endregion
246
- //#region src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts
247
- /** @notInstrumented */
248
- const getWalletProviderByKey = ({ walletProviderKey }, client) => {
249
- const walletProvider = getWalletProviders(client).find((walletProvider$1) => walletProvider$1.key === walletProviderKey);
250
- if (!walletProvider) throw new require_InvalidParamError.NoWalletProviderFoundError({ walletProviderKey });
251
- return walletProvider;
252
- };
253
-
254
- //#endregion
255
- Object.defineProperty(exports, 'checkAndRaiseWalletAccountsChangedEvent', {
256
- enumerable: true,
257
- get: function () {
258
- return checkAndRaiseWalletAccountsChangedEvent;
259
- }
260
- });
261
- Object.defineProperty(exports, 'emitWalletAccountsChangedEvent', {
262
- enumerable: true,
263
- get: function () {
264
- return emitWalletAccountsChangedEvent;
265
- }
266
- });
267
- Object.defineProperty(exports, 'findWaasWalletProviderByChain', {
268
- enumerable: true,
269
- get: function () {
270
- return findWaasWalletProviderByChain;
271
- }
272
- });
273
- Object.defineProperty(exports, 'getVerifiedCredentialForWalletAccount', {
274
- enumerable: true,
275
- get: function () {
276
- return getVerifiedCredentialForWalletAccount;
277
- }
278
- });
279
- Object.defineProperty(exports, 'getWalletProviderByKey', {
280
- enumerable: true,
281
- get: function () {
282
- return getWalletProviderByKey;
283
- }
284
- });
285
- Object.defineProperty(exports, 'getWalletProviders', {
286
- enumerable: true,
287
- get: function () {
288
- return getWalletProviders;
289
- }
290
- });
291
- Object.defineProperty(exports, 'initializeWaasClientsForEagerRecovery', {
292
- enumerable: true,
293
- get: function () {
294
- return initializeWaasClientsForEagerRecovery;
295
- }
296
- });
297
- Object.defineProperty(exports, 'isWaasWalletAccount', {
298
- enumerable: true,
299
- get: function () {
300
- return isWaasWalletAccount;
301
- }
302
- });
303
- Object.defineProperty(exports, 'parseElevatedAccessToken', {
304
- enumerable: true,
305
- get: function () {
306
- return parseElevatedAccessToken;
307
- }
308
- });
309
- Object.defineProperty(exports, 'updateAuthFromVerifyResponse', {
310
- enumerable: true,
311
- get: function () {
312
- return updateAuthFromVerifyResponse;
313
- }
314
- });
315
- Object.defineProperty(exports, 'upsertElevatedAccessToken', {
316
- enumerable: true,
317
- get: function () {
318
- return upsertElevatedAccessToken;
319
- }
320
- });
321
- //# sourceMappingURL=getWalletProviderByKey-DIFBlGlR.cjs.map
@@ -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,KAAIC,+CAAqB,OAAO,CAC9B;CAGF,MAAM,aAAa,IAAI,IACrBC,4CAAkB,OAAO,CACtB,QAAQ,kBAAkB,oBAAoB,EAAE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