@dynamic-labs-sdk/client 1.19.1 → 1.21.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 (190) hide show
  1. package/dist/{updateAuthFromVerifyResponse-D4au3jUv.native.esm.js → NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js} +158 -27
  2. package/dist/NativeModuleNotLinkedError-Ds_t3AZQ.native.esm.js.map +1 -0
  3. package/dist/client/core/createCore/getInitialState.d.ts.map +1 -1
  4. package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts +16 -0
  5. package/dist/client/createDynamicClient/assertClientProps/assertClientProps.d.ts.map +1 -0
  6. package/dist/client/createDynamicClient/assertClientProps/index.d.ts +2 -0
  7. package/dist/client/createDynamicClient/assertClientProps/index.d.ts.map +1 -0
  8. package/dist/client/createDynamicClient/createDynamicClient.d.ts.map +1 -1
  9. package/dist/client/types/DynamicClientConfig.d.ts +88 -6
  10. package/dist/client/types/DynamicClientConfig.d.ts.map +1 -1
  11. package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs +17 -0
  12. package/dist/consumeMfaTokenIfRequiredForAction-CWVbmQ2A.cjs.map +1 -0
  13. package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js +12 -0
  14. package/dist/consumeMfaTokenIfRequiredForAction-C_IvLTH6.esm.js.map +1 -0
  15. package/dist/core.cjs +13 -12
  16. package/dist/core.cjs.map +1 -1
  17. package/dist/core.esm.js +6 -5
  18. package/dist/core.esm.js.map +1 -1
  19. package/dist/core.native.esm.js +5 -5
  20. package/dist/errors/WaasLoadFailedError.d.ts +45 -0
  21. package/dist/errors/WaasLoadFailedError.d.ts.map +1 -0
  22. package/dist/exports/index.d.ts +1 -0
  23. package/dist/exports/index.d.ts.map +1 -1
  24. package/dist/exports/waas.d.ts +10 -0
  25. package/dist/exports/waas.d.ts.map +1 -1
  26. package/dist/{getNetworkProviderFromNetworkId-DmH039jx.cjs → getNetworkProviderFromNetworkId-5V4Cf8A_.cjs} +150 -70
  27. package/dist/getNetworkProviderFromNetworkId-5V4Cf8A_.cjs.map +1 -0
  28. package/dist/{getNetworkProviderFromNetworkId-Ct6nH2tC.esm.js → getNetworkProviderFromNetworkId-DhS1snCk.esm.js} +149 -68
  29. package/dist/getNetworkProviderFromNetworkId-DhS1snCk.esm.js.map +1 -0
  30. package/dist/{getNetworkProviderFromNetworkId-DL6OXPUn.native.esm.js → getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js} +151 -146
  31. package/dist/getNetworkProviderFromNetworkId-DudGvTmd.native.esm.js.map +1 -0
  32. package/dist/{getSignedSessionId-Dz4U61DG.cjs → getSignedSessionId-E6FIx5aj.cjs} +2 -17
  33. package/dist/getSignedSessionId-E6FIx5aj.cjs.map +1 -0
  34. package/dist/{getSignedSessionId-CPautem1.native.esm.js → getSignedSessionId-ekp3lswQ.esm.js} +3 -12
  35. package/dist/getSignedSessionId-ekp3lswQ.esm.js.map +1 -0
  36. package/dist/{getSignedSessionId-CAQwZYYk.esm.js → getSignedSessionId-xZGFa4nS.native.esm.js} +3 -3
  37. package/dist/{getSignedSessionId-CPautem1.native.esm.js.map → getSignedSessionId-xZGFa4nS.native.esm.js.map} +1 -1
  38. package/dist/{getWalletProviderByKey-CSVSMios.cjs → getWalletProviderByKey-BwivhTYu.cjs} +2 -2
  39. package/dist/{getWalletProviderByKey-CSVSMios.cjs.map → getWalletProviderByKey-BwivhTYu.cjs.map} +1 -1
  40. package/dist/{getWalletProviderByKey-DTBGx_qd.esm.js → getWalletProviderByKey-CS299i1V.esm.js} +2 -2
  41. package/dist/{getWalletProviderByKey-DTBGx_qd.esm.js.map → getWalletProviderByKey-CS299i1V.esm.js.map} +1 -1
  42. package/dist/{getWalletProviderByKey-BKveb5Rh.native.esm.js → getWalletProviderByKey-CYGDw6-5.native.esm.js} +2 -2
  43. package/dist/{getWalletProviderByKey-BKveb5Rh.native.esm.js.map → getWalletProviderByKey-CYGDw6-5.native.esm.js.map} +1 -1
  44. package/dist/index.cjs +58 -39
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.esm.js +36 -18
  47. package/dist/index.esm.js.map +1 -1
  48. package/dist/index.native.esm.js +36 -18
  49. package/dist/index.native.esm.js.map +1 -1
  50. package/dist/{isDynamicWaasEnabled-Dmbdiybh.cjs → isDynamicWaasEnabled-BEVAshnS.cjs} +2 -3
  51. package/dist/{isDynamicWaasEnabled-Dmbdiybh.cjs.map → isDynamicWaasEnabled-BEVAshnS.cjs.map} +1 -1
  52. package/dist/{isDynamicWaasEnabled-gu-9QF8-.native.esm.js → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js} +2 -2
  53. package/dist/{isDynamicWaasEnabled-gu-9QF8-.native.esm.js.map → isDynamicWaasEnabled-C8Fb1xHn.native.esm.js.map} +1 -1
  54. package/dist/{isDynamicWaasEnabled-Bb9e8w3u.esm.js → isDynamicWaasEnabled-D5e2K02u.esm.js} +2 -2
  55. package/dist/{isDynamicWaasEnabled-Bb9e8w3u.esm.js.map → isDynamicWaasEnabled-D5e2K02u.esm.js.map} +1 -1
  56. package/dist/{isMfaRequiredForAction-BkrwKqo1.native.esm.js → isMfaRequiredForAction-A02NFVt8.esm.js} +3 -32
  57. package/dist/isMfaRequiredForAction-A02NFVt8.esm.js.map +1 -0
  58. package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js +77 -0
  59. package/dist/isMfaRequiredForAction-D4TSMQ4m.native.esm.js.map +1 -0
  60. package/dist/isMfaRequiredForAction-odpvykkm.cjs +94 -0
  61. package/dist/isMfaRequiredForAction-odpvykkm.cjs.map +1 -0
  62. package/dist/{isUserOnboardingComplete-CruwjMvs.cjs → isUserOnboardingComplete-CEVSIxJC.cjs} +49 -4
  63. package/dist/isUserOnboardingComplete-CEVSIxJC.cjs.map +1 -0
  64. package/dist/{isUserOnboardingComplete-DAesufca.esm.js → isUserOnboardingComplete-Cgkw21XZ.esm.js} +44 -4
  65. package/dist/isUserOnboardingComplete-Cgkw21XZ.esm.js.map +1 -0
  66. package/dist/{isUserOnboardingComplete-BLm0JQ_z.native.esm.js → isUserOnboardingComplete-CvQShE05.native.esm.js} +44 -4
  67. package/dist/{isUserOnboardingComplete-CruwjMvs.cjs.map → isUserOnboardingComplete-CvQShE05.native.esm.js.map} +1 -1
  68. package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js +321 -0
  69. package/dist/migrateFromFireblocks-BMtelH1a.native.esm.js.map +1 -0
  70. package/dist/{migrateFromFireblocks-DrHwloUB.cjs → migrateFromFireblocks-CLUkVcFT.cjs} +54 -3
  71. package/dist/migrateFromFireblocks-CLUkVcFT.cjs.map +1 -0
  72. package/dist/{migrateFromFireblocks-Do4mQTl7.native.esm.js → migrateFromFireblocks-DcKrquTE.esm.js} +43 -4
  73. package/dist/migrateFromFireblocks-DcKrquTE.esm.js.map +1 -0
  74. package/dist/modules/storageSync/hydrateStateWithStorage/hydrateStateWithStorage.d.ts.map +1 -1
  75. package/dist/modules/storageSync/schema.d.ts +0 -2
  76. package/dist/modules/storageSync/schema.d.ts.map +1 -1
  77. package/dist/modules/storageSync/syncStateWithStorage/syncStateWithStorage.d.ts.map +1 -1
  78. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +25 -0
  79. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -0
  80. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts +2 -0
  81. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/index.d.ts.map +1 -0
  82. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts +35 -0
  83. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -0
  84. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts +2 -0
  85. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/index.d.ts.map +1 -0
  86. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +19 -0
  87. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -0
  88. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts +2 -0
  89. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/index.d.ts.map +1 -0
  90. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +184 -0
  91. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -0
  92. package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts +16 -0
  93. package/dist/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.d.ts.map +1 -0
  94. package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts +2 -0
  95. package/dist/modules/waas/businessAccounts/createBusinessAccount/index.d.ts.map +1 -0
  96. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts +36 -0
  97. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.d.ts.map +1 -0
  98. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts +2 -0
  99. package/dist/modules/waas/businessAccounts/createWalletForBusinessAccount/index.d.ts.map +1 -0
  100. package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts +15 -0
  101. package/dist/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.d.ts.map +1 -0
  102. package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts +2 -0
  103. package/dist/modules/waas/businessAccounts/getBusinessAccount/index.d.ts.map +1 -0
  104. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts +12 -0
  105. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/getBusinessAccountsClient.d.ts.map +1 -0
  106. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts +2 -0
  107. package/dist/modules/waas/businessAccounts/getBusinessAccountsClient/index.d.ts.map +1 -0
  108. package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts +2 -0
  109. package/dist/modules/waas/businessAccounts/listBusinessAccounts/index.d.ts.map +1 -0
  110. package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts +10 -0
  111. package/dist/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.d.ts.map +1 -0
  112. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts +2 -0
  113. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/index.d.ts.map +1 -0
  114. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +33 -0
  115. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -0
  116. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts +2 -0
  117. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/index.d.ts.map +1 -0
  118. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +37 -0
  119. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -0
  120. package/dist/modules/waas/createWaasClient/createWaasClient.d.ts.map +1 -1
  121. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  122. package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts +11 -0
  123. package/dist/modules/waas/createWaasProvider/isWaasLoadExhaustionError.d.ts.map +1 -0
  124. package/dist/modules/waas/waas.types.d.ts +11 -0
  125. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  126. package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts +4 -0
  127. package/dist/modules/wallets/networks/getNetworksData/getNetworksData.d.ts.map +1 -1
  128. package/dist/modules/wallets/networks/networkDataSchema/index.d.ts +2 -0
  129. package/dist/modules/wallets/networks/networkDataSchema/index.d.ts.map +1 -0
  130. package/dist/modules/wallets/networks/networkDataSchema/networkDataSchema.d.ts +23 -0
  131. package/dist/modules/wallets/networks/networkDataSchema/networkDataSchema.d.ts.map +1 -0
  132. package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts +2 -0
  133. package/dist/modules/wallets/walletAccount/walletAccount.types.d.ts.map +1 -1
  134. package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts +9 -1
  135. package/dist/services/keychain/createKeychainService/utils/openDatabase.d.ts.map +1 -1
  136. package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts +2 -1
  137. package/dist/services/keychain/createKeychainService/utils/withDatabase/withDatabase.d.ts.map +1 -1
  138. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  139. package/dist/{updateAuthFromVerifyResponse-CY0xTIXF.cjs → updateAuthFromVerifyResponse-CSqnGlh3.cjs} +427 -43
  140. package/dist/updateAuthFromVerifyResponse-CSqnGlh3.cjs.map +1 -0
  141. package/dist/{updateAuthFromVerifyResponse-inxvMWJB.esm.js → updateAuthFromVerifyResponse-C_YKKAIX.esm.js} +354 -27
  142. package/dist/updateAuthFromVerifyResponse-C_YKKAIX.esm.js.map +1 -0
  143. package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts +29 -0
  144. package/dist/utils/createTranslateRejection/createTranslateRejection.d.ts.map +1 -0
  145. package/dist/utils/createTranslateRejection/index.d.ts +3 -0
  146. package/dist/utils/createTranslateRejection/index.d.ts.map +1 -0
  147. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts +7 -5
  148. package/dist/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.d.ts.map +1 -1
  149. package/dist/utils/getNonce/getNonce.d.ts +10 -4
  150. package/dist/utils/getNonce/getNonce.d.ts.map +1 -1
  151. package/dist/utils/getNonce/noncePoolStorage/schema.d.ts +19 -0
  152. package/dist/utils/getNonce/noncePoolStorage/schema.d.ts.map +1 -0
  153. package/dist/utils/getNonce/noncePoolStorage/updateNoncePoolStorage/updateNoncePoolStorage.d.ts +18 -0
  154. package/dist/utils/getNonce/noncePoolStorage/updateNoncePoolStorage/updateNoncePoolStorage.d.ts.map +1 -0
  155. package/dist/utils/getNonce/prefetchNoncesIfNeeded/prefetchNoncesIfNeeded.d.ts.map +1 -1
  156. package/dist/utils/getNonce/state.d.ts +5 -9
  157. package/dist/utils/getNonce/state.d.ts.map +1 -1
  158. package/dist/waas.cjs +281 -18
  159. package/dist/waas.cjs.map +1 -1
  160. package/dist/waas.esm.js +273 -18
  161. package/dist/waas.esm.js.map +1 -1
  162. package/dist/waas.native.esm.js +272 -18
  163. package/dist/waas.native.esm.js.map +1 -1
  164. package/dist/waasCore.cjs +291 -170
  165. package/dist/waasCore.cjs.map +1 -1
  166. package/dist/waasCore.esm.js +285 -164
  167. package/dist/waasCore.esm.js.map +1 -1
  168. package/dist/waasCore.native.esm.js +273 -371
  169. package/dist/waasCore.native.esm.js.map +1 -1
  170. package/ios/DynamicClientScreenshotProtection.mm +70 -32
  171. package/package.json +5 -5
  172. package/dist/getNetworkProviderFromNetworkId-Ct6nH2tC.esm.js.map +0 -1
  173. package/dist/getNetworkProviderFromNetworkId-DL6OXPUn.native.esm.js.map +0 -1
  174. package/dist/getNetworkProviderFromNetworkId-DmH039jx.cjs.map +0 -1
  175. package/dist/getSignedSessionId-CAQwZYYk.esm.js.map +0 -1
  176. package/dist/getSignedSessionId-Dz4U61DG.cjs.map +0 -1
  177. package/dist/isMfaRequiredForAction-BkrwKqo1.native.esm.js.map +0 -1
  178. package/dist/isMfaRequiredForAction-CHeYEkjj.cjs +0 -430
  179. package/dist/isMfaRequiredForAction-CHeYEkjj.cjs.map +0 -1
  180. package/dist/isMfaRequiredForAction-DxJQm48x.esm.js +0 -343
  181. package/dist/isMfaRequiredForAction-DxJQm48x.esm.js.map +0 -1
  182. package/dist/isUserOnboardingComplete-BLm0JQ_z.native.esm.js.map +0 -1
  183. package/dist/isUserOnboardingComplete-DAesufca.esm.js.map +0 -1
  184. package/dist/migrateFromFireblocks-C-lXWvvo.esm.js +0 -65
  185. package/dist/migrateFromFireblocks-C-lXWvvo.esm.js.map +0 -1
  186. package/dist/migrateFromFireblocks-Do4mQTl7.native.esm.js.map +0 -1
  187. package/dist/migrateFromFireblocks-DrHwloUB.cjs.map +0 -1
  188. package/dist/updateAuthFromVerifyResponse-CY0xTIXF.cjs.map +0 -1
  189. package/dist/updateAuthFromVerifyResponse-D4au3jUv.native.esm.js.map +0 -1
  190. package/dist/updateAuthFromVerifyResponse-inxvMWJB.esm.js.map +0 -1
