@dynamic-labs-sdk/client 1.3.0 → 1.5.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 (225) hide show
  1. package/dist/{InvalidParamError-DQvZQdQ9.cjs → InvalidParamError-DKJhDrK8.cjs} +1056 -110
  2. package/dist/InvalidParamError-DKJhDrK8.cjs.map +1 -0
  3. package/dist/{InvalidParamError-Za4cvW7K.esm.js → InvalidParamError-DWjMfOZ5.esm.js} +852 -95
  4. package/dist/InvalidParamError-DWjMfOZ5.esm.js.map +1 -0
  5. package/dist/{InvalidParamError-9kQBK3sP.native.esm.js → InvalidParamError-DkAMYJOW.native.esm.js} +885 -95
  6. package/dist/InvalidParamError-DkAMYJOW.native.esm.js.map +1 -0
  7. package/dist/{NotWaasWalletAccountError-By3Y4taq.esm.js → NotWaasWalletAccountError-BVrvQzLz.native.esm.js} +7 -5
  8. package/dist/NotWaasWalletAccountError-BVrvQzLz.native.esm.js.map +1 -0
  9. package/dist/{NotWaasWalletAccountError-BTMvHTA8.native.esm.js → NotWaasWalletAccountError-C7NUlvvM.esm.js} +7 -5
  10. package/dist/NotWaasWalletAccountError-C7NUlvvM.esm.js.map +1 -0
  11. package/dist/{NotWaasWalletAccountError-Ciq7b-Y6.cjs → NotWaasWalletAccountError-CHzpa9kk.cjs} +7 -5
  12. package/dist/NotWaasWalletAccountError-CHzpa9kk.cjs.map +1 -0
  13. package/dist/core.cjs +46 -23
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.esm.js +29 -8
  16. package/dist/core.esm.js.map +1 -1
  17. package/dist/core.native.esm.js +27 -6
  18. package/dist/core.native.esm.js.map +1 -1
  19. package/dist/exports/core.d.ts +6 -0
  20. package/dist/exports/core.d.ts.map +1 -1
  21. package/dist/exports/index.d.ts +14 -1
  22. package/dist/exports/index.d.ts.map +1 -1
  23. package/dist/{getNetworkProviderFromNetworkId-BA0CHZzu.cjs → getNetworkProviderFromNetworkId-BJ27N-7S.cjs} +113 -348
  24. package/dist/getNetworkProviderFromNetworkId-BJ27N-7S.cjs.map +1 -0
  25. package/dist/{getNetworkProviderFromNetworkId-COptFPwJ.native.esm.js → getNetworkProviderFromNetworkId-Bs1kQdWk.native.esm.js} +106 -311
  26. package/dist/getNetworkProviderFromNetworkId-Bs1kQdWk.native.esm.js.map +1 -0
  27. package/dist/{getNetworkProviderFromNetworkId-RWcIZDgC.esm.js → getNetworkProviderFromNetworkId-Cqp9eRSs.esm.js} +110 -282
  28. package/dist/getNetworkProviderFromNetworkId-Cqp9eRSs.esm.js.map +1 -0
  29. package/dist/{getSignedSessionId-la6RXITX.esm.js → getSignedSessionId-CDdKrnw6.esm.js} +3 -3
  30. package/dist/{getSignedSessionId-la6RXITX.esm.js.map → getSignedSessionId-CDdKrnw6.esm.js.map} +1 -1
  31. package/dist/{getSignedSessionId-BCU987hO.cjs → getSignedSessionId-CHDHr-hY.cjs} +3 -3
  32. package/dist/{getSignedSessionId-BCU987hO.cjs.map → getSignedSessionId-CHDHr-hY.cjs.map} +1 -1
  33. package/dist/{getSignedSessionId-DzNCj6g_.native.esm.js → getSignedSessionId-D3KQrN8W.native.esm.js} +3 -3
  34. package/dist/{getSignedSessionId-DzNCj6g_.native.esm.js.map → getSignedSessionId-D3KQrN8W.native.esm.js.map} +1 -1
  35. package/dist/getVerifiedCredentialForWalletAccount-BuUCX040.esm.js +269 -0
  36. package/dist/getVerifiedCredentialForWalletAccount-BuUCX040.esm.js.map +1 -0
  37. package/dist/getVerifiedCredentialForWalletAccount-Ciac5d5L.native.esm.js +269 -0
  38. package/dist/getVerifiedCredentialForWalletAccount-Ciac5d5L.native.esm.js.map +1 -0
  39. package/dist/getVerifiedCredentialForWalletAccount-gCx0smU8.cjs +346 -0
  40. package/dist/getVerifiedCredentialForWalletAccount-gCx0smU8.cjs.map +1 -0
  41. package/dist/index.cjs +754 -319
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.esm.js +687 -260
  44. package/dist/index.esm.js.map +1 -1
  45. package/dist/index.native.esm.js +684 -257
  46. package/dist/index.native.esm.js.map +1 -1
  47. package/dist/{isMfaRequiredForAction-C1u4Z__n.esm.js → isMfaRequiredForAction-B0xNvBpU.native.esm.js} +5 -3
  48. package/dist/isMfaRequiredForAction-B0xNvBpU.native.esm.js.map +1 -0
  49. package/dist/{isMfaRequiredForAction-CMClgbT0.cjs → isMfaRequiredForAction-CLMvTTwl.cjs} +5 -3
  50. package/dist/isMfaRequiredForAction-CLMvTTwl.cjs.map +1 -0
  51. package/dist/{isMfaRequiredForAction-DSX-TV2z.native.esm.js → isMfaRequiredForAction-C_QPI1LH.esm.js} +5 -3
  52. package/dist/isMfaRequiredForAction-C_QPI1LH.esm.js.map +1 -0
  53. package/dist/modules/apiClient/apiClient.types.d.ts +12 -0
  54. package/dist/modules/apiClient/apiClient.types.d.ts.map +1 -1
  55. package/dist/modules/apiClient/createApiClient.d.ts.map +1 -1
  56. package/dist/modules/apiClient/utils/sessionExpiryLogoutMiddleware/createSessionExpiryLogoutMiddleware.d.ts +27 -0
  57. package/dist/modules/apiClient/utils/sessionExpiryLogoutMiddleware/createSessionExpiryLogoutMiddleware.d.ts.map +1 -0
  58. package/dist/modules/auth/externalAuth/requestExternalAuthElevatedToken/requestExternalAuthElevatedToken.d.ts +1 -0
  59. package/dist/modules/auth/externalAuth/requestExternalAuthElevatedToken/requestExternalAuthElevatedToken.d.ts.map +1 -1
  60. package/dist/modules/auth/isSignedIn/isSignedIn.d.ts +11 -1
  61. package/dist/modules/auth/isSignedIn/isSignedIn.d.ts.map +1 -1
  62. package/dist/modules/auth/logoutReason.d.ts +1 -1
  63. package/dist/modules/auth/logoutReason.d.ts.map +1 -1
  64. package/dist/modules/auth/logoutWithReason/logoutWithReason.d.ts.map +1 -1
  65. package/dist/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts +2 -1
  66. package/dist/modules/auth/passkeys/registerPasskey/registerPasskey.d.ts.map +1 -1
  67. package/dist/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts +1 -0
  68. package/dist/modules/auth/passkeys/signInWithPasskey/signInWithPasskey.d.ts.map +1 -1
  69. package/dist/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts +2 -1
  70. package/dist/modules/auth/social/oauth/unlinkSocialAccount/unlinkSocialAccount.d.ts.map +1 -1
  71. package/dist/modules/balances/getBalances/getBalances.d.ts +9 -45
  72. package/dist/modules/balances/getBalances/getBalances.d.ts.map +1 -1
  73. package/dist/modules/balances/getMultichainBalances/getMultichainBalances.d.ts +13 -20
  74. package/dist/modules/balances/getMultichainBalances/getMultichainBalances.d.ts.map +1 -1
  75. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts +26 -0
  76. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts.map +1 -0
  77. package/dist/modules/balances/getMultichainTokenBalances/index.d.ts +2 -0
  78. package/dist/modules/balances/getMultichainTokenBalances/index.d.ts.map +1 -0
  79. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts +56 -0
  80. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts.map +1 -0
  81. package/dist/modules/balances/getTokenBalances/index.d.ts +3 -0
  82. package/dist/modules/balances/getTokenBalances/index.d.ts.map +1 -0
  83. package/dist/modules/captcha/setCaptchaToken/setCaptchaToken.d.ts +2 -1
  84. package/dist/modules/captcha/setCaptchaToken/setCaptchaToken.d.ts.map +1 -1
  85. package/dist/modules/checkout/attachCheckoutTransactionSource/attachCheckoutTransactionSource.d.ts.map +1 -1
  86. package/dist/modules/checkout/broadcastCheckoutTransaction/broadcastCheckoutTransaction.d.ts +1 -1
  87. package/dist/modules/checkout/broadcastCheckoutTransaction/broadcastCheckoutTransaction.d.ts.map +1 -1
  88. package/dist/modules/checkout/cancelCheckoutTransaction/cancelCheckoutTransaction.d.ts +1 -1
  89. package/dist/modules/checkout/cancelCheckoutTransaction/cancelCheckoutTransaction.d.ts.map +1 -1
  90. package/dist/modules/checkout/getCheckoutTransactionQuote/getCheckoutTransactionQuote.d.ts.map +1 -1
  91. package/dist/modules/checkout/prepareCheckoutTransaction/prepareCheckoutTransaction.d.ts.map +1 -1
  92. package/dist/modules/checkout/utils/clearCheckoutSessionToken/clearCheckoutSessionToken.d.ts +22 -0
  93. package/dist/modules/checkout/utils/clearCheckoutSessionToken/clearCheckoutSessionToken.d.ts.map +1 -0
  94. package/dist/modules/checkout/utils/clearCheckoutSessionToken/index.d.ts +3 -0
  95. package/dist/modules/checkout/utils/clearCheckoutSessionToken/index.d.ts.map +1 -0
  96. package/dist/modules/checkout/utils/subscribeToCheckoutTransaction/subscribeToCheckoutTransaction.d.ts.map +1 -1
  97. package/dist/modules/checkout/utils/withCheckoutSessionTokenCleanupOn401/index.d.ts +3 -0
  98. package/dist/modules/checkout/utils/withCheckoutSessionTokenCleanupOn401/index.d.ts.map +1 -0
  99. package/dist/modules/checkout/utils/withCheckoutSessionTokenCleanupOn401/withCheckoutSessionTokenCleanupOn401.d.ts +16 -0
  100. package/dist/modules/checkout/utils/withCheckoutSessionTokenCleanupOn401/withCheckoutSessionTokenCleanupOn401.d.ts.map +1 -0
  101. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts.map +1 -1
  102. package/dist/modules/funding/moonpay/errors/MoonPayCurrenciesFetchError.d.ts +5 -0
  103. package/dist/modules/funding/moonpay/errors/MoonPayCurrenciesFetchError.d.ts.map +1 -0
  104. package/dist/modules/funding/moonpay/errors/MoonPayInvalidUrlError.d.ts +5 -0
  105. package/dist/modules/funding/moonpay/errors/MoonPayInvalidUrlError.d.ts.map +1 -0
  106. package/dist/modules/funding/moonpay/errors/MoonPayProviderNotAvailableError.d.ts +5 -0
  107. package/dist/modules/funding/moonpay/errors/MoonPayProviderNotAvailableError.d.ts.map +1 -0
  108. package/dist/modules/funding/moonpay/getMoonPayCurrencies/getMoonPayCurrencies.d.ts +14 -0
  109. package/dist/modules/funding/moonpay/getMoonPayCurrencies/getMoonPayCurrencies.d.ts.map +1 -0
  110. package/dist/modules/funding/moonpay/getMoonPayCurrencies/index.d.ts +2 -0
  111. package/dist/modules/funding/moonpay/getMoonPayCurrencies/index.d.ts.map +1 -0
  112. package/dist/modules/funding/moonpay/getMoonPayUrl/getMoonPayUrl.d.ts +15 -0
  113. package/dist/modules/funding/moonpay/getMoonPayUrl/getMoonPayUrl.d.ts.map +1 -0
  114. package/dist/modules/funding/moonpay/getMoonPayUrl/index.d.ts +2 -0
  115. package/dist/modules/funding/moonpay/getMoonPayUrl/index.d.ts.map +1 -0
  116. package/dist/modules/funding/moonpay/moonpay.types.d.ts +26 -0
  117. package/dist/modules/funding/moonpay/moonpay.types.d.ts.map +1 -0
  118. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainFromWalletSchema/getChainFromWalletSchema.d.ts +12 -0
  119. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainFromWalletSchema/getChainFromWalletSchema.d.ts.map +1 -1
  120. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainsFromWalletSchema/getChainsFromWalletSchema.d.ts +26 -0
  121. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainsFromWalletSchema/getChainsFromWalletSchema.d.ts.map +1 -0
  122. package/dist/modules/legacyWalletBook/hasUsableDeeplink/hasUsableDeeplink.d.ts +18 -0
  123. package/dist/modules/legacyWalletBook/hasUsableDeeplink/hasUsableDeeplink.d.ts.map +1 -0
  124. package/dist/modules/legacyWalletBook/legacyWalletBook.types.d.ts +2 -2
  125. package/dist/modules/legacyWalletBook/legacyWalletBook.types.d.ts.map +1 -1
  126. package/dist/modules/mfa/consumeMfaToken/consumeMfaToken.d.ts +2 -1
  127. package/dist/modules/mfa/consumeMfaToken/consumeMfaToken.d.ts.map +1 -1
  128. package/dist/modules/mfa/createNewMfaRecoveryCodes/createNewMfaRecoveryCodes.d.ts +2 -1
  129. package/dist/modules/mfa/createNewMfaRecoveryCodes/createNewMfaRecoveryCodes.d.ts.map +1 -1
  130. package/dist/modules/otp/verifyOTP/verifyOTP.d.ts +2 -1
  131. package/dist/modules/otp/verifyOTP/verifyOTP.d.ts.map +1 -1
  132. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts +13 -1
  133. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -1
  134. package/dist/modules/user/refreshAuth/refreshAuth.d.ts +2 -1
  135. package/dist/modules/user/refreshAuth/refreshAuth.d.ts.map +1 -1
  136. package/dist/modules/walletOptionsCatalogue/buildMetaMaskSdkUriOptions/buildMetaMaskSdkUriOptions.d.ts +27 -0
  137. package/dist/modules/walletOptionsCatalogue/buildMetaMaskSdkUriOptions/buildMetaMaskSdkUriOptions.d.ts.map +1 -0
  138. package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts +8 -5
  139. package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts.map +1 -1
  140. package/dist/modules/walletOptionsCatalogue/buildWalletOption/buildWalletOption.d.ts +11 -4
  141. package/dist/modules/walletOptionsCatalogue/buildWalletOption/buildWalletOption.d.ts.map +1 -1
  142. package/dist/modules/walletOptionsCatalogue/buildWithWalletProviderOptions/buildWithWalletProviderOptions.d.ts.map +1 -1
  143. package/dist/modules/walletOptionsCatalogue/getConnectionOptionPriority/getConnectionOptionPriority.d.ts.map +1 -1
  144. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/getInstallationLinkForCurrentPlatform.d.ts +35 -0
  145. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/getInstallationLinkForCurrentPlatform.d.ts.map +1 -0
  146. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/index.d.ts +2 -0
  147. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/index.d.ts.map +1 -0
  148. package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts +9 -14
  149. package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts.map +1 -1
  150. package/dist/modules/walletOptionsCatalogue/resolveWalletBookWalletOptionKey/resolveWalletBookWalletOptionKey.d.ts +1 -1
  151. package/dist/modules/walletOptionsCatalogue/sortConnectionOptions/sortConnectionOptions.d.ts +1 -1
  152. package/dist/modules/walletOptionsCatalogue/sortWalletOptions/sortWalletOptions.d.ts +1 -1
  153. package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts +34 -35
  154. package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts.map +1 -1
  155. package/dist/modules/wallets/connectWithWalletProvider/connectWithWalletProvider.d.ts +1 -1
  156. package/dist/modules/wallets/connectWithWalletProvider/connectWithWalletProvider.d.ts.map +1 -1
  157. package/dist/modules/wallets/constants.d.ts +7 -0
  158. package/dist/modules/wallets/constants.d.ts.map +1 -1
  159. package/dist/modules/wallets/getAvailableWalletProvidersData/getAvailableWalletProvidersData.d.ts.map +1 -1
  160. package/dist/modules/wallets/hasWalletProviderConnectMethod/hasWalletProviderConnectMethod.d.ts +26 -0
  161. package/dist/modules/wallets/hasWalletProviderConnectMethod/hasWalletProviderConnectMethod.d.ts.map +1 -0
  162. package/dist/modules/wallets/hasWalletProviderConnectMethod/index.d.ts +2 -0
  163. package/dist/modules/wallets/hasWalletProviderConnectMethod/index.d.ts.map +1 -0
  164. package/dist/modules/wallets/isAnyWalletAccountConnected/index.d.ts +2 -0
  165. package/dist/modules/wallets/isAnyWalletAccountConnected/index.d.ts.map +1 -0
  166. package/dist/modules/wallets/isAnyWalletAccountConnected/isAnyWalletAccountConnected.d.ts +14 -0
  167. package/dist/modules/wallets/isAnyWalletAccountConnected/isAnyWalletAccountConnected.d.ts.map +1 -0
  168. package/dist/modules/wallets/networks/getBalance/getBalance.d.ts +6 -17
  169. package/dist/modules/wallets/networks/getBalance/getBalance.d.ts.map +1 -1
  170. package/dist/modules/wallets/networks/getNativeBalance/getNativeBalance.d.ts +24 -0
  171. package/dist/modules/wallets/networks/getNativeBalance/getNativeBalance.d.ts.map +1 -0
  172. package/dist/modules/wallets/networks/getNativeBalance/index.d.ts +2 -0
  173. package/dist/modules/wallets/networks/getNativeBalance/index.d.ts.map +1 -0
  174. package/dist/modules/wallets/reconcileWalletAccountsAgainstClient/index.d.ts +2 -0
  175. package/dist/modules/wallets/reconcileWalletAccountsAgainstClient/index.d.ts.map +1 -0
  176. package/dist/modules/wallets/reconcileWalletAccountsAgainstClient/reconcileWalletAccountsAgainstClient.d.ts +25 -0
  177. package/dist/modules/wallets/reconcileWalletAccountsAgainstClient/reconcileWalletAccountsAgainstClient.d.ts.map +1 -0
  178. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +10 -0
  179. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
  180. package/dist/services/instrumentation/connectLoggerToInstrumentation/connectLoggerToInstrumentation.d.ts.map +1 -1
  181. package/dist/services/instrumentation/constants.d.ts +22 -0
  182. package/dist/services/instrumentation/constants.d.ts.map +1 -1
  183. package/dist/services/instrumentation/scrubParameters/scrubParameters.d.ts.map +1 -1
  184. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  185. package/dist/utils/appendConnectionUriToDeeplink/appendConnectionUriToDeeplink.d.ts +29 -0
  186. package/dist/utils/appendConnectionUriToDeeplink/appendConnectionUriToDeeplink.d.ts.map +1 -0
  187. package/dist/utils/appendConnectionUriToDeeplink/index.d.ts +2 -0
  188. package/dist/utils/appendConnectionUriToDeeplink/index.d.ts.map +1 -0
  189. package/dist/utils/getChainFromWalletBookIdentifier/getChainFromWalletBookIdentifier.d.ts +22 -0
  190. package/dist/utils/getChainFromWalletBookIdentifier/getChainFromWalletBookIdentifier.d.ts.map +1 -0
  191. package/dist/utils/getChainFromWalletBookIdentifier/index.d.ts +2 -0
  192. package/dist/utils/getChainFromWalletBookIdentifier/index.d.ts.map +1 -0
  193. package/dist/utils/getNativeLinkScheme/getNativeLinkScheme.d.ts +18 -0
  194. package/dist/utils/getNativeLinkScheme/getNativeLinkScheme.d.ts.map +1 -0
  195. package/dist/utils/getNativeLinkScheme/index.d.ts +3 -0
  196. package/dist/utils/getNativeLinkScheme/index.d.ts.map +1 -0
  197. package/dist/utils/isMobile/isMobile.d.ts +8 -0
  198. package/dist/utils/isMobile/isMobile.d.ts.map +1 -1
  199. package/dist/waas.cjs +8 -9
  200. package/dist/waas.cjs.map +1 -1
  201. package/dist/waas.esm.js +3 -3
  202. package/dist/waas.native.esm.js +3 -3
  203. package/dist/waasCore.cjs +3 -4
  204. package/dist/waasCore.cjs.map +1 -1
  205. package/dist/waasCore.esm.js +3 -3
  206. package/dist/waasCore.native.esm.js +3 -3
  207. package/package.json +4 -4
  208. package/dist/InvalidParamError-9kQBK3sP.native.esm.js.map +0 -1
  209. package/dist/InvalidParamError-DQvZQdQ9.cjs.map +0 -1
  210. package/dist/InvalidParamError-Za4cvW7K.esm.js.map +0 -1
  211. package/dist/NotWaasWalletAccountError-BTMvHTA8.native.esm.js.map +0 -1
  212. package/dist/NotWaasWalletAccountError-By3Y4taq.esm.js.map +0 -1
  213. package/dist/NotWaasWalletAccountError-Ciq7b-Y6.cjs.map +0 -1
  214. package/dist/getNetworkProviderFromNetworkId-BA0CHZzu.cjs.map +0 -1
  215. package/dist/getNetworkProviderFromNetworkId-COptFPwJ.native.esm.js.map +0 -1
  216. package/dist/getNetworkProviderFromNetworkId-RWcIZDgC.esm.js.map +0 -1
  217. package/dist/getVerifiedCredentialForWalletAccount-DKJcLLHq.native.esm.js +0 -701
  218. package/dist/getVerifiedCredentialForWalletAccount-DKJcLLHq.native.esm.js.map +0 -1
  219. package/dist/getVerifiedCredentialForWalletAccount-DSSDwOyq.cjs +0 -887
  220. package/dist/getVerifiedCredentialForWalletAccount-DSSDwOyq.cjs.map +0 -1
  221. package/dist/getVerifiedCredentialForWalletAccount-Ozctwnyv.esm.js +0 -701
  222. package/dist/getVerifiedCredentialForWalletAccount-Ozctwnyv.esm.js.map +0 -1
  223. package/dist/isMfaRequiredForAction-C1u4Z__n.esm.js.map +0 -1
  224. package/dist/isMfaRequiredForAction-CMClgbT0.cjs.map +0 -1
  225. package/dist/isMfaRequiredForAction-DSX-TV2z.native.esm.js.map +0 -1
