@dynamic-labs-sdk/client 1.30.2 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/dist/{updateAuthFromVerifyResponse-CTvWpZLa.native.esm.js → apiClient-DpzKqY39.native.esm.js} +557 -465
  2. package/dist/apiClient-DpzKqY39.native.esm.js.map +1 -0
  3. package/dist/client/types/DynamicClient.d.ts +1 -1
  4. package/dist/client/types/DynamicClient.d.ts.map +1 -1
  5. package/dist/core.cjs +121 -61
  6. package/dist/core.cjs.map +1 -1
  7. package/dist/core.esm.js +64 -6
  8. package/dist/core.esm.js.map +1 -1
  9. package/dist/core.native.esm.js +64 -6
  10. package/dist/core.native.esm.js.map +1 -1
  11. package/dist/errors/WaasRbacStaleRetryUnsafeError.d.ts +36 -0
  12. package/dist/errors/WaasRbacStaleRetryUnsafeError.d.ts.map +1 -0
  13. package/dist/exports/core.d.ts +6 -0
  14. package/dist/exports/core.d.ts.map +1 -1
  15. package/dist/exports/index.d.ts +16 -4
  16. package/dist/exports/index.d.ts.map +1 -1
  17. package/dist/exports/waas.d.ts +3 -2
  18. package/dist/exports/waas.d.ts.map +1 -1
  19. package/dist/{getNetworkProviderFromNetworkId-CamHn2s3.esm.js → getNetworkProviderFromNetworkId-BN2jUhHm.esm.js} +8 -3
  20. package/dist/getNetworkProviderFromNetworkId-BN2jUhHm.esm.js.map +1 -0
  21. package/dist/{getNetworkProviderFromNetworkId-igDf2OPy.cjs → getNetworkProviderFromNetworkId-BoNAPSjx.cjs} +62 -51
  22. package/dist/getNetworkProviderFromNetworkId-BoNAPSjx.cjs.map +1 -0
  23. package/dist/{getNetworkProviderFromNetworkId--X0cb1ad.native.esm.js → getNetworkProviderFromNetworkId-DUym3Qq0.native.esm.js} +9 -4
  24. package/dist/getNetworkProviderFromNetworkId-DUym3Qq0.native.esm.js.map +1 -0
  25. package/dist/{getSignedSessionId-DGa_pu-i.cjs → getSignedSessionId-9ADIJCl1.cjs} +11 -11
  26. package/dist/{getSignedSessionId-DGa_pu-i.cjs.map → getSignedSessionId-9ADIJCl1.cjs.map} +1 -1
  27. package/dist/{getSignedSessionId--XNTxNFo.native.esm.js → getSignedSessionId-Dr4Ic68X.native.esm.js} +3 -3
  28. package/dist/{getSignedSessionId--XNTxNFo.native.esm.js.map → getSignedSessionId-Dr4Ic68X.native.esm.js.map} +1 -1
  29. package/dist/{getSignedSessionId-DY-ietfO.esm.js → getSignedSessionId-DxpqG4pv.esm.js} +3 -3
  30. package/dist/{getSignedSessionId-DY-ietfO.esm.js.map → getSignedSessionId-DxpqG4pv.esm.js.map} +1 -1
  31. package/dist/{getWalletProviderByKey-DzpmoNlv.cjs → getVerifiedCredentialForWalletAccount-C2o5idph.cjs} +10 -10
  32. package/dist/getVerifiedCredentialForWalletAccount-C2o5idph.cjs.map +1 -0
  33. package/dist/{getWalletProviderByKey-xqyD3ybv.esm.js → getVerifiedCredentialForWalletAccount-Cjwoeej7.esm.js} +10 -10
  34. package/dist/getVerifiedCredentialForWalletAccount-Cjwoeej7.esm.js.map +1 -0
  35. package/dist/index.cjs +677 -672
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.esm.js +47 -23
  38. package/dist/index.esm.js.map +1 -1
  39. package/dist/index.native.esm.js +47 -23
  40. package/dist/index.native.esm.js.map +1 -1
  41. package/dist/{isMfaRequiredForAction-CatS60F6.esm.js → isMfaRequiredForAction-BIBmJbV9.esm.js} +2 -2
  42. package/dist/isMfaRequiredForAction-BIBmJbV9.esm.js.map +1 -0
  43. package/dist/{isMfaRequiredForAction-BcJvy7Gw.native.esm.js → isMfaRequiredForAction-DuSU67yq.native.esm.js} +2 -2
  44. package/dist/isMfaRequiredForAction-DuSU67yq.native.esm.js.map +1 -0
  45. package/dist/{isMfaRequiredForAction-DKfoMhEk.cjs → isMfaRequiredForAction-yM84r7l7.cjs} +11 -11
  46. package/dist/isMfaRequiredForAction-yM84r7l7.cjs.map +1 -0
  47. package/dist/{isUserOnboardingComplete-BWVuE4Jg.native.esm.js → isUserOnboardingComplete-B2Ha2dkP.esm.js} +47 -4
  48. package/dist/isUserOnboardingComplete-B2Ha2dkP.esm.js.map +1 -0
  49. package/dist/{isUserOnboardingComplete-jv_idxWY.cjs → isUserOnboardingComplete-BRTOnK8V.cjs} +63 -14
  50. package/dist/isUserOnboardingComplete-BRTOnK8V.cjs.map +1 -0
  51. package/dist/{isUserOnboardingComplete-jkAQQVdP.esm.js → isUserOnboardingComplete-DCIlkCub.native.esm.js} +47 -4
  52. package/dist/isUserOnboardingComplete-DCIlkCub.native.esm.js.map +1 -0
  53. package/dist/{updateAuthFromVerifyResponse-BLgNMqwN.esm.js → logoutWithReason-DV89zJmJ.esm.js} +679 -587
  54. package/dist/logoutWithReason-DV89zJmJ.esm.js.map +1 -0
  55. package/dist/{updateAuthFromVerifyResponse-Dsw-eAro.cjs → logoutWithReason-DlA15deT.cjs} +691 -587
  56. package/dist/logoutWithReason-DlA15deT.cjs.map +1 -0
  57. package/dist/{getWalletProviderByKey-Cl6WDOoD.native.esm.js → logoutWithReason-HqGlUccb.native.esm.js} +19 -19
  58. package/dist/logoutWithReason-HqGlUccb.native.esm.js.map +1 -0
  59. package/dist/migrateFromFireblocks-CiOS4_Nq.esm.js +128 -0
  60. package/dist/migrateFromFireblocks-CiOS4_Nq.esm.js.map +1 -0
  61. package/dist/migrateFromFireblocks-CqIpxGRS.cjs +163 -0
  62. package/dist/migrateFromFireblocks-CqIpxGRS.cjs.map +1 -0
  63. package/dist/migrateFromFireblocks-DnQsGmIW.native.esm.js +128 -0
  64. package/dist/migrateFromFireblocks-DnQsGmIW.native.esm.js.map +1 -0
  65. package/dist/modules/apiClient/apiClient.types.d.ts +1 -1
  66. package/dist/modules/apiClient/apiClient.types.d.ts.map +1 -1
  67. package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
  68. package/dist/modules/apiClient/utils/rbacStaleMiddleware/createRbacStaleMiddleware.d.ts +10 -0
  69. package/dist/modules/apiClient/utils/rbacStaleMiddleware/createRbacStaleMiddleware.d.ts.map +1 -0
  70. package/dist/modules/auth/auth.types.d.ts +45 -0
  71. package/dist/modules/auth/auth.types.d.ts.map +1 -0
  72. package/dist/modules/auth/checkStepUpAuth/checkStepUpAuth.d.ts +2 -1
  73. package/dist/modules/auth/checkStepUpAuth/checkStepUpAuth.d.ts.map +1 -1
  74. package/dist/modules/auth/consts.d.ts +9 -0
  75. package/dist/modules/auth/consts.d.ts.map +1 -1
  76. package/dist/modules/auth/createVisit/createVisit.d.ts.map +1 -1
  77. package/dist/modules/auth/externalAuth/requestExternalAuthElevatedToken/requestExternalAuthElevatedToken.d.ts +1 -1
  78. package/dist/modules/auth/externalAuth/requestExternalAuthElevatedToken/requestExternalAuthElevatedToken.d.ts.map +1 -1
  79. package/dist/modules/auth/externalAuth/signInWithExternalJwt/signInWithExternalJwt.d.ts +1 -1
  80. package/dist/modules/auth/externalAuth/signInWithExternalJwt/signInWithExternalJwt.d.ts.map +1 -1
  81. package/dist/modules/auth/getActionAuthorizationTokens/getActionAuthorizationTokens.d.ts +2 -1
  82. package/dist/modules/auth/getActionAuthorizationTokens/getActionAuthorizationTokens.d.ts.map +1 -1
  83. package/dist/modules/auth/mergeUserAccounts/mergeUserAccounts.d.ts +4 -3
  84. package/dist/modules/auth/mergeUserAccounts/mergeUserAccounts.d.ts.map +1 -1
  85. package/dist/modules/auth/passkeys/getPasskeys/getPasskeys.d.ts +1 -1
  86. package/dist/modules/auth/passkeys/getPasskeys/getPasskeys.d.ts.map +1 -1
  87. package/dist/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts +2 -1
  88. package/dist/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts.map +1 -1
  89. package/dist/modules/auth/passkeys/serverAuthenticatePasskey/serverAuthenticatePasskey.d.ts +3 -1
  90. package/dist/modules/auth/passkeys/serverAuthenticatePasskey/serverAuthenticatePasskey.d.ts.map +1 -1
  91. package/dist/modules/auth/passkeys/serverRegisterPasskey/serverRegisterPasskey.d.ts +2 -1
  92. package/dist/modules/auth/passkeys/serverRegisterPasskey/serverRegisterPasskey.d.ts.map +1 -1
  93. package/dist/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts +1 -1
  94. package/dist/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts.map +1 -1
  95. package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts +1 -1
  96. package/dist/modules/auth/social/oauth/completeSocialAuthentication/completeSocialAuthentication.d.ts.map +1 -1
  97. package/dist/modules/auth/social/oauth/completeSocialRedirect/completeSocialRedirect.types.d.ts +1 -1
  98. package/dist/modules/auth/social/oauth/completeSocialRedirect/completeSocialRedirect.types.d.ts.map +1 -1
  99. package/dist/modules/auth/social/oauth/processSocialCallback/processSocialCallback.d.ts +1 -1
  100. package/dist/modules/auth/social/oauth/processSocialCallback/processSocialCallback.d.ts.map +1 -1
  101. package/dist/modules/auth/social/oauth/signInWithSocialPopUp/signInWithSocialPopUp.types.d.ts +1 -1
  102. package/dist/modules/auth/social/oauth/signInWithSocialPopUp/signInWithSocialPopUp.types.d.ts.map +1 -1
  103. package/dist/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts +1 -1
  104. package/dist/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts.map +1 -1
  105. package/dist/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.d.ts +1 -1
  106. package/dist/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.d.ts.map +1 -1
  107. package/dist/modules/balances/balances.types.d.ts +59 -0
  108. package/dist/modules/balances/balances.types.d.ts.map +1 -0
  109. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts +1 -1
  110. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts.map +1 -1
  111. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts +1 -1
  112. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts.map +1 -1
  113. package/dist/modules/checkout/broadcastCheckoutTransaction/broadcastCheckoutTransaction.d.ts +1 -1
  114. package/dist/modules/checkout/broadcastCheckoutTransaction/broadcastCheckoutTransaction.d.ts.map +1 -1
  115. package/dist/modules/checkout/checkout.types.d.ts +10 -2
  116. package/dist/modules/checkout/checkout.types.d.ts.map +1 -1
  117. package/dist/modules/deviceRegistration/completeDeviceRegistration/completeDeviceRegistration.d.ts +1 -1
  118. package/dist/modules/deviceRegistration/completeDeviceRegistration/completeDeviceRegistration.d.ts.map +1 -1
  119. package/dist/modules/deviceRegistration/deviceRegistration.types.d.ts +9 -0
  120. package/dist/modules/deviceRegistration/deviceRegistration.types.d.ts.map +1 -0
  121. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts +1 -1
  122. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts.map +1 -1
  123. package/dist/modules/funding/coinbase/coinbase.types.d.ts +2 -40
  124. package/dist/modules/funding/coinbase/coinbase.types.d.ts.map +1 -1
  125. package/dist/modules/funding/coinbase/createCoinbaseExchangeTransfer/createCoinbaseExchangeTransfer.d.ts +1 -1
  126. package/dist/modules/funding/coinbase/createCoinbaseExchangeTransfer/createCoinbaseExchangeTransfer.d.ts.map +1 -1
  127. package/dist/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/validateUserCredentialsForCoinbaseOnrampOrder.d.ts +2 -2
  128. package/dist/modules/funding/coinbase/utils/validateUserCredentialsForCoinbaseOnrampOrder/validateUserCredentialsForCoinbaseOnrampOrder.d.ts.map +1 -1
  129. package/dist/modules/funding/cryptoDotCom/cryptoDotCom.types.d.ts +2 -2
  130. package/dist/modules/funding/cryptoDotCom/cryptoDotCom.types.d.ts.map +1 -1
  131. package/dist/modules/funding/funding.types.d.ts +26 -0
  132. package/dist/modules/funding/funding.types.d.ts.map +1 -0
  133. package/dist/modules/funding/kraken/createKrakenExchangeTransfer/createKrakenExchangeTransfer.d.ts +4 -4
  134. package/dist/modules/funding/kraken/createKrakenExchangeTransfer/createKrakenExchangeTransfer.d.ts.map +1 -1
  135. package/dist/modules/mfa/authenticateMfaRecoveryCode/authenticateMfaRecoveryCode.d.ts +3 -1
  136. package/dist/modules/mfa/authenticateMfaRecoveryCode/authenticateMfaRecoveryCode.d.ts.map +1 -1
  137. package/dist/modules/mfa/authenticatePasskeyMFA/authenticatePasskeyMFA.d.ts +3 -1
  138. package/dist/modules/mfa/authenticatePasskeyMFA/authenticatePasskeyMFA.d.ts.map +1 -1
  139. package/dist/modules/mfa/authenticateTotpMfaDevice/authenticateTotpMfaDevice.d.ts +3 -1
  140. package/dist/modules/mfa/authenticateTotpMfaDevice/authenticateTotpMfaDevice.d.ts.map +1 -1
  141. package/dist/modules/mfa/createNewMfaRecoveryCodes/createNewMfaRecoveryCodes.d.ts +1 -1
  142. package/dist/modules/mfa/createNewMfaRecoveryCodes/createNewMfaRecoveryCodes.d.ts.map +1 -1
  143. package/dist/modules/mfa/getMfaDevices/getMfaDevices.d.ts +1 -1
  144. package/dist/modules/mfa/getMfaDevices/getMfaDevices.d.ts.map +1 -1
  145. package/dist/modules/mfa/getMfaMethods/getMfaMethods.d.ts +1 -1
  146. package/dist/modules/mfa/getMfaMethods/getMfaMethods.d.ts.map +1 -1
  147. package/dist/modules/mfa/getMfaRecoveryCodes/getMfaRecoveryCodes.d.ts +1 -1
  148. package/dist/modules/mfa/getMfaRecoveryCodes/getMfaRecoveryCodes.d.ts.map +1 -1
  149. package/dist/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.d.ts +1 -1
  150. package/dist/modules/mfa/isMfaRequiredForAction/isMfaRequiredForAction.d.ts.map +1 -1
  151. package/dist/modules/mfa/mfa.consts.d.ts +10 -0
  152. package/dist/modules/mfa/mfa.consts.d.ts.map +1 -0
  153. package/dist/modules/mfa/mfa.types.d.ts +66 -1
  154. package/dist/modules/mfa/mfa.types.d.ts.map +1 -1
  155. package/dist/modules/mfa/registerTotpMfaDevice/registerTotpMfaDevice.d.ts +1 -1
  156. package/dist/modules/mfa/registerTotpMfaDevice/registerTotpMfaDevice.d.ts.map +1 -1
  157. package/dist/modules/otp/verifyOTP/verifyOTP.d.ts +2 -1
  158. package/dist/modules/otp/verifyOTP/verifyOTP.d.ts.map +1 -1
  159. package/dist/modules/otp/verifyOTP/verifyOTPForUserSignIn/verifyOTPForUserSignIn.d.ts +1 -1
  160. package/dist/modules/otp/verifyOTP/verifyOTPForUserSignIn/verifyOTPForUserSignIn.d.ts.map +1 -1
  161. package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts +1 -1
  162. package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
  163. package/dist/modules/projectSettings/projectSettings.types.d.ts +15 -0
  164. package/dist/modules/projectSettings/projectSettings.types.d.ts.map +1 -0
  165. package/dist/modules/simulation/simulation.types.d.ts +27 -1
  166. package/dist/modules/simulation/simulation.types.d.ts.map +1 -1
  167. package/dist/modules/storageSync/schema.d.ts +2 -2
  168. package/dist/modules/storageSync/schema.d.ts.map +1 -1
  169. package/dist/modules/swap/swap.types.d.ts +15 -2
  170. package/dist/modules/swap/swap.types.d.ts.map +1 -1
  171. package/dist/modules/user/refreshAuth/refreshAuth.d.ts +2 -2
  172. package/dist/modules/user/refreshAuth/refreshAuth.d.ts.map +1 -1
  173. package/dist/modules/user/refreshUser/refreshUser.d.ts +3 -3
  174. package/dist/modules/user/refreshUser/refreshUser.d.ts.map +1 -1
  175. package/dist/modules/user/user.consts.d.ts +19 -0
  176. package/dist/modules/user/user.consts.d.ts.map +1 -0
  177. package/dist/modules/user/user.types.d.ts +22 -2
  178. package/dist/modules/user/user.types.d.ts.map +1 -1
  179. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts +4 -2
  180. package/dist/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.d.ts.map +1 -1
  181. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts +1 -1
  182. package/dist/modules/waas/businessAccounts/businessAccounts.types.d.ts.map +1 -1
  183. package/dist/modules/waas/createWaasProvider/createWaasProvider.d.ts.map +1 -1
  184. package/dist/modules/waas/getWalletAccountShareSets/getWalletAccountShareSets.d.ts +2 -2
  185. package/dist/modules/waas/getWalletAccountShareSets/getWalletAccountShareSets.d.ts.map +1 -1
  186. package/dist/modules/waas/injectWaasVerifiedCredentialFields/injectWaasVerifiedCredentialFields.d.ts +3 -1
  187. package/dist/modules/waas/injectWaasVerifiedCredentialFields/injectWaasVerifiedCredentialFields.d.ts.map +1 -1
  188. package/dist/modules/waas/policies/applyPolicyLayerBatch/applyPolicyLayerBatch.d.ts +2 -1
  189. package/dist/modules/waas/policies/applyPolicyLayerBatch/applyPolicyLayerBatch.d.ts.map +1 -1
  190. package/dist/modules/waas/policies/buildAllowAddressesRule/buildAllowAddressesRule.d.ts +1 -2
  191. package/dist/modules/waas/policies/buildAllowAddressesRule/buildAllowAddressesRule.d.ts.map +1 -1
  192. package/dist/modules/waas/policies/buildAllowPolicyRule/buildAllowPolicyRule.d.ts +1 -2
  193. package/dist/modules/waas/policies/buildAllowPolicyRule/buildAllowPolicyRule.d.ts.map +1 -1
  194. package/dist/modules/waas/policies/buildBlockExportRule/buildBlockExportRule.d.ts +1 -2
  195. package/dist/modules/waas/policies/buildBlockExportRule/buildBlockExportRule.d.ts.map +1 -1
  196. package/dist/modules/waas/policies/buildDenyAddressesRule/buildDenyAddressesRule.d.ts +1 -2
  197. package/dist/modules/waas/policies/buildDenyAddressesRule/buildDenyAddressesRule.d.ts.map +1 -1
  198. package/dist/modules/waas/policies/buildDenyPolicyRule/buildDenyPolicyRule.d.ts +1 -2
  199. package/dist/modules/waas/policies/buildDenyPolicyRule/buildDenyPolicyRule.d.ts.map +1 -1
  200. package/dist/modules/waas/policies/buildMaxAmountPerTransactionRule/buildMaxAmountPerTransactionRule.d.ts +1 -2
  201. package/dist/modules/waas/policies/buildMaxAmountPerTransactionRule/buildMaxAmountPerTransactionRule.d.ts.map +1 -1
  202. package/dist/modules/waas/policies/buildOperationForExistingRule/buildOperationForExistingRule.d.ts +3 -2
  203. package/dist/modules/waas/policies/buildOperationForExistingRule/buildOperationForExistingRule.d.ts.map +1 -1
  204. package/dist/modules/waas/policies/buildOperationsForRule/buildOperationsForRule.d.ts +2 -2
  205. package/dist/modules/waas/policies/buildOperationsForRule/buildOperationsForRule.d.ts.map +1 -1
  206. package/dist/modules/waas/policies/createPolicy/createPolicy.d.ts +2 -1
  207. package/dist/modules/waas/policies/createPolicy/createPolicy.d.ts.map +1 -1
  208. package/dist/modules/waas/policies/desugarPolicyRules/desugarPolicyRules.d.ts +1 -2
  209. package/dist/modules/waas/policies/desugarPolicyRules/desugarPolicyRules.d.ts.map +1 -1
  210. package/dist/modules/waas/policies/expandPolicyRules/expandPolicyRules.d.ts +2 -2
  211. package/dist/modules/waas/policies/expandPolicyRules/expandPolicyRules.d.ts.map +1 -1
  212. package/dist/modules/waas/policies/fillOmittedRuleValues/fillOmittedRuleValues.d.ts +1 -2
  213. package/dist/modules/waas/policies/fillOmittedRuleValues/fillOmittedRuleValues.d.ts.map +1 -1
  214. package/dist/modules/waas/policies/findMatchedRuleKind/findMatchedRuleKind.d.ts +1 -2
  215. package/dist/modules/waas/policies/findMatchedRuleKind/findMatchedRuleKind.d.ts.map +1 -1
  216. package/dist/modules/waas/policies/getAccountPolicyLayer/getAccountPolicyLayer.d.ts +1 -1
  217. package/dist/modules/waas/policies/getAccountPolicyLayer/getAccountPolicyLayer.d.ts.map +1 -1
  218. package/dist/modules/waas/policies/getPolicy/getPolicy.d.ts +2 -2
  219. package/dist/modules/waas/policies/getPolicy/getPolicy.d.ts.map +1 -1
  220. package/dist/modules/waas/policies/getResolvedPolicyLayer/getResolvedPolicyLayer.d.ts +1 -1
  221. package/dist/modules/waas/policies/getResolvedPolicyLayer/getResolvedPolicyLayer.d.ts.map +1 -1
  222. package/dist/modules/waas/policies/getSignerPolicyLayer/getSignerPolicyLayer.d.ts +1 -1
  223. package/dist/modules/waas/policies/getSignerPolicyLayer/getSignerPolicyLayer.d.ts.map +1 -1
  224. package/dist/modules/waas/policies/getWalletPolicyLayer/getWalletPolicyLayer.d.ts +1 -1
  225. package/dist/modules/waas/policies/getWalletPolicyLayer/getWalletPolicyLayer.d.ts.map +1 -1
  226. package/dist/modules/waas/policies/hasAddresses/hasAddresses.d.ts +1 -1
  227. package/dist/modules/waas/policies/hasAddresses/hasAddresses.d.ts.map +1 -1
  228. package/dist/modules/waas/policies/hasUnrecognizedFields/hasUnrecognizedFields.d.ts +1 -1
  229. package/dist/modules/waas/policies/hasUnrecognizedFields/hasUnrecognizedFields.d.ts.map +1 -1
  230. package/dist/modules/waas/policies/isPolicyRuleDeletionMarker/isPolicyRuleDeletionMarker.d.ts +1 -2
  231. package/dist/modules/waas/policies/isPolicyRuleDeletionMarker/isPolicyRuleDeletionMarker.d.ts.map +1 -1
  232. package/dist/modules/waas/policies/matchExistingRules/matchExistingRules.d.ts +1 -1
  233. package/dist/modules/waas/policies/matchExistingRules/matchExistingRules.d.ts.map +1 -1
  234. package/dist/modules/waas/policies/policies.types.d.ts +17 -1
  235. package/dist/modules/waas/policies/policies.types.d.ts.map +1 -1
  236. package/dist/modules/waas/policies/policyRuleKinds.d.ts +1 -2
  237. package/dist/modules/waas/policies/policyRuleKinds.d.ts.map +1 -1
  238. package/dist/modules/waas/policies/readAllowAddressesRule/readAllowAddressesRule.d.ts +1 -2
  239. package/dist/modules/waas/policies/readAllowAddressesRule/readAllowAddressesRule.d.ts.map +1 -1
  240. package/dist/modules/waas/policies/readBlockExportRule/readBlockExportRule.d.ts +1 -2
  241. package/dist/modules/waas/policies/readBlockExportRule/readBlockExportRule.d.ts.map +1 -1
  242. package/dist/modules/waas/policies/readCoveredRule/readCoveredRule.d.ts +1 -2
  243. package/dist/modules/waas/policies/readCoveredRule/readCoveredRule.d.ts.map +1 -1
  244. package/dist/modules/waas/policies/readDenyAddressesRule/readDenyAddressesRule.d.ts +1 -2
  245. package/dist/modules/waas/policies/readDenyAddressesRule/readDenyAddressesRule.d.ts.map +1 -1
  246. package/dist/modules/waas/policies/readMaxAmountPerTransactionRule/readMaxAmountPerTransactionRule.d.ts +1 -2
  247. package/dist/modules/waas/policies/readMaxAmountPerTransactionRule/readMaxAmountPerTransactionRule.d.ts.map +1 -1
  248. package/dist/modules/waas/policies/removeAccountPolicyRule/removeAccountPolicyRule.d.ts +1 -1
  249. package/dist/modules/waas/policies/removeAccountPolicyRule/removeAccountPolicyRule.d.ts.map +1 -1
  250. package/dist/modules/waas/policies/removePolicyRules/removePolicyRules.d.ts +2 -1
  251. package/dist/modules/waas/policies/removePolicyRules/removePolicyRules.d.ts.map +1 -1
  252. package/dist/modules/waas/policies/removeSignerPolicyRule/removeSignerPolicyRule.d.ts +1 -1
  253. package/dist/modules/waas/policies/removeSignerPolicyRule/removeSignerPolicyRule.d.ts.map +1 -1
  254. package/dist/modules/waas/policies/removeWalletPolicyRule/removeWalletPolicyRule.d.ts +1 -1
  255. package/dist/modules/waas/policies/removeWalletPolicyRule/removeWalletPolicyRule.d.ts.map +1 -1
  256. package/dist/modules/waas/policies/resolveRuleName/resolveRuleName.d.ts +1 -2
  257. package/dist/modules/waas/policies/resolveRuleName/resolveRuleName.d.ts.map +1 -1
  258. package/dist/modules/waas/policies/sortRulesByRuleId/sortRulesByRuleId.d.ts +1 -1
  259. package/dist/modules/waas/policies/sortRulesByRuleId/sortRulesByRuleId.d.ts.map +1 -1
  260. package/dist/modules/waas/policies/upsertAccountPolicyRule/upsertAccountPolicyRule.d.ts +2 -1
  261. package/dist/modules/waas/policies/upsertAccountPolicyRule/upsertAccountPolicyRule.d.ts.map +1 -1
  262. package/dist/modules/waas/policies/upsertSignerPolicyRule/upsertSignerPolicyRule.d.ts +2 -1
  263. package/dist/modules/waas/policies/upsertSignerPolicyRule/upsertSignerPolicyRule.d.ts.map +1 -1
  264. package/dist/modules/waas/policies/upsertWalletPolicyRule/upsertWalletPolicyRule.d.ts +2 -1
  265. package/dist/modules/waas/policies/upsertWalletPolicyRule/upsertWalletPolicyRule.d.ts.map +1 -1
  266. package/dist/modules/waas/waas.consts.d.ts +23 -0
  267. package/dist/modules/waas/waas.consts.d.ts.map +1 -0
  268. package/dist/modules/waas/waas.types.d.ts +30 -1
  269. package/dist/modules/waas/waas.types.d.ts.map +1 -1
  270. package/dist/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.d.ts +2 -2
  271. package/dist/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.d.ts.map +1 -1
  272. package/dist/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts +2 -2
  273. package/dist/modules/wallets/networks/getTransactionHistory/getTransactionHistory.d.ts.map +1 -1
  274. package/dist/modules/wallets/screenTransaction/screenTransaction.d.ts +1 -1
  275. package/dist/modules/wallets/screenTransaction/screenTransaction.d.ts.map +1 -1
  276. package/dist/modules/wallets/userHasEmbeddedWalletForChain/userHasEmbeddedWalletForChain.d.ts +2 -2
  277. package/dist/modules/wallets/userHasEmbeddedWalletForChain/userHasEmbeddedWalletForChain.d.ts.map +1 -1
  278. package/dist/modules/wallets/userHasExternalWallet/userHasExternalWallet.d.ts +2 -2
  279. package/dist/modules/wallets/userHasExternalWallet/userHasExternalWallet.d.ts.map +1 -1
  280. package/dist/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.d.ts +1 -1
  281. package/dist/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.d.ts.map +1 -1
  282. package/dist/modules/wallets/verifyMessageSignatureOwnership/verifyMessageSignatureOwnership.d.ts +5 -3
  283. package/dist/modules/wallets/verifyMessageSignatureOwnership/verifyMessageSignatureOwnership.d.ts.map +1 -1
  284. package/dist/modules/wallets/verifyWalletAccount/verifyWalletAccount.d.ts +1 -1
  285. package/dist/modules/wallets/verifyWalletAccount/verifyWalletAccount.d.ts.map +1 -1
  286. package/dist/modules/wallets/verifyWalletAccountForSignInOrTransfer/verifyWalletAccountForSignInOrTransfer.d.ts +1 -1
  287. package/dist/modules/wallets/verifyWalletAccountForSignInOrTransfer/verifyWalletAccountForSignInOrTransfer.d.ts.map +1 -1
  288. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +4 -2
  289. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
  290. package/dist/modules/wallets/wallets.types.d.ts +47 -0
  291. package/dist/modules/wallets/wallets.types.d.ts.map +1 -0
  292. package/dist/modules/yield/yield.types.d.ts +8 -0
  293. package/dist/modules/yield/yield.types.d.ts.map +1 -1
  294. package/dist/services/eventEmitter/createEventEmitter.d.ts +3 -2
  295. package/dist/services/eventEmitter/createEventEmitter.d.ts.map +1 -1
  296. package/dist/services/eventEmitter/index.d.ts +1 -1
  297. package/dist/services/eventEmitter/index.d.ts.map +1 -1
  298. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  299. package/dist/utils/createSequenceQueue/createSequenceQueue.d.ts +52 -0
  300. package/dist/utils/createSequenceQueue/createSequenceQueue.d.ts.map +1 -0
  301. package/dist/utils/createSequenceQueue/index.d.ts +3 -0
  302. package/dist/utils/createSequenceQueue/index.d.ts.map +1 -0
  303. package/dist/waas-BOKafCeH.cjs +2467 -0
  304. package/dist/waas-BOKafCeH.cjs.map +1 -0
  305. package/dist/waas-CUDgU2pl.esm.js +2150 -0
  306. package/dist/waas-CUDgU2pl.esm.js.map +1 -0
  307. package/dist/waas-CkQYVo6U.native.esm.js +2150 -0
  308. package/dist/waas-CkQYVo6U.native.esm.js.map +1 -0
  309. package/dist/waas.cjs +60 -2185
  310. package/dist/waas.esm.js +5 -2126
  311. package/dist/waas.native.esm.js +5 -2126
  312. package/dist/waasCore.cjs +76 -44
  313. package/dist/waasCore.cjs.map +1 -1
  314. package/dist/waasCore.esm.js +56 -24
  315. package/dist/waasCore.esm.js.map +1 -1
  316. package/dist/waasCore.native.esm.js +56 -24
  317. package/dist/waasCore.native.esm.js.map +1 -1
  318. package/package.json +5 -5
  319. package/dist/getNetworkProviderFromNetworkId--X0cb1ad.native.esm.js.map +0 -1
  320. package/dist/getNetworkProviderFromNetworkId-CamHn2s3.esm.js.map +0 -1
  321. package/dist/getNetworkProviderFromNetworkId-igDf2OPy.cjs.map +0 -1
  322. package/dist/getWalletProviderByKey-Cl6WDOoD.native.esm.js.map +0 -1
  323. package/dist/getWalletProviderByKey-DzpmoNlv.cjs.map +0 -1
  324. package/dist/getWalletProviderByKey-xqyD3ybv.esm.js.map +0 -1
  325. package/dist/isDynamicWaasEnabled-CMccs1-6.cjs +0 -136
  326. package/dist/isDynamicWaasEnabled-CMccs1-6.cjs.map +0 -1
  327. package/dist/isDynamicWaasEnabled-DSqgpEcX.native.esm.js +0 -113
  328. package/dist/isDynamicWaasEnabled-DSqgpEcX.native.esm.js.map +0 -1
  329. package/dist/isDynamicWaasEnabled-DYORq7Jc.esm.js +0 -113
  330. package/dist/isDynamicWaasEnabled-DYORq7Jc.esm.js.map +0 -1
  331. package/dist/isMfaRequiredForAction-BcJvy7Gw.native.esm.js.map +0 -1
  332. package/dist/isMfaRequiredForAction-CatS60F6.esm.js.map +0 -1
  333. package/dist/isMfaRequiredForAction-DKfoMhEk.cjs.map +0 -1
  334. package/dist/isUserOnboardingComplete-BWVuE4Jg.native.esm.js.map +0 -1
  335. package/dist/isUserOnboardingComplete-jkAQQVdP.esm.js.map +0 -1
  336. package/dist/isUserOnboardingComplete-jv_idxWY.cjs.map +0 -1
  337. package/dist/migrateFromFireblocks-B-WUs34v.native.esm.js +0 -65
  338. package/dist/migrateFromFireblocks-B-WUs34v.native.esm.js.map +0 -1
  339. package/dist/migrateFromFireblocks-D4E9bT2H.esm.js +0 -65
  340. package/dist/migrateFromFireblocks-D4E9bT2H.esm.js.map +0 -1
  341. package/dist/migrateFromFireblocks-zp5Jbq2J.cjs +0 -82
  342. package/dist/migrateFromFireblocks-zp5Jbq2J.cjs.map +0 -1
  343. package/dist/updateAuthFromVerifyResponse-BLgNMqwN.esm.js.map +0 -1
  344. package/dist/updateAuthFromVerifyResponse-CTvWpZLa.native.esm.js.map +0 -1
  345. package/dist/updateAuthFromVerifyResponse-Dsw-eAro.cjs.map +0 -1
  346. package/dist/waas.cjs.map +0 -1
  347. package/dist/waas.esm.js.map +0 -1
  348. package/dist/waas.native.esm.js.map +0 -1
