@dynamic-labs-sdk/client 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/core.cjs +53 -53
  2. package/dist/core.cjs.map +1 -1
  3. package/dist/core.esm.js +7 -7
  4. package/dist/core.esm.js.map +1 -1
  5. package/dist/core.native.esm.js +5 -5
  6. package/dist/exports/waas.d.ts +2 -1
  7. package/dist/exports/waas.d.ts.map +1 -1
  8. package/dist/exports/waasCore.d.ts +3 -2
  9. package/dist/exports/waasCore.d.ts.map +1 -1
  10. package/dist/{getNetworkProviderFromNetworkId-CregkqLB.esm.js → getNetworkProviderFromNetworkId-BVVs3arj.esm.js} +6 -7
  11. package/dist/getNetworkProviderFromNetworkId-BVVs3arj.esm.js.map +1 -0
  12. package/dist/{getNetworkProviderFromNetworkId-BURAkmc3.native.esm.js → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js} +3 -4
  13. package/dist/{getNetworkProviderFromNetworkId-BURAkmc3.native.esm.js.map → getNetworkProviderFromNetworkId-DC1bhMuB.native.esm.js.map} +1 -1
  14. package/dist/{getNetworkProviderFromNetworkId-BpvoqbEH.cjs → getNetworkProviderFromNetworkId-DzzocxRc.cjs} +43 -44
  15. package/dist/{getNetworkProviderFromNetworkId-BpvoqbEH.cjs.map → getNetworkProviderFromNetworkId-DzzocxRc.cjs.map} +1 -1
  16. package/dist/{getSignedSessionId-Czpvp58E.esm.js → getSignedSessionId-Bnuz2Aqc.esm.js} +3 -3
  17. package/dist/{getSignedSessionId-Czpvp58E.esm.js.map → getSignedSessionId-Bnuz2Aqc.esm.js.map} +1 -1
  18. package/dist/{getSignedSessionId-C98wdvMw.cjs → getSignedSessionId-Dx0qQLMP.cjs} +11 -11
  19. package/dist/{getSignedSessionId-C98wdvMw.cjs.map → getSignedSessionId-Dx0qQLMP.cjs.map} +1 -1
  20. package/dist/{getSignedSessionId-upC71vLP.native.esm.js → getSignedSessionId-Pc_5wscD.native.esm.js} +3 -3
  21. package/dist/{getSignedSessionId-upC71vLP.native.esm.js.map → getSignedSessionId-Pc_5wscD.native.esm.js.map} +1 -1
  22. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js +20 -0
  23. package/dist/getWalletProviderByKey-BL3u0e-d.esm.js.map +1 -0
  24. package/dist/getWalletProviderByKey-BLWcueTR.cjs +31 -0
  25. package/dist/getWalletProviderByKey-BLWcueTR.cjs.map +1 -0
  26. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js +20 -0
  27. package/dist/getWalletProviderByKey-DhqKzh7g.native.esm.js.map +1 -0
  28. package/dist/index.cjs +539 -540
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.esm.js +9 -10
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/index.native.esm.js +6 -7
  33. package/dist/index.native.esm.js.map +1 -1
  34. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs +88 -0
  35. package/dist/isDynamicWaasEnabled-BEn7FcD9.cjs.map +1 -0
  36. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js +70 -0
  37. package/dist/isDynamicWaasEnabled-CvBaMGlR.native.esm.js.map +1 -0
  38. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js +70 -0
  39. package/dist/isDynamicWaasEnabled-DYy0TvLy.esm.js.map +1 -0
  40. package/dist/{isMfaRequiredForAction-CgVdSGRA.esm.js → isMfaRequiredForAction-B7wNkqQf.esm.js} +2 -2
  41. package/dist/{isMfaRequiredForAction-CgVdSGRA.esm.js.map → isMfaRequiredForAction-B7wNkqQf.esm.js.map} +1 -1
  42. package/dist/{isMfaRequiredForAction-juTvf3Pl.native.esm.js → isMfaRequiredForAction-CJ9qbBUz.native.esm.js} +2 -2
  43. package/dist/{isMfaRequiredForAction-juTvf3Pl.native.esm.js.map → isMfaRequiredForAction-CJ9qbBUz.native.esm.js.map} +1 -1
  44. package/dist/{isMfaRequiredForAction-DECknr5q.cjs → isMfaRequiredForAction-CaNdGc-m.cjs} +29 -29
  45. package/dist/{isMfaRequiredForAction-DECknr5q.cjs.map → isMfaRequiredForAction-CaNdGc-m.cjs.map} +1 -1
  46. package/dist/{isUserOnboardingComplete-DFrrp61b.esm.js → isUserOnboardingComplete-CGz-9Iyw.esm.js} +3 -3
  47. package/dist/{isUserOnboardingComplete-DFrrp61b.esm.js.map → isUserOnboardingComplete-CGz-9Iyw.esm.js.map} +1 -1
  48. package/dist/{isUserOnboardingComplete-Dtr1_Mi4.native.esm.js → isUserOnboardingComplete-FRAIuxdi.native.esm.js} +3 -3
  49. package/dist/{isUserOnboardingComplete-Dtr1_Mi4.native.esm.js.map → isUserOnboardingComplete-FRAIuxdi.native.esm.js.map} +1 -1
  50. package/dist/{isUserOnboardingComplete-DvCQh8Dj.cjs → isUserOnboardingComplete-w1IkCC_p.cjs} +13 -13
  51. package/dist/{isUserOnboardingComplete-DvCQh8Dj.cjs.map → isUserOnboardingComplete-w1IkCC_p.cjs.map} +1 -1
  52. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js +65 -0
  53. package/dist/migrateFromFireblocks-C-IqJz3q.native.esm.js.map +1 -0
  54. package/dist/migrateFromFireblocks-CjQWJPZW.cjs +82 -0
  55. package/dist/migrateFromFireblocks-CjQWJPZW.cjs.map +1 -0
  56. package/dist/migrateFromFireblocks-DXs3odF_.esm.js +65 -0
  57. package/dist/migrateFromFireblocks-DXs3odF_.esm.js.map +1 -0
  58. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  59. package/dist/modules/waas/migrateFromFireblocks/index.d.ts +2 -0
  60. package/dist/modules/waas/migrateFromFireblocks/index.d.ts.map +1 -0
  61. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts +52 -0
  62. package/dist/modules/waas/migrateFromFireblocks/migrateFromFireblocks.d.ts.map +1 -0
  63. package/dist/modules/waas/waas.types.d.ts +9 -1
  64. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  65. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  66. package/dist/{InvalidParamError-Dn_riAvL.esm.js → updateAuthFromVerifyResponse-BdokPJ21.esm.js} +237 -3
  67. package/dist/updateAuthFromVerifyResponse-BdokPJ21.esm.js.map +1 -0
  68. package/dist/{InvalidParamError-DHriGGNI.cjs → updateAuthFromVerifyResponse-CUnvs5Af.cjs} +291 -9
  69. package/dist/updateAuthFromVerifyResponse-CUnvs5Af.cjs.map +1 -0
  70. package/dist/{InvalidParamError-DYezznCD.native.esm.js → updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js} +457 -4
  71. package/dist/updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js.map +1 -0
  72. package/dist/waas.cjs +53 -67
  73. package/dist/waas.cjs.map +1 -1
  74. package/dist/waas.esm.js +5 -20
  75. package/dist/waas.esm.js.map +1 -1
  76. package/dist/waas.native.esm.js +5 -20
  77. package/dist/waas.native.esm.js.map +1 -1
  78. package/dist/waasCore.cjs +40 -23
  79. package/dist/waasCore.cjs.map +1 -1
  80. package/dist/waasCore.esm.js +23 -7
  81. package/dist/waasCore.esm.js.map +1 -1
  82. package/dist/waasCore.native.esm.js +23 -7
  83. package/dist/waasCore.native.esm.js.map +1 -1
  84. package/package.json +2 -2
  85. package/dist/InvalidParamError-DHriGGNI.cjs.map +0 -1
  86. package/dist/InvalidParamError-DYezznCD.native.esm.js.map +0 -1
  87. package/dist/InvalidParamError-Dn_riAvL.esm.js.map +0 -1
  88. package/dist/getNetworkProviderFromNetworkId-CregkqLB.esm.js.map +0 -1
  89. package/dist/getWaasWalletProviderFromWalletAccount-BrskhuL8.cjs +0 -19
  90. package/dist/getWaasWalletProviderFromWalletAccount-BrskhuL8.cjs.map +0 -1
  91. package/dist/getWaasWalletProviderFromWalletAccount-DHKga3uH.native.esm.js +0 -14
  92. package/dist/getWaasWalletProviderFromWalletAccount-DHKga3uH.native.esm.js.map +0 -1
  93. package/dist/getWaasWalletProviderFromWalletAccount-Dc6QvHVt.esm.js +0 -14
  94. package/dist/getWaasWalletProviderFromWalletAccount-Dc6QvHVt.esm.js.map +0 -1
  95. package/dist/getWalletProviderByKey-DDNCUbUe.cjs +0 -321
  96. package/dist/getWalletProviderByKey-DDNCUbUe.cjs.map +0 -1
  97. package/dist/getWalletProviderByKey-DTi6MhKt.esm.js +0 -255
  98. package/dist/getWalletProviderByKey-DTi6MhKt.esm.js.map +0 -1
  99. package/dist/getWalletProviderByKey-OYhHm11_.native.esm.js +0 -474
  100. package/dist/getWalletProviderByKey-OYhHm11_.native.esm.js.map +0 -1
  101. package/dist/isDynamicWaasEnabled-Bj3v8LZ_.cjs +0 -49
  102. package/dist/isDynamicWaasEnabled-Bj3v8LZ_.cjs.map +0 -1
  103. package/dist/isDynamicWaasEnabled-CuSe2RO1.esm.js +0 -37
  104. package/dist/isDynamicWaasEnabled-CuSe2RO1.esm.js.map +0 -1
  105. package/dist/isDynamicWaasEnabled-CvD8_c7H.native.esm.js +0 -37
  106. package/dist/isDynamicWaasEnabled-CvD8_c7H.native.esm.js.map +0 -1
  107. package/dist/refreshAuth-CKHkaRJo.native.esm.js +0 -38
  108. package/dist/refreshAuth-CKHkaRJo.native.esm.js.map +0 -1
  109. package/dist/refreshAuth-Q5fxSi3Z.esm.js +0 -38
  110. package/dist/refreshAuth-Q5fxSi3Z.esm.js.map +0 -1
  111. package/dist/refreshAuth-oycoOXtD.cjs +0 -43
  112. package/dist/refreshAuth-oycoOXtD.cjs.map +0 -1