@@ -1,12 +1,15 @@
1
- import { AuthStorageEnum, Configuration, SDKApi, isDeviceNonceSignatureRequiredForUrl } from "@dynamic-labs/sdk-api-core";
1
+ import { AuthStorageEnum, Configuration, JwtVerifiedCredentialFormatEnum, SDKApi, WalletProviderEnum, isDeviceNonceSignatureRequiredForUrl } from "@dynamic-labs/sdk-api-core";
2
+ import * as z from "zod/mini";
3
+ import AsyncStorage from "@react-native-async-storage/async-storage";
4
+ import { getGenericPassword, resetGenericPassword, setGenericPassword } from "react-native-keychain";
2
5
 
3
6
  //#region package.json
4
7
  var name = "@dynamic-labs-sdk/client";
5
- var version = "1.3.0";
8
+ var version = "1.5.0";
6
9
  var dependencies = {
7
10
  "@dynamic-labs-sdk/assert-package-version": "workspace:*",
8
- "@dynamic-labs-wallet/browser-wallet-client": "0.0.351",
9
- "@dynamic-labs-wallet/forward-mpc-client": "0.9.0",
11
+ "@dynamic-labs-wallet/browser-wallet-client": "1.0.7",
12
+ "@dynamic-labs-wallet/forward-mpc-client": "0.10.1",
10
13
  "@dynamic-labs/sdk-api-core": "catalog:",
11
14
  "@simplewebauthn/browser": "13.1.0",
12
15
  "ably": "2.17.1",
@@ -189,19 +192,50 @@ const getUserAgent = () => {
189
192
 
190
193
  //#endregion
191
194
  //#region src/services/instrumentation/constants.ts
195
+ /**
196
+ * Default key-based PII scrubber list, lowercased and matched against the
197
+ * lowercased object key.
198
+ *
199
+ * Two complementary mechanisms cover credential leakage:
200
+ *
201
+ * 1. Explicit keys listed here — matched exactly (case-insensitive). Use this
202
+ * for keys that don't end in a generic credential suffix (e.g. `mnemonic`,
203
+ * `seed`, `verificationCode`, `keyShare`).
204
+ * 2. Suffix matching in {@link scrubParameters} for the credential suffixes
205
+ * enumerated by {@link PII_KEY_SUFFIXES} — catches any field whose name
206
+ * ends in `token` or `jwt` (e.g. `mfaToken`, `minifiedJwt`, `accessToken`,
207
+ * `idToken`, `captchaToken`, …) without needing to enumerate them here.
208
+ */
192
209
  const DEFAULT_PII_FIELDS = [
193
210
  "password",
194
211
  "token",
195
212
  "secret",
196
213
  "privateKey",
214
+ "privateJwk",
197
215
  "mnemonic",
198
216
  "seed",
217
+ "keyShare",
218
+ "keyShares",
199
219
  "email",
200
220
  "phone",
201
221
  "ssn",
202
222
  "address",
203
- "authorization"
223
+ "authorization",
224
+ "verificationCode",
225
+ "recoveryCodes",
226
+ "codeVerifier",
227
+ "pkce",
228
+ "bearer",
229
+ "apiKey"
204
230
  ];
231
+ /**
232
+ * Lowercased suffixes used by {@link scrubParameters} to match credential-like
233
+ * keys without enumerating every variant (e.g. `mfaToken`, `accessToken`,
234
+ * `refreshToken`, `legacyToken`, `minifiedJwt`). Only suffixes that are
235
+ * unambiguously credentials belong here — `key` (matches `publicKey`) and
236
+ * `code` (matches `countryCode`) are too broad and must not be added.
237
+ */
238
+ const PII_KEY_SUFFIXES = ["token", "jwt"];
205
239
  const REDACTED_VALUE = "[REDACTED]";
206
240
  const MAX_STRING_LENGTH = 500;
207
241
  const TRUNCATED_SUFFIX = "...[truncated]";
@@ -220,8 +254,23 @@ const CIRCULAR_VALUE = "[Circular]";
220
254
 
221
255
  //#endregion
222
256
  //#region src/services/instrumentation/scrubParameters/scrubParameters.ts
257
+ /**
258
+ * Returns true when `key` should be redacted based on the configured PII
259
+ * field list. A key matches when its lowercased form either equals one of
260
+ * `piiFieldsLower` exactly, or ends in one of the curated credential
261
+ * suffixes in {@link PII_KEY_SUFFIXES} (currently `token` and `jwt`). The
262
+ * suffix check is what catches `mfaToken`, `minifiedJwt`, `accessToken`,
263
+ * etc. without needing every variant enumerated explicitly.
264
+ */
265
+ const keyMatchesPiiField = ({ keyLower, piiFieldsLower }) => {
266
+ if (piiFieldsLower.includes(keyLower)) return true;
267
+ return PII_KEY_SUFFIXES.some((suffix) => keyLower.endsWith(suffix));
268
+ };
223
269
  const scrubString = ({ key, piiFieldsLower, redactAll, value }) => {
224
- if (piiFieldsLower.includes(key.toLowerCase())) return REDACTED_VALUE;
270
+ if (keyMatchesPiiField({
271
+ keyLower: key.toLowerCase(),
272
+ piiFieldsLower
273
+ })) return REDACTED_VALUE;
225
274
  if (redactAll) return REDACTED_VALUE;
226
275
  if (value.length > MAX_STRING_LENGTH) return value.slice(0, MAX_STRING_LENGTH) + TRUNCATED_SUFFIX;
227
276
  return value;
@@ -252,7 +301,10 @@ const scrubObject = ({ context, value }) => {
252
301
  const scrubValue = ({ context, key, value }) => {
253
302
  if (value === null || value === void 0) return value;
254
303
  if (value instanceof Uint8Array) return `[${BINARY_LABEL}:${value.byteLength} bytes]`;
255
- if (context.piiFieldsLower.includes(key.toLowerCase())) return REDACTED_VALUE;
304
+ if (keyMatchesPiiField({
305
+ keyLower: key.toLowerCase(),
306
+ piiFieldsLower: context.piiFieldsLower
307
+ })) return REDACTED_VALUE;
256
308
  if (typeof value === "string") return scrubString({
257
309
  key,
258
310
  piiFieldsLower: context.piiFieldsLower,
@@ -860,109 +912,186 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
860
912
  };
861
913
 
862
914
  //#endregion
863
- //#region src/errors/UnauthorizedError.ts
864
- var UnauthorizedError = class extends BaseError {
865
- constructor({ cause }) {
915
+ //#region src/utils/setCookie/setCookie.ts
916
+ /**
917
+ * Sefelly sets the cookie in the browser.
918
+ * @not-instrumented
919
+ */
920
+ const setCookie = (cookie) => {
921
+ document.cookie = cookie;
922
+ };
923
+
924
+ //#endregion
925
+ //#region src/modules/clientEvents/clientEvents.ts
926
+ /**
927
+ * Adds an event listener for Dynamic client events.
928
+ *
929
+ * This function allows you to listen for various events emitted by the Dynamic client,
930
+ * such as authentication state changes, wallet connections, and more.
931
+ *
932
+ * @param params.event - The event name to listen for.
933
+ * @param params.listener - The callback function to execute when the event is fired.
934
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
935
+ * @returns A function that can be called to remove the listener.
936
+ * @not-instrumented
937
+ */
938
+ const onEvent = ({ event, listener }, client = getDefaultClient()) => {
939
+ const { eventEmitter } = getCore(client);
940
+ eventEmitter.on(event, listener);
941
+ return () => {
942
+ eventEmitter.off(event, listener);
943
+ };
944
+ };
945
+ /**
946
+ * Removes an event listener from Dynamic client events.
947
+ *
948
+ * This function unsubscribes a previously registered event listener
949
+ * from the specified Dynamic client event.
950
+ *
951
+ * @param params.event - The event name to remove the listener from.
952
+ * @param params.listener - The callback function to remove.
953
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
954
+ * @not-instrumented
955
+ */
956
+ const offEvent = ({ event, listener }, client = getDefaultClient()) => {
957
+ const { eventEmitter } = getCore(client);
958
+ eventEmitter.off(event, listener);
959
+ };
960
+ /**
961
+ * Adds a one-time event listener for Dynamic client events.
962
+ *
963
+ * This function listens for an event that will automatically remove itself
964
+ * after being triggered once.
965
+ *
966
+ * @param params.event - The event name to listen for.
967
+ * @param params.listener - The callback function to execute when the event is fired.
968
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
969
+ * @returns A function that can be called to remove the listener before it fires.
970
+ * @not-instrumented
971
+ */
972
+ const onceEvent = ({ event, listener }, client = getDefaultClient()) => {
973
+ const { eventEmitter } = getCore(client);
974
+ eventEmitter.once(event, listener);
975
+ return () => {
976
+ eventEmitter.off(event, listener);
977
+ };
978
+ };
979
+ /**
980
+ * Emits a Dynamic client event.
981
+ *
982
+ * This function triggers an event that will be received by all registered
983
+ * listeners for the specified event type.
984
+ *
985
+ * @param params.event - The event name to emit.
986
+ * @param params.args - The arguments to pass to event listeners.
987
+ * @param client - The Dynamic client instance.
988
+ * @not-instrumented
989
+ */
990
+ const emitEvent = ({ event, args }, client) => {
991
+ const { eventEmitter } = getCore(client);
992
+ eventEmitter.emit(event, args);
993
+ };
994
+
995
+ //#endregion
996
+ //#region src/utils/retryOnFail/InvalidRetryOnFailCallError.ts
997
+ /**
998
+ * This error is thrown when the `retryOnFail` function is called with an invalid
999
+ * number of retries (i.e. less than 0).
1000
+ */
1001
+ var InvalidRetryOnFailCallError = class extends BaseError {
1002
+ constructor(maxRetries) {
866
1003
  super({
867
- cause,
868
- code: "unauthorized_error",
1004
+ cause: null,
1005
+ code: "invalid_retry_on_fail_call_error",
869
1006
  docsUrl: null,
870
- name: "UnauthorizedError",
871
- shortMessage: "Unauthorized"
1007
+ name: "InvalidRetryOnFailCallError",
1008
+ shortMessage: `Invalid retries parameter for retryOnFail call: ${maxRetries}`
872
1009
  });
873
1010
  }
874
1011
  };
875
1012
 
876
1013
  //#endregion
877
- //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
1014
+ //#region src/utils/retryOnFail/retryOnFail.ts
878
1015
  /** @not-instrumented */
879
- const createUnauthorizedMiddleware = () => ({ post: async (context) => {
880
- if (context.response.status === 401) {
881
- let cause = null;
882
- try {
883
- const errorBody = await context.response.clone().json();
884
- if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
885
- } catch {}
886
- throw new UnauthorizedError({ cause });
1016
+ const retryOnFail = async ({ delay = 0, fn, maxRetries }) => {
1017
+ for (let retry = 0; retry <= maxRetries; retry++) try {
1018
+ return await fn();
1019
+ } catch (error) {
1020
+ if (retry >= maxRetries) throw error;
1021
+ if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
887
1022
  }
888
- return context.response;
889
- } });
1023
+ /**
1024
+ * Reaching this point should never happen and this
1025
+ * error is thrown to help us debug the issue.
1026
+ */
1027
+ throw new InvalidRetryOnFailCallError(maxRetries);
1028
+ };
890
1029
 
891
1030
  //#endregion
892
- //#region src/modules/apiClient/createApiClient.ts
893
- /**
894
- * Returns a new instance of the SDK API client.
895
- *
896
- * This is not meant for storing, as it is very light we can create it whenever needed.
897
- * @not-instrumented
898
- */
899
- const createApiClient = (options = {}, client) => {
900
- const core = getCore(client);
901
- const coreState = core.state.get();
902
- const settings = {
903
- basePath: core.apiBaseUrl,
904
- headers: {
905
- "Content-Type": "application/json",
906
- [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
907
- [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
908
- [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
909
- [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
910
- ...core.getApiHeaders(),
911
- ...options.headers
912
- }
913
- };
914
- if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
915
- if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
916
- if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
917
- if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
918
- if (options.elevatedAccessTokenScope) {
919
- const elevatedToken = __getElevatedAccessToken_wrapped({ scope: options.elevatedAccessTokenScope }, client);
920
- if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
1031
+ //#region src/errors/InvalidWalletProviderKeyError.ts
1032
+ var InvalidWalletProviderKeyError = class extends BaseError {
1033
+ constructor(value) {
1034
+ super({
1035
+ cause: null,
1036
+ code: "invalid_wallet_provider_key",
1037
+ docsUrl: null,
1038
+ name: "InvalidWalletProviderKeyError",
1039
+ shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`
1040
+ });
921
1041
  }
922
- const sessionPublicKey = getSessionKeys(client)?.publicKey;
923
- const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
924
- if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
925
- return new SDKApi(new Configuration({
926
- ...settings,
927
- fetchApi: core.fetch,
928
- middleware: [
929
- createDeviceSignatureHeadersMiddleware(client),
930
- createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
931
- createUnauthorizedMiddleware()
932
- ]
933
- }));
934
1042
  };
935
1043
 
936
1044
  //#endregion
937
- //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
938
- /**
939
- * Fetches a batch of nonces from the API.
940
- *
941
- * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
942
- * redirect). On iOS, a network request (like fetching a nonce) between a user
943
- * action and a deeplink call will break the gesture chain, causing iOS to
944
- * silently ignore the deeplink. By prefetching nonces ahead of time,
945
- * `getNonce` can return synchronously from cache and the deeplink fires
946
- * without an interrupting network round-trip.
947
- *
948
- * New nonces are **appended** to the existing pool so that unconsumed entries
949
- * are not discarded by a background refetch.
950
- * @not-instrumented
951
- */
952
- const fetchAndStoreNonces = async (client) => {
953
- const core = getCore(client);
954
- const { environmentId } = core;
955
- const { nonces } = await createApiClient({}, client).getNonces({
956
- count: NONCE_POOL_SIZE,
957
- environmentId
958
- });
959
- const existing = core.state.get().prefetchedNonces;
960
- core.state.set({
961
- prefetchedNonces: [...existing, ...nonces],
962
- prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME
963
- });
1045
+ //#region src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts
1046
+ /** @not-instrumented */
1047
+ const splitWalletProviderKey = (walletProviderKey) => {
1048
+ const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] = walletProviderKey.split(":");
1049
+ if (!normalizedWalletNameWithChain || !Object.values(WalletProviderEnum).includes(walletProviderType) || rest.length > 0) throw new InvalidWalletProviderKeyError(walletProviderKey);
1050
+ return {
1051
+ normalizedWalletNameWithChain,
1052
+ suffix,
1053
+ walletProviderType
1054
+ };
1055
+ };
1056
+
1057
+ //#endregion
1058
+ //#region src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts
1059
+ /** @not-instrumented */
1060
+ const normalizeAddress = ({ address, chain }) => {
1061
+ let normalizedAddress = address;
1062
+ if (normalizedAddress?.startsWith("0x")) normalizedAddress = normalizedAddress.slice(2);
1063
+ normalizedAddress = ["EVM", "FLOW"].includes(chain) ? normalizedAddress?.toLowerCase() : normalizedAddress;
1064
+ return normalizedAddress;
964
1065
  };
965
1066
 
1067
+ //#endregion
1068
+ //#region src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts
1069
+ /** @not-instrumented */
1070
+ const formatWalletAccountId = ({ address, chain, walletProviderKey }) => {
1071
+ const { normalizedWalletNameWithChain } = splitWalletProviderKey(walletProviderKey);
1072
+ return `${normalizedWalletNameWithChain}:${normalizeAddress({
1073
+ address,
1074
+ chain
1075
+ })}`;
1076
+ };
1077
+
1078
+ //#endregion
1079
+ //#region src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts
1080
+ /** @not-instrumented */
1081
+ const convertUnverifiedWalletAccountToWalletAccount = ({ unverifiedWalletAccount }) => ({
1082
+ address: unverifiedWalletAccount.address,
1083
+ addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,
1084
+ chain: unverifiedWalletAccount.chain,
1085
+ id: formatWalletAccountId({
1086
+ address: unverifiedWalletAccount.address,
1087
+ chain: unverifiedWalletAccount.chain,
1088
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
1089
+ }),
1090
+ lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
1091
+ verifiedCredentialId: null,
1092
+ walletProviderKey: unverifiedWalletAccount.walletProviderKey
1093
+ });
1094
+
966
1095
  //#endregion
967
1096
  //#region src/modules/wallets/constants.ts
968
1097
  const CHAINS_INFO_MAP = {
@@ -984,6 +1113,7 @@ const CHAINS_INFO_MAP = {
984
1113
  BTC: {
985
1114
  apiChainName: "bitcoin",
986
1115
  blockchainName: "Bitcoin",
1116
+ legacyWalletBookAliases: ["btc"],
987
1117
  verifiedCredentialChainName: "bip122"
988
1118
  },
989
1119
  COSMOS: {
@@ -1014,6 +1144,7 @@ const CHAINS_INFO_MAP = {
1014
1144
  SOL: {
1015
1145
  apiChainName: "solana",
1016
1146
  blockchainName: "Solana",
1147
+ legacyWalletBookAliases: ["sol"],
1017
1148
  verifiedCredentialChainName: "solana",
1018
1149
  waasChainNameOverride: "SVM"
1019
1150
  },
@@ -1025,6 +1156,7 @@ const CHAINS_INFO_MAP = {
1025
1156
  STARK: {
1026
1157
  apiChainName: "starknet",
1027
1158
  blockchainName: "Starknet",
1159
+ legacyWalletBookAliases: ["stark"],
1028
1160
  verifiedCredentialChainName: "starknet"
1029
1161
  },
1030
1162
  STELLAR: {
@@ -1063,6 +1195,664 @@ const getChainFromVerifiedCredentialChain = (verifiedCredentialChain) => {
1063
1195
  return chain;
1064
1196
  };
1065
1197
 
1198
+ //#endregion
1199
+ //#region src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts
1200
+ /**
1201
+ * Format the raw wallet name and chain to get the value we can use for
1202
+ * verified credentials' `walletName` field.
1203
+ * @not-instrumented
1204
+ */
1205
+ const normalizeWalletNameWithChain = ({ displayName, chain }) => {
1206
+ const sanitizedWalletName = displayName.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
1207
+ const chainLowered = chain.toLocaleLowerCase();
1208
+ if (sanitizedWalletName.endsWith(chainLowered)) return sanitizedWalletName;
1209
+ return `${sanitizedWalletName}${chainLowered}`;
1210
+ };
1211
+
1212
+ //#endregion
1213
+ //#region src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts
1214
+ /**
1215
+ * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.
1216
+ *
1217
+ * The suffix is optional and can be used to add a uniquely identifying string to the key, which
1218
+ * might be necessary for some wallet providers (like Wallet Connect).
1219
+ *
1220
+ * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account
1221
+ * to not be able to find its wallet provider when connecting to a new device (it won't be possible
1222
+ * to determine the full key just from the Verified Credential data).
1223
+ * @not-instrumented
1224
+ */
1225
+ const formatWalletProviderKey = ({ suffix, chain, displayName, walletProviderType }) => {
1226
+ return `${normalizeWalletNameWithChain({
1227
+ chain,
1228
+ displayName
1229
+ })}:${walletProviderType}${suffix ? `:${suffix}` : ""}`;
1230
+ };
1231
+
1232
+ //#endregion
1233
+ //#region src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts
1234
+ /** @not-instrumented */
1235
+ const getWalletProviderKeyFromVerifiedCredential = ({ verifiedCredential }, client) => {
1236
+ const { walletProviderKeyMap } = getCore(client).state.get();
1237
+ const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];
1238
+ if (storedWalletProviderKey) return { walletProviderKey: storedWalletProviderKey };
1239
+ /**
1240
+ * We fallback to comprising the wallet provider key from walletName and walletProvider.
1241
+ *
1242
+ * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider
1243
+ * keys, so this won't be enough for them.
1244
+ * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider
1245
+ * and will require reconnection.
1246
+ * Read walletProvider.types.ts for more info.
1247
+ */
1248
+ assertDefined(verifiedCredential.walletName, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`);
1249
+ assertDefined(verifiedCredential.walletProvider, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`);
1250
+ assertDefined(verifiedCredential.chain, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`);
1251
+ return { walletProviderKey: formatWalletProviderKey({
1252
+ chain: getChainFromVerifiedCredentialChain(verifiedCredential.chain),
1253
+ displayName: verifiedCredential.walletName,
1254
+ walletProviderType: verifiedCredential.walletProvider
1255
+ }) };
1256
+ };
1257
+
1258
+ //#endregion
1259
+ //#region src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts
1260
+ /** @not-instrumented */
1261
+ const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client) => {
1262
+ assertDefined(verifiedCredential.address, "Missing address in verified credential");
1263
+ assertDefined(verifiedCredential.chain, "Missing chain in verified credential");
1264
+ const chain = getChainFromVerifiedCredentialChain(verifiedCredential.chain);
1265
+ const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential({ verifiedCredential }, client);
1266
+ const walletAccountId = formatWalletAccountId({
1267
+ address: verifiedCredential.address,
1268
+ chain,
1269
+ walletProviderKey
1270
+ });
1271
+ return {
1272
+ address: verifiedCredential.address,
1273
+ addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
1274
+ chain,
1275
+ hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
1276
+ id: walletAccountId,
1277
+ lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,
1278
+ verifiedCredentialId: verifiedCredential.id,
1279
+ walletProviderKey
1280
+ };
1281
+ };
1282
+
1283
+ //#endregion
1284
+ //#region src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts
1285
+ /** @not-instrumented */
1286
+ const getWalletAccountsFromState = ({ unverifiedWalletAccounts, user }, client) => {
1287
+ const walletAccountsMap = /* @__PURE__ */ new Map();
1288
+ /**
1289
+ * Handle the unverified wallet accounts before the user verified credentials
1290
+ * so the later verified wallet accounts can override the unverified wallet accounts
1291
+ */
1292
+ unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {
1293
+ const walletAccount = convertUnverifiedWalletAccountToWalletAccount({ unverifiedWalletAccount });
1294
+ walletAccountsMap.set(walletAccount.id, walletAccount);
1295
+ });
1296
+ (user?.verifiedCredentials ?? []).filter((verified) => verified.format === JwtVerifiedCredentialFormatEnum.Blockchain).forEach((verifiedWalletAccount) => {
1297
+ const walletAccount = convertVerifiedCredentialToWalletAccount({ verifiedCredential: verifiedWalletAccount }, client);
1298
+ walletAccountsMap.set(walletAccount.id, walletAccount);
1299
+ });
1300
+ return Array.from(walletAccountsMap.values());
1301
+ };
1302
+
1303
+ //#endregion
1304
+ //#region src/modules/wallets/getWalletAccounts/getWalletAccounts.ts
1305
+ /**
1306
+ * Retrieves all wallet accounts associated with the current session.
1307
+ *
1308
+ * This function returns both verified and unverified wallet accounts,
1309
+ * combining data from user credentials and local unverified accounts.
1310
+ * You can differentiate between verified and unverified wallet accounts by
1311
+ * checking the `verifiedCredentialId` property.
1312
+ *
1313
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1314
+ * @returns An array of wallet accounts associated with the session.
1315
+ * @not-instrumented
1316
+ */
1317
+ const getWalletAccounts = (client = getDefaultClient()) => {
1318
+ const { unverifiedWalletAccounts, user } = getCore(client).state.get();
1319
+ return getWalletAccountsFromState({
1320
+ unverifiedWalletAccounts,
1321
+ user
1322
+ }, client);
1323
+ };
1324
+
1325
+ //#endregion
1326
+ //#region src/modules/auth/isSignedIn/isSignedIn.ts
1327
+ /**
1328
+ * Checks if the user is currently signed in to the Dynamic client.
1329
+ *
1330
+ * The client is considered to be in a signed in state if a user has
1331
+ * authenticated or if the client has at least one wallet connected.
1332
+ *
1333
+ * @deprecated What counts as "signed in" is your app's business logic, not the
1334
+ * SDK's. This helper bakes in one opinion (a user OR any connected wallet),
1335
+ * which rarely matches every app and forces a dependency on us for every
1336
+ * variation. Compose your own check from the underlying primitives instead —
1337
+ * e.g. `Boolean(client.user) || isAnyWalletAccountConnected(client)` — and
1338
+ * layer in whatever your app requires (device registration, completed
1339
+ * onboarding, satisfied MFA, a required embedded wallet, …). See the
1340
+ * "Check if signed in" guide:
1341
+ * https://www.dynamic.xyz/docs/javascript/user-session-management
1342
+ *
1343
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1344
+ * @returns True if the user is signed in, false otherwise.
1345
+ * @not-instrumented
1346
+ */
1347
+ const isSignedIn = (client = getDefaultClient()) => Boolean(client.user || getWalletAccounts(client).length > 0);
1348
+
1349
+ //#endregion
1350
+ //#region src/services/storage/createLocalStorageAdapter/createLocalStorageAdapter.native.ts
1351
+ const NAMESPACE = "dynamic";
1352
+ const namespaceKey = (key) => `${NAMESPACE}:${key}`;
1353
+ /**
1354
+ * Creates a localStorage adapter for React Native.
1355
+ * Routes operations based on the `storageTier` option:
1356
+ * - `'default'`: uses AsyncStorage
1357
+ * - `'secure'`: uses react-native-keychain
1358
+ * @not-instrumented
1359
+ */
1360
+ const createLocalStorageAdapter = () => {
1361
+ return {
1362
+ getItem: async (key, options) => {
1363
+ if (options.storageTier === "secure") {
1364
+ const result = await getGenericPassword({ service: key });
1365
+ if (!result) return null;
1366
+ return result.password;
1367
+ } else return AsyncStorage.getItem(namespaceKey(key));
1368
+ },
1369
+ removeItem: async (key, options) => {
1370
+ if (options.storageTier === "secure") await resetGenericPassword({ service: key });
1371
+ else await AsyncStorage.removeItem(namespaceKey(key));
1372
+ },
1373
+ setItem: async (key, value, options) => {
1374
+ if (options.storageTier === "secure") await setGenericPassword(key, value, { service: key });
1375
+ else await AsyncStorage.setItem(namespaceKey(key), value);
1376
+ }
1377
+ };
1378
+ };
1379
+
1380
+ //#endregion
1381
+ //#region src/services/storage/createStorageKeySchema/createStorageKeySchema.ts
1382
+ /** @not-instrumented */
1383
+ const createStorageKeySchema = (params) => {
1384
+ return params;
1385
+ };
1386
+
1387
+ //#endregion
1388
+ //#region src/modules/projectSettings/fetchProjectSettings/projectSettingsExpirationScheme.ts
1389
+ /**
1390
+ * The schema to track the expiration time of the project settings.
1391
+ */
1392
+ const projectSettingsExpirationStorageKeySchema = createStorageKeySchema({
1393
+ key: "projectSettingsExpiration",
1394
+ schema: z.number()
1395
+ });
1396
+
1397
+ //#endregion
1398
+ //#region src/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.ts
1399
+ /**
1400
+ * Expiration time of the project settings in milliseconds.
1401
+ */
1402
+ const PROJECT_SETTINGS_EXPIRATION_TIME = 1e3 * 60 * 5;
1403
+ /**
1404
+ * Fetches and updates the project settings from the API.
1405
+ *
1406
+ * This function retrieves the latest project configuration settings
1407
+ * from Dynamic's servers, including authentication options, enabled chains,
1408
+ * and security configurations. The settings are cached for performance.
1409
+ *
1410
+ * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
1411
+ * @returns A promise that resolves to the updated project settings.
1412
+ * @not-instrumented
1413
+ */
1414
+ const fetchProjectSettings = async (client = getDefaultClient()) => {
1415
+ const core = getCore(client);
1416
+ const currentExpiration = await core.storage.getItem(projectSettingsExpirationStorageKeySchema);
1417
+ if (Boolean(client.projectSettings) && !(currentExpiration && currentExpiration < Date.now()) && isSignedIn(client)) return client.projectSettings;
1418
+ const apiClient = createApiClient({}, client);
1419
+ core.logger.debug("[fetchProjectSettings] Fetching project settings...");
1420
+ const doFetch = async () => apiClient.getEnvironmentSettings({
1421
+ environmentId: core.environmentId,
1422
+ sdkVersion: `${CLIENT_SDK_NAME}/${core.version}`
1423
+ }, { credentials: "omit" });
1424
+ const projectSettings = await retryOnFail({
1425
+ fn: doFetch,
1426
+ maxRetries: 2
1427
+ });
1428
+ core.state.set({ projectSettings: projectSettings ?? null });
1429
+ await core.storage.setItem(projectSettingsExpirationStorageKeySchema, Date.now() + PROJECT_SETTINGS_EXPIRATION_TIME);
1430
+ return projectSettings;
1431
+ };
1432
+
1433
+ //#endregion
1434
+ //#region src/modules/sessionKeys/generateSessionKeys/generateSessionKeys.ts
1435
+ /** @not-instrumented */
1436
+ const generateSessionKeys = async (client) => {
1437
+ const core = getCore(client);
1438
+ await core.keychain.removeKey("session");
1439
+ const publicKey = await core.keychain.generateKey("session");
1440
+ assertDefined(publicKey, "Public key not found");
1441
+ core.state.set({ sessionKeys: publicKey });
1442
+ return { publicKey };
1443
+ };
1444
+
1445
+ //#endregion
1446
+ //#region src/errors/NoWalletProviderFoundError.ts
1447
+ var NoWalletProviderFoundError = class extends BaseError {
1448
+ constructor({ walletProviderKey }) {
1449
+ super({
1450
+ cause: null,
1451
+ code: "no_wallet_provider_found_error",
1452
+ docsUrl: null,
1453
+ name: "NoWalletProviderFoundError",
1454
+ shortMessage: `No wallet provider found with key: ${walletProviderKey}`
1455
+ });
1456
+ }
1457
+ };
1458
+
1459
+ //#endregion
1460
+ //#region src/services/runtimeServices/createRuntimeServiceAccessKey/createRuntimeServiceAccessKey.ts
1461
+ /**
1462
+ * Creates a service accessor function that manages service instantiation and caching.
1463
+ * The returned function will either retrieve an existing service from the registry or
1464
+ * create a new one using the provided builder function.
1465
+ *
1466
+ * @template - The type of service to be created/accessed
1467
+ * @param key - Unique identifier for the service in the registry
1468
+ * @param builder - Function that creates the service instance when called with a DynamicClient
1469
+ * @not-instrumented
1470
+ */
1471
+ const createRuntimeServiceAccessKey = (key, builder) => (client) => {
1472
+ const { runtimeServices } = getCore(client);
1473
+ const currentService = runtimeServices.getByKey(key);
1474
+ if (currentService) return currentService;
1475
+ const service = builder(client);
1476
+ runtimeServices.register(key, service);
1477
+ return service;
1478
+ };
1479
+
1480
+ //#endregion
1481
+ //#region src/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.ts
1482
+ /**
1483
+ * Creates a new wallet provider registry that manages wallet providers with priority-based registration.
1484
+ *
1485
+ * @returns The wallet provider registry instance
1486
+ *
1487
+ * @example
1488
+ * ```typescript
1489
+ * const registry = createWalletProviderRegistry();
1490
+ *
1491
+ * registry.register({
1492
+ * priority: WalletProviderPriority.WALLET_SDK,
1493
+ * walletProvider: myWalletProvider
1494
+ * });
1495
+ *
1496
+ * const provider = registry.getByKey('my-wallet-key');
1497
+ * const providers = registry.listProviders();
1498
+ * ```
1499
+ * @not-instrumented
1500
+ */
1501
+ const createWalletProviderRegistry = (client) => {
1502
+ const registry = /* @__PURE__ */ new Map();
1503
+ return {
1504
+ getByKey: (key) => registry.get(key)?.walletProvider,
1505
+ listProviderEntries: () => Array.from(registry.values()),
1506
+ listProviders: () => Array.from(registry.values()).map((v) => v.walletProvider),
1507
+ register: (args) => {
1508
+ const existingEntry = registry.get(args.walletProvider.key);
1509
+ if (existingEntry) {
1510
+ if (existingEntry.priority < args.priority) {
1511
+ registry.set(args.walletProvider.key, args);
1512
+ emitEvent({
1513
+ args: { walletProviderKey: args.walletProvider.key },
1514
+ event: "walletProviderChanged"
1515
+ }, client);
1516
+ }
1517
+ } else {
1518
+ registry.set(args.walletProvider.key, args);
1519
+ emitEvent({
1520
+ args: { walletProvider: args.walletProvider },
1521
+ event: "walletProviderRegistered"
1522
+ }, client);
1523
+ emitEvent({
1524
+ args: { walletProviderKey: args.walletProvider.key },
1525
+ event: "walletProviderChanged"
1526
+ }, client);
1527
+ }
1528
+ },
1529
+ unregister: (key) => {
1530
+ registry.delete(key);
1531
+ emitEvent({
1532
+ args: { walletProviderKey: key },
1533
+ event: "walletProviderUnregistered"
1534
+ }, client);
1535
+ }
1536
+ };
1537
+ };
1538
+
1539
+ //#endregion
1540
+ //#region src/modules/wallets/walletProviderRegistry/getWalletProviderRegistry/getWalletProviderRegistry.ts
1541
+ /**
1542
+ * This function provides access to a shared instance of the wallet provider registry.
1543
+ *
1544
+ * It ensures that the same registry instance is used throughout the client to maintaining
1545
+ * consistency of registered wallet providers across different parts of the codebase.
1546
+ *
1547
+ * @returns The wallet provider registry instance
1548
+ *
1549
+ * @example
1550
+ * ```typescript
1551
+ * // Get the registry instance
1552
+ * const registry = getWalletProviderRegistry();
1553
+ *
1554
+ * // Register a wallet provider
1555
+ * registry.register({
1556
+ * priority: WalletProviderPriority.WALLET_SDK,
1557
+ * walletProvider: myWalletProvider
1558
+ * });
1559
+ *
1560
+ * // Retrieve a specific provider
1561
+ * const provider = registry.getByKey('metamaskevm');
1562
+ * ```
1563
+ */
1564
+ const getWalletProviderRegistry = createRuntimeServiceAccessKey("walletProviderRegistry", (client) => createWalletProviderRegistry(client));
1565
+
1566
+ //#endregion
1567
+ //#region src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.ts
1568
+ let WalletProviderPriority = /* @__PURE__ */ function(WalletProviderPriority$1) {
1569
+ /**
1570
+ * Highest priority should be used by wallet providers that implement
1571
+ * the most reliable wallet integration.
1572
+ * example: The SDK provided by the wallet provider.
1573
+ */
1574
+ WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SDK"] = 100] = "WALLET_SDK";
1575
+ /**
1576
+ * Medium priority should be used by wallet providers that implement
1577
+ * a wallet integration via some reliable standard.
1578
+ * example: A wallet provider that uses EIP6963 announcement.
1579
+ */
1580
+ WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SELF_ANNOUNCEMENT_STANDARD"] = 50] = "WALLET_SELF_ANNOUNCEMENT_STANDARD";
1581
+ /**
1582
+ * Low priority should be used by wallet providers that implement
1583
+ * a wallet integration on a less reliable standard.
1584
+ * example: A wallet provider that uses window.ethereum, where the
1585
+ * window key can be overridden by other extensions.
1586
+ */
1587
+ WalletProviderPriority$1[WalletProviderPriority$1["WINDOW_INJECT"] = 20] = "WINDOW_INJECT";
1588
+ return WalletProviderPriority$1;
1589
+ }({});
1590
+
1591
+ //#endregion
1592
+ //#region src/modules/wallets/utils/getWalletProviderFromWalletAccount/getWalletProviderFromWalletAccount.ts
1593
+ /** @not-instrumented */
1594
+ const getWalletProviderFromWalletAccount = ({ walletAccount }, client) => {
1595
+ const walletProvider = getWalletProviderRegistry(client).getByKey(walletAccount.walletProviderKey);
1596
+ if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey: walletAccount.walletProviderKey });
1597
+ return walletProvider;
1598
+ };
1599
+
1600
+ //#endregion
1601
+ //#region src/modules/wallets/utils/getAvailableWalletProvidersFromWalletAccounts/getAvailableWalletProvidersFromWalletAccounts.ts
1602
+ /** @not-instrumented */
1603
+ const getAvailableWalletProvidersFromWalletAccounts = (client) => {
1604
+ const core = getCore(client);
1605
+ const walletProvidersMap = /* @__PURE__ */ new Map();
1606
+ getWalletAccounts(client).forEach((walletAccount) => {
1607
+ if (walletProvidersMap.has(walletAccount.walletProviderKey)) return;
1608
+ try {
1609
+ const walletProvider = getWalletProviderFromWalletAccount({ walletAccount }, client);
1610
+ walletProvidersMap.set(walletAccount.walletProviderKey, walletProvider);
1611
+ } catch (error) {
1612
+ core.logger.debug("Wallet provider not found for wallet account", {
1613
+ error,
1614
+ walletAccount: walletAccount.address
1615
+ });
1616
+ }
1617
+ });
1618
+ return Array.from(walletProvidersMap.values());
1619
+ };
1620
+
1621
+ //#endregion
1622
+ //#region src/modules/wallets/destroyWalletProviders/destroyWalletProviders.ts
1623
+ /**
1624
+ * Tear down every wallet provider on the client.
1625
+ *
1626
+ * Each provider's `destroy` is responsible for its own local + remote
1627
+ * cleanup. We swallow errors so a failing destroy on one provider does not
1628
+ * block teardown of the others (e.g. during logout).
1629
+ *
1630
+ * @not-instrumented
1631
+ */
1632
+ const destroyWalletProviders = async ({ reason }, client) => {
1633
+ const core = getCore(client);
1634
+ const walletProviders = getAvailableWalletProvidersFromWalletAccounts(client);
1635
+ await Promise.all(walletProviders.map(async (walletProvider) => {
1636
+ if (!walletProvider.destroy) return;
1637
+ try {
1638
+ await walletProvider.destroy({ reason });
1639
+ } catch (err) {
1640
+ core.logger.error(`Error destroying wallet provider ${walletProvider.key}`, err);
1641
+ }
1642
+ }));
1643
+ };
1644
+
1645
+ //#endregion
1646
+ //#region src/modules/auth/consts.ts
1647
+ const DYNAMIC_AUTH_COOKIE_NAME = "DYNAMIC_JWT_TOKEN";
1648
+
1649
+ //#endregion
1650
+ //#region src/modules/auth/logoutWithReason/logoutWithReason.ts
1651
+ /**
1652
+ * Logs the user out with an explicit reason.
1653
+ *
1654
+ * Revokes the session, clears auth state, terminates wallet providers, and
1655
+ * emits the `logout` client event with the given reason. The reason is also
1656
+ * captured as an argument on the function-instrumentation event, which is
1657
+ * how Datadog distinguishes between different logout causes.
1658
+ *
1659
+ * Use this instead of the public `logout` when triggering a logout from
1660
+ * internal or extension code — the caller owns the reason string, so the
1661
+ * telemetry correctly attributes *why* the logout happened.
1662
+ *
1663
+ * @param params - The logout params.
1664
+ * @param params.reason - Why the logout is being triggered. Extension authors
1665
+ * needing a reason outside the SDK catalog can cast with `as LogoutReason`.
1666
+ * @param client - The Dynamic client instance.
1667
+ * @instrumented
1668
+ */
1669
+ const logoutWithReason = async ({ reason }, client) => {
1670
+ const core = getCore(client);
1671
+ core.logger.debug("[logoutWithReason] Logging out...", { reason });
1672
+ await destroyWalletProviders({ reason }, client);
1673
+ if (client.user !== null) {
1674
+ const apiClient = createApiClient({ skipSessionExpiryLogout: true }, client);
1675
+ try {
1676
+ await apiClient.revokeSession({ environmentId: core.environmentId });
1677
+ } catch (error) {
1678
+ core.logger.error("Failed to revoke session", error);
1679
+ }
1680
+ /**
1681
+ * This deletes the auth cookie if it exists.
1682
+ * If the cookie doesn't exist, this sets a new cookie that expires immediately.
1683
+ */
1684
+ if (isCookieEnabled(client)) setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`);
1685
+ }
1686
+ await core.keychain.removeKey("session");
1687
+ core.state.set({
1688
+ captchaToken: null,
1689
+ elevatedAccessTokens: [],
1690
+ legacyToken: null,
1691
+ mfaToken: null,
1692
+ sessionExpiresAt: null,
1693
+ sessionKeys: null,
1694
+ token: null,
1695
+ unverifiedWalletAccounts: [],
1696
+ user: null
1697
+ });
1698
+ emitEvent({
1699
+ args: { reason },
1700
+ event: "logout"
1701
+ }, client);
1702
+ fetchProjectSettings(client);
1703
+ generateSessionKeys(client);
1704
+ };
1705
+ const __logoutWithReason_impl = logoutWithReason;
1706
+ const __logoutWithReason_wrapped = instrumentFunction({
1707
+ fn: __logoutWithReason_impl,
1708
+ functionName: "logoutWithReason",
1709
+ getCore: () => {
1710
+ try {
1711
+ return getCore(getDefaultClient());
1712
+ } catch {
1713
+ return;
1714
+ }
1715
+ }
1716
+ });
1717
+
1718
+ //#endregion
1719
+ //#region src/modules/apiClient/utils/sessionExpiryLogoutMiddleware/createSessionExpiryLogoutMiddleware.ts
1720
+ const UNAUTHORIZED_STATUS = 401;
1721
+ /**
1722
+ * Creates middleware that ends the local session when an *authenticated*
1723
+ * request is rejected with a 401.
1724
+ *
1725
+ * A 401 on a request that carried an authenticated session means the backend
1726
+ * rejected our credentials, so the local session is stale and must be cleared.
1727
+ * The check is purely local (`client.user`) — we deliberately do not
1728
+ * re-validate over the network, because the 401 itself is the rejection signal
1729
+ * and re-validating would route back through this same middleware.
1730
+ *
1731
+ * Requests made without an authenticated session (e.g. pre-auth probes) are
1732
+ * ignored — there is no session to invalidate. Endpoints that legitimately
1733
+ * return 401 for non-session reasons opt out of this behavior by omitting the
1734
+ * middleware (see `skipSessionExpiryLogout` on `createApiClient`).
1735
+ *
1736
+ * This middleware runs before the error-conversion middleware so it observes
1737
+ * every 401 regardless of response body. The logout is fired as a side effect
1738
+ * and the response is returned unchanged, so the downstream error middleware
1739
+ * still throws the typed error to the caller.
1740
+ *
1741
+ * @param client - The Dynamic client instance.
1742
+ * @not-instrumented
1743
+ */
1744
+ const createSessionExpiryLogoutMiddleware = (client) => ({ post: async (context) => {
1745
+ if (context.response.status === UNAUTHORIZED_STATUS && client.user !== null) __logoutWithReason_wrapped({ reason: "session-revoked" }, client).catch((error) => {
1746
+ getCore(client).logger.error("Failed to log out after unauthorized response", error);
1747
+ });
1748
+ return context.response;
1749
+ } });
1750
+
1751
+ //#endregion
1752
+ //#region src/errors/UnauthorizedError.ts
1753
+ var UnauthorizedError = class extends BaseError {
1754
+ constructor({ cause }) {
1755
+ super({
1756
+ cause,
1757
+ code: "unauthorized_error",
1758
+ docsUrl: null,
1759
+ name: "UnauthorizedError",
1760
+ shortMessage: "Unauthorized"
1761
+ });
1762
+ }
1763
+ };
1764
+
1765
+ //#endregion
1766
+ //#region src/modules/apiClient/utils/unauthorizedMiddleware/createUnauthorizedMiddleware.ts
1767
+ /** @not-instrumented */
1768
+ const createUnauthorizedMiddleware = () => ({ post: async (context) => {
1769
+ if (context.response.status === 401) {
1770
+ let cause = null;
1771
+ try {
1772
+ const errorBody = await context.response.clone().json();
1773
+ if (errorBody && "error" in errorBody && typeof errorBody.error === "string") cause = new Error(errorBody.error);
1774
+ } catch {}
1775
+ throw new UnauthorizedError({ cause });
1776
+ }
1777
+ return context.response;
1778
+ } });
1779
+
1780
+ //#endregion
1781
+ //#region src/modules/apiClient/createApiClient.ts
1782
+ /**
1783
+ * Returns a new instance of the SDK API client.
1784
+ *
1785
+ * This is not meant for storing, as it is very light we can create it whenever needed.
1786
+ * @not-instrumented
1787
+ */
1788
+ const createApiClient = (options = {}, client) => {
1789
+ const core = getCore(client);
1790
+ const coreState = core.state.get();
1791
+ const settings = {
1792
+ basePath: core.apiBaseUrl,
1793
+ headers: {
1794
+ "Content-Type": "application/json",
1795
+ [DYNAMIC_API_VERSION_HEADER]: `API/${DYNAMIC_SDK_API_VERSION}`,
1796
+ [DYNAMIC_REQUEST_ID_HEADER]: randomString({ length: 50 }),
1797
+ [DYNAMIC_SDK_SESSION_ID_HEADER]: core.sdkSessionId,
1798
+ [DYNAMIC_SDK_VERSION_HEADER]: `${CLIENT_SDK_NAME}/${version}`,
1799
+ ...core.getApiHeaders(),
1800
+ ...options.headers
1801
+ }
1802
+ };
1803
+ if (core.metadata?.universalLink) settings.headers["Origin"] = core.metadata.universalLink;
1804
+ if (client.token) settings.headers.Authorization = `Bearer ${client.token}`;
1805
+ if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
1806
+ if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
1807
+ if (options.elevatedAccessTokenScope) {
1808
+ const elevatedToken = __getElevatedAccessToken_wrapped({ scope: options.elevatedAccessTokenScope }, client);
1809
+ if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
1810
+ }
1811
+ const sessionPublicKey = getSessionKeys(client)?.publicKey;
1812
+ const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
1813
+ if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
1814
+ return new SDKApi(new Configuration({
1815
+ ...settings,
1816
+ fetchApi: core.fetch,
1817
+ middleware: [
1818
+ createDeviceSignatureHeadersMiddleware(client),
1819
+ ...options.skipSessionExpiryLogout ? [] : [createSessionExpiryLogoutMiddleware(client)],
1820
+ createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
1821
+ createUnauthorizedMiddleware()
1822
+ ]
1823
+ }));
1824
+ };
1825
+
1826
+ //#endregion
1827
+ //#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
1828
+ /**
1829
+ * Fetches a batch of nonces from the API.
1830
+ *
1831
+ * Prefetching is critical for iOS deep link wallet providers (e.g. Phantom
1832
+ * redirect). On iOS, a network request (like fetching a nonce) between a user
1833
+ * action and a deeplink call will break the gesture chain, causing iOS to
1834
+ * silently ignore the deeplink. By prefetching nonces ahead of time,
1835
+ * `getNonce` can return synchronously from cache and the deeplink fires
1836
+ * without an interrupting network round-trip.
1837
+ *
1838
+ * New nonces are **appended** to the existing pool so that unconsumed entries
1839
+ * are not discarded by a background refetch.
1840
+ * @not-instrumented
1841
+ */
1842
+ const fetchAndStoreNonces = async (client) => {
1843
+ const core = getCore(client);
1844
+ const { environmentId } = core;
1845
+ const { nonces } = await createApiClient({}, client).getNonces({
1846
+ count: NONCE_POOL_SIZE,
1847
+ environmentId
1848
+ });
1849
+ const existing = core.state.get().prefetchedNonces;
1850
+ core.state.set({
1851
+ prefetchedNonces: [...existing, ...nonces],
1852
+ prefetchedNoncesExpiration: Date.now() + NONCE_POOL_EXPIRATION_TIME
1853
+ });
1854
+ };
1855
+
1066
1856
  //#endregion
1067
1857
  //#region src/constants.ts
1068
1858
  const SDK_API_CORE_VERSION = dependencies["@dynamic-labs/sdk-api-core"];
@@ -1093,5 +1883,5 @@ var InvalidParamError = class extends BaseError {
1093
1883
  };
1094
1884
 
1095
1885
  //#endregion
1096
- export { extractSessionId as A, name as B, isCookieEnabled as C, instrumentFunction as D, __getElevatedAccessToken_wrapped as E, getDefaultClient as F, setDefaultClient as I, ClientNotFoundError as L, CLIENT_SDK_NAME as M, DYNAMIC_SDK_API_VERSION as N, DEFAULT_PII_FIELDS as O, NONCE_POOL_SIZE as P, BaseError as R, getSessionKeys as S, ValueMustBeDefinedError as T, version as V, MfaRateLimitedError as _, DYNAMIC_ICONIC_SPRITE_URL as a, InvalidExternalAuthError as b, CHAINS_INFO_MAP as c, UnauthorizedError as d, createDeviceSignatureHeadersMiddleware as f, SandboxMaximumThresholdReachedError as g, getNonce as h, DYNAMIC_WAAS_METADATA as i, randomString as j, getUserAgent as k, fetchAndStoreNonces as l, getDeviceSigner as m, DEFAULT_WAAS_BASE_API_URL as n, SDK_API_CORE_VERSION as o, getHeadersForNonceSignedByDeviceSigners as p, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as r, getChainFromVerifiedCredentialChain as s, InvalidParamError as t, createApiClient as u, MfaInvalidOtpError as v, assertDefined as w, APIError as x, LinkCredentialError as y, getCore as z };
1097
- //# sourceMappingURL=InvalidParamError-9kQBK3sP.native.esm.js.map
1886
+ export { instrumentFunction as $, splitWalletProviderKey as A, getDeviceSigner as B, getWalletAccountsFromState as C, CHAINS_INFO_MAP as D, getChainFromVerifiedCredentialChain as E, onEvent as F, LinkCredentialError as G, SandboxMaximumThresholdReachedError as H, onceEvent as I, getSessionKeys as J, InvalidExternalAuthError as K, setCookie as L, retryOnFail as M, emitEvent as N, formatWalletAccountId as O, offEvent as P, __getElevatedAccessToken_wrapped as Q, createDeviceSignatureHeadersMiddleware as R, getWalletAccounts as S, normalizeWalletNameWithChain as T, MfaRateLimitedError as U, getNonce as V, MfaInvalidOtpError as W, assertDefined as X, isCookieEnabled as Y, ValueMustBeDefinedError as Z, generateSessionKeys as _, DYNAMIC_ICONIC_SPRITE_URL as a, CLIENT_SDK_NAME as at, createLocalStorageAdapter as b, createApiClient as c, getDefaultClient as ct, DYNAMIC_AUTH_COOKIE_NAME as d, BaseError as dt, scrubParameters as et, getWalletProviderFromWalletAccount as f, getCore as ft, NoWalletProviderFoundError as g, createRuntimeServiceAccessKey as h, DYNAMIC_WAAS_METADATA as i, randomString as it, InvalidWalletProviderKeyError as j, normalizeAddress as k, UnauthorizedError as l, setDefaultClient as lt, getWalletProviderRegistry as m, version as mt, DEFAULT_WAAS_BASE_API_URL as n, getUserAgent as nt, SDK_API_CORE_VERSION as o, DYNAMIC_SDK_API_VERSION as ot, WalletProviderPriority as p, name as pt, APIError as q, DEFAULT_WAAS_BASE_MPC_RELAY_API_URL as r, extractSessionId as rt, fetchAndStoreNonces as s, NONCE_POOL_SIZE as st, InvalidParamError as t, DEFAULT_PII_FIELDS as tt, __logoutWithReason_wrapped as u, ClientNotFoundError as ut, fetchProjectSettings as v, formatWalletProviderKey as w, isSignedIn as x, createStorageKeySchema as y, getHeadersForNonceSignedByDeviceSigners as z };
1887
+ //# sourceMappingURL=InvalidParamError-DkAMYJOW.native.esm.js.map