@@ -0,0 +1,2150 @@
1
+ import { E as isWaasWalletProvider, Et as version, R as getWalletAccounts, St as getCore, T as findWaasWalletProviderByChain, Tt as name, V as getChainFromVerifiedCredentialChain, b as InvalidParamError, c as createApiClient, k as DYNAMIC_WAAS_METADATA, l as __refreshAuth_wrapped, mt as assertDefined, s as NoWalletProviderFoundError, t as __logoutWithReason_wrapped, w as isWaasWalletAccount, yt as getDefaultClient, z as formatWalletProviderKey } from "./logoutWithReason-DV89zJmJ.esm.js";
2
+ import { n as isDynamicWaasEnabled, o as NotWaasWalletProviderError, r as getWaasWalletProviderFromWalletAccount } from "./migrateFromFireblocks-CiOS4_Nq.esm.js";
3
+ import { n as getWalletProviderByKey, t as getVerifiedCredentialForWalletAccount } from "./getVerifiedCredentialForWalletAccount-Cjwoeej7.esm.js";
4
+ import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
5
+ import { AssignableBusinessAccountMemberRole, JwtVerifiedCredentialFormatEnum, TokenScope, UserIdentifierTypeEnum, WaasChainEnum, WaasPolicyLayerRuleOperationOpEnum, WaasPolicyLayerUpdateRequestOpEnum, WaasPolicyRuleType, WaasSignerPolicyLayerUpdateRequestOpEnum, WaasWalletShareSetType, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
6
+
7
+ //#region src/modules/waas/waas.consts.ts
8
+ /**
9
+ * Identifies the chain family targeted by WaaS policy operations.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const chain: WaasChainEnum = WaasChainEnum.Evm;
14
+ * ```
15
+ *
16
+ * @see createPolicy
17
+ * @see getPolicy
18
+ */
19
+ const WaasChainEnum$1 = WaasChainEnum;
20
+ /**
21
+ * Identifies the role of a share set exposed through a WaaS wallet account.
22
+ *
23
+ * @see getWalletAccountShareSets
24
+ * @see WaasWalletAccount
25
+ */
26
+ const WaasWalletShareSetType$1 = WaasWalletShareSetType;
27
+
28
+ //#endregion
29
+ //#region src/modules/waas/businessAccounts/assertTargetIdentity.ts
30
+ /**
31
+ * Asserts a {@link TargetIdentity} resolves to a user: a `userId`, or an
32
+ * `identifier` with its `identifierType`. Throws otherwise.
33
+ *
34
+ * @notInstrumented
35
+ */
36
+ const assertTargetIdentity = ({ fnName, targetIdentity }) => {
37
+ const hasUserId = Boolean(targetIdentity.userId);
38
+ const hasIdentifier = Boolean(targetIdentity.identifier && targetIdentity.identifierType);
39
+ if (!hasUserId && !hasIdentifier) throw new InvalidParamError(`${fnName}: targetIdentity must provide a userId, or an identifier with its identifierType`);
40
+ };
41
+
42
+ //#endregion
43
+ //#region src/modules/waas/businessAccounts/businessAccounts.constants.ts
44
+ /** Maps the SDK's identifier-type union to the generated API enum. */
45
+ const IDENTIFIER_TYPE_TO_API = {
46
+ email: UserIdentifierTypeEnum.Email,
47
+ externalUserId: UserIdentifierTypeEnum.ExternalUserId,
48
+ id: UserIdentifierTypeEnum.Id,
49
+ phoneNumber: UserIdentifierTypeEnum.PhoneNumber,
50
+ socialAccountId: UserIdentifierTypeEnum.SocialAccountId,
51
+ socialUsername: UserIdentifierTypeEnum.SocialUsername
52
+ };
53
+
54
+ //#endregion
55
+ //#region src/modules/waas/businessAccounts/addBusinessAccountMember/addBusinessAccountMember.ts
56
+ /**
57
+ * Adds a member to an existing business account. Identify the target with a
58
+ * `targetIdentity`: a known `userId`, or an `identifier` + `identifierType`
59
+ * (e.g. an email — the user is created if absent).
60
+ *
61
+ * Calls the SDK API directly (not the WaaS iframe): this is a server-state
62
+ * mutation with no MPC step, so a rejection (e.g. a 422 resource-limit) surfaces
63
+ * as a thrown error rather than stalling in the iframe bridge.
64
+ *
65
+ * @param params.businessAccountId - The ID of the business account.
66
+ * @param params.targetIdentity - The member to add (userId, or identifier + identifierType).
67
+ * @param [params.role] - The member role (`admin` or `viewer`). Defaults to `viewer`.
68
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
69
+ * @returns The created business account member.
70
+ * @notInstrumented
71
+ */
72
+ const addBusinessAccountMember = async ({ businessAccountId, targetIdentity, role }, client = getDefaultClient()) => {
73
+ assertTargetIdentity({
74
+ fnName: "addBusinessAccountMember",
75
+ targetIdentity
76
+ });
77
+ const core = getCore(client);
78
+ const apiClient = createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountmemberadd }, client);
79
+ const { userId, identifier, identifierType, socialProvider, smsCountryCode } = targetIdentity;
80
+ return await apiClient.sdkAddBusinessAccountMember({
81
+ addBusinessAccountMemberSdkRequest: {
82
+ identifier,
83
+ role: role === "admin" ? AssignableBusinessAccountMemberRole.Admin : AssignableBusinessAccountMemberRole.Viewer,
84
+ smsCountryCode,
85
+ socialProvider,
86
+ type: identifierType ? IDENTIFIER_TYPE_TO_API[identifierType] : void 0,
87
+ userId
88
+ },
89
+ businessAccountId,
90
+ environmentId: core.environmentId
91
+ });
92
+ };
93
+
94
+ //#endregion
95
+ //#region src/modules/waas/getWaasWalletProviderByChain/getWaasWalletProviderByChain.ts
96
+ /** @notInstrumented */
97
+ const getWaasWalletProviderByChain = ({ chain }, client) => {
98
+ const waasProvider = findWaasWalletProviderByChain({ chain }, client);
99
+ if (!waasProvider) throw new NoWalletProviderFoundError({ walletProviderKey: formatWalletProviderKey({
100
+ chain,
101
+ displayName: DYNAMIC_WAAS_METADATA.displayName,
102
+ walletProviderType: WalletProviderEnum.EmbeddedWallet
103
+ }) });
104
+ return waasProvider;
105
+ };
106
+
107
+ //#endregion
108
+ //#region src/modules/waas/businessAccounts/addBusinessAccountSigner/addBusinessAccountSigner.ts
109
+ /**
110
+ * Adds a signer to a business-account wallet via the reshare ceremony, minting
111
+ * the new signer's share set. Identify the target by `userId`, or `identifier`
112
+ * + `identifierType` (the user is created if absent).
113
+ *
114
+ * Omit `businessAccountId` to add a signer to a wallet that isn't in a business
115
+ * account yet: the wallet's per-account is found-or-created first (idempotent —
116
+ * converts the personal wallet, seating its owner as the first signer), then
117
+ * the new signer is reshared in.
118
+ *
119
+ * @param params.walletAccount - The wallet account to add the signer to.
120
+ * @param [params.businessAccountId] - The business account; found-or-created when omitted.
121
+ * @param [params.walletId] - The wallet UUID to link when finding-or-creating; defaults to `walletAccount.verifiedCredentialId`.
122
+ * @param params.targetIdentity - The signer to add (userId, or identifier + identifierType).
123
+ * @param [params.signerType] - `endUser` (default) or `server`.
124
+ * @param [params.password] - Password for the current signer's share, if it is password-encrypted.
125
+ * @param [params.targetSignerPassword] - Password used to encrypt the new signer's share. Required when wallet passwords are required by the environment.
126
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
127
+ * @returns The new signer's share set id.
128
+ * @notInstrumented
129
+ */
130
+ const addBusinessAccountSigner = async ({ walletAccount, businessAccountId, walletId, targetIdentity, signerType, password, targetSignerPassword }, client = getDefaultClient()) => {
131
+ assertTargetIdentity({
132
+ fnName: "addBusinessAccountSigner",
133
+ targetIdentity
134
+ });
135
+ if (walletAccount.businessAccountId) assertDefined(businessAccountId, "addBusinessAccountSigner: this wallet is already part of a business account");
136
+ let resolvedBusinessAccountId = businessAccountId;
137
+ if (!resolvedBusinessAccountId) {
138
+ const linkWalletId = walletId ?? walletAccount.verifiedCredentialId;
139
+ assertDefined(linkWalletId, "addBusinessAccountSigner: cannot resolve a wallet id to link — pass walletId, or use a verified wallet account");
140
+ const core = getCore(client);
141
+ resolvedBusinessAccountId = (await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountsigneradd }, client).sdkLinkBusinessAccountWallet({
142
+ environmentId: core.environmentId,
143
+ linkBusinessAccountWalletSdkRequest: { walletId: linkWalletId }
144
+ })).id;
145
+ }
146
+ const result = await getWaasWalletProviderByChain({ chain: walletAccount.chain }, client).reshareToNewSignerShareSet({
147
+ businessAccountId: resolvedBusinessAccountId,
148
+ password,
149
+ signerType,
150
+ targetSignerIdentity: targetIdentity,
151
+ targetSignerPassword,
152
+ walletAccount
153
+ });
154
+ await __refreshAuth_wrapped(client);
155
+ return result;
156
+ };
157
+
158
+ //#endregion
159
+ //#region src/modules/waas/businessAccounts/addWalletToBusinessAccount/addWalletToBusinessAccount.ts
160
+ /**
161
+ * Links a wallet to a business account, or omit `businessAccountId` to
162
+ * find-or-create the per-wallet business account (the server seats the wallet's
163
+ * owner as the first member/signer).
164
+ *
165
+ * Calls the SDK API directly (not the WaaS iframe): this is a server-state
166
+ * mutation with no MPC step, so a rejection (e.g. a 422 resource-limit) surfaces
167
+ * as a thrown error rather than stalling in the iframe bridge.
168
+ *
169
+ * @param [params.businessAccountId] - The business account to link to; found-or-created when omitted.
170
+ * @param params.walletId - The ID of the wallet to link.
171
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
172
+ * @returns The updated business account detail.
173
+ * @notInstrumented
174
+ */
175
+ const addWalletToBusinessAccount = async ({ businessAccountId, walletId }, client = getDefaultClient()) => {
176
+ const core = getCore(client);
177
+ const detail = await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountlinkWallet }, client).sdkLinkBusinessAccountWallet({
178
+ environmentId: core.environmentId,
179
+ linkBusinessAccountWalletSdkRequest: {
180
+ businessAccountId,
181
+ walletId
182
+ }
183
+ });
184
+ await __refreshAuth_wrapped(client);
185
+ return detail;
186
+ };
187
+
188
+ //#endregion
189
+ //#region src/modules/waas/backupWaasKeySharesToGoogleDrive/backupWaasKeySharesToGoogleDrive.ts
190
+ /**
191
+ * Backs up WaaS wallet key shares to Google Drive for secure recovery.
192
+ *
193
+ * This function creates a backup of the wallet's cryptographic key shares
194
+ * to Google Drive, allowing users to recover their wallet later.
195
+ *
196
+ * @param params.walletAccount - The WaaS wallet account to backup.
197
+ * @param [params.password] - Optional password to encrypt the backup.
198
+ * @param [params.googleDriveAccessToken] - Optional consumer-supplied Drive-scoped access token; used directly instead of the stored OAuth token (avoids a second Google consent). Useful for external-auth setups.
199
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
200
+ * @returns A promise that resolves when the backup process is complete.
201
+ * @notInstrumented
202
+ */
203
+ const backupWaasKeySharesToGoogleDrive = async ({ googleDriveAccessToken, password, walletAccount }, client = getDefaultClient()) => {
204
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).backupKeySharesToGoogleDrive({
205
+ googleDriveAccessToken,
206
+ password,
207
+ walletAccount
208
+ });
209
+ };
210
+
211
+ //#endregion
212
+ //#region src/modules/waas/policies/buildAllowPolicyRule/buildAllowPolicyRule.ts
213
+ /**
214
+ * Builds a policy rule that permits the described action.
215
+ *
216
+ * @param rule - The rule fields (name, chain, and any targeting/limit fields).
217
+ * @returns A `WaasPolicyRule` with `ruleType` set to `allow`.
218
+ * @notInstrumented
219
+ */
220
+ const buildAllowPolicyRule = (rule) => ({
221
+ ...rule,
222
+ ruleType: WaasPolicyRuleType.Allow
223
+ });
224
+
225
+ //#endregion
226
+ //#region src/modules/waas/policies/buildDenyPolicyRule/buildDenyPolicyRule.ts
227
+ /**
228
+ * Builds a policy rule that blocks the described action.
229
+ *
230
+ * @param rule - The rule fields (name, chain, and any targeting/limit fields).
231
+ * @returns A `WaasPolicyRule` with `ruleType` set to `deny`.
232
+ * @notInstrumented
233
+ */
234
+ const buildDenyPolicyRule = (rule) => ({
235
+ ...rule,
236
+ ruleType: WaasPolicyRuleType.Deny
237
+ });
238
+
239
+ //#endregion
240
+ //#region src/modules/waas/businessAccounts/createBusinessAccount/createBusinessAccount.ts
241
+ /**
242
+ * Creates a new business account.
243
+ *
244
+ * @param [params] - Optional parameters for the business account.
245
+ * @param [params.name] - Optional name for the business account.
246
+ * @param [params.externalRef] - Optional developer-supplied label (not unique; accounts may share one).
247
+ * @param [params.metadata] - Optional arbitrary key-value metadata.
248
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
249
+ * @returns The created business account.
250
+ * @notInstrumented
251
+ */
252
+ const createBusinessAccount = async (params, client = getDefaultClient()) => {
253
+ const core = getCore(client);
254
+ const result = await createApiClient({}, client).sdkCreateBusinessAccount({
255
+ createBusinessAccountSdkRequest: {
256
+ externalRef: params?.externalRef,
257
+ metadata: params?.metadata,
258
+ name: params?.name
259
+ },
260
+ environmentId: core.environmentId
261
+ });
262
+ await __refreshAuth_wrapped(client);
263
+ return result;
264
+ };
265
+
266
+ //#endregion
267
+ //#region src/modules/waas/policies/applyPolicyLayerBatch/applyPolicyLayerBatch.ts
268
+ /**
269
+ * Applies a batch of rule operations to the policy layer a
270
+ * {@link ResolvedPolicyScope} points at, atomically in one enclave cycle.
271
+ * Shared by {@link createPolicy} and {@link removePolicyRules} so the
272
+ * account-vs-wallet-vs-signer branch is written once.
273
+ *
274
+ * @notInstrumented
275
+ */
276
+ const applyPolicyLayerBatch = ({ operations, resolvedScope }, client) => {
277
+ const { environmentId } = getCore(client);
278
+ const apiClient = createApiClient({}, client);
279
+ switch (resolvedScope.target) {
280
+ case "account": return apiClient.updateBusinessAccountPolicyLayer({
281
+ businessAccountId: resolvedScope.businessAccountId,
282
+ environmentId,
283
+ waasPolicyLayerUpdateRequest: {
284
+ op: WaasPolicyLayerUpdateRequestOpEnum.Batch,
285
+ operations
286
+ }
287
+ });
288
+ case "wallet": return apiClient.updateWaasWalletSelfPolicyLayer({
289
+ environmentId,
290
+ waasPolicyLayerUpdateRequest: {
291
+ op: WaasPolicyLayerUpdateRequestOpEnum.Batch,
292
+ operations
293
+ },
294
+ walletId: resolvedScope.walletId
295
+ });
296
+ case "signer": return apiClient.updateWaasSignerSelfPolicyLayer({
297
+ environmentId,
298
+ waasSignerPolicyLayerUpdateRequest: {
299
+ op: WaasSignerPolicyLayerUpdateRequestOpEnum.Batch,
300
+ operations,
301
+ shareSetId: resolvedScope.shareSetId
302
+ },
303
+ walletId: resolvedScope.walletId
304
+ });
305
+ default: {
306
+ const unhandledScope = resolvedScope;
307
+ throw new InvalidParamError(`applyPolicyLayerBatch: unhandled target "${JSON.stringify(unhandledScope)}"`);
308
+ }
309
+ }
310
+ };
311
+
312
+ //#endregion
313
+ //#region src/utils/objectKeys/objectKeys.ts
314
+ /**
315
+ * Typed `Object.keys` — returns `(keyof T)[]` instead of `string[]`, for
316
+ * objects whose key set is fully known at the type level.
317
+ *
318
+ * @notInstrumented
319
+ */
320
+ const objectKeys = (value) => Object.keys(value);
321
+
322
+ //#endregion
323
+ //#region src/modules/waas/policies/buildValueLimit/buildValueLimit.ts
324
+ /**
325
+ * Turns a {@link PolicyRuleMaxAmountPerTransaction} into the `valueLimit` shape a rule stores it as.
326
+ * @notInstrumented
327
+ */
328
+ const buildValueLimit = ({ amount, asset }) => ({
329
+ asset,
330
+ maxPerCall: amount
331
+ });
332
+
333
+ //#endregion
334
+ //#region src/modules/waas/policies/policyRuleDefaultNames.ts
335
+ /**
336
+ * Each rule kind's name when the caller doesn't override it via
337
+ * `PolicyRules['names']`. Shared between the `build*Rule` functions and
338
+ * `desugarPolicyRules` so a rename can't drift the two out of sync — the
339
+ * same reason `RULE_KINDS` in `policyRuleKinds.ts` is a single table
340
+ * instead of parallel switches.
341
+ */
342
+ const DEFAULT_POLICY_RULE_NAMES = {
343
+ allowAddresses: "Allowed addresses",
344
+ blockExport: "Block key export",
345
+ denyAddresses: "Denied addresses",
346
+ maxAmountPerTransaction: "Per-transaction cap"
347
+ };
348
+
349
+ //#endregion
350
+ //#region src/modules/waas/policies/buildAllowAddressesRule/buildAllowAddressesRule.ts
351
+ /**
352
+ * Builds the `allowAddresses` rule, absorbing a sibling
353
+ * `maxAmountPerTransaction` onto the same rule instead of letting it emit
354
+ * its own — see `buildMaxAmountPerTransactionRule`.
355
+ * @notInstrumented
356
+ */
357
+ const buildAllowAddressesRule = ({ context: { chain, chainIds }, rules }) => {
358
+ if (!rules.allowAddresses || rules.allowAddresses.length === 0) return void 0;
359
+ return {
360
+ addresses: rules.allowAddresses,
361
+ chain,
362
+ chainIds,
363
+ name: rules.names?.allowAddresses ?? DEFAULT_POLICY_RULE_NAMES.allowAddresses,
364
+ ruleType: WaasPolicyRuleType.Allow,
365
+ ...rules.maxAmountPerTransaction ? { valueLimit: buildValueLimit(rules.maxAmountPerTransaction) } : {}
366
+ };
367
+ };
368
+
369
+ //#endregion
370
+ //#region src/modules/waas/policies/buildBlockExportRule/buildBlockExportRule.ts
371
+ /**
372
+ * Builds the `blockExport` rule. `deny`, not `allow`: an addressless
373
+ * allow-rule normalizes to an empty allowed-set, denying every transaction.
374
+ * `chain`/`chainIds` are stamped for consistency but the enforcement of a
375
+ * `blockExport` `operationRestrictions` rule is wallet-wide, ignoring them.
376
+ * @notInstrumented
377
+ */
378
+ const buildBlockExportRule = ({ context: { chain, chainIds }, rules }) => {
379
+ if (rules.blockExport !== true) return void 0;
380
+ return {
381
+ chain,
382
+ chainIds,
383
+ name: rules.names?.blockExport ?? DEFAULT_POLICY_RULE_NAMES.blockExport,
384
+ operationRestrictions: { blockExport: true },
385
+ ruleType: WaasPolicyRuleType.Deny
386
+ };
387
+ };
388
+
389
+ //#endregion
390
+ //#region src/modules/waas/policies/buildDenyAddressesRule/buildDenyAddressesRule.ts
391
+ /**
392
+ * Builds the `denyAddresses` rule. Independent of `allowAddresses`.
393
+ * @notInstrumented
394
+ */
395
+ const buildDenyAddressesRule = ({ context: { chain, chainIds }, rules }) => {
396
+ if (!rules.denyAddresses || rules.denyAddresses.length === 0) return void 0;
397
+ return {
398
+ addresses: rules.denyAddresses,
399
+ chain,
400
+ chainIds,
401
+ name: rules.names?.denyAddresses ?? DEFAULT_POLICY_RULE_NAMES.denyAddresses,
402
+ ruleType: WaasPolicyRuleType.Deny
403
+ };
404
+ };
405
+
406
+ //#endregion
407
+ //#region src/modules/waas/policies/buildMaxAmountPerTransactionRule/buildMaxAmountPerTransactionRule.ts
408
+ /**
409
+ * Builds the standalone `maxAmountPerTransaction` rule. Only fires when
410
+ * `allowAddresses` didn't already absorb this cap onto its own rule. `deny`
411
+ * for the same reason as `blockExport`'s builder.
412
+ * @notInstrumented
413
+ */
414
+ const buildMaxAmountPerTransactionRule = ({ context: { chain, chainIds }, rules }) => {
415
+ const isAbsorbedByAllowAddresses = Boolean(rules.allowAddresses?.length);
416
+ if (!rules.maxAmountPerTransaction || isAbsorbedByAllowAddresses) return void 0;
417
+ return {
418
+ chain,
419
+ chainIds,
420
+ name: rules.names?.maxAmountPerTransaction ?? DEFAULT_POLICY_RULE_NAMES.maxAmountPerTransaction,
421
+ ruleType: WaasPolicyRuleType.Deny,
422
+ valueLimit: buildValueLimit(rules.maxAmountPerTransaction)
423
+ };
424
+ };
425
+
426
+ //#endregion
427
+ //#region src/modules/waas/policies/hasAddresses/hasAddresses.ts
428
+ /**
429
+ * Checks both the current `addresses` array and the legacy singular `address` field.
430
+ * @notInstrumented
431
+ */
432
+ const hasAddresses = (rule) => rule.addresses !== void 0 && rule.addresses.length > 0 || rule.address != null;
433
+
434
+ //#endregion
435
+ //#region src/modules/waas/policies/hasUnrecognizedFields/hasUnrecognizedFields.ts
436
+ const RECOGNIZED_TOP_LEVEL_KEY_SET = new Set([
437
+ "ruleId",
438
+ "name",
439
+ "ruleType",
440
+ "addresses",
441
+ "chain",
442
+ "chainIds",
443
+ "valueLimit",
444
+ "operationRestrictions"
445
+ ]);
446
+ /**
447
+ * @notInstrumented
448
+ */
449
+ const hasUnrecognizedFields = (rule) => Object.keys(rule).some((key) => !RECOGNIZED_TOP_LEVEL_KEY_SET.has(key) && rule[key] != null) || rule.valueLimit?.totalLimit != null || rule.operationRestrictions?.blockRevocation != null || rule.operationRestrictions?.blockClientSigning != null;
450
+
451
+ //#endregion
452
+ //#region src/modules/waas/policies/readValueLimit/readValueLimit.ts
453
+ /**
454
+ * Reads a stored `valueLimit` back into a {@link PolicyRuleMaxAmountPerTransaction}.
455
+ * @notInstrumented
456
+ */
457
+ const readValueLimit = ({ asset, maxPerCall }) => ({
458
+ amount: maxPerCall,
459
+ ...asset ? { asset } : {}
460
+ });
461
+
462
+ //#endregion
463
+ //#region src/modules/waas/policies/readAllowAddressesRule/readAllowAddressesRule.ts
464
+ /**
465
+ * Recognizes an existing rule as `allowAddresses`, reading back a merged
466
+ * `maxAmountPerTransaction` cap too when the rule carries one.
467
+ * @notInstrumented
468
+ */
469
+ const readAllowAddressesRule = (rule) => {
470
+ if (!(rule.ruleType === WaasPolicyRuleType.Allow && rule.operationRestrictions === void 0 && (rule.valueLimit === void 0 || rule.valueLimit.maxPerCall !== void 0) && hasAddresses(rule) && !hasUnrecognizedFields(rule))) return void 0;
471
+ return {
472
+ allowAddresses: rule.addresses,
473
+ ...rule.valueLimit?.maxPerCall !== void 0 ? { maxAmountPerTransaction: readValueLimit({
474
+ asset: rule.valueLimit.asset,
475
+ maxPerCall: rule.valueLimit.maxPerCall
476
+ }) } : {}
477
+ };
478
+ };
479
+
480
+ //#endregion
481
+ //#region src/modules/waas/policies/readBlockExportRule/readBlockExportRule.ts
482
+ /**
483
+ * Recognizes an existing rule as `blockExport`.
484
+ * @notInstrumented
485
+ */
486
+ const readBlockExportRule = (rule) => {
487
+ if (!(rule.ruleType === WaasPolicyRuleType.Deny && rule.operationRestrictions?.blockExport === true && rule.valueLimit === void 0 && !hasAddresses(rule) && !hasUnrecognizedFields(rule))) return void 0;
488
+ return { blockExport: true };
489
+ };
490
+
491
+ //#endregion
492
+ //#region src/modules/waas/policies/readDenyAddressesRule/readDenyAddressesRule.ts
493
+ /**
494
+ * Recognizes an existing rule as `denyAddresses`.
495
+ * @notInstrumented
496
+ */
497
+ const readDenyAddressesRule = (rule) => {
498
+ if (!(rule.ruleType === WaasPolicyRuleType.Deny && rule.operationRestrictions === void 0 && rule.valueLimit === void 0 && hasAddresses(rule) && !hasUnrecognizedFields(rule))) return void 0;
499
+ return { denyAddresses: rule.addresses };
500
+ };
501
+
502
+ //#endregion
503
+ //#region src/modules/waas/policies/readMaxAmountPerTransactionRule/readMaxAmountPerTransactionRule.ts
504
+ /**
505
+ * Recognizes an existing rule as a standalone `maxAmountPerTransaction` cap.
506
+ * @notInstrumented
507
+ */
508
+ const readMaxAmountPerTransactionRule = (rule) => {
509
+ if (!(rule.ruleType === WaasPolicyRuleType.Deny && rule.operationRestrictions === void 0 && rule.valueLimit?.maxPerCall !== void 0 && !hasAddresses(rule) && !hasUnrecognizedFields(rule))) return void 0;
510
+ return { maxAmountPerTransaction: readValueLimit({
511
+ asset: rule.valueLimit.asset,
512
+ maxPerCall: rule.valueLimit.maxPerCall
513
+ }) };
514
+ };
515
+
516
+ //#endregion
517
+ //#region src/modules/waas/policies/policyRuleKinds.ts
518
+ /** The four keys of {@link PolicyRules}, each of which produces its own rule. */
519
+ const RULE_KIND_KEYS = [
520
+ "blockExport",
521
+ "allowAddresses",
522
+ "denyAddresses",
523
+ "maxAmountPerTransaction"
524
+ ];
525
+ /**
526
+ * The single source of truth {@link expandPolicyRules} and
527
+ * {@link desugarPolicyRules} both build on. Entries are alphabetized
528
+ * (enforced by lint), not grouped by relationship — `allowAddresses` and
529
+ * `maxAmountPerTransaction` cooperate (see their builders' comments) despite
530
+ * sitting apart here.
531
+ */
532
+ const RULE_KINDS = {
533
+ allowAddresses: {
534
+ buildRule: buildAllowAddressesRule,
535
+ readRule: readAllowAddressesRule
536
+ },
537
+ blockExport: {
538
+ buildRule: buildBlockExportRule,
539
+ readRule: readBlockExportRule
540
+ },
541
+ denyAddresses: {
542
+ buildRule: buildDenyAddressesRule,
543
+ readRule: readDenyAddressesRule
544
+ },
545
+ maxAmountPerTransaction: {
546
+ buildRule: buildMaxAmountPerTransactionRule,
547
+ readRule: readMaxAmountPerTransactionRule
548
+ }
549
+ };
550
+
551
+ //#endregion
552
+ //#region src/modules/waas/policies/readCoveredRule/readCoveredRule.ts
553
+ /**
554
+ * The sugar keys and values an existing rule structurally represents — a
555
+ * single rule can cover more than one key (see `allowAddresses` absorbing
556
+ * `maxAmountPerTransaction` in `policyRuleKinds.ts`). A rule carrying a
557
+ * per-rule `modifiableBySigner` grant is never matched here — treating it
558
+ * as covering keys would let a caller's batch reuse/replace/remove it and
559
+ * silently revoke that signer's edit permission (mirrors `desugarPolicyRules`).
560
+ *
561
+ * @param rule - The existing policy-layer rule to read.
562
+ * @returns The sugar keys and values the rule covers, or undefined when it matches no kind or carries a signer grant.
563
+ * @notInstrumented
564
+ */
565
+ const readCoveredRule = (rule) => {
566
+ if (rule.modifiableBySigner === true) return;
567
+ for (const kind of RULE_KIND_KEYS) {
568
+ const values = RULE_KINDS[kind].readRule(rule);
569
+ if (values === void 0) continue;
570
+ return {
571
+ keys: objectKeys(values),
572
+ kind,
573
+ values
574
+ };
575
+ }
576
+ };
577
+
578
+ //#endregion
579
+ //#region src/modules/waas/policies/sortRulesByRuleId/sortRulesByRuleId.ts
580
+ /**
581
+ * Sorts rules by `ruleId` ascending (a rule missing one sorts first, as `''`)
582
+ * — the deterministic order {@link matchExistingRules} picks its reuse
583
+ * target from, so every caller agrees on which duplicate rule wins.
584
+ *
585
+ * @param rules - The rules to sort.
586
+ * @returns A new array, sorted by `ruleId` ascending.
587
+ * @notInstrumented
588
+ */
589
+ const sortRulesByRuleId = (rules) => [...rules].sort((a, b) => {
590
+ const idA = a.ruleId ?? "";
591
+ const idB = b.ruleId ?? "";
592
+ if (idA < idB) return -1;
593
+ if (idA > idB) return 1;
594
+ return 0;
595
+ });
596
+
597
+ //#endregion
598
+ //#region src/modules/waas/policies/matchExistingRules/matchExistingRules.ts
599
+ const coveredRuleKeys = (rule) => readCoveredRule(rule)?.keys ?? [];
600
+ /**
601
+ * Matches existing rules covering any of `builtRule`'s keys. Only rules
602
+ * being *absorbed* into it — i.e. no other match claims the same key — are
603
+ * superseded (safe to remove). Two matches claiming the SAME key (e.g. two
604
+ * hand-authored `denyAddresses` rules for this chain scope) are a
605
+ * legitimate duplicate, not one superseding the other, so are left alone
606
+ * rather than removed.
607
+ *
608
+ * @param params.builtRule - The newly built rule to match existing rules against.
609
+ * @param params.consumedRuleIds - `ruleId`s already reused or removed for a prior built rule this call, so none is touched twice.
610
+ * @param params.existingRulesInScope - The layer's rules already narrowed to the target chain scope.
611
+ * @returns The rule to reuse `builtRule`'s upsert onto (if any), and every rule it supersedes.
612
+ * @notInstrumented
613
+ */
614
+ const matchExistingRules = ({ builtRule, consumedRuleIds, existingRulesInScope }) => {
615
+ const builtKeys = new Set(coveredRuleKeys(builtRule));
616
+ const matches = sortRulesByRuleId(existingRulesInScope).filter((existingRule) => existingRule.ruleId !== void 0 && !consumedRuleIds.has(existingRule.ruleId)).map((rule) => ({
617
+ keys: coveredRuleKeys(rule),
618
+ rule
619
+ })).filter(({ keys }) => keys.some((key) => builtKeys.has(key)));
620
+ const [reused, ...rest] = matches;
621
+ const superseded = rest.filter(({ keys, rule }) => {
622
+ const ruleKeys = new Set(keys);
623
+ return !matches.some((other) => other.rule.ruleId !== rule.ruleId && other.keys.some((key) => ruleKeys.has(key)));
624
+ }).map(({ rule }) => rule);
625
+ return {
626
+ reused: reused?.rule,
627
+ superseded
628
+ };
629
+ };
630
+
631
+ //#endregion
632
+ //#region src/modules/waas/policies/resolveRuleName/resolveRuleName.ts
633
+ /**
634
+ * Keeps the reused rule's label unless the caller overrides it or its
635
+ * name-owning kind changed.
636
+ *
637
+ * @param params.builtRule - The newly built rule about to be upserted.
638
+ * @param params.reused - The existing rule `builtRule` is upserted onto, if any.
639
+ * @param params.rules - The caller's requested {@link PolicyRules} sugar map.
640
+ * @returns The name to use for the upserted rule.
641
+ * @notInstrumented
642
+ */
643
+ const resolveRuleName = ({ builtRule, reused, rules }) => {
644
+ if (reused === void 0) return builtRule.name;
645
+ const builtKind = readCoveredRule(builtRule)?.kind;
646
+ const reusedKind = readCoveredRule(reused)?.kind;
647
+ const sameOwningKind = builtKind !== void 0 && builtKind === reusedKind;
648
+ const nameOverridden = builtKind !== void 0 && rules.names?.[builtKind] !== void 0;
649
+ return sameOwningKind && !nameOverridden ? reused.name : builtRule.name;
650
+ };
651
+
652
+ //#endregion
653
+ //#region src/modules/waas/policies/buildOperationsForRule/buildOperationsForRule.ts
654
+ /**
655
+ * Upserts `builtRule` onto the existing rule it reuses (if any), and
656
+ * removes every rule that rule superseded. Mutates `consumedRuleIds` so a
657
+ * later call for a different built rule never reuses or removes the same
658
+ * existing rule twice.
659
+ *
660
+ * @param params.builtRule - The newly built rule to turn into batch operations.
661
+ * @param params.consumedRuleIds - `ruleId`s already reused or removed for a prior built rule this call.
662
+ * @param params.existingRulesInScope - The layer's rules already narrowed to the target chain scope.
663
+ * @param params.rules - The caller's requested {@link PolicyRules} sugar map.
664
+ * @returns The batch operations for this built rule — one upsert, plus a remove per superseded rule.
665
+ * @notInstrumented
666
+ */
667
+ const buildOperationsForRule = ({ builtRule, consumedRuleIds, existingRulesInScope, rules }) => {
668
+ const { reused, superseded } = matchExistingRules({
669
+ builtRule,
670
+ consumedRuleIds,
671
+ existingRulesInScope
672
+ });
673
+ const reusedRuleId = reused?.ruleId;
674
+ const operations = [{
675
+ op: WaasPolicyLayerRuleOperationOpEnum.Upsert,
676
+ rule: reusedRuleId ? {
677
+ ...builtRule,
678
+ name: resolveRuleName({
679
+ builtRule,
680
+ reused,
681
+ rules
682
+ }),
683
+ ruleId: reusedRuleId
684
+ } : builtRule
685
+ }];
686
+ if (reusedRuleId) consumedRuleIds.add(reusedRuleId);
687
+ for (const { ruleId } of superseded) {
688
+ consumedRuleIds.add(ruleId);
689
+ operations.push({
690
+ op: WaasPolicyLayerRuleOperationOpEnum.Remove,
691
+ ruleId
692
+ });
693
+ }
694
+ return operations;
695
+ };
696
+
697
+ //#endregion
698
+ //#region src/modules/waas/policies/expandPolicyRules/expandPolicyRules.ts
699
+ /**
700
+ * Expands the {@link PolicyRules} sugar map into `WaasPolicyRule[]` for one
701
+ * chain scope. Omitting `chainIds` (or passing an empty array) builds a
702
+ * wildcard rule matching every chain id of `chain`.
703
+ *
704
+ * @param params.rules - The sugar map describing the desired rules.
705
+ * @param params.chain - The chain these rules apply to.
706
+ * @param params.chainIds - The chain ids these rules apply to; omit for a wildcard rule that matches every chain id of `chain`.
707
+ * @returns The expanded `WaasPolicyRule[]`, without `ruleId`.
708
+ * @throws When expansion would produce an `allow` rule with a value limit and no addresses — that empties the allowed set and denies every transaction on the chain.
709
+ * @notInstrumented
710
+ */
711
+ const expandPolicyRules = ({ chain, chainIds, rules }) => {
712
+ const context = {
713
+ chain,
714
+ chainIds: chainIds ?? []
715
+ };
716
+ const expanded = RULE_KIND_KEYS.flatMap((key) => {
717
+ const rule = RULE_KINDS[key].buildRule({
718
+ context,
719
+ rules
720
+ });
721
+ return rule ? [rule] : [];
722
+ });
723
+ if (expanded.some((rule) => rule.ruleType === WaasPolicyRuleType.Allow && rule.valueLimit !== void 0 && (rule.addresses === void 0 || rule.addresses.length === 0))) throw new InvalidParamError("expandPolicyRules: refusing to emit an allow rule with a value limit and no addresses — it would empty the allowed-address set and deny every transaction on this chain");
724
+ return expanded;
725
+ };
726
+
727
+ //#endregion
728
+ //#region src/modules/waas/policies/fillOmittedRuleValues/fillOmittedRuleValues.ts
729
+ /**
730
+ * Whether the caller's value for a sugar key would actually produce a rule —
731
+ * an empty `allowAddresses`/`denyAddresses` array builds no rule (see
732
+ * `buildAllowAddressesRule`/`buildDenyAddressesRule`), so it must count the
733
+ * same as omitted here. Otherwise a real value is present.
734
+ */
735
+ const isRuleKeyRequested = (value) => Array.isArray(value) ? value.length > 0 : value !== void 0;
736
+ /**
737
+ * A key the caller omitted can be silently dropped if it's merged into the
738
+ * same rule as a key they DID supply (e.g. re-saving only `allowAddresses`
739
+ * when the existing rule also carries `maxAmountPerTransaction`) — carries
740
+ * it forward so a partial re-save never erases a restriction the caller
741
+ * didn't ask to remove.
742
+ *
743
+ * Rules are visited in the same lexicographically-smallest-`ruleId` order
744
+ * `matchExistingRules` reuses, and only the first rule to cover a given key
745
+ * fills it — so when duplicate rules cover the same omitted key, the value
746
+ * always comes from the rule that will actually be upserted.
747
+ *
748
+ * @param params.existingRulesInScope - The layer's rules already narrowed to the target chain scope.
749
+ * @param params.rules - The caller's requested {@link PolicyRules} sugar map.
750
+ * @returns `rules`, with any key a partially-requested existing rule also covers filled in from that rule's current value.
751
+ * @notInstrumented
752
+ */
753
+ const fillOmittedRuleValues = ({ existingRulesInScope, rules }) => {
754
+ const mergedRules = { ...rules };
755
+ for (const existingRule of sortRulesByRuleId(existingRulesInScope)) {
756
+ const covered = readCoveredRule(existingRule);
757
+ const isPartiallyRequested = covered !== void 0 && covered.keys.some((key) => isRuleKeyRequested(rules[key])) && covered.keys.some((key) => !isRuleKeyRequested(rules[key]));
758
+ if (covered === void 0 || !isPartiallyRequested) continue;
759
+ for (const key of covered.keys) if (!isRuleKeyRequested(rules[key]) && mergedRules[key] === void 0) Object.assign(mergedRules, { [key]: covered.values[key] });
760
+ }
761
+ return mergedRules;
762
+ };
763
+
764
+ //#endregion
765
+ //#region src/modules/waas/policies/getResolvedPolicyLayer/getResolvedPolicyLayer.ts
766
+ /**
767
+ * Fetches the policy layer a {@link ResolvedPolicyScope} points at. Shared
768
+ * by {@link createPolicy}, {@link getPolicy}, and {@link removePolicyRules}
769
+ * so the account/wallet/signer branch is written once.
770
+ *
771
+ * @notInstrumented
772
+ */
773
+ const getResolvedPolicyLayer = ({ resolvedScope }, client) => {
774
+ const { environmentId } = getCore(client);
775
+ const apiClient = createApiClient({}, client);
776
+ switch (resolvedScope.target) {
777
+ case "account": return apiClient.getBusinessAccountPolicyLayer({
778
+ businessAccountId: resolvedScope.businessAccountId,
779
+ environmentId
780
+ });
781
+ case "wallet": return apiClient.getWaasWalletSelfPolicyLayer({
782
+ environmentId,
783
+ walletId: resolvedScope.walletId
784
+ });
785
+ case "signer": return apiClient.getWaasSignerSelfPolicyLayer({
786
+ environmentId,
787
+ shareSetId: resolvedScope.shareSetId,
788
+ walletId: resolvedScope.walletId
789
+ });
790
+ default: {
791
+ const unhandledScope = resolvedScope;
792
+ throw new InvalidParamError(`getResolvedPolicyLayer: unhandled target "${JSON.stringify(unhandledScope)}"`);
793
+ }
794
+ }
795
+ };
796
+
797
+ //#endregion
798
+ //#region src/modules/waas/policies/resolvePolicyScope/resolvePolicyScope.ts
799
+ /** Narrows a {@link WalletAccount} to {@link WaasWalletAccount} so WaaS-only fields (e.g. `shareSetId`) are accessible. */
800
+ const isWaasWallet = (walletAccount) => isWaasWalletAccount({ walletAccount });
801
+ /**
802
+ * Resolves a {@link PolicyScope} to its concrete policy layer. When only a
803
+ * `shareSetId` is given, the owning wallet is found locally by scanning the
804
+ * client's own wallet accounts — no network request.
805
+ *
806
+ * @param params.scope - The scope to resolve.
807
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
808
+ * @returns The concrete target (`account`, `wallet`, or `signer`) plus the ids needed to call the SDK API.
809
+ * @throws When a `shareSetId`-only scope doesn't match any of the client's wallet accounts.
810
+ * @notInstrumented
811
+ */
812
+ const resolvePolicyScope = ({ scope }, client = getDefaultClient()) => {
813
+ if ("businessAccountId" in scope) return {
814
+ businessAccountId: scope.businessAccountId,
815
+ target: "account"
816
+ };
817
+ if ("walletId" in scope) return scope.shareSetId === void 0 ? {
818
+ target: "wallet",
819
+ walletId: scope.walletId
820
+ } : {
821
+ shareSetId: scope.shareSetId,
822
+ target: "signer",
823
+ walletId: scope.walletId
824
+ };
825
+ const owningWalletAccount = getWalletAccounts(client).filter(isWaasWallet).find((walletAccount) => walletAccount.shareSetId === scope.shareSetId || walletAccount.otherShareSets?.some((shareSet) => shareSet.shareSetId === scope.shareSetId));
826
+ assertDefined(owningWalletAccount?.verifiedCredentialId, `resolvePolicyScope: could not resolve a wallet for shareSetId "${scope.shareSetId}" — no verified wallet account exposes this share set`);
827
+ return {
828
+ shareSetId: scope.shareSetId,
829
+ target: "signer",
830
+ walletId: owningWalletAccount.verifiedCredentialId
831
+ };
832
+ };
833
+
834
+ //#endregion
835
+ //#region src/modules/waas/policies/sameChainIds/sameChainIds.ts
836
+ /**
837
+ * Whether two chainIds arrays describe the same set, regardless of order.
838
+ * Shared by {@link createPolicy} and {@link removePolicyRules} to keep their
839
+ * existing-rule lookups consistent.
840
+ *
841
+ * @notInstrumented
842
+ */
843
+ const sameChainIds = ({ existing = [], requested }) => {
844
+ if (existing.length !== requested.length) return false;
845
+ const sortedExisting = [...existing].sort((x, y) => x - y);
846
+ const sortedRequested = [...requested].sort((x, y) => x - y);
847
+ return sortedExisting.every((id, index) => id === sortedRequested[index]);
848
+ };
849
+
850
+ //#endregion
851
+ //#region src/modules/waas/policies/createPolicy/createPolicy.ts
852
+ /**
853
+ * Creates or updates a wallet's, signer's, or business account's policy rules from the
854
+ * {@link PolicyRules} sugar map, in one atomic `batch` PATCH. Each key in
855
+ * `rules` maps to at most one underlying rule, so calling this twice with
856
+ * the same map updates that rule in place instead of duplicating it.
857
+ *
858
+ * Known race: no ETag / optimistic-concurrency check — concurrent calls for
859
+ * the same scope can both read-then-write and duplicate a rule.
860
+ *
861
+ * When more than one existing rule matches the same sugar key(s), only
862
+ * rules being absorbed into the newly built rule (i.e. no other match
863
+ * claims the same key) are removed. Two rules that duplicate the same key
864
+ * (e.g. two hand-authored `denyAddresses` rules for this chain scope) are
865
+ * left as-is rather than one being silently deleted — this call updates the
866
+ * lexicographically-smallest-`ruleId` match in place and leaves the rest
867
+ * untouched. A caller repeating this call will not converge on a single
868
+ * rule; the duplicate has to be removed by hand.
869
+ *
870
+ * @param params.scope - Which policy layer to update — see {@link resolvePolicyScope}.
871
+ * @param params.chain - The chain the rules apply to.
872
+ * @param params.chainIds - The chain ids the rules apply to; omit for a wildcard rule that matches every chain id of `chain`.
873
+ * @param params.rules - The desired rules, as a {@link PolicyRules} sugar map.
874
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
875
+ * @returns The policy layer as it stands after the batch is applied.
876
+ * @throws When `rules` produces no recognized keys, or via {@link resolvePolicyScope}'s scope-resolution errors.
877
+ * @notInstrumented
878
+ */
879
+ const createPolicy = async ({ chain, chainIds, rules, scope }, client = getDefaultClient()) => {
880
+ const normalizedChainIds = chainIds ?? [];
881
+ const resolvedScope = resolvePolicyScope({ scope }, client);
882
+ const existingRulesInScope = ((await getResolvedPolicyLayer({ resolvedScope }, client)).layerContent.rules ?? []).filter((existingRule) => existingRule.chain === chain && sameChainIds({
883
+ existing: existingRule.chainIds,
884
+ requested: normalizedChainIds
885
+ }));
886
+ const expandedRules = expandPolicyRules({
887
+ chain,
888
+ chainIds: normalizedChainIds,
889
+ rules: fillOmittedRuleValues({
890
+ existingRulesInScope,
891
+ rules
892
+ })
893
+ });
894
+ if (expandedRules.length === 0) throw new InvalidParamError("createPolicy: rules must include at least one recognized policy key");
895
+ const consumedRuleIds = /* @__PURE__ */ new Set();
896
+ const operations = [];
897
+ for (const builtRule of expandedRules) operations.push(...buildOperationsForRule({
898
+ builtRule,
899
+ consumedRuleIds,
900
+ existingRulesInScope,
901
+ rules
902
+ }));
903
+ return applyPolicyLayerBatch({
904
+ operations,
905
+ resolvedScope
906
+ }, client);
907
+ };
908
+
909
+ //#endregion
910
+ //#region src/modules/waas/createWaasOfflineRecoveryShares/createWaasOfflineRecoveryShares.ts
911
+ /**
912
+ * Mints an offline-recovery share set for a WaaS wallet account.
913
+ *
914
+ * This mints a second, independent 2-of-2 share set: the client's share is
915
+ * uploaded to Google Drive, and the server's share is delivered to the
916
+ * developer's webhook. Dynamic never retains its half, so recovery works even
917
+ * if Dynamic is fully offline.
918
+ *
919
+ * @param params.walletAccount - The WaaS wallet account to create offline-recovery shares for.
920
+ * @param [params.password] - Optional password to encrypt the client share.
921
+ * @param [params.cloudProviderAccessToken] - Optional consumer-supplied Drive-scoped access token; used directly instead of the stored OAuth token (avoids a second Google consent). Useful for external-auth setups.
922
+ * @param [params.mfaToken] - Optional MFA token proving step-up verification, when required for this action.
923
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
924
+ * @returns A promise that resolves when the offline-recovery share set has been minted.
925
+ * @notInstrumented
926
+ */
927
+ const createWaasOfflineRecoveryShares = async ({ cloudProviderAccessToken, mfaToken, password, walletAccount }, client = getDefaultClient()) => {
928
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).createOfflineRecoveryShares({
929
+ cloudProviderAccessToken,
930
+ mfaToken,
931
+ password,
932
+ walletAccount
933
+ });
934
+ };
935
+
936
+ //#endregion
937
+ //#region src/modules/waas/isWalletCreationRequirement/isWalletCreationRequirement.ts
938
+ /**
939
+ * Type guard to check if an item is a WalletCreationRequirement object.
940
+ * Chain values are strings, so we can distinguish by checking if it's an object with a 'chain' property.
941
+ *
942
+ * @param item - The item to check, either a WalletCreationRequirement or Chain string
943
+ * @returns True if the item is a WalletCreationRequirement object
944
+ * @notInstrumented
945
+ */
946
+ const isWalletCreationRequirement = (item) => typeof item === "object" && item !== null && "chain" in item;
947
+
948
+ //#endregion
949
+ //#region src/modules/waas/normalizeWalletRequirements/normalizeWalletRequirements.ts
950
+ const DEFAULT_BITCOIN_ADDRESS_TYPE = "native_segwit";
951
+ /**
952
+ * Normalizes wallet creation input from either legacy Chain[] format
953
+ * or new WalletCreationRequirement[] format to WalletCreationRequirement[].
954
+ *
955
+ * For BTC chains without explicit bitcoinConfig, defaults to native_segwit.
956
+ *
957
+ * @param params.input - Either an array of Chain strings or WalletCreationRequirement objects
958
+ * @param params.defaultBitcoinConfig - Optional default bitcoin config to use for BTC chains when converting from legacy format
959
+ * @returns Array of WalletCreationRequirement objects
960
+ * @notInstrumented
961
+ */
962
+ const normalizeWalletRequirements = ({ defaultBitcoinConfig, input }) => {
963
+ if (input.length === 0) return [];
964
+ const [firstItem] = input;
965
+ if (isWalletCreationRequirement(firstItem)) return input.map((requirement) => {
966
+ if (requirement.chain === "BTC" && !requirement.bitcoinConfig) return {
967
+ ...requirement,
968
+ bitcoinConfig: { addressType: DEFAULT_BITCOIN_ADDRESS_TYPE }
969
+ };
970
+ return requirement;
971
+ });
972
+ return input.map((chain) => {
973
+ const requirement = { chain };
974
+ if (chain === "BTC") requirement.bitcoinConfig = defaultBitcoinConfig ?? { addressType: DEFAULT_BITCOIN_ADDRESS_TYPE };
975
+ return requirement;
976
+ });
977
+ };
978
+
979
+ //#endregion
980
+ //#region src/modules/waas/createWaasWalletAccounts/createWaasWalletAccounts.ts
981
+ /**
982
+ * Creates wallet accounts for the specified chains.
983
+ *
984
+ * This function creates wallet accounts for the specified chains.
985
+ * If the same chain is passed multiple times, just as many wallet accounts will be created
986
+ * for that chain.
987
+ *
988
+ * @example
989
+ * ```ts
990
+ * // Legacy format - will create wallet accounts for EVM and SOL, BTC defaults to native_segwit
991
+ * await createWaasWalletAccounts({ chains: ['EVM', 'SOL', 'BTC'] });
992
+ *
993
+ * // New format with chain-specific config
994
+ * await createWaasWalletAccounts({
995
+ * chains: [
996
+ * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },
997
+ * { chain: 'EVM' },
998
+ * ]
999
+ * });
1000
+ *
1001
+ * // Create both BTC address types
1002
+ * await createWaasWalletAccounts({
1003
+ * chains: [
1004
+ * { chain: 'BTC', bitcoinConfig: { addressType: 'native_segwit' } },
1005
+ * { chain: 'BTC', bitcoinConfig: { addressType: 'taproot' } },
1006
+ * ]
1007
+ * });
1008
+ * ```
1009
+ *
1010
+ * @param params.chains - The chains to create wallet accounts for.
1011
+ * @param params.password - The optional password to use for the wallet accounts.
1012
+ * @param params.thresholdSignatureScheme - The threshold signature scheme to use for the wallet accounts. (Default: TWO_OF_TWO)
1013
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1014
+ * @returns A promise that resolves when all wallet accounts are created.
1015
+ * @notInstrumented
1016
+ */
1017
+ const createWaasWalletAccounts = async ({ chains, password, thresholdSignatureScheme }, client = getDefaultClient()) => {
1018
+ const normalizedRequirements = normalizeWalletRequirements({ input: chains });
1019
+ const supportedChains = [
1020
+ "ALEO",
1021
+ "BTC",
1022
+ "EVM",
1023
+ "SOL",
1024
+ "SUI",
1025
+ "TON",
1026
+ "TRON"
1027
+ ];
1028
+ const filteredRequirements = normalizedRequirements.filter((requirement) => supportedChains.includes(requirement.chain));
1029
+ if (filteredRequirements.length === 0) return;
1030
+ const walletProviderMap = /* @__PURE__ */ new Map();
1031
+ for (const requirement of filteredRequirements) {
1032
+ const walletProviderKey = formatWalletProviderKey({
1033
+ chain: requirement.chain,
1034
+ displayName: DYNAMIC_WAAS_METADATA.displayName,
1035
+ walletProviderType: WalletProviderEnum.EmbeddedWallet
1036
+ });
1037
+ if (!walletProviderMap.has(walletProviderKey)) {
1038
+ const walletProvider = getWalletProviderByKey({ walletProviderKey }, client);
1039
+ if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey });
1040
+ if (!isWaasWalletProvider(walletProvider)) throw new NotWaasWalletProviderError({ walletProviderKey });
1041
+ walletProviderMap.set(walletProviderKey, walletProvider);
1042
+ }
1043
+ }
1044
+ await Promise.all(filteredRequirements.map((requirement) => {
1045
+ const walletProviderKey = formatWalletProviderKey({
1046
+ chain: requirement.chain,
1047
+ displayName: DYNAMIC_WAAS_METADATA.displayName,
1048
+ walletProviderType: WalletProviderEnum.EmbeddedWallet
1049
+ });
1050
+ const walletProvider = walletProviderMap.get(walletProviderKey);
1051
+ if (!walletProvider || !isWaasWalletProvider(walletProvider)) return Promise.resolve();
1052
+ return walletProvider.createWalletAccount({
1053
+ bitcoinConfig: requirement.bitcoinConfig,
1054
+ password,
1055
+ thresholdSignatureScheme
1056
+ });
1057
+ }));
1058
+ await __refreshAuth_wrapped(client);
1059
+ };
1060
+
1061
+ //#endregion
1062
+ //#region src/modules/waas/businessAccounts/createWalletForBusinessAccount/createWalletForBusinessAccount.ts
1063
+ /**
1064
+ * Creates a WaaS wallet account owned directly by a business account, in one
1065
+ * step — the server seats the wallet's signer row against the business account
1066
+ * as it is minted, so no separate link call is needed.
1067
+ *
1068
+ * @example
1069
+ * ```ts
1070
+ * const wallet = await createWalletForBusinessAccount({
1071
+ * businessAccountId: 'ba-1',
1072
+ * chain: 'EVM',
1073
+ * });
1074
+ * ```
1075
+ *
1076
+ * @param params.businessAccountId - The business account that will own the wallet.
1077
+ * @param params.chain - The chain to create the wallet account for.
1078
+ * @param [params.password] - Optional password used to encrypt the user share.
1079
+ * @param [params.thresholdSignatureScheme] - The threshold signature scheme to use. (Default: TWO_OF_TWO)
1080
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1081
+ * @returns The created wallet account.
1082
+ * @notInstrumented
1083
+ */
1084
+ const createWalletForBusinessAccount = async ({ businessAccountId, chain, password, thresholdSignatureScheme }, client = getDefaultClient()) => {
1085
+ const wallet = await getWaasWalletProviderByChain({ chain }, client).createWalletAccount({
1086
+ businessAccountId,
1087
+ password,
1088
+ thresholdSignatureScheme
1089
+ });
1090
+ await __refreshAuth_wrapped(client);
1091
+ return wallet;
1092
+ };
1093
+
1094
+ //#endregion
1095
+ //#region src/modules/waas/delegateWaasKeyShares/delegateWaasKeyShares.ts
1096
+ /**
1097
+ * Delegates cryptographic key shares for a WaaS wallet account.
1098
+ *
1099
+ * This function allows the delegation of key management responsibilities,
1100
+ * enabling distributed key management for enhanced security.
1101
+ *
1102
+ * @param params.walletAccount - The WaaS wallet account to delegate shares for.
1103
+ * @param [params.password] - Optional password for key share operations.
1104
+ * @param [params.initialSignerRules] - Optional policy rules used to seed the delegated signer's policy layer at delegation time.
1105
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1106
+ * @returns A promise that resolves when the key delegation is complete.
1107
+ * @notInstrumented
1108
+ */
1109
+ const delegateWaasKeyShares = async ({ initialSignerRules, password, walletAccount }, client = getDefaultClient()) => {
1110
+ await getWaasWalletProviderFromWalletAccount({ walletAccount }, client).delegateKeyShares({
1111
+ initialSignerRules,
1112
+ password,
1113
+ walletAccount
1114
+ });
1115
+ await __refreshAuth_wrapped(client);
1116
+ };
1117
+
1118
+ //#endregion
1119
+ //#region src/modules/waas/policies/findMatchedRuleKind/findMatchedRuleKind.ts
1120
+ const COUPLED_RULE_KINDS = new Set(["allowAddresses", "maxAmountPerTransaction"]);
1121
+ const isBlocked = ({ claimedKinds, populatedKeys }) => populatedKeys.some((key) => claimedKinds.has(key) || COUPLED_RULE_KINDS.has(key) && [...COUPLED_RULE_KINDS].some((coupledKey) => claimedKinds.has(coupledKey)));
1122
+ /**
1123
+ * Finds the first {@link RULE_KINDS} entry that recognizes `entry` as its
1124
+ * kind without colliding with an already-claimed key. Must check every key
1125
+ * `readRule` would populate, not just this kind's own key — allowAddresses'
1126
+ * `readRule` also populates `maxAmountPerTransaction` when the rule carries
1127
+ * a merged cap, so accepting it while that key is already claimed would
1128
+ * overwrite an earlier standalone cap.
1129
+ * @notInstrumented
1130
+ */
1131
+ const findMatchedRuleKind = ({ claimedKinds, entry }) => {
1132
+ for (const key of RULE_KIND_KEYS) {
1133
+ const readResult = RULE_KINDS[key].readRule(entry);
1134
+ if (readResult === void 0) continue;
1135
+ if (!isBlocked({
1136
+ claimedKinds,
1137
+ populatedKeys: Object.keys(readResult)
1138
+ })) return {
1139
+ kind: key,
1140
+ readResult
1141
+ };
1142
+ }
1143
+ };
1144
+
1145
+ //#endregion
1146
+ //#region src/modules/waas/policies/isPolicyRuleDeletionMarker/isPolicyRuleDeletionMarker.ts
1147
+ /** The exact key set of a deletion marker — checked as a closed shape, not by presence alone. */
1148
+ const DELETION_MARKER_KEYS = new Set([
1149
+ "ruleId",
1150
+ "deletedByType",
1151
+ "deletedById"
1152
+ ]);
1153
+ /**
1154
+ * Recognizes a policy-Layer deletion marker — the enclave's stand-in for a
1155
+ * rule it couldn't drop outright, kept so the removal stays attributable.
1156
+ * Matches on the entry's exact key set, not field presence, since the read
1157
+ * response types every entry as a live rule.
1158
+ *
1159
+ * @param entry - The raw policy-Layer rule entry to check.
1160
+ * @returns Whether `entry` is a deletion marker rather than a live rule.
1161
+ * @notInstrumented
1162
+ */
1163
+ const isPolicyRuleDeletionMarker = (entry) => {
1164
+ const candidate = entry;
1165
+ return typeof candidate.ruleId === "string" && typeof candidate.deletedByType === "string" && typeof candidate.deletedById === "string" && Object.keys(entry).every((key) => DELETION_MARKER_KEYS.has(key));
1166
+ };
1167
+
1168
+ //#endregion
1169
+ //#region src/modules/waas/policies/desugarPolicyRules/desugarPolicyRules.ts
1170
+ /**
1171
+ * Reverses {@link expandPolicyRules} using {@link findMatchedRuleKind}'s
1172
+ * same rule-kind table, skipping deletion markers. A kind claims at most
1173
+ * one rule; extra matches, out-of-vocabulary fields, and per-rule
1174
+ * `modifiableBySigner` grants (no sugar representation) all go to
1175
+ * `unmapped` instead of being dropped.
1176
+ *
1177
+ * @param params.entries - The policy-Layer's rule entries, as returned in `layerContent.rules`.
1178
+ * @returns The recognized rules as a {@link PolicyRules} map, plus whatever wasn't recognized.
1179
+ * @notInstrumented
1180
+ */
1181
+ const desugarPolicyRules = ({ entries }) => {
1182
+ const rules = {};
1183
+ const unmapped = [];
1184
+ const claimedKinds = /* @__PURE__ */ new Set();
1185
+ for (const entry of entries) {
1186
+ if (isPolicyRuleDeletionMarker(entry)) continue;
1187
+ if (entry.modifiableBySigner === true) {
1188
+ unmapped.push(entry);
1189
+ continue;
1190
+ }
1191
+ const matched = findMatchedRuleKind({
1192
+ claimedKinds,
1193
+ entry
1194
+ });
1195
+ if (matched === void 0) {
1196
+ unmapped.push(entry);
1197
+ continue;
1198
+ }
1199
+ const { kind, readResult } = matched;
1200
+ Object.assign(rules, readResult);
1201
+ for (const key of Object.keys(readResult)) claimedKinds.add(key);
1202
+ if (entry.name !== DEFAULT_POLICY_RULE_NAMES[kind]) rules.names = {
1203
+ ...rules.names,
1204
+ [kind]: entry.name
1205
+ };
1206
+ }
1207
+ return {
1208
+ rules,
1209
+ unmapped
1210
+ };
1211
+ };
1212
+
1213
+ //#endregion
1214
+ //#region src/modules/waas/exportWaasClientKeyshares/exportWaasClientKeyshares.ts
1215
+ /**
1216
+ * Exports the client-side key shares for a WaaS wallet account.
1217
+ *
1218
+ * This function retrieves the cryptographic key shares that are stored
1219
+ * on the client side for backup or migration purposes.
1220
+ *
1221
+ * @param params.walletAccount - The WaaS wallet account to export shares from.
1222
+ * @param [params.password] - Optional password to encrypt the exported shares.
1223
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1224
+ * @returns A promise that resolves to the exported key shares.
1225
+ * @notInstrumented
1226
+ */
1227
+ const exportWaasClientKeyshares = async ({ password, walletAccount }, client = getDefaultClient()) => {
1228
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).exportClientKeyshares({
1229
+ password,
1230
+ walletAccount
1231
+ });
1232
+ };
1233
+
1234
+ //#endregion
1235
+ //#region src/modules/waas/exportWaasPrivateKey/exportWaasPrivateKey.ts
1236
+ /**
1237
+ * Exports the private key for a WaaS wallet account with secure display.
1238
+ *
1239
+ * This function reveals the private key for a WaaS wallet and displays it
1240
+ * securely within an iframe dynamically inserted into the specified HTML container element.
1241
+ *
1242
+ * @param params.walletAccount - The WaaS wallet account to export the private key from.
1243
+ * @param params.displayContainer - The HTML element where the iframe will be injected.
1244
+ * @param [params.password] - Optional password to decrypt the private key.
1245
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1246
+ * @returns A promise that resolves when the private key export is complete.
1247
+ * @notInstrumented
1248
+ */
1249
+ const exportWaasPrivateKey = async ({ displayContainer, password, walletAccount }, client = getDefaultClient()) => {
1250
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).exportPrivateKey({
1251
+ displayContainer,
1252
+ password,
1253
+ walletAccount
1254
+ });
1255
+ };
1256
+
1257
+ //#endregion
1258
+ //#region src/modules/waas/policies/getAccountPolicyLayer/getAccountPolicyLayer.ts
1259
+ /**
1260
+ * Fetches a business account's active policy rules (the account-Layer).
1261
+ * BA owner/admin only. Calls the SDK API directly (no MPC step), so a
1262
+ * rejection surfaces as a thrown error.
1263
+ *
1264
+ * @param params.businessAccountId - The business account to read policy rules for.
1265
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1266
+ * @returns The account-Layer, including its current rules.
1267
+ * @notInstrumented
1268
+ */
1269
+ const getAccountPolicyLayer = async ({ businessAccountId }, client = getDefaultClient()) => {
1270
+ const core = getCore(client);
1271
+ return createApiClient({}, client).getBusinessAccountPolicyLayer({
1272
+ businessAccountId,
1273
+ environmentId: core.environmentId
1274
+ });
1275
+ };
1276
+
1277
+ //#endregion
1278
+ //#region src/modules/waas/businessAccounts/getBusinessAccount/getBusinessAccount.ts
1279
+ /**
1280
+ * Retrieves a business account by ID, including its members, signers, and wallets.
1281
+ *
1282
+ * @param params.businessAccountId - The ID of the business account to retrieve.
1283
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1284
+ * @returns The business account with its members, signers, and wallets.
1285
+ * @notInstrumented
1286
+ */
1287
+ const getBusinessAccount = async ({ businessAccountId }, client = getDefaultClient()) => {
1288
+ const core = getCore(client);
1289
+ return await createApiClient({}, client).sdkGetBusinessAccountById({
1290
+ businessAccountId,
1291
+ environmentId: core.environmentId
1292
+ });
1293
+ };
1294
+
1295
+ //#endregion
1296
+ //#region src/modules/wallets/userHasEmbeddedWalletForChain/userHasEmbeddedWalletForChain.ts
1297
+ /** @notInstrumented */
1298
+ const userHasEmbeddedWalletForChain = ({ user, chain }) => {
1299
+ return user.verifiedCredentials.some((vc) => vc.walletProvider === WalletProviderEnum.EmbeddedWallet && vc.chain && getChainFromVerifiedCredentialChain(vc.chain) === chain);
1300
+ };
1301
+
1302
+ //#endregion
1303
+ //#region src/modules/waas/getChainsMissingWaasWalletAccounts/getChainsMissingWaasWalletAccounts.ts
1304
+ /**
1305
+ * Gets all chains missing a waas wallet account for the current user.
1306
+ *
1307
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1308
+ * @returns An array of all chains that have waas wallet accounts enabled
1309
+ * but for which the current user does not yet have an embedded wallet account.
1310
+ * @notInstrumented
1311
+ */
1312
+ const getChainsMissingWaasWalletAccounts = (client = getDefaultClient()) => {
1313
+ const projectSettings = client.projectSettings;
1314
+ assertDefined(projectSettings, "Project settings are not available");
1315
+ const embeddedWalletSettings = projectSettings.sdk.embeddedWallets;
1316
+ const isWaasEnabled = isDynamicWaasEnabled(client);
1317
+ const user = client.user;
1318
+ if (!user || !isWaasEnabled) return [];
1319
+ return (embeddedWalletSettings?.chainConfigurations?.filter((chain) => chain.enabled) ?? []).map((chain) => chain.name).filter((chain) => !userHasEmbeddedWalletForChain({
1320
+ chain,
1321
+ user
1322
+ }));
1323
+ };
1324
+
1325
+ //#endregion
1326
+ //#region src/modules/waas/policies/getPolicy/getPolicy.ts
1327
+ /**
1328
+ * Fetches a policy layer and reads its `chain`/`chainIds` scope back into
1329
+ * the {@link PolicyRules} sugar map (see {@link desugarPolicyRules}). A
1330
+ * layer can hold rules for more than one chain, so entries are narrowed to
1331
+ * `chain`/`chainIds` first — the same scoping {@link createPolicy} uses —
1332
+ * to keep the `getPolicy` → edit → `createPolicy` round-trip safe for
1333
+ * multi-chain wallets. Calls the SDK API directly (no MPC step), so a
1334
+ * rejection surfaces as a thrown error.
1335
+ *
1336
+ * @param params.scope - Which policy layer to read — see {@link resolvePolicyScope}.
1337
+ * @param params.chain - The chain to read rules for.
1338
+ * @param params.chainIds - The chain ids to read rules for; omit to read the wildcard rule matching every chain id of `chain`.
1339
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1340
+ * @returns The recognized rules as a {@link PolicyRules} map, whatever wasn't recognized within `chain`/`chainIds`, and the layer's id and last-updated timestamp.
1341
+ * @throws Via {@link resolvePolicyScope}'s scope-resolution errors.
1342
+ * @notInstrumented
1343
+ */
1344
+ const getPolicy = async ({ chain, chainIds, scope }, client = getDefaultClient()) => {
1345
+ const normalizedChainIds = chainIds ?? [];
1346
+ const layer = await getResolvedPolicyLayer({ resolvedScope: resolvePolicyScope({ scope }, client) }, client);
1347
+ const { rules, unmapped } = desugarPolicyRules({ entries: (layer.layerContent.rules ?? []).filter((entry) => entry.chain === chain && sameChainIds({
1348
+ existing: entry.chainIds,
1349
+ requested: normalizedChainIds
1350
+ })) });
1351
+ return {
1352
+ layerId: layer.layerId,
1353
+ rules,
1354
+ unmapped,
1355
+ updatedAt: layer.updatedAt
1356
+ };
1357
+ };
1358
+
1359
+ //#endregion
1360
+ //#region src/modules/waas/policies/getSignerPolicyLayer/getSignerPolicyLayer.ts
1361
+ /**
1362
+ * Fetches a signer's active policy rules (the signer-Layer) — the caller's
1363
+ * own active share set by default, or another share set on the same wallet
1364
+ * (e.g. a delegated share set) when `shareSetId` is given. Calls the SDK API
1365
+ * directly (no MPC step), so a rejection surfaces as a thrown error.
1366
+ *
1367
+ * @param params.walletAccount - The wallet account whose signer-Layer to read.
1368
+ * @param [params.shareSetId] - The share set to target; defaults to the caller's own.
1369
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1370
+ * @returns The signer-Layer, including its current rules.
1371
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
1372
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
1373
+ * @notInstrumented
1374
+ */
1375
+ const getSignerPolicyLayer = async ({ shareSetId, walletAccount }, client = getDefaultClient()) => {
1376
+ assertDefined(walletAccount.verifiedCredentialId, "getSignerPolicyLayer: cannot resolve a wallet id — use a verified wallet account");
1377
+ const core = getCore(client);
1378
+ return createApiClient({}, client).getWaasSignerSelfPolicyLayer({
1379
+ environmentId: core.environmentId,
1380
+ shareSetId,
1381
+ walletId: walletAccount.verifiedCredentialId
1382
+ });
1383
+ };
1384
+
1385
+ //#endregion
1386
+ //#region src/modules/waas/getWalletAccountShareSets/getWalletAccountShareSets.ts
1387
+ /**
1388
+ * No network request. Share set ids rotate on refresh/reshare (stale ids are
1389
+ * rejected server-side), so re-read rather than cache; non-WaaS accounts
1390
+ * return `{ own: undefined, others: [] }` instead of throwing.
1391
+ *
1392
+ * @param params.walletAccount - The WaaS wallet account whose share sets to read.
1393
+ * @returns The account's own share set (if any) and the wallet's other active share sets.
1394
+ * @notInstrumented
1395
+ */
1396
+ const getWalletAccountShareSets = ({ walletAccount }) => {
1397
+ const own = walletAccount.shareSetId ? {
1398
+ shareSetId: walletAccount.shareSetId,
1399
+ shareSetType: walletAccount.shareSetType
1400
+ } : void 0;
1401
+ return {
1402
+ others: walletAccount.otherShareSets ?? [],
1403
+ own
1404
+ };
1405
+ };
1406
+
1407
+ //#endregion
1408
+ //#region src/modules/waas/policies/getWalletPolicyLayer/getWalletPolicyLayer.ts
1409
+ /**
1410
+ * Fetches a wallet's active policy rules (the wallet-Layer). Calls the SDK
1411
+ * API directly (no MPC step), so a rejection surfaces as a thrown error.
1412
+ *
1413
+ * @param params.walletAccount - The wallet account to read policy rules for.
1414
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1415
+ * @returns The wallet-Layer, including its current rules.
1416
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
1417
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
1418
+ * @notInstrumented
1419
+ */
1420
+ const getWalletPolicyLayer = async ({ walletAccount }, client = getDefaultClient()) => {
1421
+ assertDefined(walletAccount.verifiedCredentialId, "getWalletPolicyLayer: cannot resolve a wallet id — use a verified wallet account");
1422
+ const core = getCore(client);
1423
+ return createApiClient({}, client).getWaasWalletSelfPolicyLayer({
1424
+ environmentId: core.environmentId,
1425
+ walletId: walletAccount.verifiedCredentialId
1426
+ });
1427
+ };
1428
+
1429
+ //#endregion
1430
+ //#region src/modules/waas/getWalletRecoveryState/getWalletRecoveryState.ts
1431
+ /**
1432
+ * Retrieves the recovery state of a WaaS wallet account.
1433
+ *
1434
+ * @param params.walletAccount - The WaaS wallet account to get the recovery state for.
1435
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1436
+ * @returns A promise that resolves with the wallet recovery state.
1437
+ * @notInstrumented
1438
+ */
1439
+ const getWalletRecoveryState = async ({ walletAccount }, client = getDefaultClient()) => {
1440
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).getWalletRecoveryState({ walletAccount });
1441
+ };
1442
+
1443
+ //#endregion
1444
+ //#region src/modules/waas/hasDelegatedAccess/hasDelegatedAccess.ts
1445
+ /**
1446
+ * Checks if a WaaS wallet account has delegated access.
1447
+ *
1448
+ * @param params.walletAccount - The WaaS wallet account to check for delegated access.
1449
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1450
+ * @returns True if the wallet account has delegated access, false otherwise.
1451
+ * @notInstrumented
1452
+ */
1453
+ const hasDelegatedAccess = ({ walletAccount }, client = getDefaultClient()) => {
1454
+ const verifiedCredential = getVerifiedCredentialForWalletAccount({ walletAccount }, client);
1455
+ assertDefined(verifiedCredential, "Verified credential not found for Waas wallet account");
1456
+ const hasDelegatedKeyShare = verifiedCredential.walletProperties?.keyShares?.some((keyShare) => keyShare.backupLocation === "delegated");
1457
+ const hasDelegatedShareSet = verifiedCredential.walletProperties?.otherShareSets?.some((shareSet) => shareSet.shareSetType === WaasWalletShareSetType.Delegated);
1458
+ return Boolean(hasDelegatedKeyShare || hasDelegatedShareSet);
1459
+ };
1460
+
1461
+ //#endregion
1462
+ //#region src/modules/waas/importWaasPrivateKey/importWaasPrivateKey.ts
1463
+ /**
1464
+ * Imports an existing private key to create a new WaaS wallet account.
1465
+ *
1466
+ * This function allows users to import their existing private key into
1467
+ * Dynamic's WaaS infrastructure for secure management.
1468
+ *
1469
+ * @param params.chain - The chain for the imported wallet.
1470
+ * @param params.privateKey - The private key to import.
1471
+ * @param [params.thresholdSignatureScheme] - Optional threshold signature scheme configuration. Default is TWO_OF_TWO.
1472
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1473
+ * @returns A promise that resolves when the private key is successfully imported.
1474
+ * @notInstrumented
1475
+ */
1476
+ const importWaasPrivateKey = async ({ chain, privateKey, thresholdSignatureScheme }, client = getDefaultClient()) => {
1477
+ return getWaasWalletProviderByChain({ chain }, client).importPrivateKey({
1478
+ privateKey,
1479
+ thresholdSignatureScheme
1480
+ });
1481
+ };
1482
+
1483
+ //#endregion
1484
+ //#region src/modules/waas/isPasswordRequiredForWaasWallets/isPasswordRequiredForWaasWallets.ts
1485
+ /**
1486
+ * Checks if the user Waas wallets are password protected.
1487
+ *
1488
+ * If the user's Waas wallets are password protected, it means that user's will have to be prompted for a
1489
+ * password for the first wallet action that happens on each session.
1490
+ * The password is also required for creating any new Waas wallets.
1491
+ *
1492
+ * @param client - The Dynamic client instance. Only required when using multiple Dynamic clients.
1493
+ * @returns True if the user has any password protected Waas wallets, false otherwise
1494
+ * @notInstrumented
1495
+ */
1496
+ const isPasswordRequiredForWaasWallets = (client = getDefaultClient()) => {
1497
+ const { user } = client;
1498
+ assertDefined(user, "User is not authenticated");
1499
+ return user.verifiedCredentials.some((credential) => credential.walletProperties?.keyShares?.some((keyShare) => keyShare.passwordEncrypted));
1500
+ };
1501
+
1502
+ //#endregion
1503
+ //#region src/modules/waas/businessAccounts/listBusinessAccounts/listBusinessAccounts.ts
1504
+ /**
1505
+ * Lists the business accounts the current user is a member of, scoped to the
1506
+ * active project environment. Optionally filter by `externalRefs`.
1507
+ *
1508
+ * @param [params] - Optional filters.
1509
+ * @param [params.externalRefs] - Return only accounts whose externalRef is in this list.
1510
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1511
+ * @returns A paginated list of business accounts.
1512
+ * @notInstrumented
1513
+ */
1514
+ const listBusinessAccounts = async (params, client = getDefaultClient()) => {
1515
+ const core = getCore(client);
1516
+ return await createApiClient({}, client).sdkListBusinessAccounts({
1517
+ environmentId: core.environmentId,
1518
+ externalRef: params?.externalRefs
1519
+ });
1520
+ };
1521
+
1522
+ //#endregion
1523
+ //#region src/modules/waas/refreshWaasWalletAccountShares/refreshWaasWalletAccountShares.ts
1524
+ /**
1525
+ * Refreshes the cryptographic key shares for a WaaS wallet account.
1526
+ *
1527
+ * This function generates new key shares for the wallet while maintaining
1528
+ * the same threshold signature scheme.
1529
+ *
1530
+ * @param params.walletAccount - The WaaS wallet account to refresh shares for.
1531
+ * @param [params.password] - Optional password for key share operations.
1532
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1533
+ * @returns A promise that resolves when the key shares are refreshed.
1534
+ * @notInstrumented
1535
+ */
1536
+ const refreshWaasWalletAccountShares = async ({ walletAccount, password }, client = getDefaultClient()) => {
1537
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).refreshWalletAccountShares({
1538
+ password,
1539
+ walletAccount
1540
+ });
1541
+ };
1542
+
1543
+ //#endregion
1544
+ //#region src/modules/waas/policies/removeAccountPolicyRule/removeAccountPolicyRule.ts
1545
+ /**
1546
+ * Removes a single rule from a business account's account-Layer. BA
1547
+ * owner/admin only. Calls the SDK API directly (no MPC step), so a
1548
+ * rejection surfaces as a thrown error.
1549
+ *
1550
+ * @param params.businessAccountId - The business account to remove the rule from.
1551
+ * @param params.ruleId - The id of the rule to remove.
1552
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1553
+ * @returns The account-Layer as it stands after the rule is removed.
1554
+ * @notInstrumented
1555
+ */
1556
+ const removeAccountPolicyRule = async ({ businessAccountId, ruleId }, client = getDefaultClient()) => {
1557
+ const core = getCore(client);
1558
+ return createApiClient({}, client).updateBusinessAccountPolicyLayer({
1559
+ businessAccountId,
1560
+ environmentId: core.environmentId,
1561
+ waasPolicyLayerUpdateRequest: {
1562
+ op: WaasPolicyLayerUpdateRequestOpEnum.Remove,
1563
+ ruleId
1564
+ }
1565
+ });
1566
+ };
1567
+
1568
+ //#endregion
1569
+ //#region src/modules/waas/businessAccounts/removeBusinessAccountMember/removeBusinessAccountMember.ts
1570
+ /**
1571
+ * Removes a member from a business account. Any signer rows the member held on
1572
+ * the account's wallets are torn down as part of the removal. The backend
1573
+ * refuses to remove the account's last owner.
1574
+ *
1575
+ * @param params.businessAccountId - The business account to remove the member from.
1576
+ * @param params.userId - The id of the user to remove.
1577
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1578
+ * @returns The removed member.
1579
+ *
1580
+ * @example
1581
+ * ```ts
1582
+ * const detail = await getBusinessAccount({ businessAccountId });
1583
+ * const member = detail.members[0];
1584
+ * await removeBusinessAccountMember({
1585
+ * businessAccountId,
1586
+ * userId: member.userId,
1587
+ * });
1588
+ * ```
1589
+ *
1590
+ * @see addBusinessAccountMember
1591
+ * @see getBusinessAccount
1592
+ * @notInstrumented
1593
+ */
1594
+ const removeBusinessAccountMember = async ({ businessAccountId, userId }, client = getDefaultClient()) => {
1595
+ const core = getCore(client);
1596
+ const { member } = await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountmemberremove }, client).sdkRemoveBusinessAccountMember({
1597
+ businessAccountId,
1598
+ environmentId: core.environmentId,
1599
+ userId
1600
+ });
1601
+ return member;
1602
+ };
1603
+
1604
+ //#endregion
1605
+ //#region src/modules/waas/businessAccounts/removeBusinessAccountSigner/removeBusinessAccountSigner.ts
1606
+ /**
1607
+ * Removes a signer from a business-account wallet. This detaches the signer's
1608
+ * share set from the wallet — it does not run an MPC ceremony — so the removed
1609
+ * identity can no longer sign for that wallet. The backend refuses to remove
1610
+ * the last remaining signer on a wallet.
1611
+ *
1612
+ * @param params.businessAccountId - The business account the wallet belongs to.
1613
+ * @param params.walletId - The wallet the signer is attached to.
1614
+ * @param params.signerId - The id of the signer to remove (`BusinessAccountSigner.id`).
1615
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1616
+ * @returns The removed signer.
1617
+ *
1618
+ * @example
1619
+ * ```ts
1620
+ * const detail = await getBusinessAccount({ businessAccountId });
1621
+ * const signer = detail.signers[0];
1622
+ * await removeBusinessAccountSigner({
1623
+ * businessAccountId,
1624
+ * walletId: signer.walletId,
1625
+ * signerId: signer.id,
1626
+ * });
1627
+ * ```
1628
+ *
1629
+ * @see addBusinessAccountSigner
1630
+ * @see getBusinessAccount
1631
+ * @notInstrumented
1632
+ */
1633
+ const removeBusinessAccountSigner = async ({ businessAccountId, walletId, signerId }, client = getDefaultClient()) => {
1634
+ const core = getCore(client);
1635
+ const { signer } = await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountsignerremove }, client).sdkRemoveBusinessAccountSigner({
1636
+ businessAccountId,
1637
+ environmentId: core.environmentId,
1638
+ signerId,
1639
+ walletId
1640
+ });
1641
+ return signer;
1642
+ };
1643
+
1644
+ //#endregion
1645
+ //#region src/modules/waas/businessAccounts/removeBusinessAccountWallet/removeBusinessAccountWallet.ts
1646
+ /**
1647
+ * Removes a wallet from a business account (owner-/admin-only). The wallet and
1648
+ * all its associated signer rows are detached from the account. The backend
1649
+ * refuses to remove the last wallet on a business account.
1650
+ *
1651
+ * @param params.businessAccountId - The business account the wallet belongs to.
1652
+ * @param params.walletId - The wallet to remove (`BusinessAccountWallet.id`).
1653
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1654
+ * @returns The updated business account detail.
1655
+ *
1656
+ * @example
1657
+ * ```ts
1658
+ * const detail = await getBusinessAccount({ businessAccountId });
1659
+ * await removeBusinessAccountWallet({
1660
+ * businessAccountId,
1661
+ * walletId: detail.wallets[0].id,
1662
+ * });
1663
+ * ```
1664
+ *
1665
+ * @see addWalletToBusinessAccount
1666
+ * @see getBusinessAccount
1667
+ * @notInstrumented
1668
+ */
1669
+ const removeBusinessAccountWallet = async ({ businessAccountId, walletId }, client = getDefaultClient()) => {
1670
+ const core = getCore(client);
1671
+ const detail = await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountwalletremove }, client).sdkRemoveBusinessAccountWallet({
1672
+ businessAccountId,
1673
+ environmentId: core.environmentId,
1674
+ walletId
1675
+ });
1676
+ await __refreshAuth_wrapped(client);
1677
+ return detail;
1678
+ };
1679
+
1680
+ //#endregion
1681
+ //#region src/modules/waas/policies/buildOperationForExistingRule/buildOperationForExistingRule.ts
1682
+ /**
1683
+ * Builds the operation to remove or rebuild `existingRule` when the
1684
+ * caller's requested keys touch it — outright removal when every key it
1685
+ * covers is being removed, or an upsert of the rule rebuilt from its
1686
+ * remaining keys when only some are. Returns undefined when none of the
1687
+ * requested keys touch this rule, when it's outside the sugar vocabulary,
1688
+ * or when it can't be identified without a `ruleId`.
1689
+ *
1690
+ * @param params.chain - The chain the rule to remove/rebuild applies to.
1691
+ * @param params.chainIds - The chain ids the rule to remove/rebuild applies to.
1692
+ * @param params.existingRule - The existing layer rule to check.
1693
+ * @param params.rules - The sugar keys to remove.
1694
+ * @returns The operation for this rule, or undefined when it isn't touched.
1695
+ * @notInstrumented
1696
+ */
1697
+ const buildOperationForExistingRule = ({ chain, chainIds, existingRule, rules }) => {
1698
+ if (existingRule.ruleId === void 0) return;
1699
+ const covered = readCoveredRule(existingRule);
1700
+ if (covered === void 0) return;
1701
+ const remainingKeys = covered.keys.filter((key) => !rules.includes(key));
1702
+ if (remainingKeys.length === covered.keys.length) return;
1703
+ if (remainingKeys.length === 0) return {
1704
+ op: WaasPolicyLayerRuleOperationOpEnum.Remove,
1705
+ ruleId: existingRule.ruleId
1706
+ };
1707
+ const remainingRules = {};
1708
+ for (const key of remainingKeys) Object.assign(remainingRules, { [key]: covered.values[key] });
1709
+ const [rebuiltRule] = expandPolicyRules({
1710
+ chain,
1711
+ chainIds,
1712
+ rules: remainingRules
1713
+ });
1714
+ if (rebuiltRule === void 0) return;
1715
+ const keepsName = readCoveredRule(rebuiltRule)?.kind === covered.kind;
1716
+ return {
1717
+ op: WaasPolicyLayerRuleOperationOpEnum.Upsert,
1718
+ rule: {
1719
+ ...rebuiltRule,
1720
+ name: keepsName ? existingRule.name ?? rebuiltRule.name : rebuiltRule.name,
1721
+ ruleId: existingRule.ruleId
1722
+ }
1723
+ };
1724
+ };
1725
+
1726
+ //#endregion
1727
+ //#region src/modules/waas/policies/removePolicyRules/removePolicyRules.ts
1728
+ /**
1729
+ * Removes the rules behind one or more {@link PolicyRules} keys from a
1730
+ * policy layer, in one atomic `batch` PATCH. For every existing rule the
1731
+ * given keys touch, either removes it outright or — when it also covers a
1732
+ * key the caller didn't ask to remove (e.g. an
1733
+ * `allowAddresses`+`maxAmountPerTransaction` rule with only the cap
1734
+ * removed) — rebuilds it from the remaining keys so that restriction
1735
+ * survives.
1736
+ *
1737
+ * @param params.scope - Which policy layer to update — see {@link resolvePolicyScope}.
1738
+ * @param params.chain - The chain the rules to remove apply to.
1739
+ * @param params.chainIds - The chain ids the rules to remove apply to; omit to target the wildcard rule that matches every chain id of `chain`.
1740
+ * @param params.rules - The sugar keys to remove.
1741
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1742
+ * @returns The policy layer as it stands after the batch is applied.
1743
+ * @throws When none of the given keys match an existing rule for this chain scope, or via {@link resolvePolicyScope}'s scope-resolution errors.
1744
+ * @notInstrumented
1745
+ */
1746
+ const removePolicyRules = async ({ chain, chainIds, rules, scope }, client = getDefaultClient()) => {
1747
+ const normalizedChainIds = chainIds ?? [];
1748
+ const resolvedScope = resolvePolicyScope({ scope }, client);
1749
+ const operations = ((await getResolvedPolicyLayer({ resolvedScope }, client)).layerContent.rules ?? []).filter((existingRule) => existingRule.chain === chain && sameChainIds({
1750
+ existing: existingRule.chainIds,
1751
+ requested: normalizedChainIds
1752
+ })).map((existingRule) => buildOperationForExistingRule({
1753
+ chain,
1754
+ chainIds: normalizedChainIds,
1755
+ existingRule,
1756
+ rules
1757
+ })).filter((operation) => operation !== void 0);
1758
+ if (operations.length === 0) throw new InvalidParamError("removePolicyRules: none of the given rule keys matched an existing rule for this scope");
1759
+ return applyPolicyLayerBatch({
1760
+ operations,
1761
+ resolvedScope
1762
+ }, client);
1763
+ };
1764
+
1765
+ //#endregion
1766
+ //#region src/modules/waas/policies/removeSignerPolicyRule/removeSignerPolicyRule.ts
1767
+ /**
1768
+ * Removes a single rule from a signer's policy layer. Calls the SDK API
1769
+ * directly (no MPC step), so a rejection surfaces as a thrown error.
1770
+ *
1771
+ * @param params.walletAccount - The wallet account whose signer-Layer to update.
1772
+ * @param params.ruleId - The id of the rule to remove.
1773
+ * @param [params.shareSetId] - The share set to target; defaults to the caller's own. Only the wallet's own owner may target another share set.
1774
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1775
+ * @returns The signer-Layer as it stands after the rule is removed.
1776
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
1777
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
1778
+ * @notInstrumented
1779
+ */
1780
+ const removeSignerPolicyRule = async ({ ruleId, shareSetId, walletAccount }, client = getDefaultClient()) => {
1781
+ assertDefined(walletAccount.verifiedCredentialId, "removeSignerPolicyRule: cannot resolve a wallet id — use a verified wallet account");
1782
+ const core = getCore(client);
1783
+ return createApiClient({}, client).updateWaasSignerSelfPolicyLayer({
1784
+ environmentId: core.environmentId,
1785
+ waasSignerPolicyLayerUpdateRequest: {
1786
+ op: WaasSignerPolicyLayerUpdateRequestOpEnum.Remove,
1787
+ ruleId,
1788
+ shareSetId
1789
+ },
1790
+ walletId: walletAccount.verifiedCredentialId
1791
+ });
1792
+ };
1793
+
1794
+ //#endregion
1795
+ //#region src/modules/waas/policies/removeWalletPolicyRule/removeWalletPolicyRule.ts
1796
+ /**
1797
+ * Removes a single rule from a wallet's policy layer. Calls the SDK API
1798
+ * directly (no MPC step), so a rejection surfaces as a thrown error.
1799
+ *
1800
+ * @param params.walletAccount - The wallet account to remove the rule from.
1801
+ * @param params.ruleId - The id of the rule to remove.
1802
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1803
+ * @returns The wallet-Layer as it stands after the rule is removed.
1804
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
1805
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
1806
+ * @notInstrumented
1807
+ */
1808
+ const removeWalletPolicyRule = async ({ ruleId, walletAccount }, client = getDefaultClient()) => {
1809
+ assertDefined(walletAccount.verifiedCredentialId, "removeWalletPolicyRule: cannot resolve a wallet id — use a verified wallet account");
1810
+ const core = getCore(client);
1811
+ return createApiClient({}, client).updateWaasWalletSelfPolicyLayer({
1812
+ environmentId: core.environmentId,
1813
+ waasPolicyLayerUpdateRequest: {
1814
+ op: WaasPolicyLayerUpdateRequestOpEnum.Remove,
1815
+ ruleId
1816
+ },
1817
+ walletId: walletAccount.verifiedCredentialId
1818
+ });
1819
+ };
1820
+
1821
+ //#endregion
1822
+ //#region src/modules/waas/revokeWaasDelegation/revokeWaasDelegation.ts
1823
+ /**
1824
+ * Revokes the delegation of a WaaS wallet account.
1825
+ *
1826
+ * @param params.walletAccount - The WaaS wallet account to revoke delegation for.
1827
+ * @param [params.password] - Optional password for delegation operations.
1828
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1829
+ * @returns A promise that resolves when the delegation is revoked.
1830
+ * @notInstrumented
1831
+ */
1832
+ const revokeWaasDelegation = async ({ password, walletAccount }, client = getDefaultClient()) => {
1833
+ await getWaasWalletProviderFromWalletAccount({ walletAccount }, client).revokeDelegation({
1834
+ password,
1835
+ walletAccount
1836
+ });
1837
+ await __refreshAuth_wrapped(client);
1838
+ };
1839
+
1840
+ //#endregion
1841
+ //#region src/modules/waas/setWaasWalletAccountPassword/setWaasWalletAccountPassword.ts
1842
+ /**
1843
+ * Sets a password for a WaaS wallet account.
1844
+ *
1845
+ * @param params.walletAccount - The WaaS wallet account to set the password for.
1846
+ * @param params.password - The password to set for the wallet.
1847
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1848
+ * @returns A promise that resolves when the password is successfully set.
1849
+ * @notInstrumented
1850
+ */
1851
+ const setWaasWalletAccountPassword = async ({ password, walletAccount }, client = getDefaultClient()) => {
1852
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).setWaasWalletAccountPassword({
1853
+ password,
1854
+ walletAccount
1855
+ });
1856
+ };
1857
+
1858
+ //#endregion
1859
+ //#region src/modules/wallets/userHasExternalWallet/userHasExternalWallet.ts
1860
+ /** @notInstrumented */
1861
+ const userHasExternalWallet = (user) => {
1862
+ return user?.verifiedCredentials.some((vc) => vc.format === JwtVerifiedCredentialFormatEnum.Blockchain && vc.walletProvider !== WalletProviderEnum.EmbeddedWallet);
1863
+ };
1864
+
1865
+ //#endregion
1866
+ //#region src/modules/waas/shouldAutoCreateWalletForChain/shouldAutoCreateWalletForChain.ts
1867
+ /**
1868
+ * Checks if a WaaS wallet should be automatically created for the specified blockchain.
1869
+ *
1870
+ * This function determines whether the current user configuration and project
1871
+ * settings require automatic wallet creation for the given chain, considering
1872
+ * whether the user already has an embedded wallet for the enabled chains or an external wallet.
1873
+ *
1874
+ * @param params.chain - The blockchain network to check.
1875
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1876
+ * @returns True if a wallet should be auto-created for the chain, false otherwise.
1877
+ * @notInstrumented
1878
+ */
1879
+ const shouldAutoCreateWalletForChain = ({ chain }, client = getDefaultClient()) => {
1880
+ assertDefined(client.projectSettings, "Project settings are not available");
1881
+ const embeddedWalletSettings = client.projectSettings.sdk.embeddedWallets;
1882
+ if (!embeddedWalletSettings?.automaticEmbeddedWalletCreation || !client.user) return false;
1883
+ const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings?.automaticEmbeddedWalletCreationForExternal;
1884
+ if (!(!userHasExternalWallet(client.user) || automaticEmbeddedWalletCreationForExternalEnabled)) return false;
1885
+ return getChainsMissingWaasWalletAccounts(client).includes(chain);
1886
+ };
1887
+
1888
+ //#endregion
1889
+ //#region src/modules/waas/signSerializedTransaction/signSerializedTransaction.ts
1890
+ /**
1891
+ * No gas estimation, balance check, or broadcast — unlike `transferAmount`.
1892
+ * Useful for exercising WaaS policy enforcement in isolation.
1893
+ *
1894
+ * @param params.walletAccount - The wallet account to sign with.
1895
+ * @param params.serializedTransaction - The raw serialized transaction (e.g. viem's `serializeTransaction`).
1896
+ * @param [params.chainId] - The chain id, if required by the target chain's signer.
1897
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1898
+ * @returns The raw signature.
1899
+ * @notInstrumented
1900
+ */
1901
+ const signSerializedTransaction = async ({ chainId, serializedTransaction, walletAccount }, client = getDefaultClient()) => {
1902
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).signSerializedTransaction({
1903
+ chainId,
1904
+ serializedTransaction,
1905
+ walletAccount
1906
+ });
1907
+ };
1908
+
1909
+ //#endregion
1910
+ //#region src/modules/waas/businessAccounts/transferBusinessAccountOwnership/transferBusinessAccountOwnership.ts
1911
+ /**
1912
+ * Transfers ownership of a business account to another member. Owner-only: the
1913
+ * `newOwnerUserId` must already be a member, is promoted to owner, and the
1914
+ * current owner is atomically demoted to admin.
1915
+ *
1916
+ * @param params.businessAccountId - The business account whose ownership moves.
1917
+ * @param params.newOwnerUserId - The member to promote to owner.
1918
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1919
+ * @returns The updated business account detail.
1920
+ *
1921
+ * @example
1922
+ * ```ts
1923
+ * const detail = await getBusinessAccount({ businessAccountId });
1924
+ * const target = detail.members.find((m) => m.role === 'admin');
1925
+ * await transferBusinessAccountOwnership({
1926
+ * businessAccountId,
1927
+ * newOwnerUserId: target.userId,
1928
+ * });
1929
+ * ```
1930
+ *
1931
+ * @see getBusinessAccount
1932
+ * @notInstrumented
1933
+ */
1934
+ const transferBusinessAccountOwnership = async ({ businessAccountId, newOwnerUserId }, client = getDefaultClient()) => {
1935
+ const core = getCore(client);
1936
+ const detail = await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccounttransferOwnership }, client).sdkTransferBusinessAccountOwnership({
1937
+ businessAccountId,
1938
+ environmentId: core.environmentId,
1939
+ transferBusinessAccountOwnershipSdkRequest: { newOwnerUserId }
1940
+ });
1941
+ await __logoutWithReason_wrapped({ reason: "business-account-ownership-transferred" }, client);
1942
+ return detail;
1943
+ };
1944
+
1945
+ //#endregion
1946
+ //#region src/modules/waas/unlockWallet/unlockWallet.ts
1947
+ /**
1948
+ * Unlocks a WaaS wallet account.
1949
+ *
1950
+ * @param params.walletAccount - The WaaS wallet account to unlock.
1951
+ * @param params.password - The password to unlock the wallet.
1952
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1953
+ * @returns A promise that resolves with the wallet information.
1954
+ * @notInstrumented
1955
+ */
1956
+ const unlockWallet = async ({ password, walletAccount }, client = getDefaultClient()) => {
1957
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).unlockWallet({
1958
+ password,
1959
+ walletAccount
1960
+ });
1961
+ };
1962
+
1963
+ //#endregion
1964
+ //#region src/modules/waas/businessAccounts/updateBusinessAccount/updateBusinessAccount.ts
1965
+ /**
1966
+ * Renames a business account (owner-/admin-only). Calls the SDK API directly
1967
+ * (no MPC step), so a rejection surfaces as a thrown error.
1968
+ *
1969
+ * @param params.businessAccountId - The business account to rename.
1970
+ * @param params.name - The new name.
1971
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1972
+ * @returns The updated business account.
1973
+ *
1974
+ * @example
1975
+ * ```ts
1976
+ * await updateBusinessAccount({ businessAccountId, name: 'Acme Inc' });
1977
+ * ```
1978
+ *
1979
+ * @see getBusinessAccount
1980
+ * @notInstrumented
1981
+ */
1982
+ const updateBusinessAccount = async ({ businessAccountId, name: name$1 }, client = getDefaultClient()) => {
1983
+ const core = getCore(client);
1984
+ return await createApiClient({}, client).sdkUpdateBusinessAccount({
1985
+ businessAccountId,
1986
+ environmentId: core.environmentId,
1987
+ updateBusinessAccountSdkRequest: { name: name$1 }
1988
+ });
1989
+ };
1990
+
1991
+ //#endregion
1992
+ //#region src/modules/waas/businessAccounts/updateBusinessAccountMemberRole/updateBusinessAccountMemberRole.ts
1993
+ const ROLE_TO_API = {
1994
+ admin: AssignableBusinessAccountMemberRole.Admin,
1995
+ viewer: AssignableBusinessAccountMemberRole.Viewer
1996
+ };
1997
+ /**
1998
+ * Changes an existing member's role between `admin` and `viewer` (owner-/admin-only).
1999
+ * Owner is not assignable here — use `transferBusinessAccountOwnership` for that.
2000
+ *
2001
+ * @param params.businessAccountId - The business account the member belongs to.
2002
+ * @param params.userId - The member whose role changes.
2003
+ * @param params.role - The new role (`admin` or `viewer`).
2004
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2005
+ * @returns The updated business account member.
2006
+ *
2007
+ * @example
2008
+ * ```ts
2009
+ * await updateBusinessAccountMemberRole({
2010
+ * businessAccountId,
2011
+ * userId: member.userId,
2012
+ * role: 'admin',
2013
+ * });
2014
+ * ```
2015
+ *
2016
+ * @see transferBusinessAccountOwnership
2017
+ * @see addBusinessAccountMember
2018
+ * @notInstrumented
2019
+ */
2020
+ const updateBusinessAccountMemberRole = async ({ businessAccountId, userId, role }, client = getDefaultClient()) => {
2021
+ const core = getCore(client);
2022
+ return await createApiClient({ elevatedAccessTokenScope: TokenScope.BusinessAccountmemberroleupdate }, client).sdkUpdateBusinessAccountMemberRole({
2023
+ businessAccountId,
2024
+ environmentId: core.environmentId,
2025
+ updateBusinessAccountMemberRoleSdkRequest: { role: ROLE_TO_API[role] },
2026
+ userId
2027
+ });
2028
+ };
2029
+
2030
+ //#endregion
2031
+ //#region src/modules/waas/updateWaasPassword/updateWaasPassword.ts
2032
+ /**
2033
+ * Updates the password for a WaaS wallet account.
2034
+ *
2035
+ * This function changes the password used to encrypt and protect the
2036
+ * cryptographic key shares for the specified wallet account.
2037
+ *
2038
+ * @param params.walletAccount - The WaaS wallet account to update the password for.
2039
+ * @param params.currentPassword - The current password for the wallet.
2040
+ * @param params.newPassword - The new password to set for the wallet.
2041
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2042
+ * @returns A promise that resolves when the password is successfully updated.
2043
+ * @notInstrumented
2044
+ */
2045
+ const updateWaasPassword = async ({ currentPassword, newPassword, walletAccount }, client = getDefaultClient()) => {
2046
+ return getWaasWalletProviderFromWalletAccount({ walletAccount }, client).updatePassword({
2047
+ currentPassword,
2048
+ newPassword,
2049
+ walletAccount
2050
+ });
2051
+ };
2052
+
2053
+ //#endregion
2054
+ //#region src/modules/waas/policies/upsertAccountPolicyRule/upsertAccountPolicyRule.ts
2055
+ /**
2056
+ * Creates or updates a single rule on a business account's account-Layer
2057
+ * (rules applied to every wallet in the account). Build `rule` with
2058
+ * {@link buildAllowPolicyRule} / {@link buildDenyPolicyRule}. Omit
2059
+ * `rule.ruleId` to create a new rule (the enclave mints one for you); pass
2060
+ * an existing `ruleId` to update it in place. BA owner/admin only. Calls
2061
+ * the SDK API directly (no MPC step), so a rejection surfaces as a thrown
2062
+ * error.
2063
+ *
2064
+ * @param params.businessAccountId - The business account to apply the rule to.
2065
+ * @param params.rule - The rule to create or update.
2066
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2067
+ * @returns The account-Layer as it stands after the rule is applied.
2068
+ * @notInstrumented
2069
+ */
2070
+ const upsertAccountPolicyRule = async ({ businessAccountId, rule }, client = getDefaultClient()) => {
2071
+ const core = getCore(client);
2072
+ return createApiClient({}, client).updateBusinessAccountPolicyLayer({
2073
+ businessAccountId,
2074
+ environmentId: core.environmentId,
2075
+ waasPolicyLayerUpdateRequest: {
2076
+ op: WaasPolicyLayerUpdateRequestOpEnum.Upsert,
2077
+ rule
2078
+ }
2079
+ });
2080
+ };
2081
+
2082
+ //#endregion
2083
+ //#region src/modules/waas/policies/upsertSignerPolicyRule/upsertSignerPolicyRule.ts
2084
+ /**
2085
+ * Creates or updates a single rule on a signer's policy layer. Build `rule`
2086
+ * with {@link buildAllowPolicyRule} / {@link buildDenyPolicyRule}. Omit
2087
+ * `rule.ruleId` to create a new rule (the enclave mints one for you); pass an
2088
+ * existing `ruleId` to update it in place. Calls the SDK API directly (no MPC
2089
+ * step), so a rejection surfaces as a thrown error.
2090
+ *
2091
+ * @param params.walletAccount - The wallet account whose signer-Layer to update.
2092
+ * @param params.rule - The rule to create or update.
2093
+ * @param [params.shareSetId] - The share set to target; defaults to the caller's own. Only the wallet's own owner may target another share set.
2094
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2095
+ * @returns The signer-Layer as it stands after the rule is applied.
2096
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
2097
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
2098
+ * @notInstrumented
2099
+ */
2100
+ const upsertSignerPolicyRule = async ({ rule, shareSetId, walletAccount }, client = getDefaultClient()) => {
2101
+ assertDefined(walletAccount.verifiedCredentialId, "upsertSignerPolicyRule: cannot resolve a wallet id — use a verified wallet account");
2102
+ const core = getCore(client);
2103
+ return createApiClient({}, client).updateWaasSignerSelfPolicyLayer({
2104
+ environmentId: core.environmentId,
2105
+ waasSignerPolicyLayerUpdateRequest: {
2106
+ op: WaasSignerPolicyLayerUpdateRequestOpEnum.Upsert,
2107
+ rule,
2108
+ shareSetId
2109
+ },
2110
+ walletId: walletAccount.verifiedCredentialId
2111
+ });
2112
+ };
2113
+
2114
+ //#endregion
2115
+ //#region src/modules/waas/policies/upsertWalletPolicyRule/upsertWalletPolicyRule.ts
2116
+ /**
2117
+ * Creates or updates a single rule on a wallet's policy layer. Build `rule`
2118
+ * with {@link buildAllowPolicyRule} / {@link buildDenyPolicyRule}. Omit
2119
+ * `rule.ruleId` to create a new rule (the enclave mints one for you); pass an
2120
+ * existing `ruleId` to update it in place. Calls the SDK API directly (no MPC
2121
+ * step), so a rejection surfaces as a thrown error.
2122
+ *
2123
+ * @param params.walletAccount - The wallet account to apply the rule to.
2124
+ * @param params.rule - The rule to create or update.
2125
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
2126
+ * @returns The wallet-Layer as it stands after the rule is applied.
2127
+ * @throws {ValueMustBeDefinedError} When `walletAccount` has no `verifiedCredentialId` (it isn't a verified wallet account yet).
2128
+ * @throws {APIError} When the SDK API request fails, for example an unauthorized, not-found, or server error response.
2129
+ * @notInstrumented
2130
+ */
2131
+ const upsertWalletPolicyRule = async ({ rule, walletAccount }, client = getDefaultClient()) => {
2132
+ assertDefined(walletAccount.verifiedCredentialId, "upsertWalletPolicyRule: cannot resolve a wallet id — use a verified wallet account");
2133
+ const core = getCore(client);
2134
+ return createApiClient({}, client).updateWaasWalletSelfPolicyLayer({
2135
+ environmentId: core.environmentId,
2136
+ waasPolicyLayerUpdateRequest: {
2137
+ op: WaasPolicyLayerUpdateRequestOpEnum.Upsert,
2138
+ rule
2139
+ },
2140
+ walletId: walletAccount.verifiedCredentialId
2141
+ });
2142
+ };
2143
+
2144
+ //#endregion
2145
+ //#region src/exports/waas.ts
2146
+ assertPackageVersion(name, version);
2147
+
2148
+ //#endregion
2149
+ export { WaasWalletShareSetType$1 as $, getChainsMissingWaasWalletAccounts as A, isWalletCreationRequirement as B, importWaasPrivateKey as C, getWalletAccountShareSets as D, getWalletPolicyLayer as E, desugarPolicyRules as F, createBusinessAccount as G, createPolicy as H, delegateWaasKeyShares as I, backupWaasKeySharesToGoogleDrive as J, buildDenyPolicyRule as K, createWalletForBusinessAccount as L, getAccountPolicyLayer as M, exportWaasPrivateKey as N, getSignerPolicyLayer as O, exportWaasClientKeyshares as P, WaasChainEnum$1 as Q, createWaasWalletAccounts as R, isPasswordRequiredForWaasWallets as S, getWalletRecoveryState as T, resolvePolicyScope as U, createWaasOfflineRecoveryShares as V, expandPolicyRules as W, addBusinessAccountSigner as X, addWalletToBusinessAccount as Y, addBusinessAccountMember as Z, removeBusinessAccountSigner as _, updateBusinessAccountMemberRole as a, refreshWaasWalletAccountShares as b, transferBusinessAccountOwnership as c, setWaasWalletAccountPassword as d, revokeWaasDelegation as f, removeBusinessAccountWallet as g, removePolicyRules as h, updateWaasPassword as i, getBusinessAccount as j, getPolicy as k, signSerializedTransaction as l, removeSignerPolicyRule as m, upsertSignerPolicyRule as n, updateBusinessAccount as o, removeWalletPolicyRule as p, buildAllowPolicyRule as q, upsertAccountPolicyRule as r, unlockWallet as s, upsertWalletPolicyRule as t, shouldAutoCreateWalletForChain as u, removeBusinessAccountMember as v, hasDelegatedAccess as w, listBusinessAccounts as x, removeAccountPolicyRule as y, normalizeWalletRequirements as z };
2150
+ //# sourceMappingURL=waas-CUDgU2pl.esm.js.map