@@ -0,0 +1,88 @@
1
+ const require_isMfaRequiredForAction = require('./isMfaRequiredForAction-CaNdGc-m.cjs');
2
+ const require_updateAuthFromVerifyResponse = require('./updateAuthFromVerifyResponse-CUnvs5Af.cjs');
3
+ let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
4
+
5
+ //#region src/modules/user/refreshAuth/refreshAuth.ts
6
+ /**
7
+ * Refreshes the current user's data from the server.
8
+ *
9
+ * This function fetches the latest user information and token from the backend
10
+ * updating the local user and token states with any changes.
11
+ *
12
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
13
+ * @returns A promise that resolves to the verify response.
14
+ * @instrumented
15
+ * @redact-params
16
+ */
17
+ const refreshAuth = async (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
18
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
19
+ const response = await require_updateAuthFromVerifyResponse.createApiClient({}, client).refreshAuth({ environmentId: core.environmentId });
20
+ require_updateAuthFromVerifyResponse.updateAuthFromVerifyResponse({ response }, client);
21
+ return response;
22
+ };
23
+ const __refreshAuth_impl = refreshAuth;
24
+ const __refreshAuth_wrapped = require_updateAuthFromVerifyResponse.instrumentFunction({
25
+ fn: __refreshAuth_impl,
26
+ functionName: "refreshAuth",
27
+ getCore: () => {
28
+ try {
29
+ return require_updateAuthFromVerifyResponse.getCore(require_updateAuthFromVerifyResponse.getDefaultClient());
30
+ } catch {
31
+ return;
32
+ }
33
+ },
34
+ redactAll: true
35
+ });
36
+
37
+ //#endregion
38
+ //#region src/errors/NotWaasWalletAccountError.ts
39
+ var NotWaasWalletAccountError = class extends require_updateAuthFromVerifyResponse.BaseError {
40
+ constructor({ walletAddress }) {
41
+ super({
42
+ cause: null,
43
+ code: "not_waas_wallet_account_error",
44
+ docsUrl: null,
45
+ name: "NotWaasWalletAccountError",
46
+ shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`
47
+ });
48
+ }
49
+ };
50
+
51
+ //#endregion
52
+ //#region src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts
53
+ /**
54
+ * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.
55
+ *
56
+ * This function examines the project settings to determine if Dynamic WaaS is
57
+ * enabled in the Dynamic Dashboard or not.
58
+ *
59
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
60
+ * @returns True if Dynamic WaaS is enabled, false otherwise.
61
+ * @notInstrumented
62
+ */
63
+ const isDynamicWaasEnabled = (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
64
+ const projectSettings = client.projectSettings;
65
+ require_updateAuthFromVerifyResponse.assertDefined(projectSettings, "Project settings are not available");
66
+ return projectSettings.sdk.embeddedWallets?.defaultWalletVersion === _dynamic_labs_sdk_api_core.EmbeddedWalletVersionEnum.V3;
67
+ };
68
+
69
+ //#endregion
70
+ Object.defineProperty(exports, 'NotWaasWalletAccountError', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return NotWaasWalletAccountError;
74
+ }
75
+ });
76
+ Object.defineProperty(exports, '__refreshAuth_wrapped', {
77
+ enumerable: true,
78
+ get: function () {
79
+ return __refreshAuth_wrapped;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, 'isDynamicWaasEnabled', {
83
+ enumerable: true,
84
+ get: function () {
85
+ return isDynamicWaasEnabled;
86
+ }
87
+ });
88
+ //# sourceMappingURL=isDynamicWaasEnabled-BEn7FcD9.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDynamicWaasEnabled-BEn7FcD9.cjs","names":["BaseError","getDefaultClient","EmbeddedWalletVersionEnum"],"sources":["../src/modules/user/refreshAuth/refreshAuth.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts"],"sourcesContent":["import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport { updateAuthFromVerifyResponse } from '../../auth/updateAuthFromVerifyResponse';\n\n/**\n * Refreshes the current user's data from the server.\n *\n * This function fetches the latest user information and token from the backend\n * updating the local user and token states with any changes.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the verify response.\n * @instrumented\n * @redact-params\n */\nexport const refreshAuth = async (\n client = getDefaultClient()\n): Promise<VerifyResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const response = await apiClient.refreshAuth({\n environmentId: core.environmentId,\n });\n\n updateAuthFromVerifyResponse({ response }, client);\n\n return response;\n};\n","import { BaseError } from './base';\n\ntype NotWaasWalletAccountErrorParams = {\n walletAddress: string;\n};\n\nexport class NotWaasWalletAccountError extends BaseError {\n constructor({ walletAddress }: NotWaasWalletAccountErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_account_error',\n docsUrl: null,\n name: 'NotWaasWalletAccountError',\n shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`,\n });\n }\n}\n","import { EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.\n *\n * This function examines the project settings to determine if Dynamic WaaS is\n * enabled in the Dynamic Dashboard or not.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if Dynamic WaaS is enabled, false otherwise.\n * @notInstrumented\n */\nexport const isDynamicWaasEnabled = (client = getDefaultClient()) => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;\n\n const dynamicWaasIsEnabled =\n embeddedWalletSettings?.defaultWalletVersion ===\n EmbeddedWalletVersionEnum.V3;\n\n return dynamicWaasIsEnabled;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAE,cAAa,OACb,SAAM,uDAAY;CAElB,MAAM,OAAA,6CAAW,OAAM;wBACN,qDAAK,EAAa,EAAA,OAAA,eAGnC,eAAA,KAAA;AAGD,mEAAA,EAAA,UAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;ACzBD,IAAa,4BAAb,cAA+CA,+CAAU;CACvD,YAAY,EAAE,iBAAkD;AAC9D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,kBAAkB,cAAc;GAC/C,CAAC;;;;;;;;;;;;;;;;ACCN,MAAa,wBAAwB,SAASC,uDAAkB,KAAK;CACnE,MAAM,kBAAkB,OAAO;AAE/B,oDAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxBC,qDAA0B"}
@@ -0,0 +1,70 @@
1
+ import { K as createApiClient, _t as getCore, gt as BaseError, ot as assertDefined, pt as getDefaultClient, t as updateAuthFromVerifyResponse, v as instrumentFunction } from "./updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js";
2
+ import { EmbeddedWalletVersionEnum } from "@dynamic-labs/sdk-api-core";
3
+
4
+ //#region src/modules/user/refreshAuth/refreshAuth.ts
5
+ /**
6
+ * Refreshes the current user's data from the server.
7
+ *
8
+ * This function fetches the latest user information and token from the backend
9
+ * updating the local user and token states with any changes.
10
+ *
11
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
12
+ * @returns A promise that resolves to the verify response.
13
+ * @instrumented
14
+ * @redact-params
15
+ */
16
+ const refreshAuth = async (client = getDefaultClient()) => {
17
+ const core = getCore(client);
18
+ const response = await createApiClient({}, client).refreshAuth({ environmentId: core.environmentId });
19
+ updateAuthFromVerifyResponse({ response }, client);
20
+ return response;
21
+ };
22
+ const __refreshAuth_impl = refreshAuth;
23
+ const __refreshAuth_wrapped = instrumentFunction({
24
+ fn: __refreshAuth_impl,
25
+ functionName: "refreshAuth",
26
+ getCore: () => {
27
+ try {
28
+ return getCore(getDefaultClient());
29
+ } catch {
30
+ return;
31
+ }
32
+ },
33
+ redactAll: true
34
+ });
35
+
36
+ //#endregion
37
+ //#region src/errors/NotWaasWalletAccountError.ts
38
+ var NotWaasWalletAccountError = class extends BaseError {
39
+ constructor({ walletAddress }) {
40
+ super({
41
+ cause: null,
42
+ code: "not_waas_wallet_account_error",
43
+ docsUrl: null,
44
+ name: "NotWaasWalletAccountError",
45
+ shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`
46
+ });
47
+ }
48
+ };
49
+
50
+ //#endregion
51
+ //#region src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts
52
+ /**
53
+ * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.
54
+ *
55
+ * This function examines the project settings to determine if Dynamic WaaS is
56
+ * enabled in the Dynamic Dashboard or not.
57
+ *
58
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
59
+ * @returns True if Dynamic WaaS is enabled, false otherwise.
60
+ * @notInstrumented
61
+ */
62
+ const isDynamicWaasEnabled = (client = getDefaultClient()) => {
63
+ const projectSettings = client.projectSettings;
64
+ assertDefined(projectSettings, "Project settings are not available");
65
+ return projectSettings.sdk.embeddedWallets?.defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
66
+ };
67
+
68
+ //#endregion
69
+ export { NotWaasWalletAccountError as n, __refreshAuth_wrapped as r, isDynamicWaasEnabled as t };
70
+ //# sourceMappingURL=isDynamicWaasEnabled-CvBaMGlR.native.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDynamicWaasEnabled-CvBaMGlR.native.esm.js","names":[],"sources":["../src/modules/user/refreshAuth/refreshAuth.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts"],"sourcesContent":["import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport { updateAuthFromVerifyResponse } from '../../auth/updateAuthFromVerifyResponse';\n\n/**\n * Refreshes the current user's data from the server.\n *\n * This function fetches the latest user information and token from the backend\n * updating the local user and token states with any changes.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the verify response.\n * @instrumented\n * @redact-params\n */\nexport const refreshAuth = async (\n client = getDefaultClient()\n): Promise<VerifyResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const response = await apiClient.refreshAuth({\n environmentId: core.environmentId,\n });\n\n updateAuthFromVerifyResponse({ response }, client);\n\n return response;\n};\n","import { BaseError } from './base';\n\ntype NotWaasWalletAccountErrorParams = {\n walletAddress: string;\n};\n\nexport class NotWaasWalletAccountError extends BaseError {\n constructor({ walletAddress }: NotWaasWalletAccountErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_account_error',\n docsUrl: null,\n name: 'NotWaasWalletAccountError',\n shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`,\n });\n }\n}\n","import { EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.\n *\n * This function examines the project settings to determine if Dynamic WaaS is\n * enabled in the Dynamic Dashboard or not.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if Dynamic WaaS is enabled, false otherwise.\n * @notInstrumented\n */\nexport const isDynamicWaasEnabled = (client = getDefaultClient()) => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;\n\n const dynamicWaasIsEnabled =\n embeddedWalletSettings?.defaultWalletVersion ===\n EmbeddedWalletVersionEnum.V3;\n\n return dynamicWaasIsEnabled;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAE,cAAa,OACb,SAAM,kBAAY;CAElB,MAAM,OAAA,QAAW,OAAM;wBACN,gBAAK,EAAa,EAAA,OAAA,eAGnC,eAAA,KAAA;AAGD,8BAAA,EAAA,UAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;ACzBD,IAAa,4BAAb,cAA+C,UAAU;CACvD,YAAY,EAAE,iBAAkD;AAC9D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,kBAAkB,cAAc;GAC/C,CAAC;;;;;;;;;;;;;;;;ACCN,MAAa,wBAAwB,SAAS,kBAAkB,KAAK;CACnE,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxB,0BAA0B"}
@@ -0,0 +1,70 @@
1
+ import { K as createApiClient, _t as getCore, gt as BaseError, ot as assertDefined, pt as getDefaultClient, t as updateAuthFromVerifyResponse, v as instrumentFunction } from "./updateAuthFromVerifyResponse-BdokPJ21.esm.js";
2
+ import { EmbeddedWalletVersionEnum } from "@dynamic-labs/sdk-api-core";
3
+
4
+ //#region src/modules/user/refreshAuth/refreshAuth.ts
5
+ /**
6
+ * Refreshes the current user's data from the server.
7
+ *
8
+ * This function fetches the latest user information and token from the backend
9
+ * updating the local user and token states with any changes.
10
+ *
11
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
12
+ * @returns A promise that resolves to the verify response.
13
+ * @instrumented
14
+ * @redact-params
15
+ */
16
+ const refreshAuth = async (client = getDefaultClient()) => {
17
+ const core = getCore(client);
18
+ const response = await createApiClient({}, client).refreshAuth({ environmentId: core.environmentId });
19
+ updateAuthFromVerifyResponse({ response }, client);
20
+ return response;
21
+ };
22
+ const __refreshAuth_impl = refreshAuth;
23
+ const __refreshAuth_wrapped = instrumentFunction({
24
+ fn: __refreshAuth_impl,
25
+ functionName: "refreshAuth",
26
+ getCore: () => {
27
+ try {
28
+ return getCore(getDefaultClient());
29
+ } catch {
30
+ return;
31
+ }
32
+ },
33
+ redactAll: true
34
+ });
35
+
36
+ //#endregion
37
+ //#region src/errors/NotWaasWalletAccountError.ts
38
+ var NotWaasWalletAccountError = class extends BaseError {
39
+ constructor({ walletAddress }) {
40
+ super({
41
+ cause: null,
42
+ code: "not_waas_wallet_account_error",
43
+ docsUrl: null,
44
+ name: "NotWaasWalletAccountError",
45
+ shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`
46
+ });
47
+ }
48
+ };
49
+
50
+ //#endregion
51
+ //#region src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts
52
+ /**
53
+ * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.
54
+ *
55
+ * This function examines the project settings to determine if Dynamic WaaS is
56
+ * enabled in the Dynamic Dashboard or not.
57
+ *
58
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
59
+ * @returns True if Dynamic WaaS is enabled, false otherwise.
60
+ * @notInstrumented
61
+ */
62
+ const isDynamicWaasEnabled = (client = getDefaultClient()) => {
63
+ const projectSettings = client.projectSettings;
64
+ assertDefined(projectSettings, "Project settings are not available");
65
+ return projectSettings.sdk.embeddedWallets?.defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
66
+ };
67
+
68
+ //#endregion
69
+ export { NotWaasWalletAccountError as n, __refreshAuth_wrapped as r, isDynamicWaasEnabled as t };
70
+ //# sourceMappingURL=isDynamicWaasEnabled-DYy0TvLy.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDynamicWaasEnabled-DYy0TvLy.esm.js","names":[],"sources":["../src/modules/user/refreshAuth/refreshAuth.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.ts"],"sourcesContent":["import type { VerifyResponse } from '@dynamic-labs/sdk-api-core';\n\nimport { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { createApiClient } from '../../apiClient';\nimport { updateAuthFromVerifyResponse } from '../../auth/updateAuthFromVerifyResponse';\n\n/**\n * Refreshes the current user's data from the server.\n *\n * This function fetches the latest user information and token from the backend\n * updating the local user and token states with any changes.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns A promise that resolves to the verify response.\n * @instrumented\n * @redact-params\n */\nexport const refreshAuth = async (\n client = getDefaultClient()\n): Promise<VerifyResponse> => {\n const core = getCore(client);\n const apiClient = createApiClient({}, client);\n\n const response = await apiClient.refreshAuth({\n environmentId: core.environmentId,\n });\n\n updateAuthFromVerifyResponse({ response }, client);\n\n return response;\n};\n","import { BaseError } from './base';\n\ntype NotWaasWalletAccountErrorParams = {\n walletAddress: string;\n};\n\nexport class NotWaasWalletAccountError extends BaseError {\n constructor({ walletAddress }: NotWaasWalletAccountErrorParams) {\n super({\n cause: null,\n code: 'not_waas_wallet_account_error',\n docsUrl: null,\n name: 'NotWaasWalletAccountError',\n shortMessage: `Wallet account ${walletAddress} is not a Dynamic WaaS wallet account`,\n });\n }\n}\n","import { EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';\n\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { assertDefined } from '../../../utils/assertDefined';\n\n/**\n * Checks if Dynamic WaaS (Wallet as a Service) is enabled for the current project.\n *\n * This function examines the project settings to determine if Dynamic WaaS is\n * enabled in the Dynamic Dashboard or not.\n *\n * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.\n * @returns True if Dynamic WaaS is enabled, false otherwise.\n * @notInstrumented\n */\nexport const isDynamicWaasEnabled = (client = getDefaultClient()) => {\n const projectSettings = client.projectSettings;\n\n assertDefined(projectSettings, 'Project settings are not available');\n\n const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;\n\n const dynamicWaasIsEnabled =\n embeddedWalletSettings?.defaultWalletVersion ===\n EmbeddedWalletVersionEnum.V3;\n\n return dynamicWaasIsEnabled;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAE,cAAa,OACb,SAAM,kBAAY;CAElB,MAAM,OAAA,QAAW,OAAM;wBACN,gBAAK,EAAa,EAAA,OAAA,eAGnC,eAAA,KAAA;AAGD,8BAAA,EAAA,UAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;ACzBD,IAAa,4BAAb,cAA+C,UAAU;CACvD,YAAY,EAAE,iBAAkD;AAC9D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,kBAAkB,cAAc;GAC/C,CAAC;;;;;;;;;;;;;;;;ACCN,MAAa,wBAAwB,SAAS,kBAAkB,KAAK;CACnE,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxB,0BAA0B"}
@@ -1,4 +1,4 @@
1
- import { I as setCookie, M as emitEvent, Q as assertDefined, R as createApiClient, S as getWalletAccounts, Z as isCookieEnabled, _ as getWalletProviderFromWalletAccount, at as getDefaultClient, ct as BaseError, g as DYNAMIC_AUTH_COOKIE_NAME, l as instrumentFunction, lt as getCore, nt as CLIENT_SDK_NAME } from "./InvalidParamError-Dn_riAvL.esm.js";
1
+ import { B as emitEvent, E as getWalletProviderFromWalletAccount, K as createApiClient, T as DYNAMIC_AUTH_COOKIE_NAME, W as setCookie, _t as getCore, at as isCookieEnabled, gt as BaseError, j as getWalletAccounts, ot as assertDefined, pt as getDefaultClient, ut as CLIENT_SDK_NAME, v as instrumentFunction } from "./updateAuthFromVerifyResponse-BdokPJ21.esm.js";
2
2
  import * as z from "zod/mini";
3
3
 
4
4
  //#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
@@ -316,4 +316,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
316
316
 
317
317
  //#endregion
318
318
  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 };
319
- //# sourceMappingURL=isMfaRequiredForAction-CgVdSGRA.esm.js.map
319
+ //# sourceMappingURL=isMfaRequiredForAction-B7wNkqQf.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isMfaRequiredForAction-CgVdSGRA.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 * @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 * @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 * @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 * @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 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 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 { 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 setCookie(\n `${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`\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 * @redact-params\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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"}
1
+ {"version":3,"file":"isMfaRequiredForAction-B7wNkqQf.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 * @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 * @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 * @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 * @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 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 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 { 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 setCookie(\n `${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`\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 * @redact-params\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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"}
@@ -1,4 +1,4 @@
1
- import { $ as getCore, H as assertDefined, O as createApiClient, Q as BaseError, Y as getDefaultClient, l as instrumentFunction } from "./InvalidParamError-DYezznCD.native.esm.js";
1
+ import { K as createApiClient, _t as getCore, gt as BaseError, ot as assertDefined, pt as getDefaultClient, v as instrumentFunction } from "./updateAuthFromVerifyResponse-DW-tPgdV.native.esm.js";
2
2
 
3
3
  //#region src/errors/NativeModuleNotLinkedError.ts
4
4
  var NativeModuleNotLinkedError = class extends BaseError {
@@ -105,4 +105,4 @@ const isMfaRequiredForAction = async ({ mfaAction }, client = getDefaultClient()
105
105
 
106
106
  //#endregion
107
107
  export { NativeModuleNotLinkedError as i, getMfaMethods as n, __consumeMfaToken_wrapped as r, isMfaRequiredForAction as t };
108
- //# sourceMappingURL=isMfaRequiredForAction-juTvf3Pl.native.esm.js.map
108
+ //# sourceMappingURL=isMfaRequiredForAction-CJ9qbBUz.native.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isMfaRequiredForAction-juTvf3Pl.native.esm.js","names":[],"sources":["../src/errors/NativeModuleNotLinkedError.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NativeModuleNotLinkedErrorParams = {\n moduleName: string;\n};\n\nexport class NativeModuleNotLinkedError extends BaseError {\n constructor({ moduleName }: NativeModuleNotLinkedErrorParams) {\n super({\n cause: null,\n code: 'native_module_not_linked_error',\n details: [\n `The \"${moduleName}\" TurboModule is not registered with React Native.`,\n 'This usually means the native module was not autolinked into the host app,',\n 'or the app binary was not rebuilt after installing the SDK.',\n '',\n 'To resolve:',\n ' 1. Ensure \"@dynamic-labs-sdk/client\" is a direct dependency of the app',\n ' and reinstall (e.g. `pnpm install`).',\n ' 2. Rebuild the native app:',\n ' iOS: `cd ios && pod install && cd .. && npx react-native run-ios`',\n ' Android: `npx react-native run-android`',\n ' Expo: `npx expo prebuild --clean` then run the app.',\n ' 3. Confirm autolinking sees the package:',\n ' `npx expo-modules-autolinking react-native-config --json`',\n ].join('\\n'),\n docsUrl: null,\n name: 'NativeModuleNotLinkedError',\n shortMessage: `Native TurboModule \"${moduleName}\" is not linked.`,\n });\n }\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 * @redact-params\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,6BAAb,cAAgD,UAAU;CACxD,YAAY,EAAE,cAAgD;AAC5D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;IACP,QAAQ,WAAW;IACnB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,KAAK,KAAK;GACZ,SAAS;GACT,MAAM;GACN,cAAc,uBAAuB,WAAW;GACjD,CAAC;;;;;;;;;;;;;;;;;;ACVN,MAAE,mBAAsB,SAAU,kBAAU,KAAA;;;AAK1C,eAAY,UAAI,qBAAA;kBAGhB,UAAO,MACR,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdD,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
+ {"version":3,"file":"isMfaRequiredForAction-CJ9qbBUz.native.esm.js","names":[],"sources":["../src/errors/NativeModuleNotLinkedError.ts","../src/modules/mfa/consumeMfaToken/consumeMfaToken.ts","../src/modules/mfa/getMfaMethods/getMfaMethods.ts","../src/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.ts"],"sourcesContent":["import { BaseError } from './base';\n\ntype NativeModuleNotLinkedErrorParams = {\n moduleName: string;\n};\n\nexport class NativeModuleNotLinkedError extends BaseError {\n constructor({ moduleName }: NativeModuleNotLinkedErrorParams) {\n super({\n cause: null,\n code: 'native_module_not_linked_error',\n details: [\n `The \"${moduleName}\" TurboModule is not registered with React Native.`,\n 'This usually means the native module was not autolinked into the host app,',\n 'or the app binary was not rebuilt after installing the SDK.',\n '',\n 'To resolve:',\n ' 1. Ensure \"@dynamic-labs-sdk/client\" is a direct dependency of the app',\n ' and reinstall (e.g. `pnpm install`).',\n ' 2. Rebuild the native app:',\n ' iOS: `cd ios && pod install && cd .. && npx react-native run-ios`',\n ' Android: `npx react-native run-android`',\n ' Expo: `npx expo prebuild --clean` then run the app.',\n ' 3. Confirm autolinking sees the package:',\n ' `npx expo-modules-autolinking react-native-config --json`',\n ].join('\\n'),\n docsUrl: null,\n name: 'NativeModuleNotLinkedError',\n shortMessage: `Native TurboModule \"${moduleName}\" is not linked.`,\n });\n }\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 * @redact-params\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,6BAAb,cAAgD,UAAU;CACxD,YAAY,EAAE,cAAgD;AAC5D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;IACP,QAAQ,WAAW;IACnB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD,CAAC,KAAK,KAAK;GACZ,SAAS;GACT,MAAM;GACN,cAAc,uBAAuB,WAAW;GACjD,CAAC;;;;;;;;;;;;;;;;;;ACVN,MAAE,mBAAsB,SAAU,kBAAU,KAAA;;;AAK1C,eAAY,UAAI,qBAAA;kBAGhB,UAAO,MACR,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdD,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"}
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_InvalidParamError = require('./InvalidParamError-DHriGGNI.cjs');
28
+ const require_updateAuthFromVerifyResponse = require('./updateAuthFromVerifyResponse-CUnvs5Af.cjs');
29
29
  let zod_mini = require("zod/mini");
30
30
  zod_mini = __toESM(zod_mini);
31
31
 
@@ -34,7 +34,7 @@ zod_mini = __toESM(zod_mini);
34
34
  * This error is thrown when the `retryOnFail` function is called with an invalid
35
35
  * number of retries (i.e. less than 0).
36
36
  */
37
- var InvalidRetryOnFailCallError = class extends require_InvalidParamError.BaseError {
37
+ var InvalidRetryOnFailCallError = class extends require_updateAuthFromVerifyResponse.BaseError {
38
38
  constructor(maxRetries) {
39
39
  super({
40
40
  cause: null,
@@ -85,7 +85,7 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
85
85
  * @returns True if the user is signed in, false otherwise.
86
86
  * @notInstrumented
87
87
  */
88
- const isSignedIn = (client = require_InvalidParamError.getDefaultClient()) => Boolean(client.user || require_InvalidParamError.getWalletAccounts(client).length > 0);
88
+ const isSignedIn = (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => Boolean(client.user || require_updateAuthFromVerifyResponse.getWalletAccounts(client).length > 0);
89
89
 
90
90
  //#endregion
91
91
  //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
@@ -122,15 +122,15 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
122
122
  * @notInstrumented
123
123
  * @noHook Internal settings fetch that is not part of the public hook surface.
124
124
  */
125
- const fetchProjectSettings = async (client = require_InvalidParamError.getDefaultClient()) => {
126
- const core = require_InvalidParamError.getCore(client);
125
+ const fetchProjectSettings = async (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
126
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
127
127
  const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
128
128
  if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
129
- const apiClient = require_InvalidParamError.createApiClient({}, client);
129
+ const apiClient = require_updateAuthFromVerifyResponse.createApiClient({}, client);
130
130
  core.logger.debug("[fetchProjectSettings] Fetching project settings...");
131
131
  const doFetch = async () => apiClient.getEnvironmentSettings({
132
132
  environmentId: core.environmentId,
133
- sdkVersion: `${require_InvalidParamError.CLIENT_SDK_NAME}/${core.version}`
133
+ sdkVersion: `${require_updateAuthFromVerifyResponse.CLIENT_SDK_NAME}/${core.version}`
134
134
  }, { credentials: "omit" });
135
135
  const projectSettings = await retryOnFail({
136
136
  fn: doFetch,
@@ -145,10 +145,10 @@ const fetchProjectSettings = async (client = require_InvalidParamError.getDefaul
145
145
  //#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
146
146
  /** @notInstrumented */
147
147
  const generateSessionKeys = async (client) => {
148
- const core = require_InvalidParamError.getCore(client);
148
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
149
149
  await core.keychain.removeKey("session");
150
150
  const publicKey = await core.keychain.generateKey("session");
151
- require_InvalidParamError.assertDefined(publicKey, "Public key not found");
151
+ require_updateAuthFromVerifyResponse.assertDefined(publicKey, "Public key not found");
152
152
  core.state.set({ sessionKeys: publicKey });
153
153
  return { publicKey };
154
154
  };
@@ -157,12 +157,12 @@ const generateSessionKeys = async (client) => {
157
157
  //#region src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts
158
158
  /** @notInstrumented */
159
159
  const getAvailableWalletProvidersFromWalletAccounts = (client) => {
160
- const core = require_InvalidParamError.getCore(client);
160
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
161
161
  const walletProvidersMap = /* @__PURE__ */ new Map();
162
- require_InvalidParamError.getWalletAccounts(client).forEach((walletAccount) => {
162
+ require_updateAuthFromVerifyResponse.getWalletAccounts(client).forEach((walletAccount) => {
163
163
  if (walletProvidersMap.has(walletAccount.walletProviderKey)) return;
164
164
  try {
165
- const walletProvider = require_InvalidParamError.getWalletProviderFromWalletAccount({ walletAccount }, client);
165
+ const walletProvider = require_updateAuthFromVerifyResponse.getWalletProviderFromWalletAccount({ walletAccount }, client);
166
166
  walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
167
167
  } catch (error) {
168
168
  core.logger.debug("Wallet provider not found for wallet account", {
@@ -186,7 +186,7 @@ const getAvailableWalletProvidersFromWalletAccounts = (client) => {
186
186
  * @notInstrumented
187
187
  */
188
188
  const destroyWalletProviders = async ({ reason }, client) => {
189
- const core = require_InvalidParamError.getCore(client);
189
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
190
190
  const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
191
191
  await Promise.all(walletProviders.map(async (walletProvider) => {
192
192
  if (!walletProvider.destroy) return;
@@ -219,11 +219,11 @@ const destroyWalletProviders = async ({ reason }, client) => {
219
219
  * @instrumented
220
220
  */
221
221
  const logoutWithReason = async ({ reason }, client) => {
222
- const core = require_InvalidParamError.getCore(client);
222
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
223
223
  core.logger.debug("[logoutWithReason] Logging out...", { reason });
224
224
  await destroyWalletProviders({ reason }, client);
225
225
  if (client.user !== null) {
226
- const apiClient = require_InvalidParamError.createApiClient({}, client);
226
+ const apiClient = require_updateAuthFromVerifyResponse.createApiClient({}, client);
227
227
  try {
228
228
  await apiClient.revokeSession({ environmentId: core.environmentId });
229
229
  } catch (error) {
@@ -233,7 +233,7 @@ const logoutWithReason = async ({ reason }, client) => {
233
233
  * This deletes the auth cookie if it exists.
234
234
  * If the cookie doesn't exist, this sets a new cookie that expires immediately.
235
235
  */
236
- if (require_InvalidParamError.isCookieEnabled(client)) require_InvalidParamError.setCookie(`${require_InvalidParamError.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
236
+ if (require_updateAuthFromVerifyResponse.isCookieEnabled(client)) require_updateAuthFromVerifyResponse.setCookie(`${require_updateAuthFromVerifyResponse.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
237
237
  }
238
238
  await core.keychain.removeKey("session");
239
239
  core.state.set({
@@ -247,7 +247,7 @@ const logoutWithReason = async ({ reason }, client) => {
247
247
  unverifiedWalletAccounts: [],
248
248
  user: null
249
249
  });
250
- require_InvalidParamError.emitEvent({
250
+ require_updateAuthFromVerifyResponse.emitEvent({
251
251
  args: { reason },
252
252
  event: "logout"
253
253
  }, client);
@@ -255,12 +255,12 @@ const logoutWithReason = async ({ reason }, client) => {
255
255
  generateSessionKeys(client);
256
256
  };
257
257
  const __logoutWithReason_impl = logoutWithReason;
258
- const __logoutWithReason_wrapped = require_InvalidParamError.instrumentFunction({
258
+ const __logoutWithReason_wrapped = require_updateAuthFromVerifyResponse.instrumentFunction({
259
259
  fn: __logoutWithReason_impl,
260
260
  functionName: "logoutWithReason",
261
261
  getCore: () => {
262
262
  try {
263
- return require_InvalidParamError.getCore(require_InvalidParamError.getDefaultClient());
263
+ return require_updateAuthFromVerifyResponse.getCore(require_updateAuthFromVerifyResponse.getDefaultClient());
264
264
  } catch {
265
265
  return;
266
266
  }
@@ -281,20 +281,20 @@ const __logoutWithReason_wrapped = require_InvalidParamError.instrumentFunction(
281
281
  * @instrumented
282
282
  * @redact-params
283
283
  */
284
- const consumeMfaToken = (client = require_InvalidParamError.getDefaultClient()) => {
285
- const core = require_InvalidParamError.getCore(client);
284
+ const consumeMfaToken = (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
285
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
286
286
  const mfaToken = core.state.get().mfaToken;
287
- require_InvalidParamError.assertDefined(mfaToken, "No MFA token found");
287
+ require_updateAuthFromVerifyResponse.assertDefined(mfaToken, "No MFA token found");
288
288
  core.state.set({ mfaToken: null });
289
289
  return mfaToken;
290
290
  };
291
291
  const __consumeMfaToken_impl = consumeMfaToken;
292
- const __consumeMfaToken_wrapped = require_InvalidParamError.instrumentFunction({
292
+ const __consumeMfaToken_wrapped = require_updateAuthFromVerifyResponse.instrumentFunction({
293
293
  fn: __consumeMfaToken_impl,
294
294
  functionName: "consumeMfaToken",
295
295
  getCore: () => {
296
296
  try {
297
- return require_InvalidParamError.getCore(require_InvalidParamError.getDefaultClient());
297
+ return require_updateAuthFromVerifyResponse.getCore(require_updateAuthFromVerifyResponse.getDefaultClient());
298
298
  } catch {
299
299
  return;
300
300
  }
@@ -314,9 +314,9 @@ const __consumeMfaToken_wrapped = require_InvalidParamError.instrumentFunction({
314
314
  * @returns A promise that resolves to the user's MFA methods configuration.
315
315
  * @notInstrumented
316
316
  */
317
- const getMfaMethods = async (client = require_InvalidParamError.getDefaultClient()) => {
318
- const core = require_InvalidParamError.getCore(client);
319
- return await require_InvalidParamError.createApiClient({}, client).getUserMfaMethods({
317
+ const getMfaMethods = async (client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
318
+ const core = require_updateAuthFromVerifyResponse.getCore(client);
319
+ return await require_updateAuthFromVerifyResponse.createApiClient({}, client).getUserMfaMethods({
320
320
  environmentId: core.environmentId,
321
321
  verifiedOnly: true
322
322
  });
@@ -335,7 +335,7 @@ const getMfaMethods = async (client = require_InvalidParamError.getDefaultClient
335
335
  * @returns A promise that resolves to true if MFA is required for the action, false otherwise.
336
336
  * @notInstrumented
337
337
  */
338
- const isMfaRequiredForAction = async ({ mfaAction }, client = require_InvalidParamError.getDefaultClient()) => {
338
+ const isMfaRequiredForAction = async ({ mfaAction }, client = require_updateAuthFromVerifyResponse.getDefaultClient()) => {
339
339
  const projectSettings = client.projectSettings;
340
340
  if (!projectSettings?.security?.mfa?.actions?.some((action) => action.action === mfaAction && action.required)) return false;
341
341
  if (projectSettings?.security?.mfa?.required) return true;
@@ -403,4 +403,4 @@ Object.defineProperty(exports, 'retryOnFail', {
403
403
  return retryOnFail;
404
404
  }
405
405
  });
406
- //# sourceMappingURL=isMfaRequiredForAction-DECknr5q.cjs.map
406
+ //# sourceMappingURL=isMfaRequiredForAction-CaNdGc-m.cjs.map