@@ -1,430 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
- const require_updateAuthFromVerifyResponse = require('./updateAuthFromVerifyResponse-CY0xTIXF.cjs');
29
- let zod_mini = require("zod/mini");
30
- zod_mini = __toESM(zod_mini);
31
-
32
- //#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
33
- /**
34
- * This error is thrown when the `retryOnFail` function is called with an invalid
35
- * number of retries (i.e. less than 0).
36
- */
37
- var InvalidRetryOnFailCallError = class extends require_updateAuthFromVerifyResponse.BaseError {
38
- constructor(maxRetries) {
39
- super({
40
- cause: null,
41
- code: "invalid_retry_on_fail_call_error",
42
- docsUrl: null,
43
- name: "InvalidRetryOnFailCallError",
44
- shortMessage: `Invalid retries parameter for retryOnFail call: ${maxRetries}`
45
- });
46
- }
47
- };
48
-
49
- //#endregion
50
- //#region src/utils/retryOnFail/retryOnFail.ts
51
- /** @notInstrumented */
52
- const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
53
- for (let retry = 0; retry <= maxRetries; retry++) try {
54
- return await fn();
55
- } catch (error) {
56
- if (retry >= maxRetries) throw error;
57
- if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
58
- }
59
- /**
60
- * Reaching this point should never happen and this
61
- * error is thrown to help us debug the issue.
62
- */
63
- throw new InvalidRetryOnFailCallError(maxRetries);
64
- };
65
-
66
- //#endregion
67
- //#region src/modules/auth/isSignedIn/isSignedIn.ts
68
- /**
69
- * Checks if the user is currently signed in to the Dynamic client.
70
- *
71
- * The client is considered to be in a signed in state if a user has
72
- * authenticated or if the client has at least one wallet connected.
73
- *
74
- * @deprecated What counts as "signed in" is your app's business logic, not the
75
- * SDK's. This helper bakes in one opinion (a user OR any connected wallet),
76
- * which rarely matches every app and forces a dependency on us for every
77
- * variation. Compose your own check from the underlying primitives instead —
78
- * e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and
79
- * layer in whatever your app requires (device registration, completed
80
- * onboarding, satisfied MFA, a required embedded wallet, …). See the
81
- * "Check if signed in" guide:
82
- * https://www.dynamic.xyz/docs/javascript/user-session-management
83
- *
84
- * @example
85
- * ```ts
86
- * if (isSignedIn()) {
87
- * console.log('User is authenticated or has a wallet connected');
88
- * }
89
- * ```
90
- *
91
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
92
- * @returns True if the user is signed in, false otherwise.
93
- * @see logout
94
- * @see isAnyWalletAccountConnected
95
- * @notInstrumented
96
- */
97
- const isSignedIn = (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => Boolean(client.user || require_updateAuthFromVerifyResponse.getWalletAccounts(client).length > 0);
98
-
99
- //#endregion
100
- //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
101
- /** @notInstrumented */
102
- const createStorageKeySchema = (params) => {
103
- return params;
104
- };
105
-
106
- //#endregion
107
- //#region src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts
108
- /**
109
- * The schema to track the expiration time of the project settings.
110
- */
111
- const projectSettingsExpirationStorageKeySchema = createStorageKeySchema({
112
- key: "projectSettingsExpiration",
113
- schema: zod_mini.number()
114
- });
115
-
116
- //#endregion
117
- //#region src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts
118
- /**
119
- * Expiration time of the project settings in milliseconds.
120
- */
121
- const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
122
- /**
123
- * Fetches and updates the project settings from the API.
124
- *
125
- * This function retrieves the latest project configuration settings
126
- * from Dynamic's servers, including authentication options, enabled chains,
127
- * and security configurations. The settings are cached for performance.
128
- *
129
- * @example
130
- * ```ts
131
- * const settings = await fetchProjectSettings();
132
- * console.log('Enabled chains:', settings.chains);
133
- * ```
134
- *
135
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
136
- * @returns A promise that resolves to the updated project settings.
137
- * @see createDynamicClient
138
- * @see initializeClient
139
- * @notInstrumented
140
- * @noHook Internal settings fetch that is not part of the public hook surface.
141
- */
142
- const fetchProjectSettings = async (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
143
- const core = require_updateAuthFromVerifyResponse.getCore(client);
144
- const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
145
- if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
146
- const apiClient = require_updateAuthFromVerifyResponse.createApiClient({}, client);
147
- core.logger.debug("[fetchProjectSettings] Fetching project settings...");
148
- const doFetch = async () => apiClient.getEnvironmentSettings({
149
- environmentId: core.environmentId,
150
- sdkVersion: `${require_updateAuthFromVerifyResponse.CLIENT_SDK_NAME}/${core.version}`
151
- }, { credentials: "omit" });
152
- const projectSettings = await retryOnFail({
153
- fn: doFetch,
154
- maxRetries: 2
155
- });
156
- core.state.set({ projectSettings: projectSettings ?? null });
157
- await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
158
- return projectSettings;
159
- };
160
-
161
- //#endregion
162
- //#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
163
- /** @notInstrumented */
164
- const generateSessionKeys = async (client) => {
165
- const core = require_updateAuthFromVerifyResponse.getCore(client);
166
- const currentState = core.state.get();
167
- const isRotation = Boolean(currentState.sessionKeys);
168
- const logContext = {
169
- environmentId: core.environmentId,
170
- operation: isRotation ? "rotate" : "create",
171
- userId: currentState.user?.id ?? null
172
- };
173
- core.logger.info(isRotation ? "[generateSessionKeys] Rotating session key..." : "[generateSessionKeys] Creating session key...", logContext);
174
- await core.keychain.removeKey("session");
175
- const publicKey = await core.keychain.generateKey("session");
176
- require_updateAuthFromVerifyResponse.assertDefined(publicKey, "Public key not found");
177
- core.state.set({ sessionKeys: publicKey });
178
- core.logger.info(isRotation ? "[generateSessionKeys] Session key rotated" : "[generateSessionKeys] Session key created", logContext);
179
- return { publicKey };
180
- };
181
-
182
- //#endregion
183
- //#region src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts
184
- /** @notInstrumented */
185
- const getAvailableWalletProvidersFromWalletAccounts = (client) => {
186
- const core = require_updateAuthFromVerifyResponse.getCore(client);
187
- const walletProvidersMap = /* @__PURE__ */ new Map();
188
- require_updateAuthFromVerifyResponse.getWalletAccounts(client).forEach((walletAccount) => {
189
- if (walletProvidersMap.has(walletAccount.walletProviderKey)) return;
190
- try {
191
- const walletProvider = require_updateAuthFromVerifyResponse.getWalletProviderFromWalletAccount({ walletAccount }, client);
192
- walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
193
- } catch (error) {
194
- core.logger.debug("Wallet provider not found for wallet account", {
195
- error,
196
- walletAccount: walletAccount.address
197
- });
198
- }
199
- });
200
- return Array.from(walletProvidersMap.values());
201
- };
202
-
203
- //#endregion
204
- //#region src/modules/wallets/destroyWalletProviders/destroyWalletProviders.ts
205
- /**
206
- * Tear down every wallet provider on the client.
207
- *
208
- * Each provider's `destroy` is responsible for its own local + remote
209
- * cleanup. We swallow errors so a failing destroy on one provider does not
210
- * block teardown of the others (e.g. during logout).
211
- *
212
- * @notInstrumented
213
- */
214
- const destroyWalletProviders = async ({ reason }, client) => {
215
- const core = require_updateAuthFromVerifyResponse.getCore(client);
216
- const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
217
- await Promise.all(walletProviders.map(async (walletProvider) => {
218
- if (!walletProvider.destroy) return;
219
- try {
220
- await walletProvider.destroy({ reason });
221
- } catch (err) {
222
- core.logger.error(`Error destroying wallet provider ${walletProvider.key}`, err);
223
- }
224
- }));
225
- };
226
-
227
- //#endregion
228
- //#region src/modules/auth/logoutWithReason/logoutWithReason.ts
229
- /**
230
- * Logs the user out with an explicit reason.
231
- *
232
- * Revokes the session, clears auth state, terminates wallet providers, and
233
- * emits the `logout` client event with the given reason. The reason is also
234
- * captured as an argument on the function-instrumentation event, which is
235
- * how Datadog distinguishes between different logout causes.
236
- *
237
- * Use this instead of the public `logout` when triggering a logout from
238
- * internal or extension code — the caller owns the reason string, so the
239
- * telemetry correctly attributes *why* the logout happened.
240
- *
241
- * @param params - The logout params.
242
- * @param params.reason - Why the logout is being triggered. Extension authors
243
- * needing a reason outside the SDK catalog can cast with `as LogoutReason`.
244
- * @param client - The Dynamic client instance.
245
- * @instrumented
246
- */
247
- const logoutWithReason = async ({ reason }, client) => {
248
- const core = require_updateAuthFromVerifyResponse.getCore(client);
249
- core.logger.debug("[logoutWithReason] Logging out...", { reason });
250
- await destroyWalletProviders({ reason }, client);
251
- if (client.user !== null) {
252
- const apiClient = require_updateAuthFromVerifyResponse.createApiClient({}, client);
253
- try {
254
- await apiClient.revokeSession({ environmentId: core.environmentId });
255
- } catch (error) {
256
- core.logger.error("Failed to revoke session", error);
257
- }
258
- /**
259
- * This deletes the auth cookie if it exists.
260
- * If the cookie doesn't exist, this sets a new cookie that expires immediately.
261
- */
262
- if (require_updateAuthFromVerifyResponse.isCookieEnabled(client)) require_updateAuthFromVerifyResponse.setCookie(`${require_updateAuthFromVerifyResponse.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax${require_updateAuthFromVerifyResponse.getSecureCookieAttribute()}`);
263
- }
264
- await core.keychain.removeKey("session");
265
- core.state.set({
266
- captchaToken: null,
267
- elevatedAccessTokens: [],
268
- legacyToken: null,
269
- mfaToken: null,
270
- sessionExpiresAt: null,
271
- sessionKeys: null,
272
- token: null,
273
- unverifiedWalletAccounts: [],
274
- user: null
275
- });
276
- require_updateAuthFromVerifyResponse.emitEvent({
277
- args: { reason },
278
- event: "logout"
279
- }, client);
280
- fetchProjectSettings(client);
281
- generateSessionKeys(client);
282
- };
283
- const __logoutWithReason_impl = logoutWithReason;
284
- const __logoutWithReason_wrapped = require_updateAuthFromVerifyResponse.instrumentFunction({
285
- fn: __logoutWithReason_impl,
286
- functionName: "logoutWithReason",
287
- getCore: () => {
288
- try {
289
- return require_updateAuthFromVerifyResponse.getCore(require_updateAuthFromVerifyResponse.getDefaultClient());
290
- } catch {
291
- return;
292
- }
293
- }
294
- });
295
-
296
- //#endregion
297
- //#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
298
- /**
299
- * Consumes and clears the current MFA token from the client state.
300
- *
301
- * This function retrieves the MFA token obtained from a successful MFA authentication,
302
- * and removes it from the client, to prevent it from being used again.
303
- *
304
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
305
- * @returns The MFA token that was consumed.
306
- * @throws Error if no MFA token is found.
307
- * @instrumented
308
- */
309
- const consumeMfaToken = (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
310
- const core = require_updateAuthFromVerifyResponse.getCore(client);
311
- const mfaToken = core.state.get().mfaToken;
312
- require_updateAuthFromVerifyResponse.assertDefined(mfaToken, "No MFA token found");
313
- core.state.set({ mfaToken: null });
314
- return mfaToken;
315
- };
316
- const __consumeMfaToken_impl = consumeMfaToken;
317
- const __consumeMfaToken_wrapped = require_updateAuthFromVerifyResponse.instrumentFunction({
318
- fn: __consumeMfaToken_impl,
319
- functionName: "consumeMfaToken",
320
- getCore: () => {
321
- try {
322
- return require_updateAuthFromVerifyResponse.getCore(require_updateAuthFromVerifyResponse.getDefaultClient());
323
- } catch {
324
- return;
325
- }
326
- }
327
- });
328
-
329
- //#endregion
330
- //#region src/modules/mfa/getMfaMethods/getMfaMethods.ts
331
- /**
332
- * Retrieves the available MFA methods for the current user.
333
- *
334
- * This function fetches information about which multi-factor authentication
335
- * methods are available and configured for the user's account.
336
- *
337
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
338
- * @returns A promise that resolves to the user's MFA methods configuration.
339
- * @notInstrumented
340
- */
341
- const getMfaMethods = async (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
342
- const core = require_updateAuthFromVerifyResponse.getCore(client);
343
- return await require_updateAuthFromVerifyResponse.createApiClient({}, client).getUserMfaMethods({
344
- environmentId: core.environmentId,
345
- verifiedOnly: true
346
- });
347
- };
348
-
349
- //#endregion
350
- //#region src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts
351
- /**
352
- * Checks if MFA is required for a specific action.
353
- *
354
- * This function determines whether multi-factor authentication is required
355
- * for the specified action based on project settings and user configuration.
356
- *
357
- * @param params.mfaAction - The action to check MFA requirements for.
358
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
359
- * @returns A promise that resolves to true if MFA is required for the action, false otherwise.
360
- * @notInstrumented
361
- */
362
- const isMfaRequiredForAction = async ({ mfaAction }, client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
363
- const projectSettings = client.projectSettings;
364
- if (!projectSettings?.security?.mfa?.actions?.some((action) => action.action === mfaAction && action.required)) return false;
365
- if (projectSettings?.security?.mfa?.required) return true;
366
- return (await getMfaMethods(client)).userHasVerifiedMfaMethods;
367
- };
368
-
369
- //#endregion
370
- Object.defineProperty(exports, '__consumeMfaToken_wrapped', {
371
- enumerable: true,
372
- get: function () {
373
- return __consumeMfaToken_wrapped;
374
- }
375
- });
376
- Object.defineProperty(exports, '__logoutWithReason_wrapped', {
377
- enumerable: true,
378
- get: function () {
379
- return __logoutWithReason_wrapped;
380
- }
381
- });
382
- Object.defineProperty(exports, '__toESM', {
383
- enumerable: true,
384
- get: function () {
385
- return __toESM;
386
- }
387
- });
388
- Object.defineProperty(exports, 'createStorageKeySchema', {
389
- enumerable: true,
390
- get: function () {
391
- return createStorageKeySchema;
392
- }
393
- });
394
- Object.defineProperty(exports, 'fetchProjectSettings', {
395
- enumerable: true,
396
- get: function () {
397
- return fetchProjectSettings;
398
- }
399
- });
400
- Object.defineProperty(exports, 'generateSessionKeys', {
401
- enumerable: true,
402
- get: function () {
403
- return generateSessionKeys;
404
- }
405
- });
406
- Object.defineProperty(exports, 'getMfaMethods', {
407
- enumerable: true,
408
- get: function () {
409
- return getMfaMethods;
410
- }
411
- });
412
- Object.defineProperty(exports, 'isMfaRequiredForAction', {
413
- enumerable: true,
414
- get: function () {
415
- return isMfaRequiredForAction;
416
- }
417
- });
418
- Object.defineProperty(exports, 'isSignedIn', {
419
- enumerable: true,
420
- get: function () {
421
- return isSignedIn;
422
- }
423
- });
424
- Object.defineProperty(exports, 'retryOnFail', {
425
- enumerable: true,
426
- get: function () {
427
- return retryOnFail;
428
- }
429
- });
430
- //# sourceMappingURL=isMfaRequiredForAction-CHeYEkjj.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isMfaRequiredForAction-CHeYEkjj.cjs","names":["BaseError","getDefaultClient","getWalletAccounts","z","getDefaultClient","getCore","createApiClient","CLIENT_SDK_NAME","getCore","getCore","walletProvidersMap: Map<string, WalletProvider>","getWalletAccounts","getWalletProviderFromWalletAccount","getCore","getDefaultClient","getCore","createApiClient","getDefaultClient"],"sources":["../src/utils/retryOnFail/InvalidRetryOnFailCallError.ts","../src/utils/retryOnFail/retryOnFail.ts","../src/modules/auth/isSignedIn/isSignedIn.ts","../src/services/storage/createStorageKeySchema/createStorageKeySchema.ts","../src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts","../src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts","../src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts","../src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts","../src/modules/wallets/destroyWalletProviders/destroyWalletProviders.ts","../src/modules/auth/logoutWithReason/logoutWithReason.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { BaseError } from '../../errors/base';\n\n/**\n * This error is thrown when the `retryOnFail` function is called with an invalid\n * number of retries (i.e. less than 0).\n */\nexport class InvalidRetryOnFailCallError extends BaseError {\n // eslint-disable-next-line custom-rules/require-single-object-param\n constructor(maxRetries: number) {\n super({\n cause: null,\n code: 'invalid_retry_on_fail_call_error',\n docsUrl: null,\n name: 'InvalidRetryOnFailCallError',\n shortMessage: `Invalid retries parameter for retryOnFail call: ${maxRetries}`,\n });\n }\n}\n","import { InvalidRetryOnFailCallError } from './InvalidRetryOnFailCallError';\n\nexport type RetryOnFailParams<T> = {\n /**\n * The delay between retries in milliseconds.\n */\n delay?: number;\n /**\n * The function to call.\n */\n fn: () => Promise<T>;\n /**\n * The maximum number of retries.\n *\n * When set to 0, the function will be called only once and is\n * therefore equivalent to calling the function directly.\n */\n maxRetries: number;\n};\n\n/** @notInstrumented */\nexport const retryOnFail = async <T>({\n delay = 0,\n fn,\n maxRetries,\n}: RetryOnFailParams<T>) => {\n for (let retry = 0; retry <= maxRetries; retry++) {\n try {\n return await fn();\n } catch (error) {\n if (retry >= maxRetries) {\n throw error;\n }\n\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n }\n\n /**\n * Reaching this point should never happen and this\n * error is thrown to help us debug the issue.\n */\n throw new InvalidRetryOnFailCallError(maxRetries);\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { getWalletAccounts } from '../../wallets/getWalletAccounts';\n\n/**\n * Checks if the user is currently signed in to the Dynamic client.\n *\n * The client is considered to be in a signed in state if a user has\n * authenticated or if the client has at least one wallet connected.\n *\n * @deprecated What counts as \"signed in\" is your app's business logic, not the\n * SDK's. This helper bakes in one opinion (a user OR any connected wallet),\n * which rarely matches every app and forces a dependency on us for every\n * variation. Compose your own check from the underlying primitives instead —\n * e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and\n * layer in whatever your app requires (device registration, completed\n * onboarding, satisfied MFA, a required embedded wallet, …). See the\n * \"Check if signed in\" guide:\n * https://www.dynamic.xyz/docs/javascript/user-session-management\n *\n * @example\n * ```ts\n * if (isSignedIn()) {\n * console.log('User is authenticated or has a wallet connected');\n * }\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if the user is signed in, false otherwise.\n * @see logout\n * @see isAnyWalletAccountConnected\n * @notInstrumented\n */\nexport const isSignedIn = (client = getDefaultClient()) =>\n Boolean(client.user || getWalletAccounts(client).length > 0);\n","import type * as z from 'zod/mini';\n\nimport type { StorageKeySchema, StorageKeySchemaConfig } from '../storage.types';\n\n/** @notInstrumented */\nexport const createStorageKeySchema = <T>(params: {\n config?: StorageKeySchemaConfig;\n key: string;\n schema: z.ZodMiniType<T>;\n}): StorageKeySchema<T> => {\n return params;\n};\n","import * as z from 'zod/mini';\n\nimport { createStorageKeySchema } from '../../../services/storage';\n\n/**\n * The schema to track the expiration time of the project settings.\n */\nexport const projectSettingsExpirationStorageKeySchema = createStorageKeySchema(\n {\n key: 'projectSettingsExpiration',\n schema: z.number(),\n }\n);\n","import { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { retryOnFail } from '../../../utils/retryOnFail';\nimport { createApiClient } from '../../apiClient';\nimport { CLIENT_SDK_NAME } from '../../apiClient/constants';\nimport { isSignedIn } from '../../auth/isSignedIn';\nimport { projectSettingsExpirationStorageKeySchema } from './projectSettingsExpirationScheme';\n\n/**\n * Expiration time of the project settings in milliseconds.\n */\nexport const PROJECT_SETTINGS_EXPIRATION_TIME = 1000 * 60 * 5; // 5 minutes\n\n/**\n * Fetches and updates the project settings from the API.\n *\n * This function retrieves the latest project configuration settings\n * from Dynamic's servers, including authentication options, enabled chains,\n * and security configurations. The settings are cached for performance.\n *\n * @example\n * ```ts\n * const settings = await fetchProjectSettings();\n * console.log('Enabled chains:', settings.chains);\n * ```\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the updated project settings.\n * @see createDynamicClient\n * @see initializeClient\n * @notInstrumented\n * @noHook Internal settings fetch that is not part of the public hook surface.\n */\nexport const fetchProjectSettings = async (client = getDefaultClient()) => {\n const core = getCore(client);\n\n const currentExpiration = await core.storage.getItem(\n projectSettingsExpirationStorageKeySchema\n );\n\n const hasProjectSettings = Boolean(client.projectSettings);\n const isExpired = currentExpiration && currentExpiration < Date.now();\n\n // We want to cache the project settings if its valid and user is connected.\n // This avoids unnecessary API calls and speeds up the initial load.\n if (hasProjectSettings && !isExpired && isSignedIn(client)) {\n return client.projectSettings;\n }\n\n const apiClient = createApiClient({}, client);\n\n core.logger.debug('[fetchProjectSettings] Fetching project settings...');\n\n const doFetch = async () =>\n apiClient.getEnvironmentSettings(\n {\n environmentId: core.environmentId,\n sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`,\n },\n {\n credentials: 'omit',\n }\n );\n\n const projectSettings = await retryOnFail({\n fn: doFetch,\n maxRetries: 2,\n });\n\n core.state.set({ projectSettings: projectSettings ?? null });\n\n await core.storage.setItem(\n projectSettingsExpirationStorageKeySchema,\n Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME\n );\n\n return projectSettings;\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport type { SessionKeys } from '../sessionKeys.types';\n\n/** @notInstrumented */\nexport const generateSessionKeys = async (\n client: DynamicClient\n): Promise<SessionKeys> => {\n const core = getCore(client);\n\n const currentState = core.state.get();\n\n const isRotation = Boolean(currentState.sessionKeys);\n\n const logContext = {\n environmentId: core.environmentId,\n operation: isRotation ? 'rotate' : 'create',\n userId: currentState.user?.id ?? null,\n };\n\n core.logger.info(\n isRotation\n ? '[generateSessionKeys] Rotating session key...'\n : '[generateSessionKeys] Creating session key...',\n logContext\n );\n\n await core.keychain.removeKey('session');\n\n const publicKey = await core.keychain.generateKey('session');\n\n assertDefined(publicKey, 'Public key not found');\n\n core.state.set({\n sessionKeys: publicKey,\n });\n\n core.logger.info(\n isRotation\n ? '[generateSessionKeys] Session key rotated'\n : '[generateSessionKeys] Session key created',\n logContext\n );\n\n return { publicKey };\n};\n","import { getCore } from '../../../../client/core/getCore';\nimport type { DynamicClient } from '../../../../client/types';\nimport { getWalletAccounts } from '../../getWalletAccounts';\nimport type { WalletProvider } from '../../walletProvider';\nimport { getWalletProviderFromWalletAccount } from '../getWalletProviderFromWalletAccount';\n\n/** @notInstrumented */\nexport const getAvailableWalletProvidersFromWalletAccounts = (\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const walletProvidersMap: Map<string, WalletProvider> = new Map();\n\n const walletAccounts = getWalletAccounts(client);\n\n walletAccounts.forEach((walletAccount) => {\n if (walletProvidersMap.has(walletAccount.walletProviderKey)) {\n return;\n }\n\n try {\n const walletProvider = getWalletProviderFromWalletAccount(\n {\n walletAccount,\n },\n client\n );\n\n walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);\n } catch (error) {\n core.logger.debug('Wallet provider not found for wallet account', {\n error,\n walletAccount: walletAccount.address,\n });\n }\n });\n\n return Array.from(walletProvidersMap.values());\n};\n","import { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types/DynamicClient';\nimport type { LogoutReason } from '../../auth/logoutReason';\nimport { getAvailableWalletProvidersFromWalletAccounts } from '../utils/getAvailableWalletProvidersFromWalletAccounts';\n\n/**\n * Tear down every wallet provider on the client.\n *\n * Each provider's `destroy` is responsible for its own local + remote\n * cleanup. We swallow errors so a failing destroy on one provider does not\n * block teardown of the others (e.g. during logout).\n *\n * @notInstrumented\n */\nexport const destroyWalletProviders = async (\n { reason }: { reason?: LogoutReason },\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);\n\n await Promise.all(\n walletProviders.map(async (walletProvider) => {\n if (!walletProvider.destroy) return;\n try {\n await walletProvider.destroy({ reason });\n } catch (err) {\n core.logger.error(\n `Error destroying wallet provider ${walletProvider.key}`,\n err\n );\n }\n })\n );\n};\n","import type { DynamicClient } from '../../../client/types';\nimport { getCore } from '../../../client/core/getCore';\nimport { getSecureCookieAttribute } from '../../../utils/getSecureCookieAttribute';\nimport { setCookie } from '../../../utils/setCookie';\nimport { createApiClient } from '../../apiClient';\nimport { emitEvent } from '../../clientEvents';\nimport { fetchProjectSettings } from '../../projectSettings/fetchProjectSettings';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { generateSessionKeys } from '../../sessionKeys/generateSessionKeys';\nimport { destroyWalletProviders } from '../../wallets/destroyWalletProviders';\nimport { DYNAMIC_AUTH_COOKIE_NAME } from '../consts';\nimport type { LogoutReason } from '../logoutReason';\n\n/**\n * Logs the user out with an explicit reason.\n *\n * Revokes the session, clears auth state, terminates wallet providers, and\n * emits the `logout` client event with the given reason. The reason is also\n * captured as an argument on the function-instrumentation event, which is\n * how Datadog distinguishes between different logout causes.\n *\n * Use this instead of the public `logout` when triggering a logout from\n * internal or extension code — the caller owns the reason string, so the\n * telemetry correctly attributes *why* the logout happened.\n *\n * @param params - The logout params.\n * @param params.reason - Why the logout is being triggered. Extension authors\n * needing a reason outside the SDK catalog can cast with `as LogoutReason`.\n * @param client - The Dynamic client instance.\n * @instrumented\n */\nexport const logoutWithReason = async (\n { reason }: { reason: LogoutReason },\n client: DynamicClient\n) => {\n const core = getCore(client);\n\n core.logger.debug('[logoutWithReason] Logging out...', { reason });\n\n await destroyWalletProviders({ reason }, client);\n\n if (client.user !== null) {\n const apiClient = createApiClient({}, client);\n\n try {\n await apiClient.revokeSession({\n environmentId: core.environmentId,\n });\n } catch (error) {\n core.logger.error('Failed to revoke session', error);\n }\n\n /**\n * This deletes the auth cookie if it exists.\n * If the cookie doesn't exist, this sets a new cookie that expires immediately.\n */\n if (isCookieEnabled(client)) {\n // Match the Secure attribute used when the cookie was written so the\n // deletion cookie is accepted consistently in a secure context.\n const secureAttribute = getSecureCookieAttribute();\n\n setCookie(\n `${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax${secureAttribute}`\n );\n }\n }\n\n await core.keychain.removeKey('session');\n\n core.state.set({\n captchaToken: null,\n elevatedAccessTokens: [],\n legacyToken: null,\n mfaToken: null,\n sessionExpiresAt: null,\n sessionKeys: null,\n token: null,\n unverifiedWalletAccounts: [],\n user: null,\n });\n\n emitEvent({ args: { reason }, event: 'logout' }, client);\n\n // Refetch project settings\n void fetchProjectSettings(client);\n\n // Regenerate session keys\n void generateSessionKeys(client);\n};\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 * @instrumented\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 * @notInstrumented\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 * @notInstrumented\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":"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"}