@dynamic-labs-sdk/client 1.33.1 → 1.33.3

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 (156) hide show
  1. package/dist/{apiClient-BbjPoAwE.native.esm.js → apiClient-CpfEx6Uc.native.esm.js} +3 -3
  2. package/dist/{apiClient-BbjPoAwE.native.esm.js.map → apiClient-CpfEx6Uc.native.esm.js.map} +1 -1
  3. package/dist/core.cjs +5 -78
  4. package/dist/core.cjs.map +1 -1
  5. package/dist/core.esm.js +8 -79
  6. package/dist/core.esm.js.map +1 -1
  7. package/dist/core.native.esm.js +6 -77
  8. package/dist/core.native.esm.js.map +1 -1
  9. package/dist/exports/core.d.ts +0 -2
  10. package/dist/exports/core.d.ts.map +1 -1
  11. package/dist/exports/waas.d.ts +13 -1
  12. package/dist/exports/waas.d.ts.map +1 -1
  13. package/dist/{getNetworkProviderFromNetworkId-BXoTukxv.cjs → getNetworkProviderFromNetworkId-Cez8TM-n.cjs} +9 -2
  14. package/dist/getNetworkProviderFromNetworkId-Cez8TM-n.cjs.map +1 -0
  15. package/dist/{getNetworkProviderFromNetworkId-D_Hg6kP7.esm.js → getNetworkProviderFromNetworkId-Cf-CfYM4.esm.js} +9 -8
  16. package/dist/getNetworkProviderFromNetworkId-Cf-CfYM4.esm.js.map +1 -0
  17. package/dist/{getNetworkProviderFromNetworkId-Cs3hLqBS.native.esm.js → getNetworkProviderFromNetworkId-CuTEQ9dg.native.esm.js} +5 -4
  18. package/dist/getNetworkProviderFromNetworkId-CuTEQ9dg.native.esm.js.map +1 -0
  19. package/dist/{getSignedSessionId-Bk-8is5J.native.esm.js → getSignedSessionId-Bt4obN3w.native.esm.js} +3 -3
  20. package/dist/{getSignedSessionId-Bk-8is5J.native.esm.js.map → getSignedSessionId-Bt4obN3w.native.esm.js.map} +1 -1
  21. package/dist/{getSignedSessionId-D_TknHwX.esm.js → getSignedSessionId-Cx7WP4ZJ.esm.js} +3 -3
  22. package/dist/{getSignedSessionId-D_TknHwX.esm.js.map → getSignedSessionId-Cx7WP4ZJ.esm.js.map} +1 -1
  23. package/dist/{getSignedSessionId-2O_cJtIV.cjs → getSignedSessionId-DiVxv0qz.cjs} +3 -3
  24. package/dist/{getSignedSessionId-2O_cJtIV.cjs.map → getSignedSessionId-DiVxv0qz.cjs.map} +1 -1
  25. package/dist/{getVerifiedCredentialForWalletAccount-BmsHgXbj.esm.js → getVerifiedCredentialForWalletAccount-DfKRbqco.esm.js} +2 -2
  26. package/dist/{getVerifiedCredentialForWalletAccount-BmsHgXbj.esm.js.map → getVerifiedCredentialForWalletAccount-DfKRbqco.esm.js.map} +1 -1
  27. package/dist/{getVerifiedCredentialForWalletAccount-upiwolAi.cjs → getVerifiedCredentialForWalletAccount-UIcOv7IN.cjs} +2 -2
  28. package/dist/{getVerifiedCredentialForWalletAccount-upiwolAi.cjs.map → getVerifiedCredentialForWalletAccount-UIcOv7IN.cjs.map} +1 -1
  29. package/dist/index.cjs +56 -69
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.esm.js +50 -63
  32. package/dist/index.esm.js.map +1 -1
  33. package/dist/index.native.esm.js +48 -61
  34. package/dist/index.native.esm.js.map +1 -1
  35. package/dist/{isMfaRequiredForAction-D7b7mUT9.native.esm.js → isMfaRequiredForAction-CxYft5KR.native.esm.js} +2 -2
  36. package/dist/{isMfaRequiredForAction-D7b7mUT9.native.esm.js.map → isMfaRequiredForAction-CxYft5KR.native.esm.js.map} +1 -1
  37. package/dist/{isMfaRequiredForAction-DF65MJNN.cjs → isMfaRequiredForAction-Czx-uPFY.cjs} +2 -2
  38. package/dist/{isMfaRequiredForAction-DF65MJNN.cjs.map → isMfaRequiredForAction-Czx-uPFY.cjs.map} +1 -1
  39. package/dist/{isMfaRequiredForAction-CHqeZeTS.esm.js → isMfaRequiredForAction-DS8fcwxO.esm.js} +2 -2
  40. package/dist/{isMfaRequiredForAction-CHqeZeTS.esm.js.map → isMfaRequiredForAction-DS8fcwxO.esm.js.map} +1 -1
  41. package/dist/{isUserOnboardingComplete-CpHVw8ee.esm.js → isUserOnboardingComplete-COmYFW26.esm.js} +3 -3
  42. package/dist/{isUserOnboardingComplete-CpHVw8ee.esm.js.map → isUserOnboardingComplete-COmYFW26.esm.js.map} +1 -1
  43. package/dist/{isUserOnboardingComplete-CYpgo52t.native.esm.js → isUserOnboardingComplete-DYnRDLep.native.esm.js} +3 -3
  44. package/dist/{isUserOnboardingComplete-CYpgo52t.native.esm.js.map → isUserOnboardingComplete-DYnRDLep.native.esm.js.map} +1 -1
  45. package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs → isUserOnboardingComplete-FbjleMQm.cjs} +3 -3
  46. package/dist/{isUserOnboardingComplete-BAL-3zu7.cjs.map → isUserOnboardingComplete-FbjleMQm.cjs.map} +1 -1
  47. package/dist/{logoutWithReason-CFjm8dbR.cjs → logoutWithReason-BKwWBsCT.cjs} +73 -55
  48. package/dist/logoutWithReason-BKwWBsCT.cjs.map +1 -0
  49. package/dist/{logoutWithReason-CX9hGTPw.esm.js → logoutWithReason-DO0kP7nf.esm.js} +62 -50
  50. package/dist/logoutWithReason-DO0kP7nf.esm.js.map +1 -0
  51. package/dist/{logoutWithReason-Bd1qUh7l.native.esm.js → logoutWithReason-DWkIKoLk.native.esm.js} +61 -49
  52. package/dist/logoutWithReason-DWkIKoLk.native.esm.js.map +1 -0
  53. package/dist/{migrateFromFireblocks-BLz9aHOY.native.esm.js → migrateFromFireblocks-BwYnNAAh.native.esm.js} +2 -2
  54. package/dist/{migrateFromFireblocks-BLz9aHOY.native.esm.js.map → migrateFromFireblocks-BwYnNAAh.native.esm.js.map} +1 -1
  55. package/dist/{migrateFromFireblocks-C8KXMXk-.esm.js → migrateFromFireblocks-C_cap--b.esm.js} +2 -2
  56. package/dist/{migrateFromFireblocks-C8KXMXk-.esm.js.map → migrateFromFireblocks-C_cap--b.esm.js.map} +1 -1
  57. package/dist/{migrateFromFireblocks-BiZmnKp9.cjs → migrateFromFireblocks-ycJIYcrm.cjs} +2 -2
  58. package/dist/{migrateFromFireblocks-BiZmnKp9.cjs.map → migrateFromFireblocks-ycJIYcrm.cjs.map} +1 -1
  59. package/dist/modules/initializeClient/consts.d.ts +1 -0
  60. package/dist/modules/initializeClient/consts.d.ts.map +1 -1
  61. package/dist/modules/initializeClient/initializeClient.d.ts.map +1 -1
  62. package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts +4 -5
  63. package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
  64. package/dist/modules/sessionKeys/canonicalizeJson/canonicalizeJson.d.ts +20 -0
  65. package/dist/modules/sessionKeys/canonicalizeJson/canonicalizeJson.d.ts.map +1 -0
  66. package/dist/modules/sessionKeys/canonicalizeJson/index.d.ts +2 -0
  67. package/dist/modules/sessionKeys/canonicalizeJson/index.d.ts.map +1 -0
  68. package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts +39 -6
  69. package/dist/modules/sessionKeys/signBusinessAccountIntent/signBusinessAccountIntent.d.ts.map +1 -1
  70. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts +9 -3
  71. package/dist/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.d.ts.map +1 -1
  72. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts +10 -3
  73. package/dist/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.d.ts.map +1 -1
  74. package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/approveBusinessAccountProposal.d.ts +43 -0
  75. package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/approveBusinessAccountProposal.d.ts.map +1 -0
  76. package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/index.d.ts +2 -0
  77. package/dist/modules/waas/businessAccounts/approveBusinessAccountProposal/index.d.ts.map +1 -0
  78. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +249 -0
  79. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -1
  80. package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/defineBusinessAccountRole.d.ts +45 -0
  81. package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/defineBusinessAccountRole.d.ts.map +1 -0
  82. package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/index.d.ts +2 -0
  83. package/dist/modules/waas/businessAccounts/defineBusinessAccountRole/index.d.ts.map +1 -0
  84. package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/deleteBusinessAccountRole.d.ts +41 -0
  85. package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/deleteBusinessAccountRole.d.ts.map +1 -0
  86. package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/index.d.ts +2 -0
  87. package/dist/modules/waas/businessAccounts/deleteBusinessAccountRole/index.d.ts.map +1 -0
  88. package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/executeBusinessAccountProposal.d.ts +39 -0
  89. package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/executeBusinessAccountProposal.d.ts.map +1 -0
  90. package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/index.d.ts +2 -0
  91. package/dist/modules/waas/businessAccounts/executeBusinessAccountProposal/index.d.ts.map +1 -0
  92. package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/getBusinessAccountGovernance.d.ts +30 -0
  93. package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/getBusinessAccountGovernance.d.ts.map +1 -0
  94. package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/index.d.ts +2 -0
  95. package/dist/modules/waas/businessAccounts/getBusinessAccountGovernance/index.d.ts.map +1 -0
  96. package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/index.d.ts +2 -0
  97. package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/index.d.ts.map +1 -0
  98. package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/listBusinessAccountProposals.d.ts +26 -0
  99. package/dist/modules/waas/businessAccounts/listBusinessAccountProposals/listBusinessAccountProposals.d.ts.map +1 -0
  100. package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/index.d.ts +2 -0
  101. package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/index.d.ts.map +1 -0
  102. package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/listBusinessAccountProposalsAwaitingMyApproval.d.ts +21 -0
  103. package/dist/modules/waas/businessAccounts/listBusinessAccountProposalsAwaitingMyApproval/listBusinessAccountProposalsAwaitingMyApproval.d.ts.map +1 -0
  104. package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/index.d.ts +2 -0
  105. package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/index.d.ts.map +1 -0
  106. package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/listBusinessAccountRoles.d.ts +26 -0
  107. package/dist/modules/waas/businessAccounts/listBusinessAccountRoles/listBusinessAccountRoles.d.ts.map +1 -0
  108. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts +11 -2
  109. package/dist/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.d.ts.map +1 -1
  110. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts +11 -2
  111. package/dist/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.d.ts.map +1 -1
  112. package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts +12 -4
  113. package/dist/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.d.ts.map +1 -1
  114. package/dist/modules/waas/businessAccounts/resendFields.d.ts +39 -0
  115. package/dist/modules/waas/businessAccounts/resendFields.d.ts.map +1 -0
  116. package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/index.d.ts +2 -0
  117. package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/index.d.ts.map +1 -0
  118. package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/setBusinessAccountGovernance.d.ts +49 -0
  119. package/dist/modules/waas/businessAccounts/setBusinessAccountGovernance/setBusinessAccountGovernance.d.ts.map +1 -0
  120. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts +11 -2
  121. package/dist/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.d.ts.map +1 -1
  122. package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts +11 -2
  123. package/dist/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.d.ts.map +1 -1
  124. package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/index.d.ts +2 -0
  125. package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/index.d.ts.map +1 -0
  126. package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/vetoBusinessAccountProposal.d.ts +29 -0
  127. package/dist/modules/waas/businessAccounts/vetoBusinessAccountProposal/vetoBusinessAccountProposal.d.ts.map +1 -0
  128. package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/index.d.ts +2 -0
  129. package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/index.d.ts.map +1 -0
  130. package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/withdrawBusinessAccountProposalApproval.d.ts +29 -0
  131. package/dist/modules/waas/businessAccounts/withdrawBusinessAccountProposalApproval/withdrawBusinessAccountProposalApproval.d.ts.map +1 -0
  132. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  133. package/dist/{waas-oKD6ZDP9.native.esm.js → waas-C4jtRxx1.native.esm.js} +688 -26
  134. package/dist/waas-C4jtRxx1.native.esm.js.map +1 -0
  135. package/dist/{waas-G-4JvdgJ.cjs → waas-CioG-_yp.cjs} +764 -24
  136. package/dist/waas-CioG-_yp.cjs.map +1 -0
  137. package/dist/{waas-DjgZ-ghV.esm.js → waas-DjivkzyT.esm.js} +688 -26
  138. package/dist/waas-DjivkzyT.esm.js.map +1 -0
  139. package/dist/waas.cjs +18 -5
  140. package/dist/waas.esm.js +5 -5
  141. package/dist/waas.native.esm.js +5 -5
  142. package/dist/waasCore.cjs +5 -5
  143. package/dist/waasCore.esm.js +5 -5
  144. package/dist/waasCore.native.esm.js +5 -5
  145. package/package.json +3 -4
  146. package/dist/getNetworkProviderFromNetworkId-BXoTukxv.cjs.map +0 -1
  147. package/dist/getNetworkProviderFromNetworkId-Cs3hLqBS.native.esm.js.map +0 -1
  148. package/dist/getNetworkProviderFromNetworkId-D_Hg6kP7.esm.js.map +0 -1
  149. package/dist/logoutWithReason-Bd1qUh7l.native.esm.js.map +0 -1
  150. package/dist/logoutWithReason-CFjm8dbR.cjs.map +0 -1
  151. package/dist/logoutWithReason-CX9hGTPw.esm.js.map +0 -1
  152. package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts +0 -5
  153. package/dist/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.d.ts.map +0 -1
  154. package/dist/waas-DjgZ-ghV.esm.js.map +0 -1
  155. package/dist/waas-G-4JvdgJ.cjs.map +0 -1
  156. package/dist/waas-oKD6ZDP9.native.esm.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ct as getCore, E as getWalletProviders, G as getSecureCookieAttribute, P as getWalletAccounts, Q as createStorageKeySchema, Tt as DYNAMIC_AUTH_COOKIE_NAME, W as setCookie, _ as checkAndRaiseWalletAccountsChangedEvent, a as resolveInstrumentationCore, bt as getDefaultClient, ct as CLIENT_SDK_NAME, ht as assertDefined, k as emitEvent, lt as DYNAMIC_LOGOUT_REASON_HEADER, mt as isCookieEnabled, n as NoWalletProviderFoundError, o as instrumentFunction, r as createApiClient, t as getWalletProviderFromWalletAccount, wt as BaseError } from "./apiClient-BbjPoAwE.native.esm.js";
