@dynamic-labs-sdk/client 0.14.0 → 0.16.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 (147) hide show
  1. package/dist/{InvalidParamError-DQn49mNB.esm.js → InvalidParamError-Cty-xWsw.esm.js} +268 -10
  2. package/dist/InvalidParamError-Cty-xWsw.esm.js.map +1 -0
  3. package/dist/{InvalidParamError-DVzrk97b.cjs.js → InvalidParamError-DO9X0rAe.cjs.js} +360 -9
  4. package/dist/InvalidParamError-DO9X0rAe.cjs.js.map +1 -0
  5. package/dist/{NotWaasWalletAccountError-IxbdRVGy.cjs.js → NotWaasWalletAccountError-Bj3-tWL3.cjs.js} +3 -3
  6. package/dist/{NotWaasWalletAccountError-IxbdRVGy.cjs.js.map → NotWaasWalletAccountError-Bj3-tWL3.cjs.js.map} +1 -1
  7. package/dist/{NotWaasWalletAccountError-D0BXVuKy.esm.js → NotWaasWalletAccountError-x0HlFCot.esm.js} +3 -3
  8. package/dist/{NotWaasWalletAccountError-D0BXVuKy.esm.js.map → NotWaasWalletAccountError-x0HlFCot.esm.js.map} +1 -1
  9. package/dist/client/core/createCore/getInitialState.d.ts.map +1 -1
  10. package/dist/core.cjs.js +34 -65
  11. package/dist/core.cjs.js.map +1 -1
  12. package/dist/core.esm.js +24 -60
  13. package/dist/core.esm.js.map +1 -1
  14. package/dist/errors/DeeplinkConnectAndVerifyUnsupportedError.d.ts +9 -0
  15. package/dist/errors/DeeplinkConnectAndVerifyUnsupportedError.d.ts.map +1 -0
  16. package/dist/errors/UnauthorizedError.d.ts +5 -0
  17. package/dist/errors/UnauthorizedError.d.ts.map +1 -0
  18. package/dist/exports/core.d.ts +11 -1
  19. package/dist/exports/core.d.ts.map +1 -1
  20. package/dist/exports/index.d.ts +13 -2
  21. package/dist/exports/index.d.ts.map +1 -1
  22. package/dist/{getNetworkProviderFromNetworkId-z8WEapnj.cjs.js → getNetworkProviderFromNetworkId-B2NiAPL7.cjs.js} +66 -148
  23. package/dist/getNetworkProviderFromNetworkId-B2NiAPL7.cjs.js.map +1 -0
  24. package/dist/{getNetworkProviderFromNetworkId-DMMnYrfG.esm.js → getNetworkProviderFromNetworkId-DKM-ec3L.esm.js} +59 -96
  25. package/dist/getNetworkProviderFromNetworkId-DKM-ec3L.esm.js.map +1 -0
  26. package/dist/{getSignedSessionId-BdGOv_TA.cjs.js → getSignedSessionId-BQb75faX.cjs.js} +5 -24
  27. package/dist/getSignedSessionId-BQb75faX.cjs.js.map +1 -0
  28. package/dist/{getSignedSessionId-BKKO2mqj.esm.js → getSignedSessionId-DczIbYxd.esm.js} +4 -17
  29. package/dist/getSignedSessionId-DczIbYxd.esm.js.map +1 -0
  30. package/dist/{getVerifiedCredentialForWalletAccount-Ck7DNGPJ.cjs.js → getVerifiedCredentialForWalletAccount-CTL5-19B.cjs.js} +2 -3
  31. package/dist/{getVerifiedCredentialForWalletAccount-Ck7DNGPJ.cjs.js.map → getVerifiedCredentialForWalletAccount-CTL5-19B.cjs.js.map} +1 -1
  32. package/dist/{getVerifiedCredentialForWalletAccount-DQ7g6O7y.esm.js → getVerifiedCredentialForWalletAccount-CpUomVzT.esm.js} +2 -2
  33. package/dist/{getVerifiedCredentialForWalletAccount-DQ7g6O7y.esm.js.map → getVerifiedCredentialForWalletAccount-CpUomVzT.esm.js.map} +1 -1
  34. package/dist/index.cjs.js +333 -87
  35. package/dist/index.cjs.js.map +1 -1
  36. package/dist/index.esm.js +315 -78
  37. package/dist/index.esm.js.map +1 -1
  38. package/dist/{isMfaRequiredForAction-BINs954q.cjs.js → isMfaRequiredForAction-DyrKyoVd.cjs.js} +2 -15
  39. package/dist/isMfaRequiredForAction-DyrKyoVd.cjs.js.map +1 -0
  40. package/dist/{isMfaRequiredForAction-MvVGc7k3.esm.js → isMfaRequiredForAction-Hi4dCidj.esm.js} +3 -10
  41. package/dist/isMfaRequiredForAction-Hi4dCidj.esm.js.map +1 -0
  42. package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
  43. package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.d.ts +4 -0
  44. package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.d.ts.map +1 -0
  45. package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/index.d.ts +2 -0
  46. package/dist/modules/apiClient/utils/deviceSignatureHeadersMiddleware/index.d.ts.map +1 -0
  47. package/dist/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.d.ts +3 -0
  48. package/dist/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.d.ts.map +1 -0
  49. package/dist/modules/checkout/attachCheckoutTransactionSource/attachCheckoutTransactionSource.d.ts +3 -1
  50. package/dist/modules/checkout/attachCheckoutTransactionSource/attachCheckoutTransactionSource.d.ts.map +1 -1
  51. package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts +1 -1
  52. package/dist/modules/checkout/createCheckoutTransaction/createCheckoutTransaction.d.ts.map +1 -1
  53. package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts +1 -2
  54. package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts.map +1 -1
  55. package/dist/modules/checkout/getCheckouts/getCheckouts.d.ts +4 -0
  56. package/dist/modules/checkout/getCheckouts/getCheckouts.d.ts.map +1 -0
  57. package/dist/modules/checkout/getCheckouts/index.d.ts +2 -0
  58. package/dist/modules/checkout/getCheckouts/index.d.ts.map +1 -0
  59. package/dist/modules/checkout/submitCheckoutTransaction/index.d.ts +3 -0
  60. package/dist/modules/checkout/submitCheckoutTransaction/index.d.ts.map +1 -0
  61. package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts +22 -0
  62. package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -0
  63. package/dist/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.d.ts.map +1 -1
  64. package/dist/modules/deviceRegistration/getDeviceSigner/{getOrCreateUserDeviceSigningKeys/getOrCreateUserDeviceSigningKeys.d.ts → getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.d.ts} +2 -2
  65. package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/getOrCreateEnvironmentDeviceSigningKeys.d.ts.map +1 -0
  66. package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/index.d.ts +2 -0
  67. package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateEnvironmentDeviceSigningKeys/index.d.ts.map +1 -0
  68. package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.d.ts +3 -0
  69. package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.d.ts.map +1 -0
  70. package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/index.d.ts +2 -0
  71. package/dist/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/index.d.ts.map +1 -0
  72. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts +3 -0
  73. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts.map +1 -0
  74. package/dist/modules/deviceRegistration/getRegisteredDevices/index.d.ts +2 -0
  75. package/dist/modules/deviceRegistration/getRegisteredDevices/index.d.ts.map +1 -0
  76. package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/index.d.ts +2 -0
  77. package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/index.d.ts.map +1 -0
  78. package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.d.ts +2 -0
  79. package/dist/modules/deviceRegistration/revokeAllRegisteredDevices/revokeAllRegisteredDevices.d.ts.map +1 -0
  80. package/dist/modules/deviceRegistration/revokeRegisteredDevice/index.d.ts +2 -0
  81. package/dist/modules/deviceRegistration/revokeRegisteredDevice/index.d.ts.map +1 -0
  82. package/dist/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.d.ts +6 -0
  83. package/dist/modules/deviceRegistration/revokeRegisteredDevice/revokeRegisteredDevice.d.ts.map +1 -0
  84. package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
  85. package/dist/modules/storageSync/hydrateStateWithStorage/hydrateStateWithStorage.d.ts.map +1 -1
  86. package/dist/modules/storageSync/schema.d.ts +2 -0
  87. package/dist/modules/storageSync/schema.d.ts.map +1 -1
  88. package/dist/modules/storageSync/syncStateWithStorage/syncStateWithStorage.d.ts.map +1 -1
  89. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  90. package/dist/modules/waas/waas.types.d.ts +1 -0
  91. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  92. package/dist/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.d.ts +10 -0
  93. package/dist/modules/wallets/connectAndVerifyWithWalletProvider/connectAndVerifyWithWalletProvider.d.ts.map +1 -1
  94. package/dist/modules/wallets/transferAmount/index.d.ts +2 -0
  95. package/dist/modules/wallets/transferAmount/index.d.ts.map +1 -0
  96. package/dist/modules/wallets/transferAmount/transferAmount.d.ts +19 -0
  97. package/dist/modules/wallets/transferAmount/transferAmount.d.ts.map +1 -0
  98. package/dist/modules/wallets/walletProvider/index.d.ts +1 -1
  99. package/dist/modules/wallets/walletProvider/index.d.ts.map +1 -1
  100. package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/index.d.ts +2 -0
  101. package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/index.d.ts.map +1 -0
  102. package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.d.ts +10 -0
  103. package/dist/modules/wallets/walletProvider/isDeeplinkWalletProvider/isDeeplinkWalletProvider.d.ts.map +1 -0
  104. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +17 -0
  105. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
  106. package/dist/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.d.ts +11 -1
  107. package/dist/services/openDeeplink/createWebDeeplinkOpener/createWebDeeplinkOpener.d.ts.map +1 -1
  108. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  109. package/dist/utils/getNonce/constants.d.ts +3 -0
  110. package/dist/utils/getNonce/constants.d.ts.map +1 -0
  111. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts +13 -0
  112. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -0
  113. package/dist/utils/getNonce/fetchAndStoreNonces/index.d.ts +2 -0
  114. package/dist/utils/getNonce/fetchAndStoreNonces/index.d.ts.map +1 -0
  115. package/dist/utils/getNonce/getNonce.d.ts +7 -0
  116. package/dist/utils/getNonce/getNonce.d.ts.map +1 -1
  117. package/dist/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.d.ts +3 -0
  118. package/dist/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.d.ts.map +1 -0
  119. package/dist/utils/getNonce/state.d.ts +15 -0
  120. package/dist/utils/getNonce/state.d.ts.map +1 -0
  121. package/dist/utils/parseAmountToSmallestUnit/index.d.ts +2 -0
  122. package/dist/utils/parseAmountToSmallestUnit/index.d.ts.map +1 -0
  123. package/dist/utils/parseAmountToSmallestUnit/parseAmountToSmallestUnit.d.ts +22 -0
  124. package/dist/utils/parseAmountToSmallestUnit/parseAmountToSmallestUnit.d.ts.map +1 -0
  125. package/dist/utils/parseUserAgent/index.d.ts +2 -0
  126. package/dist/utils/parseUserAgent/index.d.ts.map +1 -0
  127. package/dist/utils/parseUserAgent/parseUserAgent.d.ts +10 -0
  128. package/dist/utils/parseUserAgent/parseUserAgent.d.ts.map +1 -0
  129. package/dist/utils/randomString/randomString.d.ts +6 -1
  130. package/dist/utils/randomString/randomString.d.ts.map +1 -1
  131. package/dist/waas.cjs.js +3 -4
  132. package/dist/waas.cjs.js.map +1 -1
  133. package/dist/waas.esm.js +3 -3
  134. package/dist/waasCore.cjs.js +5 -5
  135. package/dist/waasCore.cjs.js.map +1 -1
  136. package/dist/waasCore.esm.js +5 -4
  137. package/dist/waasCore.esm.js.map +1 -1
  138. package/package.json +4 -3
  139. package/dist/InvalidParamError-DQn49mNB.esm.js.map +0 -1
  140. package/dist/InvalidParamError-DVzrk97b.cjs.js.map +0 -1
  141. package/dist/getNetworkProviderFromNetworkId-DMMnYrfG.esm.js.map +0 -1
  142. package/dist/getNetworkProviderFromNetworkId-z8WEapnj.cjs.js.map +0 -1
  143. package/dist/getSignedSessionId-BKKO2mqj.esm.js.map +0 -1
  144. package/dist/getSignedSessionId-BdGOv_TA.cjs.js.map +0 -1
  145. package/dist/isMfaRequiredForAction-BINs954q.cjs.js.map +0 -1
  146. package/dist/isMfaRequiredForAction-MvVGc7k3.esm.js.map +0 -1
  147. package/dist/modules/deviceRegistration/getDeviceSigner/getOrCreateUserDeviceSigningKeys/getOrCreateUserDeviceSigningKeys.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSignedSessionId-BdGOv_TA.cjs.js","names":["isMfaRequiredForAction","consumeMfaToken","bufferToHex","getSessionKeys","getSessionKeys","getCore","createApiClient"],"sources":["../src/modules/mfa/consumeMfaTokenIfRequiredForAction/consumeMfaTokenIfRequiredForAction.ts","../src/utils/p256Sign/p256Sign.ts","../src/modules/sessionKeys/generateNonceSignature/generateNonceSignature.ts","../src/modules/sessionKeys/generateSessionSignature/generateSessionSignature.ts","../src/modules/sessionKeys/getSignedSessionId/getSignedSessionId.ts"],"sourcesContent":["import type { MFAAction } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { consumeMfaToken } from '../consumeMfaToken';\nimport { isMfaRequiredForAction } from '../isMfaRequiredForAction';\n\ntype ConsumeMfaTokenIfRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\nexport const consumeMfaTokenIfRequiredForAction = async (\n { mfaAction }: ConsumeMfaTokenIfRequiredForActionParams,\n client: DynamicClient\n): Promise<string | undefined> => {\n const isRequiredForAction = await isMfaRequiredForAction(\n { mfaAction },\n client\n );\n\n if (!isRequiredForAction) {\n return;\n }\n\n return consumeMfaToken(client);\n};\n","import { bufferToHex } from '../bufferToHex';\n\ntype P256SignParams = {\n message: string;\n privateKeyJwk: JsonWebKey;\n};\n\nexport const p256Sign = async ({ privateKeyJwk, message }: P256SignParams) => {\n const privateKey = await crypto.subtle.importKey(\n 'jwk',\n privateKeyJwk,\n {\n name: 'ECDSA',\n namedCurve: 'P-256',\n },\n false,\n ['sign']\n );\n\n const signature = await crypto.subtle.sign(\n {\n hash: 'SHA-256',\n name: 'ECDSA',\n },\n privateKey,\n new TextEncoder().encode(message)\n );\n\n return bufferToHex(signature);\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getSessionKeys } from '../getSessionKeys';\n\ntype GenerateNonceSignatureParams = {\n nonce: string;\n};\n\nexport const generateNonceSignature = async (\n { nonce }: GenerateNonceSignatureParams,\n client: DynamicClient\n) => {\n const sessionKeys = getSessionKeys(client);\n assertDefined(sessionKeys, 'Session keys not found');\n\n const { privateKeyJwk } = sessionKeys;\n\n const signature = await p256Sign({\n message: nonce,\n privateKeyJwk,\n });\n\n return { signature };\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { p256Sign } from '../../../utils/p256Sign';\nimport { getSessionKeys } from '../getSessionKeys';\n\ntype GenerateSessionSignatureParams = {\n sessionId: string;\n};\n\nexport const generateSessionSignature = async (\n { sessionId }: GenerateSessionSignatureParams,\n client: DynamicClient\n) => {\n const sessionKeys = getSessionKeys(client);\n assertDefined(sessionKeys, 'Session keys not found');\n\n const { privateKeyJwk } = sessionKeys;\n\n const signature = await p256Sign({\n message: sessionId,\n privateKeyJwk,\n });\n\n return { signature };\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { createApiClient } from '../../apiClient';\nimport { generateNonceSignature } from '../generateNonceSignature';\nimport { generateSessionSignature } from '../generateSessionSignature';\n\nexport const getSignedSessionId = async (client: DynamicClient) => {\n const core = getCore(client);\n\n const sessionId = core.state.get().user?.sessionId;\n assertDefined(sessionId, 'Session ID is required');\n\n const { signature: signedSessionId } = await generateSessionSignature(\n {\n sessionId,\n },\n client\n );\n\n assertDefined(signedSessionId, 'Signed session ID is required');\n\n const apiClient = createApiClient({}, client);\n const { nonce } = await apiClient.getNonce({\n environmentId: core.environmentId,\n });\n\n assertDefined(nonce, 'Nonce is required');\n\n const { signature: nonceSignature } = await generateNonceSignature(\n {\n nonce,\n },\n client\n );\n\n assertDefined(nonceSignature, 'Nonce signature is required');\n\n const signature = `${signedSessionId}/${nonceSignature}/${nonce}`;\n\n return { signature };\n};\n"],"mappings":";;;;AAUA,MAAa,qCAAqC,OAChD,EAAE,aACF,WACgC;AAMhC,KAAI,CALwB,MAAMA,sDAChC,EAAE,WAAW,EACb,OACD,CAGC;AAGF,QAAOC,+CAAgB,OAAO;;;;;AChBhC,MAAa,WAAW,OAAO,EAAE,eAAe,cAA8B;CAC5E,MAAM,aAAa,MAAM,OAAO,OAAO,UACrC,OACA,eACA;EACE,MAAM;EACN,YAAY;EACb,EACD,OACA,CAAC,OAAO,CACT;AAWD,QAAOC,2CATW,MAAM,OAAO,OAAO,KACpC;EACE,MAAM;EACN,MAAM;EACP,EACD,YACA,IAAI,aAAa,CAAC,OAAO,QAAQ,CAClC,CAE4B;;;;;ACnB/B,MAAa,yBAAyB,OACpC,EAAE,SACF,WACG;CACH,MAAM,cAAcC,yCAAe,OAAO;AAC1C,yCAAc,aAAa,yBAAyB;CAEpD,MAAM,EAAE,kBAAkB;AAO1B,QAAO,EAAE,WALS,MAAM,SAAS;EAC/B,SAAS;EACT;EACD,CAAC,EAEkB;;;;;ACdtB,MAAa,2BAA2B,OACtC,EAAE,aACF,WACG;CACH,MAAM,cAAcC,yCAAe,OAAO;AAC1C,yCAAc,aAAa,yBAAyB;CAEpD,MAAM,EAAE,kBAAkB;AAO1B,QAAO,EAAE,WALS,MAAM,SAAS;EAC/B,SAAS;EACT;EACD,CAAC,EAEkB;;;;;AChBtB,MAAa,qBAAqB,OAAO,WAA0B;CACjE,MAAM,OAAOC,kCAAQ,OAAO;CAE5B,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC,MAAM;AACzC,yCAAc,WAAW,yBAAyB;CAElD,MAAM,EAAE,WAAW,oBAAoB,MAAM,yBAC3C,EACE,WACD,EACD,OACD;AAED,yCAAc,iBAAiB,gCAAgC;CAG/D,MAAM,EAAE,UAAU,MADAC,0CAAgB,EAAE,EAAE,OAAO,CACX,SAAS,EACzC,eAAe,KAAK,eACrB,CAAC;AAEF,yCAAc,OAAO,oBAAoB;CAEzC,MAAM,EAAE,WAAW,mBAAmB,MAAM,uBAC1C,EACE,OACD,EACD,OACD;AAED,yCAAc,gBAAgB,8BAA8B;AAI5D,QAAO,EAAE,WAFS,GAAG,gBAAgB,GAAG,eAAe,GAAG,SAEtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isMfaRequiredForAction-BINs954q.cjs.js","names":["getDefaultClient","getCore","getDefaultClient","getCore","createApiClient","getDefaultClient"],"sources":["../src/utils/bufferToHex/bufferToHex.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Consumes and clears the current MFA token from the client state.\n *\n * This function retrieves the MFA token obtained from a successful MFA authentication,\n * and removes it from the client, to prevent it from being used again.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The MFA token that was consumed.\n * @throws Error if no MFA token is found.\n */\nexport const consumeMfaToken = (client = getDefaultClient()) => {\n const core = getCore(client);\n\n const mfaToken = core.state.get().mfaToken;\n\n assertDefined(mfaToken, 'No MFA token found');\n\n core.state.set({\n mfaToken: null,\n });\n\n return mfaToken;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\n\n/**\n * Retrieves the available MFA methods for the current user.\n *\n * This function fetches information about which multi-factor authentication\n * methods are available and configured for the user's account.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the user's MFA methods configuration.\n */\nexport const getMfaMethods = async (client = getDefaultClient()) => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const userMfaMethods = await apiClient.getUserMfaMethods({\n environmentId: core.environmentId,\n verifiedOnly: true,\n });\n\n return userMfaMethods;\n};\n","import type { MFAAction } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { getMfaMethods } from '../getMfaMethods';\n\ntype IsMfaRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\n/**\n * Checks if MFA is required for a specific action.\n *\n * This function determines whether multi-factor authentication is required\n * for the specified action based on project settings and user configuration.\n *\n * @param params.mfaAction - The action to check MFA requirements for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to true if MFA is required for the action, false otherwise.\n */\nexport const isMfaRequiredForAction = async (\n { mfaAction }: IsMfaRequiredForActionParams,\n client = getDefaultClient()\n) => {\n const projectSettings = client.projectSettings;\n\n const isRequiredForAction = projectSettings?.security?.mfa?.actions?.some(\n (action) => action.action === mfaAction && action.required\n );\n\n // if mfa is not required for the action, return false\n // no matter if general mfa is set to required or not\n if (!isRequiredForAction) {\n return false;\n }\n\n const isMfaMethodRequired = projectSettings?.security?.mfa?.required;\n\n // if mfa is required for the action and also set as required in general, return true\n if (isMfaMethodRequired) {\n return true;\n }\n\n const mfaMethods = await getMfaMethods(client);\n // if general mfa is optional, but user has registered methods,\n // then it should be required for the action\n return mfaMethods.userHasVerifiedMfaMethods;\n};\n"],"mappings":";;;;;;AAGA,MAAa,eAAe,WAC1B,CAAC,GAAI,kBAAkB,aAAa,SAAS,IAAI,WAAW,OAAO,CAAE,CAClE,KAAK,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC3C,KAAK,GAAG;;;;;;;;;;;;;;ACQb,MAAa,mBAAmB,SAASA,4CAAkB,KAAK;CAC9D,MAAM,OAAOC,kCAAQ,OAAO;CAE5B,MAAM,WAAW,KAAK,MAAM,KAAK,CAAC;AAElC,yCAAc,UAAU,qBAAqB;AAE7C,MAAK,MAAM,IAAI,EACb,UAAU,MACX,CAAC;AAEF,QAAO;;;;;;;;;;;;;;ACZT,MAAa,gBAAgB,OAAO,SAASC,4CAAkB,KAAK;CAClE,MAAM,OAAOC,kCAAQ,OAAO;AAQ5B,QALuB,MAFLC,0CAAgB,EAAE,EAAE,OAAO,CAEN,kBAAkB;EACvD,eAAe,KAAK;EACpB,cAAc;EACf,CAAC;;;;;;;;;;;;;;;ACDJ,MAAa,yBAAyB,OACpC,EAAE,aACF,SAASC,4CAAkB,KACxB;CACH,MAAM,kBAAkB,OAAO;AAQ/B,KAAI,CANwB,iBAAiB,UAAU,KAAK,SAAS,MAClE,WAAW,OAAO,WAAW,aAAa,OAAO,SACnD,CAKC,QAAO;AAMT,KAH4B,iBAAiB,UAAU,KAAK,SAI1D,QAAO;AAMT,SAHmB,MAAM,cAAc,OAAO,EAG5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isMfaRequiredForAction-MvVGc7k3.esm.js","names":[],"sources":["../src/utils/bufferToHex/bufferToHex.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["/**\n * Converts an ArrayBuffer or Uint8Array to a hex-encoded string\n */\nexport const bufferToHex = (buffer: ArrayBufferLike | Uint8Array) =>\n [...(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer))]\n .map((x) => x.toString(16).padStart(2, '0'))\n .join('');\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Consumes and clears the current MFA token from the client state.\n *\n * This function retrieves the MFA token obtained from a successful MFA authentication,\n * and removes it from the client, to prevent it from being used again.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns The MFA token that was consumed.\n * @throws Error if no MFA token is found.\n */\nexport const consumeMfaToken = (client = getDefaultClient()) => {\n const core = getCore(client);\n\n const mfaToken = core.state.get().mfaToken;\n\n assertDefined(mfaToken, 'No MFA token found');\n\n core.state.set({\n mfaToken: null,\n });\n\n return mfaToken;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\n\n/**\n * Retrieves the available MFA methods for the current user.\n *\n * This function fetches information about which multi-factor authentication\n * methods are available and configured for the user's account.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the user's MFA methods configuration.\n */\nexport const getMfaMethods = async (client = getDefaultClient()) => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const userMfaMethods = await apiClient.getUserMfaMethods({\n environmentId: core.environmentId,\n verifiedOnly: true,\n });\n\n return userMfaMethods;\n};\n","import type { MFAAction } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { getMfaMethods } from '../getMfaMethods';\n\ntype IsMfaRequiredForActionParams = {\n mfaAction: MFAAction;\n};\n\n/**\n * Checks if MFA is required for a specific action.\n *\n * This function determines whether multi-factor authentication is required\n * for the specified action based on project settings and user configuration.\n *\n * @param params.mfaAction - The action to check MFA requirements for.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to true if MFA is required for the action, false otherwise.\n */\nexport const isMfaRequiredForAction = async (\n { mfaAction }: IsMfaRequiredForActionParams,\n client = getDefaultClient()\n) => {\n const projectSettings = client.projectSettings;\n\n const isRequiredForAction = projectSettings?.security?.mfa?.actions?.some(\n (action) => action.action === mfaAction && action.required\n );\n\n // if mfa is not required for the action, return false\n // no matter if general mfa is set to required or not\n if (!isRequiredForAction) {\n return false;\n }\n\n const isMfaMethodRequired = projectSettings?.security?.mfa?.required;\n\n // if mfa is required for the action and also set as required in general, return true\n if (isMfaMethodRequired) {\n return true;\n }\n\n const mfaMethods = await getMfaMethods(client);\n // if general mfa is optional, but user has registered methods,\n // then it should be required for the action\n return mfaMethods.userHasVerifiedMfaMethods;\n};\n"],"mappings":";;;;;;AAGA,MAAa,eAAe,WAC1B,CAAC,GAAI,kBAAkB,aAAa,SAAS,IAAI,WAAW,OAAO,CAAE,CAClE,KAAK,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC3C,KAAK,GAAG;;;;;;;;;;;;;;ACQb,MAAa,mBAAmB,SAAS,kBAAkB,KAAK;CAC9D,MAAM,OAAO,QAAQ,OAAO;CAE5B,MAAM,WAAW,KAAK,MAAM,KAAK,CAAC;AAElC,eAAc,UAAU,qBAAqB;AAE7C,MAAK,MAAM,IAAI,EACb,UAAU,MACX,CAAC;AAEF,QAAO;;;;;;;;;;;;;;ACZT,MAAa,gBAAgB,OAAO,SAAS,kBAAkB,KAAK;CAClE,MAAM,OAAO,QAAQ,OAAO;AAQ5B,QALuB,MAFL,gBAAgB,EAAE,EAAE,OAAO,CAEN,kBAAkB;EACvD,eAAe,KAAK;EACpB,cAAc;EACf,CAAC;;;;;;;;;;;;;;;ACDJ,MAAa,yBAAyB,OACpC,EAAE,aACF,SAAS,kBAAkB,KACxB;CACH,MAAM,kBAAkB,OAAO;AAQ/B,KAAI,CANwB,iBAAiB,UAAU,KAAK,SAAS,MAClE,WAAW,OAAO,WAAW,aAAa,OAAO,SACnD,CAKC,QAAO;AAMT,KAH4B,iBAAiB,UAAU,KAAK,SAI1D,QAAO;AAMT,SAHmB,MAAM,cAAc,OAAO,EAG5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getOrCreateUserDeviceSigningKeys.d.ts","sourceRoot":"","sources":["../../../../../src/modules/deviceRegistration/getDeviceSigner/getOrCreateUserDeviceSigningKeys/getOrCreateUserDeviceSigningKeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,UAAU,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,WACnC,aAAa,KACpB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAqCjD,CAAC"}