@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,343 +0,0 @@
1
- import { A as getWalletAccounts, K as createApiClient, T as getWalletProviderFromWalletAccount, U as setCookie, W as getSecureCookieAttribute, _t as BaseError, at as isCookieEnabled, dt as CLIENT_SDK_NAME, mt as getDefaultClient, ot as assertDefined, v as instrumentFunction, vt as getCore, w as DYNAMIC_AUTH_COOKIE_NAME, z as emitEvent } from "./updateAuthFromVerifyResponse-inxvMWJB.esm.js";
2
- import * as z from "zod/mini";
3
-
4
- //#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
5
- /**
6
- * This error is thrown when the `retryOnFail` function is called with an invalid
7
- * number of retries (i.e. less than 0).
8
- */
9
- var InvalidRetryOnFailCallError = class extends BaseError {
10
- constructor(maxRetries) {
11
- super({
12
- cause: null,
13
- code: "invalid_retry_on_fail_call_error",
14
- docsUrl: null,
15
- name: "InvalidRetryOnFailCallError",
16
- shortMessage: `Invalid retries parameter for retryOnFail call: ${maxRetries}`
17
- });
18
- }
19
- };
20
-
21
- //#endregion
22
- //#region src/utils/retryOnFail/retryOnFail.ts
23
- /** @notInstrumented */
24
- const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
25
- for (let retry = 0; retry <= maxRetries; retry++) try {
26
- return await fn();
27
- } catch (error) {
28
- if (retry >= maxRetries) throw error;
29
- if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
30
- }
31
- /**
32
- * Reaching this point should never happen and this
33
- * error is thrown to help us debug the issue.
34
- */
35
- throw new InvalidRetryOnFailCallError(maxRetries);
36
- };
37
-
38
- //#endregion
39
- //#region src/modules/auth/isSignedIn/isSignedIn.ts
40
- /**
41
- * Checks if the user is currently signed in to the Dynamic client.
42
- *
43
- * The client is considered to be in a signed in state if a user has
44
- * authenticated or if the client has at least one wallet connected.
45
- *
46
- * @deprecated What counts as "signed in" is your app's business logic, not the
47
- * SDK's. This helper bakes in one opinion (a user OR any connected wallet),
48
- * which rarely matches every app and forces a dependency on us for every
49
- * variation. Compose your own check from the underlying primitives instead —
50
- * e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and
51
- * layer in whatever your app requires (device registration, completed
52
- * onboarding, satisfied MFA, a required embedded wallet, …). See the
53
- * "Check if signed in" guide:
54
- * https://www.dynamic.xyz/docs/javascript/user-session-management
55
- *
56
- * @example
57
- * ```ts
58
- * if (isSignedIn()) {
59
- * console.log('User is authenticated or has a wallet connected');
60
- * }
61
- * ```
62
- *
63
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
64
- * @returns True if the user is signed in, false otherwise.
65
- * @see logout
66
- * @see isAnyWalletAccountConnected
67
- * @notInstrumented
68
- */
69
- const isSignedIn = (client = getDefaultClient()) => Boolean(client.user || getWalletAccounts(client).length > 0);
70
-
71
- //#endregion
72
- //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
73
- /** @notInstrumented */
74
- const createStorageKeySchema = (params) => {
75
- return params;
76
- };
77
-
78
- //#endregion
79
- //#region src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts
80
- /**
81
- * The schema to track the expiration time of the project settings.
82
- */
83
- const projectSettingsExpirationStorageKeySchema = createStorageKeySchema({
84
- key: "projectSettingsExpiration",
85
- schema: z.number()
86
- });
87
-
88
- //#endregion
89
- //#region src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts
90
- /**
91
- * Expiration time of the project settings in milliseconds.
92
- */
93
- const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
94
- /**
95
- * Fetches and updates the project settings from the API.
96
- *
97
- * This function retrieves the latest project configuration settings
98
- * from Dynamic's servers, including authentication options, enabled chains,
99
- * and security configurations. The settings are cached for performance.
100
- *
101
- * @example
102
- * ```ts
103
- * const settings = await fetchProjectSettings();
104
- * console.log('Enabled chains:', settings.chains);
105
- * ```
106
- *
107
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
108
- * @returns A promise that resolves to the updated project settings.
109
- * @see createDynamicClient
110
- * @see initializeClient
111
- * @notInstrumented
112
- * @noHook Internal settings fetch that is not part of the public hook surface.
113
- */
114
- const fetchProjectSettings = async (client = getDefaultClient()) => {
115
- const core = getCore(client);
116
- const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
117
- if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
118
- const apiClient = createApiClient({}, client);
119
- core.logger.debug("[fetchProjectSettings] Fetching project settings...");
120
- const doFetch = async () => apiClient.getEnvironmentSettings({
121
- environmentId: core.environmentId,
122
- sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`
123
- }, { credentials: "omit" });
124
- const projectSettings = await retryOnFail({
125
- fn: doFetch,
126
- maxRetries: 2
127
- });
128
- core.state.set({ projectSettings: projectSettings ?? null });
129
- await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
130
- return projectSettings;
131
- };
132
-
133
- //#endregion
134
- //#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
135
- /** @notInstrumented */
136
- const generateSessionKeys = async (client) => {
137
- const core = getCore(client);
138
- const currentState = core.state.get();
139
- const isRotation = Boolean(currentState.sessionKeys);
140
- const logContext = {
141
- environmentId: core.environmentId,
142
- operation: isRotation ? "rotate" : "create",
143
- userId: currentState.user?.id ?? null
144
- };
145
- core.logger.info(isRotation ? "[generateSessionKeys] Rotating session key..." : "[generateSessionKeys] Creating session key...", logContext);
146
- await core.keychain.removeKey("session");
147
- const publicKey = await core.keychain.generateKey("session");
148
- assertDefined(publicKey, "Public key not found");
149
- core.state.set({ sessionKeys: publicKey });
150
- core.logger.info(isRotation ? "[generateSessionKeys] Session key rotated" : "[generateSessionKeys] Session key created", logContext);
151
- return { publicKey };
152
- };
153
-
154
- //#endregion
155
- //#region src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts
156
- /** @notInstrumented */
157
- const getAvailableWalletProvidersFromWalletAccounts = (client) => {
158
- const core = getCore(client);
159
- const walletProvidersMap = /* @__PURE__ */ new Map();
160
- getWalletAccounts(client).forEach((walletAccount) => {
161
- if (walletProvidersMap.has(walletAccount.walletProviderKey)) return;
162
- try {
163
- const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
164
- walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
165
- } catch (error) {
166
- core.logger.debug("Wallet provider not found for wallet account", {
167
- error,
168
- walletAccount: walletAccount.address
169
- });
170
- }
171
- });
172
- return Array.from(walletProvidersMap.values());
173
- };
174
-
175
- //#endregion
176
- //#region src/modules/wallets/destroyWalletProviders/destroyWalletProviders.ts
177
- /**
178
- * Tear down every wallet provider on the client.
179
- *
180
- * Each provider's `destroy` is responsible for its own local + remote
181
- * cleanup. We swallow errors so a failing destroy on one provider does not
182
- * block teardown of the others (e.g. during logout).
183
- *
184
- * @notInstrumented
185
- */
186
- const destroyWalletProviders = async ({ reason }, client) => {
187
- const core = getCore(client);
188
- const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
189
- await Promise.all(walletProviders.map(async (walletProvider) => {
190
- if (!walletProvider.destroy) return;
191
- try {
192
- await walletProvider.destroy({ reason });
193
- } catch (err) {
194
- core.logger.error(`Error destroying wallet provider ${walletProvider.key}`, err);
195
- }
196
- }));
197
- };
198
-
199
- //#endregion
200
- //#region src/modules/auth/logoutWithReason/logoutWithReason.ts
201
- /**
202
- * Logs the user out with an explicit reason.
203
- *
204
- * Revokes the session, clears auth state, terminates wallet providers, and
205
- * emits the `logout` client event with the given reason. The reason is also
206
- * captured as an argument on the function-instrumentation event, which is
207
- * how Datadog distinguishes between different logout causes.
208
- *
209
- * Use this instead of the public `logout` when triggering a logout from
210
- * internal or extension code — the caller owns the reason string, so the
211
- * telemetry correctly attributes *why* the logout happened.
212
- *
213
- * @param params - The logout params.
214
- * @param params.reason - Why the logout is being triggered. Extension authors
215
- * needing a reason outside the SDK catalog can cast with `as LogoutReason`.
216
- * @param client - The Dynamic client instance.
217
- * @instrumented
218
- */
219
- const logoutWithReason = async ({ reason }, client) => {
220
- const core = getCore(client);
221
- core.logger.debug("[logoutWithReason] Logging out...", { reason });
222
- await destroyWalletProviders({ reason }, client);
223
- if (client.user !== null) {
224
- const apiClient = createApiClient({}, client);
225
- try {
226
- await apiClient.revokeSession({ environmentId: core.environmentId });
227
- } catch (error) {
228
- core.logger.error("Failed to revoke session", error);
229
- }
230
- /**
231
- * This deletes the auth cookie if it exists.
232
- * If the cookie doesn't exist, this sets a new cookie that expires immediately.
233
- */
234
- if (isCookieEnabled(client)) setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax${getSecureCookieAttribute()}`);
235
- }
236
- await core.keychain.removeKey("session");
237
- core.state.set({
238
- captchaToken: null,
239
- elevatedAccessTokens: [],
240
- legacyToken: null,
241
- mfaToken: null,
242
- sessionExpiresAt: null,
243
- sessionKeys: null,
244
- token: null,
245
- unverifiedWalletAccounts: [],
246
- user: null
247
- });
248
- emitEvent({
249
- args: { reason },
250
- event: "logout"
251
- }, client);
252
- fetchProjectSettings(client);
253
- generateSessionKeys(client);
254
- };
255
- const __logoutWithReason_impl = logoutWithReason;
256
- const __logoutWithReason_wrapped = instrumentFunction({
257
- fn: __logoutWithReason_impl,
258
- functionName: "logoutWithReason",
259
- getCore: () => {
260
- try {
261
- return getCore(getDefaultClient());
262
- } catch {
263
- return;
264
- }
265
- }
266
- });
267
-
268
- //#endregion
269
- //#region src/modules/mfa/consumeMfaToken/consumeMfaToken.ts
270
- /**
271
- * Consumes and clears the current MFA token from the client state.
272
- *
273
- * This function retrieves the MFA token obtained from a successful MFA authentication,
274
- * and removes it from the client, to prevent it from being used again.
275
- *
276
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
277
- * @returns The MFA token that was consumed.
278
- * @throws Error if no MFA token is found.
279
- * @instrumented
280
- */
281
- const consumeMfaToken = (client = getDefaultClient()) => {
282
- const core = getCore(client);
283
- const mfaToken = core.state.get().mfaToken;
284
- assertDefined(mfaToken, "No MFA token found");
285
- core.state.set({ mfaToken: null });
286
- return mfaToken;
287
- };
288
- const __consumeMfaToken_impl = consumeMfaToken;
289
- const __consumeMfaToken_wrapped = instrumentFunction({
290
- fn: __consumeMfaToken_impl,
291
- functionName: "consumeMfaToken",
292
- getCore: () => {
293
- try {
294
- return getCore(getDefaultClient());
295
- } catch {
296
- return;
297
- }
298
- }
299
- });
300
-
301
- //#endregion
302
- //#region src/modules/mfa/getMfaMethods/getMfaMethods.ts
303
- /**
304
- * Retrieves the available MFA methods for the current user.
305
- *
306
- * This function fetches information about which multi-factor authentication
307
- * methods are available and configured for the user's account.
308
- *
309
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
310
- * @returns A promise that resolves to the user's MFA methods configuration.
311
- * @notInstrumented
312
- */
313
- const getMfaMethods = async (client = getDefaultClient()) => {
314
- const core = getCore(client);
315
- return await createApiClient({}, client).getUserMfaMethods({
316
- environmentId: core.environmentId,
317
- verifiedOnly: true
318
- });
319
- };
320
-
321
- //#endregion
322
- //#region src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts
323
- /**
324
- * Checks if MFA is required for a specific action.
325
- *
326
- * This function determines whether multi-factor authentication is required
327
- * for the specified action based on project settings and user configuration.
328
- *
329
- * @param params.mfaAction - The action to check MFA requirements for.
330
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
331
- * @returns A promise that resolves to true if MFA is required for the action, false otherwise.
332
- * @notInstrumented
333
- */
334
- const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()) => {
335
- const projectSettings = client.projectSettings;
336
- if (!projectSettings?.security?.mfa?.actions?.some((action) => action.action === mfaAction && action.required)) return false;
337
- if (projectSettings?.security?.mfa?.required) return true;
338
- return (await getMfaMethods(client)).userHasVerifiedMfaMethods;
339
- };
340
-
341
- //#endregion
342
- export { generateSessionKeys as a, isSignedIn as c, __logoutWithReason_wrapped as i, retryOnFail as l, getMfaMethods as n, fetchProjectSettings as o, __consumeMfaToken_wrapped as r, createStorageKeySchema as s, isMfaRequiredForAction as t };
343
- //# sourceMappingURL=isMfaRequiredForAction-DxJQm48x.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isMfaRequiredForAction-DxJQm48x.esm.js","names":["walletProvidersMap: Map<string, WalletProvider>"],"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":";;;;;;;;AAMA,IAAa,8BAAb,cAAiD,UAAU;CAEzD,YAAY,YAAoB;AAC9B,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,mDAAmD;GAClE,CAAC;;;;;;;ACMN,MAAa,cAAc,OAAU,EACnC,QAAQ,GACR,IACA,iBAC0B;AAC1B,MAAK,IAAI,QAAQ,GAAG,SAAS,YAAY,QACvC,KAAI;AACF,SAAO,MAAM,IAAI;UACV,OAAO;AACd,MAAI,SAAS,WACX,OAAM;AAGR,MAAI,QAAQ,EACV,OAAM,IAAI,SAAS,YAAY,WAAW,SAAS,MAAM,CAAC;;;;;;AAShE,OAAM,IAAI,4BAA4B,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZnD,MAAa,cAAc,SAAS,kBAAkB,KACpD,QAAQ,OAAO,QAAQ,kBAAkB,OAAO,CAAC,SAAS,EAAE;;;;;AC5B9D,MAAa,0BAA6B,WAIf;AACzB,QAAO;;;;;;;;ACHT,MAAa,4CAA4C,uBACvD;CACE,KAAK;CACL,QAAQ,EAAE,QAAQ;CACnB,CACF;;;;;;;ACDD,MAAa,mCAAmC,MAAO,KAAK;;;;;;;;;;;;;;;;;;;;;AAsB5D,MAAa,uBAAuB,OAAO,SAAS,kBAAkB,KAAK;CACzE,MAAM,OAAO,QAAQ,OAAO;CAE5B,MAAM,oBAAoB,MAAM,KAAK,QAAQ,QAC3C,0CACD;AAOD,KAL2B,QAAQ,OAAO,gBAAgB,IAKhC,EAJR,qBAAqB,oBAAoB,KAAK,KAAK,KAI7B,WAAW,OAAO,CACxD,QAAO,OAAO;CAGhB,MAAM,YAAY,gBAAgB,EAAE,EAAE,OAAO;AAE7C,MAAK,OAAO,MAAM,sDAAsD;CAExE,MAAM,UAAU,YACd,UAAU,uBACR;EACE,eAAe,KAAK;EACpB,YAAY,GAAG,gBAAgB,GAAG,KAAK;EACxC,EACD,EACE,aAAa,QACd,CACF;CAEH,MAAM,kBAAkB,MAAM,YAAY;EACxC,IAAI;EACJ,YAAY;EACb,CAAC;AAEF,MAAK,MAAM,IAAI,EAAE,iBAAiB,mBAAmB,MAAM,CAAC;AAE5D,OAAM,KAAK,QAAQ,QACjB,2CACA,KAAK,KAAK,GAAG,iCACd;AAED,QAAO;;;;;;ACtET,MAAa,sBAAsB,OACjC,WACyB;CACzB,MAAM,OAAO,QAAQ,OAAO;CAE5B,MAAM,eAAe,KAAK,MAAM,KAAK;CAErC,MAAM,aAAa,QAAQ,aAAa,YAAY;CAEpD,MAAM,aAAa;EACjB,eAAe,KAAK;EACpB,WAAW,aAAa,WAAW;EACnC,QAAQ,aAAa,MAAM,MAAM;EAClC;AAED,MAAK,OAAO,KACV,aACI,kDACA,iDACJ,WACD;AAED,OAAM,KAAK,SAAS,UAAU,UAAU;CAExC,MAAM,YAAY,MAAM,KAAK,SAAS,YAAY,UAAU;AAE5D,eAAc,WAAW,uBAAuB;AAEhD,MAAK,MAAM,IAAI,EACb,aAAa,WACd,CAAC;AAEF,MAAK,OAAO,KACV,aACI,8CACA,6CACJ,WACD;AAED,QAAO,EAAE,WAAW;;;;;;ACtCtB,MAAa,iDACX,WACG;CACH,MAAM,OAAO,QAAQ,OAAO;CAE5B,MAAMA,qCAAkD,IAAI,KAAK;AAIjE,CAFuB,kBAAkB,OAAO,CAEjC,SAAS,kBAAkB;AACxC,MAAI,mBAAmB,IAAI,cAAc,kBAAkB,CACzD;AAGF,MAAI;GACF,MAAM,iBAAiB,mCACrB,EACE,eACD,EACD,OACD;AAED,sBAAmB,IAAI,cAAc,mBAAmB,eAAe;WAChE,OAAO;AACd,QAAK,OAAO,MAAM,gDAAgD;IAChE;IACA,eAAe,cAAc;IAC9B,CAAC;;GAEJ;AAEF,QAAO,MAAM,KAAK,mBAAmB,QAAQ,CAAC;;;;;;;;;;;;;;ACxBhD,MAAa,yBAAyB,OACpC,EAAE,UACF,WACG;CACH,MAAM,OAAO,QAAQ,OAAO;CAE5B,MAAM,kBAAkB,8CAA8C,OAAO;AAE7E,OAAM,QAAQ,IACZ,gBAAgB,IAAI,OAAO,mBAAmB;AAC5C,MAAI,CAAC,eAAe,QAAS;AAC7B,MAAI;AACF,SAAM,eAAe,QAAQ,EAAE,QAAQ,CAAC;WACjC,KAAK;AACZ,QAAK,OAAO,MACV,oCAAoC,eAAe,OACnD,IACD;;GAEH,CACH;;;;;;;;;;;;;;;;;;;;;;;ACAH,MAAK,mBAAA,OACH,EAAA,qBAEA;;;AAKA,OAAE,uBAAkB,EAAA,QAAmB,EAAC,OAAO;AAE/C,KAAE,OAAI,SAAA,MAAA;EACJ,MAAE,YAAgB,gBAAc,EAAA,EAAA,OAAA;AAEhC,MAAI;AACF,SAAM,UAAQ,cAAA,EACd,eAAiB,KAAE,eACrB,CAAA;;AAEE,QAAA,OAAA,MAAA,4BAAA,MAAA;;;;;;AAOF,MAAE,gBAAM,OAAkB,CAK1B,WACF,GAAA,yBAAA,4CAHS,0BAA6C;;AAQtD,OAAE,KAAA,SAAkB,UAAA,UAAA;AAEpB,MAAE,MAAA,IAAa;EACb,cAAc;EACd,sBAAsB,EAAA;EACtB,aAAa;EACb,UAAO;EACP,kBAAA;EACA,aAAU;EACV,OAAA;;EAEF,MAAA;;AAGA,WAAK;EAAA,MAAA,EAAA,QAAqB;EAAA,OAAO;EAAA,EAAA,OAAA;AAGjC,CAAK,qBAAoB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrElC,MAAE,mBAAsB,SAAU,kBAAU,KAAA;;;AAK1C,eAAY,UAAI,qBAAA;kBAGhB,UAAO,MACR,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACbD,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":"isUserOnboardingComplete-BLm0JQ_z.native.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasOnboardingIncompleteError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User) =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n) => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (client = getDefaultClient()) => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAeA,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACLN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACxB;CACH,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BAA4B,SAAS,kBAAkB,KAAK;CACvE,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isUserOnboardingComplete-DAesufca.esm.js","names":["preconnectWaasIframe"],"sources":["../src/errors/WaasOnboardingIncompleteError.ts","../src/modules/waas/preconnectWaasIframe/preconnectWaasIframe.ts","../src/modules/deviceRegistration/isDeviceRegistrationRequired/isDeviceRegistrationRequired.ts","../src/modules/mfa/isPendingRecoveryCodesAcknowledgment/isPendingRecoveryCodesAcknowledgment.ts","../src/modules/user/isUserOnboardingComplete/isUserOnboardingComplete.ts"],"sourcesContent":["import { BaseError } from './base';\n\n/**\n * Thrown when the embedded (WaaS) wallet client is requested before the user\n * has completed onboarding — i.e. the JWT has not upgraded to `user:basic`\n * because MFA, KYC, recovery-codes acknowledgment, or device registration is\n * still pending.\n *\n * The WaaS iframe's init-time room-cache pre-warm fires `createRooms` using the\n * token captured at client construction (before any per-operation token\n * resync). Building the client during this window lets that pre-warm fire with\n * a pre-`user:basic` token, get a 401, and the iframe's unauthorized handler\n * force-logs-out the user. Throwing here surfaces a clear, recoverable reason\n * instead — wait for onboarding to complete and retry.\n */\nexport class WaasOnboardingIncompleteError extends BaseError {\n constructor() {\n super({\n cause: null,\n code: 'waas_onboarding_incomplete',\n docsUrl: null,\n name: 'WaasOnboardingIncompleteError',\n shortMessage:\n 'Cannot create or access the embedded wallet until onboarding is complete (pending MFA, KYC, recovery-codes acknowledgment, or device registration).',\n });\n }\n}\n","import type { AuthMode } from '@dynamic-labs-wallet/browser-wallet-client';\nimport { preconnectWaasIframe as preconnectWaasIframeOrigin } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getCore } from '../../../client/core/getCore';\nimport type { DynamicClient } from '../../../client/types';\nimport { isCookieEnabled } from '../../projectSettings/isCookieEnabled';\nimport { DEFAULT_WAAS_BASE_API_URL } from '../constants';\nimport { isDynamicWaasEnabled } from '../isDynamicWaasEnabled';\n\n/**\n * Warms the browser's connection (DNS + TCP + TLS) to the embedded-wallet\n * iframe origin so the iframe mounted after authentication completes loads on\n * a hot connection. Called when an auth flow starts (OTP send/verify, social\n * callback). Safe to call repeatedly; no-op on React Native / SSR and when\n * Dynamic WaaS is not enabled.\n *\n * @param client - The Dynamic client instance.\n * @notInstrumented\n */\nexport const preconnectWaasIframe = (client: DynamicClient): void => {\n const core = getCore(client);\n try {\n if (!isDynamicWaasEnabled(client)) return;\n\n preconnectWaasIframeOrigin({\n authMode: (isCookieEnabled(client) ? 'cookie' : 'header') as AuthMode,\n baseApiUrl: (core.apiBaseUrl || DEFAULT_WAAS_BASE_API_URL).replace(\n '/api/v0',\n ''\n ),\n });\n } catch (error) {\n // Best-effort: never break the auth flow (also swallows the assertion\n // from isDynamicWaasEnabled when project settings are not loaded yet).\n core.logger.warn('[preconnectWaasIframe] skipped', error);\n }\n};\n","import type { User } from '../../user/user.types';\n\n/**\n * Checks if device registration is required for the given user.\n *\n * This function determines if the user has the deviceRegistration\n * scope, indicating that device registration is required.\n *\n * @param user - The user to check.\n * @returns True if device registration is required, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when this device must be registered, updated when the user changes.\n */\nexport const isDeviceRegistrationRequired = (user: User) =>\n Boolean(user.scope?.includes('device:register'));\n","import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if the user is still pending acknowledgment of their MFA recovery codes.\n *\n * This function determines whether the user has been presented with recovery\n * codes that they have not yet acknowledged as saved or backed up.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if recovery codes are pending acknowledgment, false otherwise.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when recovery codes await acknowledgment, updated when the user changes.\n */\nexport const isPendingRecoveryCodesAcknowledgment = (\n client = getDefaultClient()\n) => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n return (\n user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending\n );\n};\n","import { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\nimport { isDeviceRegistrationRequired } from '../../deviceRegistration/isDeviceRegistrationRequired';\nimport { isPendingRecoveryCodesAcknowledgment } from '../../mfa/isPendingRecoveryCodesAcknowledgment';\nimport { isUserMissingMfaAuth } from '../../mfa/isUserMissingMfaAuth';\n\n/**\n * Checks if the user has completed all onboarding requirements.\n *\n * This function verifies whether a user has fulfilled all necessary requirements\n * including KYC fields (Know Your Customer information), MFA setup\n * (Multi-Factor Authentication including recovery codes acknowledgment), and\n * device registration.\n *\n * A `false` result means the user still has an outstanding onboarding step, so\n * any feature that requires a fully onboarded (`user:basic`) user should hold\n * off until it returns `true`. Creating or accessing an embedded (WaaS) wallet\n * is one such feature — its backend calls reject a pre-`user:basic` token — but\n * this predicate is general and not specific to embedded wallets.\n *\n * @deprecated Use {@link checkUserScopes} instead. This function conflates\n * Dynamic-controlled requirements (MFA, device registration, required fields)\n * with the concept of \"onboarding complete\", which is app-specific. Replace\n * with `checkUserScopes({ user, scopes: ['user:basic'] })` to check whether\n * Dynamic's requirements are satisfied, and compose your own logic on top for\n * any app-specific onboarding steps.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if onboarding is complete (no pending requirements), false if there are pending requirements.\n * @notInstrumented\n * @hook Exposed as a hook so consumers reactively know when onboarding is complete, updated when the user changes.\n */\nexport const isUserOnboardingComplete = (client = getDefaultClient()) => {\n const user = client.user;\n\n assertDefined(user, 'User not logged in');\n\n const hasMissingKycFields = Boolean(user.missingFields?.length);\n const hasPendingMfaAuth = isUserMissingMfaAuth(client);\n const hasPendingRecoveryCodes = isPendingRecoveryCodesAcknowledgment(client);\n const hasPendingDeviceRegistration = isDeviceRegistrationRequired(user);\n\n const userOnboardingComplete =\n !hasMissingKycFields &&\n !hasPendingMfaAuth &&\n !hasPendingRecoveryCodes &&\n !hasPendingDeviceRegistration;\n\n return userOnboardingComplete;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAeA,IAAa,gCAAb,cAAmD,UAAU;CAC3D,cAAc;AACZ,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cACE;GACH,CAAC;;;;;;;;;;;;;;;;ACLN,MAAaA,0BAAwB,WAAgC;CACnE,MAAM,OAAO,QAAQ,OAAO;AAC5B,KAAI;AACF,MAAI,CAAC,qBAAqB,OAAO,CAAE;AAEnC,uBAA2B;GACzB,UAAW,gBAAgB,OAAO,GAAG,WAAW;GAChD,aAAa,KAAK,cAAc,2BAA2B,QACzD,WACA,GACD;GACF,CAAC;UACK,OAAO;AAGd,OAAK,OAAO,KAAK,kCAAkC,MAAM;;;;;;;;;;;;;;;;;ACrB7D,MAAa,gCAAgC,SAC3C,QAAQ,KAAK,OAAO,SAAS,kBAAkB,CAAC;;;;;;;;;;;;;;;ACElD,MAAa,wCACX,SAAS,kBAAkB,KACxB;CACH,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;AAEzC,QACE,KAAK,iCAAiC,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQvE,MAAa,4BAA4B,SAAS,kBAAkB,KAAK;CACvE,MAAM,OAAO,OAAO;AAEpB,eAAc,MAAM,qBAAqB;CAEzC,MAAM,sBAAsB,QAAQ,KAAK,eAAe,OAAO;CAC/D,MAAM,oBAAoB,qBAAqB,OAAO;CACtD,MAAM,0BAA0B,qCAAqC,OAAO;CAC5E,MAAM,+BAA+B,6BAA6B,KAAK;AAQvE,QALE,CAAC,uBACD,CAAC,qBACD,CAAC,2BACD,CAAC"}
@@ -1,65 +0,0 @@
1
- import { T as getWalletProviderFromWalletAccount, _t as BaseError, c as isWaasWalletProvider, d as DYNAMIC_WAAS_METADATA, f as getWalletProviders, k as NoWalletProviderFoundError, mt as getDefaultClient } from "./updateAuthFromVerifyResponse-inxvMWJB.esm.js";
2
- import { n as NotWaasWalletAccountError, r as __refreshAuth_wrapped } from "./isDynamicWaasEnabled-Bb9e8w3u.esm.js";
3
-
4
- //#region src/errors/NotWaasWalletProviderError.ts
5
- var NotWaasWalletProviderError = class extends BaseError {
6
- constructor({ walletProviderKey }) {
7
- super({
8
- cause: null,
9
- code: "not_waas_wallet_provider_error",
10
- docsUrl: null,
11
- name: "NotWaasWalletProviderError",
12
- shortMessage: `Wallet provider ${walletProviderKey} is not a Dynamic WaaS wallet provider`
13
- });
14
- }
15
- };
16
-
17
- //#endregion
18
- //#region src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts
19
- /** @notInstrumented */
20
- const getWaasWalletProviderFromWalletAccount = ({ walletAccount }, client) => {
21
- const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
22
- if (!isWaasWalletProvider(walletProvider)) throw new NotWaasWalletAccountError({ walletAddress: walletAccount.address });
23
- return walletProvider;
24
- };
25
-
26
- //#endregion
27
- //#region src/modules/waas/migrateFromFireblocks/migrateFromFireblocks.ts
28
- /**
29
- * Migrates an existing Fireblocks NCW wallet into Dynamic's WaaS infrastructure.
30
- *
31
- * Migration is a single cross-chain operation: one call takes over the Fireblocks
32
- * key material and provisions Dynamic WaaS wallet accounts for every supported
33
- * chain. Because it is not per-chain, this resolves a single WaaS wallet provider
34
- * (any registered chain) and delegates the takeover to it.
35
- *
36
- * @param params.deviceId - The Fireblocks NCW device id being migrated.
37
- * @param params.jwt - The Fireblocks-issued JWT authorizing the takeover.
38
- * @param params.storage - The serialized Fireblocks NCW device storage.
39
- * @param params.password - The password that encrypted the legacy device storage.
40
- * @param params.expectedAddresses - Required per-chain expected address; its keys are the chains migration runs on, and each imported address is verified against it.
41
- * @param [params.coinTypes] - Optional SLIP-0044 coin types per chain name.
42
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
43
- * @returns A promise resolving to the per-chain migration results.
44
- * @notInstrumented
45
- */
46
- const migrateFromFireblocks = async ({ coinTypes, deviceId, expectedAddresses, jwt, password, storage }, client = getDefaultClient()) => {
47
- const providers = getWalletProviders(client);
48
- if (providers.length === 0) throw new NoWalletProviderFoundError({ walletProviderKey: DYNAMIC_WAAS_METADATA.displayName });
49
- const waasProvider = providers.find(isWaasWalletProvider);
50
- if (!waasProvider) throw new NotWaasWalletProviderError({ walletProviderKey: providers[0].key });
51
- const result = await waasProvider.migrateFromFireblocks({
52
- coinTypes,
53
- deviceId,
54
- expectedAddresses,
55
- jwt,
56
- password,
57
- storage
58
- });
59
- await __refreshAuth_wrapped(client);
60
- return result;
61
- };
62
-
63
- //#endregion
64
- export { getWaasWalletProviderFromWalletAccount as n, NotWaasWalletProviderError as r, migrateFromFireblocks as t };
65
- //# sourceMappingURL=migrateFromFireblocks-C-lXWvvo.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateFromFireblocks-C-lXWvvo.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/migrateFromFireblocks/migrateFromFireblocks.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NotWaasWalletProviderErrorParams = {\n walletProviderKey: string;\n};\n\nexport class NotWaasWalletProviderError extends BaseError {\n constructor({ walletProviderKey }: NotWaasWalletProviderErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_provider_error',\n docsUrl: null,\n name: 'NotWaasWalletProviderError',\n shortMessage: `Wallet provider ${walletProviderKey} is not a Dynamic WaaS wallet provider`,\n });\n }\n}\n","import type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { NotWaasWalletAccountError } from '../../../errors/NotWaasWalletAccountError';\nimport { getWalletProviderFromWalletAccount } from '../../wallets/utils/getWalletProviderFromWalletAccount';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport type { WaasWalletProvider } from '../waas.types';\n\ntype GetWalletProviderFromWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const getWaasWalletProviderFromWalletAccount = (\n { walletAccount }: GetWalletProviderFromWalletAccountParams,\n client: DynamicClient\n): WaasWalletProvider => {\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isWaasWalletProvider(walletProvider)) {\n throw new NotWaasWalletAccountError({\n walletAddress: walletAccount.address,\n });\n }\n\n return walletProvider;\n};\n","import type { MigrateFromFireblocksResponse } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { NotWaasWalletProviderError } from '../../../errors/NotWaasWalletProviderError';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport { getWalletProviders } from '../../wallets/getWalletProviders';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\n\ntype MigrateFromFireblocksParams = {\n /**\n * Optional SLIP-0044 coin types per chain name for BIP44 derivation off the\n * Fireblocks takeover xprv (e.g. `{ EVM: 1 }` for Sepolia).\n */\n coinTypes?: Record<string, number>;\n /**\n * The Fireblocks NCW device id whose key material is being migrated.\n */\n deviceId: string;\n /**\n * Required per-chain expected wallet address (the address Fireblocks held). Its\n * keys are the chains migration runs on, and the migration iframe verifies each\n * imported Dynamic address matches the value, so a wrong derivation fails loudly\n * instead of producing an unusable wallet.\n */\n expectedAddresses: Record<string, string>;\n /**\n * The Fireblocks-issued JWT authorizing the takeover.\n */\n jwt: string;\n /**\n * The password that encrypted the legacy Fireblocks NCW device storage.\n */\n password: string;\n /**\n * The serialized Fireblocks NCW device storage (the local key share backup).\n */\n storage: Record<string, string>;\n};\n\n/**\n * Migrates an existing Fireblocks NCW wallet into Dynamic's WaaS infrastructure.\n *\n * Migration is a single cross-chain operation: one call takes over the Fireblocks\n * key material and provisions Dynamic WaaS wallet accounts for every supported\n * chain. Because it is not per-chain, this resolves a single WaaS wallet provider\n * (any registered chain) and delegates the takeover to it.\n *\n * @param params.deviceId - The Fireblocks NCW device id being migrated.\n * @param params.jwt - The Fireblocks-issued JWT authorizing the takeover.\n * @param params.storage - The serialized Fireblocks NCW device storage.\n * @param params.password - The password that encrypted the legacy device storage.\n * @param params.expectedAddresses - Required per-chain expected address; its keys are the chains migration runs on, and each imported address is verified against it.\n * @param [params.coinTypes] - Optional SLIP-0044 coin types per chain name.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise resolving to the per-chain migration results.\n * @notInstrumented\n */\nexport const migrateFromFireblocks = async (\n {\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n }: MigrateFromFireblocksParams,\n client = getDefaultClient()\n): Promise<MigrateFromFireblocksResponse> => {\n const providers = getWalletProviders(client);\n\n if (providers.length === 0) {\n throw new NoWalletProviderFoundError({\n walletProviderKey: DYNAMIC_WAAS_METADATA.displayName,\n });\n }\n\n // Migration is cross-chain, so any registered WaaS provider can drive the\n // takeover. Resolve the first one rather than iterating per chain.\n const waasProvider = providers.find(isWaasWalletProvider);\n\n if (!waasProvider) {\n throw new NotWaasWalletProviderError({\n walletProviderKey: providers[0].key,\n });\n }\n\n const result = await waasProvider.migrateFromFireblocks({\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n });\n\n await refreshAuth(client);\n\n return result;\n};\n"],"mappings":";;;;AAMA,IAAa,6BAAb,cAAgD,UAAU;CACxD,YAAY,EAAE,qBAAuD;AACnE,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,mBAAmB,kBAAkB;GACpD,CAAC;;;;;;;ACFN,MAAa,0CACX,EAAE,iBACF,WACuB;CACvB,MAAM,iBAAiB,mCACrB,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAAC,qBAAqB,eAAe,CACvC,OAAM,IAAI,0BAA0B,EAClC,eAAe,cAAc,SAC9B,CAAC;AAGJ,QAAO;;;;;;;;;;;;;;;;;;;;;;;ACgCT,MAAa,wBAAwB,OACnC,EACE,WACA,UACA,mBACA,KACA,UACA,WAEF,SAAS,kBAAkB,KACgB;CAC3C,MAAM,YAAY,mBAAmB,OAAO;AAE5C,KAAI,UAAU,WAAW,EACvB,OAAM,IAAI,2BAA2B,EACnC,mBAAmB,sBAAsB,aAC1C,CAAC;CAKJ,MAAM,eAAe,UAAU,KAAK,qBAAqB;AAEzD,KAAI,CAAC,aACH,OAAM,IAAI,2BAA2B,EACnC,mBAAmB,UAAU,GAAG,KACjC,CAAC;CAGJ,MAAM,SAAS,MAAM,aAAa,sBAAsB;EACtD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,OAAMA,sBAAY,OAAO;AAEzB,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateFromFireblocks-Do4mQTl7.native.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/migrateFromFireblocks/migrateFromFireblocks.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NotWaasWalletProviderErrorParams = {\n walletProviderKey: string;\n};\n\nexport class NotWaasWalletProviderError extends BaseError {\n constructor({ walletProviderKey }: NotWaasWalletProviderErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_provider_error',\n docsUrl: null,\n name: 'NotWaasWalletProviderError',\n shortMessage: `Wallet provider ${walletProviderKey} is not a Dynamic WaaS wallet provider`,\n });\n }\n}\n","import type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { NotWaasWalletAccountError } from '../../../errors/NotWaasWalletAccountError';\nimport { getWalletProviderFromWalletAccount } from '../../wallets/utils/getWalletProviderFromWalletAccount';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport type { WaasWalletProvider } from '../waas.types';\n\ntype GetWalletProviderFromWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const getWaasWalletProviderFromWalletAccount = (\n { walletAccount }: GetWalletProviderFromWalletAccountParams,\n client: DynamicClient\n): WaasWalletProvider => {\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isWaasWalletProvider(walletProvider)) {\n throw new NotWaasWalletAccountError({\n walletAddress: walletAccount.address,\n });\n }\n\n return walletProvider;\n};\n","import type { MigrateFromFireblocksResponse } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { NotWaasWalletProviderError } from '../../../errors/NotWaasWalletProviderError';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport { getWalletProviders } from '../../wallets/getWalletProviders';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\n\ntype MigrateFromFireblocksParams = {\n /**\n * Optional SLIP-0044 coin types per chain name for BIP44 derivation off the\n * Fireblocks takeover xprv (e.g. `{ EVM: 1 }` for Sepolia).\n */\n coinTypes?: Record<string, number>;\n /**\n * The Fireblocks NCW device id whose key material is being migrated.\n */\n deviceId: string;\n /**\n * Required per-chain expected wallet address (the address Fireblocks held). Its\n * keys are the chains migration runs on, and the migration iframe verifies each\n * imported Dynamic address matches the value, so a wrong derivation fails loudly\n * instead of producing an unusable wallet.\n */\n expectedAddresses: Record<string, string>;\n /**\n * The Fireblocks-issued JWT authorizing the takeover.\n */\n jwt: string;\n /**\n * The password that encrypted the legacy Fireblocks NCW device storage.\n */\n password: string;\n /**\n * The serialized Fireblocks NCW device storage (the local key share backup).\n */\n storage: Record<string, string>;\n};\n\n/**\n * Migrates an existing Fireblocks NCW wallet into Dynamic's WaaS infrastructure.\n *\n * Migration is a single cross-chain operation: one call takes over the Fireblocks\n * key material and provisions Dynamic WaaS wallet accounts for every supported\n * chain. Because it is not per-chain, this resolves a single WaaS wallet provider\n * (any registered chain) and delegates the takeover to it.\n *\n * @param params.deviceId - The Fireblocks NCW device id being migrated.\n * @param params.jwt - The Fireblocks-issued JWT authorizing the takeover.\n * @param params.storage - The serialized Fireblocks NCW device storage.\n * @param params.password - The password that encrypted the legacy device storage.\n * @param params.expectedAddresses - Required per-chain expected address; its keys are the chains migration runs on, and each imported address is verified against it.\n * @param [params.coinTypes] - Optional SLIP-0044 coin types per chain name.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise resolving to the per-chain migration results.\n * @notInstrumented\n */\nexport const migrateFromFireblocks = async (\n {\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n }: MigrateFromFireblocksParams,\n client = getDefaultClient()\n): Promise<MigrateFromFireblocksResponse> => {\n const providers = getWalletProviders(client);\n\n if (providers.length === 0) {\n throw new NoWalletProviderFoundError({\n walletProviderKey: DYNAMIC_WAAS_METADATA.displayName,\n });\n }\n\n // Migration is cross-chain, so any registered WaaS provider can drive the\n // takeover. Resolve the first one rather than iterating per chain.\n const waasProvider = providers.find(isWaasWalletProvider);\n\n if (!waasProvider) {\n throw new NotWaasWalletProviderError({\n walletProviderKey: providers[0].key,\n });\n }\n\n const result = await waasProvider.migrateFromFireblocks({\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n });\n\n await refreshAuth(client);\n\n return result;\n};\n"],"mappings":";;;;AAMA,IAAa,6BAAb,cAAgD,UAAU;CACxD,YAAY,EAAE,qBAAuD;AACnE,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,mBAAmB,kBAAkB;GACpD,CAAC;;;;;;;ACFN,MAAa,0CACX,EAAE,iBACF,WACuB;CACvB,MAAM,iBAAiB,mCACrB,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAAC,qBAAqB,eAAe,CACvC,OAAM,IAAI,0BAA0B,EAClC,eAAe,cAAc,SAC9B,CAAC;AAGJ,QAAO;;;;;;;;;;;;;;;;;;;;;;;ACgCT,MAAa,wBAAwB,OACnC,EACE,WACA,UACA,mBACA,KACA,UACA,WAEF,SAAS,kBAAkB,KACgB;CAC3C,MAAM,YAAY,mBAAmB,OAAO;AAE5C,KAAI,UAAU,WAAW,EACvB,OAAM,IAAI,2BAA2B,EACnC,mBAAmB,sBAAsB,aAC1C,CAAC;CAKJ,MAAM,eAAe,UAAU,KAAK,qBAAqB;AAEzD,KAAI,CAAC,aACH,OAAM,IAAI,2BAA2B,EACnC,mBAAmB,UAAU,GAAG,KACjC,CAAC;CAGJ,MAAM,SAAS,MAAM,aAAa,sBAAsB;EACtD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,OAAMA,sBAAY,OAAO;AAEzB,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrateFromFireblocks-DrHwloUB.cjs","names":["BaseError","getWalletProviderFromWalletAccount","isWaasWalletProvider","NotWaasWalletAccountError","getDefaultClient","getWalletProviders","NoWalletProviderFoundError","DYNAMIC_WAAS_METADATA","isWaasWalletProvider","refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/migrateFromFireblocks/migrateFromFireblocks.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NotWaasWalletProviderErrorParams = {\n walletProviderKey: string;\n};\n\nexport class NotWaasWalletProviderError extends BaseError {\n constructor({ walletProviderKey }: NotWaasWalletProviderErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_provider_error',\n docsUrl: null,\n name: 'NotWaasWalletProviderError',\n shortMessage: `Wallet provider ${walletProviderKey} is not a Dynamic WaaS wallet provider`,\n });\n }\n}\n","import type { DynamicClient } from '../../../client/types/DynamicClient';\nimport { NotWaasWalletAccountError } from '../../../errors/NotWaasWalletAccountError';\nimport { getWalletProviderFromWalletAccount } from '../../wallets/utils/getWalletProviderFromWalletAccount';\nimport type { WalletAccount } from '../../wallets/walletAccount';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\nimport type { WaasWalletProvider } from '../waas.types';\n\ntype GetWalletProviderFromWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const getWaasWalletProviderFromWalletAccount = (\n { walletAccount }: GetWalletProviderFromWalletAccountParams,\n client: DynamicClient\n): WaasWalletProvider => {\n const walletProvider = getWalletProviderFromWalletAccount(\n { walletAccount },\n client\n );\n\n if (!isWaasWalletProvider(walletProvider)) {\n throw new NotWaasWalletAccountError({\n walletAddress: walletAccount.address,\n });\n }\n\n return walletProvider;\n};\n","import type { MigrateFromFireblocksResponse } from '@dynamic-labs-wallet/browser-wallet-client';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { NotWaasWalletProviderError } from '../../../errors/NotWaasWalletProviderError';\nimport { refreshAuth } from '../../user/refreshAuth';\nimport { getWalletProviders } from '../../wallets/getWalletProviders';\nimport { DYNAMIC_WAAS_METADATA } from '../constants';\nimport { isWaasWalletProvider } from '../isWaasWalletProvider';\n\ntype MigrateFromFireblocksParams = {\n /**\n * Optional SLIP-0044 coin types per chain name for BIP44 derivation off the\n * Fireblocks takeover xprv (e.g. `{ EVM: 1 }` for Sepolia).\n */\n coinTypes?: Record<string, number>;\n /**\n * The Fireblocks NCW device id whose key material is being migrated.\n */\n deviceId: string;\n /**\n * Required per-chain expected wallet address (the address Fireblocks held). Its\n * keys are the chains migration runs on, and the migration iframe verifies each\n * imported Dynamic address matches the value, so a wrong derivation fails loudly\n * instead of producing an unusable wallet.\n */\n expectedAddresses: Record<string, string>;\n /**\n * The Fireblocks-issued JWT authorizing the takeover.\n */\n jwt: string;\n /**\n * The password that encrypted the legacy Fireblocks NCW device storage.\n */\n password: string;\n /**\n * The serialized Fireblocks NCW device storage (the local key share backup).\n */\n storage: Record<string, string>;\n};\n\n/**\n * Migrates an existing Fireblocks NCW wallet into Dynamic's WaaS infrastructure.\n *\n * Migration is a single cross-chain operation: one call takes over the Fireblocks\n * key material and provisions Dynamic WaaS wallet accounts for every supported\n * chain. Because it is not per-chain, this resolves a single WaaS wallet provider\n * (any registered chain) and delegates the takeover to it.\n *\n * @param params.deviceId - The Fireblocks NCW device id being migrated.\n * @param params.jwt - The Fireblocks-issued JWT authorizing the takeover.\n * @param params.storage - The serialized Fireblocks NCW device storage.\n * @param params.password - The password that encrypted the legacy device storage.\n * @param params.expectedAddresses - Required per-chain expected address; its keys are the chains migration runs on, and each imported address is verified against it.\n * @param [params.coinTypes] - Optional SLIP-0044 coin types per chain name.\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise resolving to the per-chain migration results.\n * @notInstrumented\n */\nexport const migrateFromFireblocks = async (\n {\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n }: MigrateFromFireblocksParams,\n client = getDefaultClient()\n): Promise<MigrateFromFireblocksResponse> => {\n const providers = getWalletProviders(client);\n\n if (providers.length === 0) {\n throw new NoWalletProviderFoundError({\n walletProviderKey: DYNAMIC_WAAS_METADATA.displayName,\n });\n }\n\n // Migration is cross-chain, so any registered WaaS provider can drive the\n // takeover. Resolve the first one rather than iterating per chain.\n const waasProvider = providers.find(isWaasWalletProvider);\n\n if (!waasProvider) {\n throw new NotWaasWalletProviderError({\n walletProviderKey: providers[0].key,\n });\n }\n\n const result = await waasProvider.migrateFromFireblocks({\n coinTypes,\n deviceId,\n expectedAddresses,\n jwt,\n password,\n storage,\n });\n\n await refreshAuth(client);\n\n return result;\n};\n"],"mappings":";;;;AAMA,IAAa,6BAAb,cAAgDA,+CAAU;CACxD,YAAY,EAAE,qBAAuD;AACnE,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,mBAAmB,kBAAkB;GACpD,CAAC;;;;;;;ACFN,MAAa,0CACX,EAAE,iBACF,WACuB;CACvB,MAAM,iBAAiBC,wEACrB,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAACC,0DAAqB,eAAe,CACvC,OAAM,IAAIC,uDAA0B,EAClC,eAAe,cAAc,SAC9B,CAAC;AAGJ,QAAO;;;;;;;;;;;;;;;;;;;;;;;ACgCT,MAAa,wBAAwB,OACnC,EACE,WACA,UACA,mBACA,KACA,UACA,WAEF,SAASC,uDAAkB,KACgB;CAC3C,MAAM,YAAYC,wDAAmB,OAAO;AAE5C,KAAI,UAAU,WAAW,EACvB,OAAM,IAAIC,gEAA2B,EACnC,mBAAmBC,2DAAsB,aAC1C,CAAC;CAKJ,MAAM,eAAe,UAAU,KAAKC,0DAAqB;AAEzD,KAAI,CAAC,aACH,OAAM,IAAI,2BAA2B,EACnC,mBAAmB,UAAU,GAAG,KACjC,CAAC;CAGJ,MAAM,SAAS,MAAM,aAAa,sBAAsB;EACtD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,OAAMC,mDAAY,OAAO;AAEzB,QAAO"}