1
+ import { Ct as getCore, E as getWalletProviders, G as getSecureCookieAttribute, P as getWalletAccounts, Q as createStorageKeySchema, Tt as DYNAMIC_AUTH_COOKIE_NAME, W as setCookie, _ as checkAndRaiseWalletAccountsChangedEvent, a as resolveInstrumentationCore, bt as getDefaultClient, ct as CLIENT_SDK_NAME, ft as SDK_API_CORE_VERSION, ht as assertDefined, k as emitEvent, lt as DYNAMIC_LOGOUT_REASON_HEADER, mt as isCookieEnabled, n as NoWalletProviderFoundError, o as instrumentFunction, r as createApiClient, t as getWalletProviderFromWalletAccount, wt as BaseError } from "./apiClient-CpfEx6Uc.native.esm.js";
2
2
  import * as z from "zod/mini";
3
3
 
4
4
  //#region src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts
@@ -52,60 +52,66 @@ const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
52
52
  };
53
53
 
54
54
  //#endregion
55
- //#region src/modules/auth/isSignedIn/isSignedIn.ts
56
- /**
57
- * Checks if the user is currently signed in to the Dynamic client.
58
- *
59
- * The client is considered to be in a signed in state if a user has
60
- * authenticated or if the client has at least one wallet connected.
61
- *
62
- * @deprecated What counts as "signed in" is your app's business logic, not the
63
- * SDK's. This helper bakes in one opinion (a user OR any connected wallet),
64
- * which rarely matches every app and forces a dependency on us for every
65
- * variation. Compose your own check from the underlying primitives instead —
66
- * e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and
67
- * layer in whatever your app requires (device registration, completed
68
- * onboarding, satisfied MFA, a required embedded wallet, …). See the
69
- * "Check if signed in" guide:
70
- * https://www.dynamic.xyz/docs/javascript/user-session-management
71
- *
72
- * @example
73
- * ```ts
74
- * if (isSignedIn()) {
75
- * console.log('User is authenticated or has a wallet connected');
76
- * }
77
- * ```
78
- *
79
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
80
- * @returns True if the user is signed in, false otherwise.
81
- * @see logout
82
- * @see isAnyWalletAccountConnected
83
- * @notInstrumented
84
- */
85
- const isSignedIn = (client = getDefaultClient()) => Boolean(client.user || getWalletAccounts(client).length > 0);
55
+ //#region src/modules/wallets/unverifiedWalletAccounts/schema.ts
56
+ const unverifiedWalletAccountSchema = z.object({
57
+ address: z.string(),
58
+ addressesWithTypes: z.optional(z.array(z.object({
59
+ address: z.string(),
60
+ publicKey: z.optional(z.string()),
61
+ type: z.custom((val) => typeof val === "string")
62
+ }))),
63
+ chain: z.custom((val) => typeof val === "string"),
64
+ hardwareWalletVendor: z.optional(z.custom((val) => typeof val === "string")),
65
+ id: z.string(),
66
+ lastSelectedAt: z.nullable(z.date()),
67
+ walletProviderKey: z.string()
68
+ });
86
69
 
87
70
  //#endregion
88
- //#region src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts
89
- /**
90
- * The schema to track the expiration time of the project settings.
91
- */
92
- const projectSettingsExpirationStorageKeySchema = createStorageKeySchema({
93
- key: "projectSettingsExpiration",
94
- schema: z.number()
71
+ //#region src/modules/wallets/walletProvider/walletProviderKeyMap/schema.ts
72
+ const walletProviderKeyMapSchema = z.record(z.string(), z.string());
73
+
74
+ //#endregion
75
+ //#region src/modules/storageSync/schema.ts
76
+ const stateStorageKeySchema = createStorageKeySchema({
77
+ key: "state",
78
+ schema: z.object({
79
+ apiVersion: z.string(),
80
+ projectSettings: z.custom(),
81
+ unverifiedWalletAccounts: z.array(unverifiedWalletAccountSchema),
82
+ user: z.custom(),
83
+ walletProviderKeyMap: walletProviderKeyMapSchema
84
+ })
85
+ });
86
+ const sessionStorageKeySchema = createStorageKeySchema({
87
+ config: { storageTier: "secure" },
88
+ key: "session",
89
+ schema: z.object({
90
+ captchaToken: z.nullable(z.string()),
91
+ elevatedAccessTokens: z.array(z.object({
92
+ expiresAt: z.number(),
93
+ scopes: z.array(z.string()),
94
+ singleUse: z.nullable(z.boolean()),
95
+ token: z.string()
96
+ })),
97
+ legacyToken: z.nullable(z.string()),
98
+ mfaToken: z.nullable(z.string()),
99
+ sessionExpiration: z.number(),
100
+ sessionKeys: z.nullable(z.string()),
101
+ token: z.nullable(z.string())
102
+ })
95
103
  });
96
104
 
97
105
  //#endregion
98
106
  //#region src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts
99
107
  /**
100
- * Expiration time of the project settings in milliseconds.
101
- */
102
- const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
103
- /**
104
108
  * Fetches and updates the project settings from the API.
105
109
  *
106
110
  * This function retrieves the latest project configuration settings
107
111
  * from Dynamic's servers, including authentication options, enabled chains,
108
- * and security configurations. The settings are cached for performance.
112
+ * and security configurations. It always performs a live fetch. If the API
113
+ * call fails, it falls back to the last known-good settings from storage,
114
+ * provided they were saved by a matching SDK API version.
109
115
  *
110
116
  * @example
111
117
  * ```ts
@@ -115,6 +121,7 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
115
121
  *
116
122
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
117
123
  * @returns A promise that resolves to the updated project settings.
124
+ * @throws {Error} Rethrows the original fetch error when no matching-version cached settings exist.
118
125
  * @see createDynamicClient
119
126
  * @see initializeClient
120
127
  * @notInstrumented
@@ -122,8 +129,6 @@ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
122
129
  */
123
130
  const fetchProjectSettings = async (client = getDefaultClient()) => {
124
131
  const core = getCore(client);
125
- const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
126
- if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
127
132
  const apiClient = createApiClient({}, client);
128
133
  core.logger.debug("[fetchProjectSettings] Fetching project settings...");
129
134
  const doFetch = async () => apiClient.getEnvironmentSettings({
@@ -133,9 +138,16 @@ const fetchProjectSettings = async (client = getDefaultClient()) => {
133
138
  const projectSettings = await retryOnFail({
134
139
  fn: doFetch,
135
140
  maxRetries: 2
141
+ }).catch(async (error) => {
142
+ const cachedState = await core.storage.getItem(stateStorageKeySchema).catch(() => null);
143
+ if (cachedState?.apiVersion === SDK_API_CORE_VERSION && cachedState.projectSettings) {
144
+ core.logger.error("[fetchProjectSettings] Failed to fetch project settings, falling back to cached settings", error);
145
+ return cachedState.projectSettings;
146
+ }
147
+ core.logger.error("[fetchProjectSettings] Failed to fetch project settings and no cached settings are available", error);
148
+ throw error;
136
149
  });
137
150
  core.state.set({ projectSettings: projectSettings ?? null });
138
- await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
139
151
  return projectSettings;
140
152
  };
141
153
 
@@ -271,5 +283,5 @@ const __logoutWithReason_wrapped = instrumentFunction({
271
283
  });
272
284
 
273
285
  //#endregion
274
- export { retryOnFail as a, isSignedIn as i, generateSessionKeys as n, getVerifiedCredentialForWalletAccount as o, fetchProjectSettings as r, getWalletProviderByKey as s, __logoutWithReason_wrapped as t };
275
- //# sourceMappingURL=logoutWithReason-Bd1qUh7l.native.esm.js.map
286
+ export { stateStorageKeySchema as a, getWalletProviderByKey as c, sessionStorageKeySchema as i, generateSessionKeys as n, retryOnFail as o, fetchProjectSettings as r, getVerifiedCredentialForWalletAccount as s, __logoutWithReason_wrapped as t };
287
+ //# sourceMappingURL=logoutWithReason-DWkIKoLk.native.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logoutWithReason-DWkIKoLk.native.esm.js","names":["walletProvider","walletProvidersMap: Map<string, WalletProvider>"],"sources":["../src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts","../src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts","../src/utils/retryOnFail/InvalidRetryOnFailCallError.ts","../src/utils/retryOnFail/retryOnFail.ts","../src/modules/wallets/unverifiedWalletAccounts/schema.ts","../src/modules/wallets/walletProvider/walletProviderKeyMap/schema.ts","../src/modules/storageSync/schema.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"],"sourcesContent":["import type { DynamicClient } from '../../../client/types';\nimport { NoWalletProviderFoundError } from '../../../errors/NoWalletProviderFoundError';\nimport { getWalletProviders } from '../getWalletProviders';\nimport type { WalletProvider } from '../walletProvider';\n\ntype GetWalletProviderByKeyParams = {\n walletProviderKey: string;\n};\n\n/** @notInstrumented */\nexport const getWalletProviderByKey = (\n { walletProviderKey }: GetWalletProviderByKeyParams,\n client: DynamicClient\n): WalletProvider => {\n const walletProviders = getWalletProviders(client);\n\n const walletProvider = walletProviders.find(\n (walletProvider) => walletProvider.key === walletProviderKey\n );\n\n if (!walletProvider) {\n throw new NoWalletProviderFoundError({ walletProviderKey });\n }\n\n return walletProvider;\n};\n","import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';\n\nimport type { DynamicClient } from '../../../../client/types/DynamicClient';\nimport type { WalletAccount } from '../../walletAccount';\n\ntype GetVerifiedCredentialForWalletAccountParams = {\n walletAccount: WalletAccount;\n};\n\n/** @notInstrumented */\nexport const getVerifiedCredentialForWalletAccount = (\n { walletAccount }: GetVerifiedCredentialForWalletAccountParams,\n client: DynamicClient\n): JwtVerifiedCredential | undefined => {\n return client.user?.verifiedCredentials.find(\n (vc) => vc.id === walletAccount.verifiedCredentialId\n );\n};\n","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>): Promise<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 * as z from 'zod/mini';\n\nimport type { Chain } from '../../chain';\nimport type { HardwareWalletVendor } from '../hardwareWallet/hardwareWallet.types';\nimport type { WalletAddressType } from '../walletAccount';\n\nexport const unverifiedWalletAccountSchema = z.object({\n address: z.string(),\n addressesWithTypes: z.optional(\n z.array(\n z.object({\n address: z.string(),\n publicKey: z.optional(z.string()),\n type: z.custom<WalletAddressType>((val) => typeof val === 'string'),\n })\n )\n ),\n chain: z.custom<Chain>((val) => typeof val === 'string'),\n hardwareWalletVendor: z.optional(\n z.custom<HardwareWalletVendor>((val) => typeof val === 'string')\n ),\n id: z.string(),\n lastSelectedAt: z.nullable(z.date()),\n walletProviderKey: z.string(),\n});\n","import * as z from 'zod/mini';\n\nexport const walletProviderKeyMapSchema = z.record(z.string(), z.string());\n","import type { ProjectSettings } from '@dynamic-labs/sdk-api-core';\nimport * as z from 'zod/mini';\n\nimport { createStorageKeySchema } from '../../services/storage';\nimport { unverifiedWalletAccountSchema } from '../wallets/unverifiedWalletAccounts';\nimport { walletProviderKeyMapSchema } from '../wallets/walletProvider/walletProviderKeyMap/schema';\nimport type { User } from '../user/user.types';\n\nexport const stateStorageKeySchema = createStorageKeySchema({\n key: 'state',\n schema: z.object({\n apiVersion: z.string(),\n projectSettings: z.custom<ProjectSettings | null>(),\n unverifiedWalletAccounts: z.array(unverifiedWalletAccountSchema),\n user: z.custom<User | null>(),\n walletProviderKeyMap: walletProviderKeyMapSchema,\n }),\n});\n\nexport const sessionStorageKeySchema = createStorageKeySchema({\n config: { storageTier: 'secure' },\n key: 'session',\n schema: z.object({\n /**\n * The current available captcha token.\n */\n captchaToken: z.nullable(z.string()),\n\n /**\n * The current available elevated access tokens.\n */\n elevatedAccessTokens: z.array(\n z.object({\n /**\n * Milliseconds since epoch of token expiration.\n */\n expiresAt: z.number(),\n /**\n * The scopes of the token.\n */\n scopes: z.array(z.string()),\n /**\n * Whether the token is single use.\n */\n singleUse: z.nullable(z.boolean()),\n /**\n * The token string.\n */\n token: z.string(),\n })\n ),\n\n /**\n * Legacy token will be undefined in environments with cookie based sessions.\n *\n * @deprecated Use `token` instead.\n */\n legacyToken: z.nullable(z.string()),\n\n /**\n * The current available MFA token.\n */\n mfaToken: z.nullable(z.string()),\n\n /**\n * Milliseconds since epoch of session expiration.\n */\n sessionExpiration: z.number(),\n\n /**\n * The current session keys.\n */\n sessionKeys: z.nullable(z.string()),\n\n /**\n * Token will be undefined in environments with cookie based sessions.\n */\n token: z.nullable(z.string()),\n }),\n});\n","import type { ProjectSettings } from '../projectSettings.types';\nimport { getCore } from '../../../client/core/getCore';\nimport { getDefaultClient } from '../../../client/defaultClient';\nimport { SDK_API_CORE_VERSION } from '../../../constants';\nimport { retryOnFail } from '../../../utils/retryOnFail';\nimport { createApiClient } from '../../apiClient';\nimport { CLIENT_SDK_NAME } from '../../apiClient/constants';\nimport { stateStorageKeySchema } from '../../storageSync/schema';\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. It always performs a live fetch. If the API\n * call fails, it falls back to the last known-good settings from storage,\n * provided they were saved by a matching SDK API version.\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 * @throws {Error} Rethrows the original fetch error when no matching-version cached settings exist.\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 (\n client = getDefaultClient()\n): Promise<ProjectSettings | null> => {\n const core = getCore(client);\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 }).catch(async (error) => {\n const cachedState = await core.storage\n .getItem(stateStorageKeySchema)\n .catch(() => null);\n\n if (\n cachedState?.apiVersion === SDK_API_CORE_VERSION &&\n cachedState.projectSettings\n ) {\n core.logger.error(\n '[fetchProjectSettings] Failed to fetch project settings, falling back to cached settings',\n error\n );\n\n return cachedState.projectSettings;\n }\n\n core.logger.error(\n '[fetchProjectSettings] Failed to fetch project settings and no cached settings are available',\n error\n );\n\n throw error;\n });\n\n core.state.set({ projectSettings: projectSettings ?? null });\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): WalletProvider[] => {\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): Promise<void> => {\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 { DYNAMIC_LOGOUT_REASON_HEADER } from '../../apiClient/constants';\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';\nimport { checkAndRaiseWalletAccountsChangedEvent } from '../updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent';\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): Promise<void> => {\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 // Forward the logout reason so the backend can attribute the revocation in\n // Datadog instead of it being inferred from downstream 401s.\n const apiClient = createApiClient(\n { headers: { [DYNAMIC_LOGOUT_REASON_HEADER]: reason } },\n client\n );\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 const previousState = core.state.get();\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 // core.state.set above has no subscribers of its own, so this is the only\n // way listeners relying on getWalletAccounts() (e.g. chain extensions\n // reconciling a wallet provider's registration) learn the accounts are\n // gone. We diff against the pre-logout snapshot so this only fires when\n // there actually were wallet accounts to lose.\n checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);\n\n // Refetch project settings\n void fetchProjectSettings(client);\n\n // Regenerate session keys\n void generateSessionKeys(client);\n};\n"],"mappings":";;;;;AAUA,MAAa,0BACX,EAAE,qBACF,WACmB;CAGnB,MAAM,iBAFkB,mBAAmB,OAAO,CAEX,MACpC,qBAAmBA,iBAAe,QAAQ,kBAC5C;AAED,KAAI,CAAC,eACH,OAAM,IAAI,2BAA2B,EAAE,mBAAmB,CAAC;AAG7D,QAAO;;;;;;ACdT,MAAa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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;;;;;;;;;;;;;;;;;;;;;;;ACCH,MAAE,mBAAQ,OACR,EAAC,UACD;CAEA,MAAK,OAAO,QAAQ,OAAA;AAEpB,MAAK,OAAC,MAAA,qCAA0C,EAAA,QAAA,CAAA;AAEhD,OAAI,uBAAsB,EAAA,QAAA,EAAA,OAAA;AAE1B,KAAI,OAAC,SAAe,MAAM;EAGxB,MAAE,YAAA,gBACD,EAAA,SAAA,GAAA,+BAAA,QAAA,EAAA,SAED;AAEA,MAAI;AACF,SAAE,UAAA,cAAA,EACF,eAAc,KAAA,eACd,CAAA;WACF,OAAA;;;;;;;AAQA,MAAI,gBAAgB,OAAI,CAKtB,WACF,GAAA,yBAAA,4CAHW,0BAAA,GAIb;;AAIA,OAAM,KAAA,SAAc,UAAO,UAAW;CAEtC,MAAK,gBAAU,KAAA,MAAA,KAAA;AAEf,MAAE,MAAA,IAAA;EACA,cAAa;EACb,sBAAc,EAAA;EACd,aAAA;EACA,UAAA;EACA,kBAAW;EACX,aAAA;EACA,OAAM;EACN,0BAAA,EAAA;;EAEF,CAAA;AAEA,WAAO;EAAA,MAAU,EAAA,QAAW;EAAA,OAAA;EAAmB,EAAE,OAAK;AAMtD,yCAAmB,EAAA,eAAA,EAAA,OAAA;AAGnB,CAAG,qBAAmB,OAAA"}
@@ -1,4 +1,4 @@
1
- import { E as getWalletProviders, S as isWaasWalletProvider, T as DYNAMIC_WAAS_METADATA, bt as getDefaultClient, ht as assertDefined, i as __refreshAuth_wrapped, n as NoWalletProviderFoundError, t as getWalletProviderFromWalletAccount, wt as BaseError } from "./apiClient-BbjPoAwE.native.esm.js";
1
+ import { E as getWalletProviders, S as isWaasWalletProvider, T as DYNAMIC_WAAS_METADATA, bt as getDefaultClient, ht as assertDefined, i as __refreshAuth_wrapped, n as NoWalletProviderFoundError, t as getWalletProviderFromWalletAccount, wt as BaseError } from "./apiClient-CpfEx6Uc.native.esm.js";
2
2
  import { EmbeddedWalletVersionEnum } from "@dynamic-labs/sdk-api-core";
3
3
 
4
4
  //#region src/errors/NotWaasWalletProviderError.ts
@@ -125,4 +125,4 @@ const migrateFromFireblocks = async ({ coinTypes, deviceId, expectedAddresses, j
125
125
 
126
126
  //#endregion
127
127
  export { TransactionBroadcastError as a, NotWaasWalletAccountError as i, isDynamicWaasEnabled as n, NotWaasWalletProviderError as o, getWaasWalletProviderFromWalletAccount as r, migrateFromFireblocks as t };
128
- //# sourceMappingURL=migrateFromFireblocks-BLz9aHOY.native.esm.js.map
128
+ //# sourceMappingURL=migrateFromFireblocks-BwYnNAAh.native.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrateFromFireblocks-BLz9aHOY.native.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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;;;;;;;;;;;;;ACqCN,IAAa,4BAAb,cAA+C,UAAU;CACvD;CACA;CACA;CACA;CACA;CAEA,YAAY,EACV,UACA,aACA,OACA,MACA,SACA,WACA,iBACA,iBACkC;AAClC,QAAM;GACJ;GACA;GACA,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,WAAW;AAChB,OAAK,cAAc;AACnB,OAAK,YAAY;AACjB,OAAK,kBAAkB;AACvB,OAAK,gBAAgB;;;;;;AC1EzB,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;;;;;;;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;;;;;;;;;;;;;;;ACZT,MAAa,wBAAwB,SAAS,kBAAkB,KAAc;CAC5E,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;ACmC9B,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
+ {"version":3,"file":"migrateFromFireblocks-BwYnNAAh.native.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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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SAAS,MAAM,aAAa,sBAAsB;EACtD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,OAAMA,sBAAY,OAAO;AAEzB,QAAO"}
@@ -1,4 +1,4 @@
1
- import { A as DYNAMIC_WAAS_METADATA, D as isWaasWalletProvider, Tt as BaseError, gt as assertDefined, j as getWalletProviders, l as __refreshAuth_wrapped, o as getWalletProviderFromWalletAccount, s as NoWalletProviderFoundError, xt as getDefaultClient } from "./logoutWithReason-CX9hGTPw.esm.js";
1
+ import { Et as BaseError, M as getWalletProviders, O as isWaasWalletProvider, St as getDefaultClient, _t as assertDefined, c as NoWalletProviderFoundError, j as DYNAMIC_WAAS_METADATA, s as getWalletProviderFromWalletAccount, u as __refreshAuth_wrapped } from "./logoutWithReason-DO0kP7nf.esm.js";
2
2
  import { EmbeddedWalletVersionEnum } from "@dynamic-labs/sdk-api-core";
3
3
 
4
4
  //#region src/errors/NotWaasWalletProviderError.ts
@@ -125,4 +125,4 @@ const migrateFromFireblocks = async ({ coinTypes, deviceId, expectedAddresses, j
125
125
 
126
126
  //#endregion
127
127
  export { TransactionBroadcastError as a, NotWaasWalletAccountError as i, isDynamicWaasEnabled as n, NotWaasWalletProviderError as o, getWaasWalletProviderFromWalletAccount as r, migrateFromFireblocks as t };
128
- //# sourceMappingURL=migrateFromFireblocks-C8KXMXk-.esm.js.map
128
+ //# sourceMappingURL=migrateFromFireblocks-C_cap--b.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrateFromFireblocks-C8KXMXk-.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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,CA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EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,OAAMA,sBAAY,OAAO;AAEzB,QAAO"}
1
+ {"version":3,"file":"migrateFromFireblocks-C_cap--b.esm.js","names":["refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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;;;;;;;;;;;;;ACqCN,IAAa,4BAAb,cAA+C,UAAU;CACvD;CACA;CACA;CACA;CACA;CAEA,YAAY,EACV,UACA,aACA,OACA,MACA,SACA,WACA,iBACA,iBACkC;AAClC,QAAM;GACJ;GACA;GACA,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,WAAW;AAChB,OAAK,cAAc;AACnB,OAAK,YAAY;AACjB,OAAK,kBAAkB;AACvB,OAAK,gBAAgB;;;;;;AC1EzB,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;;;;;;;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;;;;;;;;;;;;;;;ACZT,MAAa,wBAAwB,SAAS,kBAAkB,KAAc;CAC5E,MAAM,kBAAkB,OAAO;AAE/B,eAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;ACmC9B,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,4 +1,4 @@
1
- const require_logoutWithReason = require('./logoutWithReason-CFjm8dbR.cjs');
1
+ const require_logoutWithReason = require('./logoutWithReason-BKwWBsCT.cjs');
2
2
  let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
3
3
 
4
4
  //#region src/errors/NotWaasWalletProviderError.ts
@@ -160,4 +160,4 @@ Object.defineProperty(exports, 'migrateFromFireblocks', {
160
160
  return migrateFromFireblocks;
161
161
  }
162
162
  });
163
- //# sourceMappingURL=migrateFromFireblocks-BiZmnKp9.cjs.map
163
+ //# sourceMappingURL=migrateFromFireblocks-ycJIYcrm.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrateFromFireblocks-BiZmnKp9.cjs","names":["BaseError","BaseError","BaseError","getWalletProviderFromWalletAccount","isWaasWalletProvider","getDefaultClient","EmbeddedWalletVersionEnum","getDefaultClient","getWalletProviders","NoWalletProviderFoundError","DYNAMIC_WAAS_METADATA","isWaasWalletProvider","refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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,c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AKC,8CAAqB;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,+CAAY,OAAO;AAEzB,QAAO"}
1
+ {"version":3,"file":"migrateFromFireblocks-ycJIYcrm.cjs","names":["BaseError","BaseError","BaseError","getWalletProviderFromWalletAccount","isWaasWalletProvider","getDefaultClient","EmbeddedWalletVersionEnum","getDefaultClient","getWalletProviders","NoWalletProviderFoundError","DYNAMIC_WAAS_METADATA","isWaasWalletProvider","refreshAuth"],"sources":["../src/errors/NotWaasWalletProviderError.ts","../src/errors/TransactionBroadcastError.ts","../src/errors/NotWaasWalletAccountError.ts","../src/modules/waas/getWaasWalletProviderFromWalletAccount/getWaasWalletProviderFromWalletAccount.ts","../src/modules/waas/isDynamicWaasEnabled/isDynamicWaasEnabled.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 { BaseError } from './base';\n\n/**\n * Error codes that identify why a v3 WaaS transaction broadcast was rejected.\n *\n * @example 'BROADCAST_REJECTED'\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastErrorCode =\n | 'BROADCAST_IDEMPOTENCY_CONFLICT'\n | 'BROADCAST_OUTCOME_UNKNOWN'\n | 'BROADCAST_RATE_LIMITED'\n | 'BROADCAST_REJECTED'\n | 'BROADCAST_REQUIRES_RESIGN'\n | 'BROADCAST_WALLET_INELIGIBLE'\n | 'INVALID_SIGNED_TRANSACTION'\n | 'NETWORK_NOT_ENABLED'\n | 'SIGNED_TRANSACTION_WALLET_MISMATCH'\n | 'UNSUPPORTED_WAAS_CHAIN';\n\n/**\n * States describing whether the signed transaction reached the chain.\n *\n * @example 'not_submitted'\n * @see TransactionBroadcastError\n * @see broadcastWaasTransaction\n */\nexport type TransactionBroadcastSubmissionState =\n | 'not_submitted'\n | 'requires_resign'\n | 'unknown';\n\ntype TransactionBroadcastErrorParams = {\n attempts: number;\n broadcastId: string;\n cause: Error;\n code: TransactionBroadcastErrorCode;\n message: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId?: string;\n};\n\n/**\n * Error raised when Redcoast fails to submit a v3 WaaS transaction after the SDK signed it.\n *\n * @example new TransactionBroadcastError({ attempts: 1, broadcastId: 'broadcast-id', cause, code: 'BROADCAST_REJECTED', message: 'rejected', retryable: false, submissionState: 'not_submitted', transactionId: undefined })\n * @see transactionBroadcastErrorMapper\n * @see broadcastWaasTransaction\n */\nexport class TransactionBroadcastError extends BaseError {\n attempts: number;\n broadcastId: string;\n retryable: boolean;\n submissionState: TransactionBroadcastSubmissionState;\n transactionId: string | undefined;\n\n constructor({\n attempts,\n broadcastId,\n cause,\n code,\n message,\n retryable,\n submissionState,\n transactionId,\n }: TransactionBroadcastErrorParams) {\n super({\n cause,\n code,\n docsUrl: null,\n name: 'TransactionBroadcastError',\n shortMessage: message,\n });\n\n this.attempts = attempts;\n this.broadcastId = broadcastId;\n this.retryable = retryable;\n this.submissionState = submissionState;\n this.transactionId = transactionId;\n }\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 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 { 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()): boolean => {\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","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,mCAAU;CACxD,YAAY,EAAE,qBAAuD;AACnE,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,mBAAmB,kBAAkB;GACpD,CAAC;;;;;;;;;;;;;ACqCN,IAAa,4BAAb,cAA+CC,mCAAU;CACvD;CACA;CACA;CACA;CACA;CAEA,YAAY,EACV,UACA,aACA,OACA,MACA,SACA,WACA,iBACA,iBACkC;AAClC,QAAM;GACJ;GACA;GACA,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,WAAW;AAChB,OAAK,cAAc;AACnB,OAAK,YAAY;AACjB,OAAK,kBAAkB;AACvB,OAAK,gBAAgB;;;;;;AC1EzB,IAAa,4BAAb,cAA+CC,mCAAU;CACvD,YAAY,EAAE,iBAAkD;AAC9D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,kBAAkB,cAAc;GAC/C,CAAC;;;;;;;ACFN,MAAa,0CACX,EAAE,iBACF,WACuB;CACvB,MAAM,iBAAiBC,4DACrB,EAAE,eAAe,EACjB,OACD;AAED,KAAI,CAACC,8CAAqB,eAAe,CACvC,OAAM,IAAI,0BAA0B,EAClC,eAAe,cAAc,SAC9B,CAAC;AAGJ,QAAO;;;;;;;;;;;;;;;ACZT,MAAa,wBAAwB,SAASC,2CAAkB,KAAc;CAC5E,MAAM,kBAAkB,OAAO;AAE/B,wCAAc,iBAAiB,qCAAqC;AAQpE,QAN+B,gBAAgB,IAAI,iBAGzB,yBACxBC,qDAA0B;;;;;;;;;;;;;;;;;;;;;;;ACmC9B,MAAa,wBAAwB,OACnC,EACE,WACA,UACA,mBACA,KACA,UACA,WAEF,SAASC,2CAAkB,KACgB;CAC3C,MAAM,YAAYC,4CAAmB,OAAO;AAE5C,KAAI,UAAU,WAAW,EACvB,OAAM,IAAIC,oDAA2B,EACnC,mBAAmBC,+CAAsB,aAC1C,CAAC;CAKJ,MAAM,eAAe,UAAU,KAAKC,8CAAqB;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,+CAAY,OAAO;AAEzB,QAAO"}
@@ -1,5 +1,6 @@
1
1
  export declare const REFRESH_USER_STATE_FROM_COOKIE_TRACKER_KEY = "refresh-user-state-from-cookie";
2
2
  export declare const INITIALIZE_STORAGE_SYNC_TRACKER_KEY = "initialize-storage-sync";
3
+ export declare const MIGRATE_SESSION_KEY_TRACKER_KEY = "migrate-session-key";
3
4
  export declare const FETCH_PROJECT_SETTINGS_TRACKER_KEY = "fetch-project-settings";
4
5
  export declare const GENERATE_SESSION_KEYS_TRACKER_KEY = "generate-session-keys";
5
6
  export declare const REFRESH_USER_STATE_FROM_VALID_TOKEN_TRACKER_KEY = "refresh-user-state-from-valid-token";
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/modules/initializeClient/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0CAA0C,mCACrB,CAAC;AAEnC,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAE7E,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,eAAO,MAAM,iCAAiC,0BAA0B,CAAC;AAEzE,eAAO,MAAM,+CAA+C,wCACrB,CAAC"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/modules/initializeClient/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0CAA0C,mCACrB,CAAC;AAEnC,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAE7E,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AAErE,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,eAAO,MAAM,iCAAiC,0BAA0B,CAAC;AAEzE,eAAO,MAAM,+CAA+C,wCACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"initializeClient.d.ts","sourceRoot":"","sources":["../../../src/modules/initializeClient/initializeClient.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,gBAAgB,sDAE1B,OAAO,CAAC,IAAI,CAuKd,CAAC"}
1
+ {"version":3,"file":"initializeClient.d.ts","sourceRoot":"","sources":["../../../src/modules/initializeClient/initializeClient.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,gBAAgB,sDAE1B,OAAO,CAAC,IAAI,CAyKd,CAAC"}
@@ -1,14 +1,12 @@
1
1
  import type { ProjectSettings } from '../projectSettings.types';
2
- /**
3
- * Expiration time of the project settings in milliseconds.
4
- */
5
- export declare const PROJECT_SETTINGS_EXPIRATION_TIME: number;
6
2
  /**
7
3
  * Fetches and updates the project settings from the API.
8
4
  *
9
5
  * This function retrieves the latest project configuration settings
10
6
  * from Dynamic's servers, including authentication options, enabled chains,
11
- * and security configurations. The settings are cached for performance.
7
+ * and security configurations. It always performs a live fetch. If the API
8
+ * call fails, it falls back to the last known-good settings from storage,
9
+ * provided they were saved by a matching SDK API version.
12
10
  *
13
11
  * @example
14
12
  * ```ts
@@ -18,6 +16,7 @@ export declare const PROJECT_SETTINGS_EXPIRATION_TIME: number;
18
16
  *
19
17
  * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
20
18
  * @returns A promise that resolves to the updated project settings.
19
+ * @throws {Error} Rethrows the original fetch error when no matching-version cached settings exist.
21
20
  * @see createDynamicClient
22
21
  * @see initializeClient
23
22
  * @notInstrumented
@@ -1 +1 @@
1
- {"version":3,"file":"fetchProjectSettings.d.ts","sourceRoot":"","sources":["../../../../src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAShE;;GAEG;AACH,eAAO,MAAM,gCAAgC,QAAgB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,yDAE9B,OAAO,CAAC,eAAe,GAAG,IAAI,CA4ChC,CAAC"}
1
+ {"version":3,"file":"fetchProjectSettings.d.ts","sourceRoot":"","sources":["../../../../src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAShE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,yDAE9B,OAAO,CAAC,eAAe,GAAG,IAAI,CAiDhC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Deterministic canonical JSON: codepoint-sorted keys at every depth, arrays
3
+ * in order, `undefined` fields removed, no whitespace. Byte-identical to
4
+ * auth-service's `enclave/canonical-json`, which the enclave re-canonicalizes
5
+ * against when verifying signatures.
6
+ *
7
+ * @param obj - The document to canonicalize.
8
+ * @returns The canonical JSON string.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * canonicalizeJson({ b: 1, a: 2 }); // '{"a":2,"b":1}'
13
+ * ```
14
+ *
15
+ * @see {@link signBusinessAccountIntent} for the signature flow that depends on this byte sequence.
16
+ * @see {@link signBusinessAccountApproval} for the co-signer flow using the same canonical form.
17
+ * @notInstrumented
18
+ */
19
+ export declare const canonicalizeJson: (obj: Record<string, unknown>) => string;
20
+ //# sourceMappingURL=canonicalizeJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalizeJson.d.ts","sourceRoot":"","sources":["../../../../src/modules/sessionKeys/canonicalizeJson/canonicalizeJson.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,QAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { canonicalizeJson } from './canonicalizeJson';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/sessionKeys/canonicalizeJson/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}