@dynamic-labs-sdk/client 1.4.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 (179) hide show
  1. package/dist/{InvalidParamError-DEmLKJKZ.cjs → InvalidParamError-DKJhDrK8.cjs} +1007 -116
  2. package/dist/InvalidParamError-DKJhDrK8.cjs.map +1 -0
  3. package/dist/{InvalidParamError-BPMi0iWC.esm.js → InvalidParamError-DWjMfOZ5.esm.js} +800 -92
  4. package/dist/InvalidParamError-DWjMfOZ5.esm.js.map +1 -0
  5. package/dist/{InvalidParamError-CDmVW2DS.native.esm.js → InvalidParamError-DkAMYJOW.native.esm.js} +833 -92
  6. package/dist/InvalidParamError-DkAMYJOW.native.esm.js.map +1 -0
  7. package/dist/{NotWaasWalletAccountError-Cntietge.esm.js → NotWaasWalletAccountError-BVrvQzLz.native.esm.js} +4 -4
  8. package/dist/NotWaasWalletAccountError-BVrvQzLz.native.esm.js.map +1 -0
  9. package/dist/{NotWaasWalletAccountError-Chpne8_Q.native.esm.js → NotWaasWalletAccountError-C7NUlvvM.esm.js} +4 -4
  10. package/dist/NotWaasWalletAccountError-C7NUlvvM.esm.js.map +1 -0
  11. package/dist/{NotWaasWalletAccountError-BZsBHRQe.cjs → NotWaasWalletAccountError-CHzpa9kk.cjs} +4 -4
  12. package/dist/NotWaasWalletAccountError-CHzpa9kk.cjs.map +1 -0
  13. package/dist/core.cjs +45 -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 +4 -0
  20. package/dist/exports/core.d.ts.map +1 -1
  21. package/dist/exports/index.d.ts +12 -0
  22. package/dist/exports/index.d.ts.map +1 -1
  23. package/dist/{getNetworkProviderFromNetworkId-szJOsbQN.cjs → getNetworkProviderFromNetworkId-BJ27N-7S.cjs} +44 -341
  24. package/dist/getNetworkProviderFromNetworkId-BJ27N-7S.cjs.map +1 -0
  25. package/dist/{getNetworkProviderFromNetworkId-JGrKwBj7.native.esm.js → getNetworkProviderFromNetworkId-Bs1kQdWk.native.esm.js} +38 -299
  26. package/dist/getNetworkProviderFromNetworkId-Bs1kQdWk.native.esm.js.map +1 -0
  27. package/dist/{getNetworkProviderFromNetworkId-CEeFL-gV.esm.js → getNetworkProviderFromNetworkId-Cqp9eRSs.esm.js} +42 -270
  28. package/dist/getNetworkProviderFromNetworkId-Cqp9eRSs.esm.js.map +1 -0
  29. package/dist/{getSignedSessionId-BOx1nFt_.esm.js → getSignedSessionId-CDdKrnw6.esm.js} +3 -3
  30. package/dist/{getSignedSessionId-BOx1nFt_.esm.js.map → getSignedSessionId-CDdKrnw6.esm.js.map} +1 -1
  31. package/dist/{getSignedSessionId-BxOK-Tdo.cjs → getSignedSessionId-CHDHr-hY.cjs} +3 -3
  32. package/dist/{getSignedSessionId-BxOK-Tdo.cjs.map → getSignedSessionId-CHDHr-hY.cjs.map} +1 -1
  33. package/dist/{getSignedSessionId-B5DikCap.native.esm.js → getSignedSessionId-D3KQrN8W.native.esm.js} +3 -3
  34. package/dist/{getSignedSessionId-B5DikCap.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 +580 -253
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.esm.js +514 -194
  44. package/dist/index.esm.js.map +1 -1
  45. package/dist/index.native.esm.js +511 -191
  46. package/dist/index.native.esm.js.map +1 -1
  47. package/dist/{isMfaRequiredForAction-DUvZEpjA.native.esm.js → isMfaRequiredForAction-B0xNvBpU.native.esm.js} +2 -2
  48. package/dist/{isMfaRequiredForAction-DUvZEpjA.native.esm.js.map → isMfaRequiredForAction-B0xNvBpU.native.esm.js.map} +1 -1
  49. package/dist/{isMfaRequiredForAction-6N6JB7wa.cjs → isMfaRequiredForAction-CLMvTTwl.cjs} +2 -2
  50. package/dist/{isMfaRequiredForAction-6N6JB7wa.cjs.map → isMfaRequiredForAction-CLMvTTwl.cjs.map} +1 -1
  51. package/dist/{isMfaRequiredForAction-D9p_du8C.esm.js → isMfaRequiredForAction-C_QPI1LH.esm.js} +2 -2
  52. package/dist/{isMfaRequiredForAction-D9p_du8C.esm.js.map → isMfaRequiredForAction-C_QPI1LH.esm.js.map} +1 -1
  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/isSignedIn/isSignedIn.d.ts +11 -1
  59. package/dist/modules/auth/isSignedIn/isSignedIn.d.ts.map +1 -1
  60. package/dist/modules/auth/logoutReason.d.ts +1 -1
  61. package/dist/modules/auth/logoutReason.d.ts.map +1 -1
  62. package/dist/modules/auth/logoutWithReason/logoutWithReason.d.ts.map +1 -1
  63. package/dist/modules/balances/getBalances/getBalances.d.ts +9 -45
  64. package/dist/modules/balances/getBalances/getBalances.d.ts.map +1 -1
  65. package/dist/modules/balances/getMultichainBalances/getMultichainBalances.d.ts +13 -20
  66. package/dist/modules/balances/getMultichainBalances/getMultichainBalances.d.ts.map +1 -1
  67. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts +26 -0
  68. package/dist/modules/balances/getMultichainTokenBalances/getMultichainTokenBalances.d.ts.map +1 -0
  69. package/dist/modules/balances/getMultichainTokenBalances/index.d.ts +2 -0
  70. package/dist/modules/balances/getMultichainTokenBalances/index.d.ts.map +1 -0
  71. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts +56 -0
  72. package/dist/modules/balances/getTokenBalances/getTokenBalances.d.ts.map +1 -0
  73. package/dist/modules/balances/getTokenBalances/index.d.ts +3 -0
  74. package/dist/modules/balances/getTokenBalances/index.d.ts.map +1 -0
  75. package/dist/modules/deviceRegistration/getRegisteredDevices/getRegisteredDevices.d.ts.map +1 -1
  76. package/dist/modules/funding/moonpay/errors/MoonPayCurrenciesFetchError.d.ts +5 -0
  77. package/dist/modules/funding/moonpay/errors/MoonPayCurrenciesFetchError.d.ts.map +1 -0
  78. package/dist/modules/funding/moonpay/errors/MoonPayInvalidUrlError.d.ts +5 -0
  79. package/dist/modules/funding/moonpay/errors/MoonPayInvalidUrlError.d.ts.map +1 -0
  80. package/dist/modules/funding/moonpay/errors/MoonPayProviderNotAvailableError.d.ts +5 -0
  81. package/dist/modules/funding/moonpay/errors/MoonPayProviderNotAvailableError.d.ts.map +1 -0
  82. package/dist/modules/funding/moonpay/getMoonPayCurrencies/getMoonPayCurrencies.d.ts +14 -0
  83. package/dist/modules/funding/moonpay/getMoonPayCurrencies/getMoonPayCurrencies.d.ts.map +1 -0
  84. package/dist/modules/funding/moonpay/getMoonPayCurrencies/index.d.ts +2 -0
  85. package/dist/modules/funding/moonpay/getMoonPayCurrencies/index.d.ts.map +1 -0
  86. package/dist/modules/funding/moonpay/getMoonPayUrl/getMoonPayUrl.d.ts +15 -0
  87. package/dist/modules/funding/moonpay/getMoonPayUrl/getMoonPayUrl.d.ts.map +1 -0
  88. package/dist/modules/funding/moonpay/getMoonPayUrl/index.d.ts +2 -0
  89. package/dist/modules/funding/moonpay/getMoonPayUrl/index.d.ts.map +1 -0
  90. package/dist/modules/funding/moonpay/moonpay.types.d.ts +26 -0
  91. package/dist/modules/funding/moonpay/moonpay.types.d.ts.map +1 -0
  92. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainFromWalletSchema/getChainFromWalletSchema.d.ts +12 -0
  93. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainFromWalletSchema/getChainFromWalletSchema.d.ts.map +1 -1
  94. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainsFromWalletSchema/getChainsFromWalletSchema.d.ts +26 -0
  95. package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainsFromWalletSchema/getChainsFromWalletSchema.d.ts.map +1 -0
  96. package/dist/modules/legacyWalletBook/hasUsableDeeplink/hasUsableDeeplink.d.ts +18 -0
  97. package/dist/modules/legacyWalletBook/hasUsableDeeplink/hasUsableDeeplink.d.ts.map +1 -0
  98. package/dist/modules/legacyWalletBook/legacyWalletBook.types.d.ts +2 -2
  99. package/dist/modules/legacyWalletBook/legacyWalletBook.types.d.ts.map +1 -1
  100. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts +13 -1
  101. package/dist/modules/swap/executeSwapTransaction/executeSwapTransaction.d.ts.map +1 -1
  102. package/dist/modules/user/refreshAuth/refreshAuth.d.ts.map +1 -1
  103. package/dist/modules/walletOptionsCatalogue/buildMetaMaskSdkUriOptions/buildMetaMaskSdkUriOptions.d.ts +27 -0
  104. package/dist/modules/walletOptionsCatalogue/buildMetaMaskSdkUriOptions/buildMetaMaskSdkUriOptions.d.ts.map +1 -0
  105. package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts +26 -0
  106. package/dist/modules/walletOptionsCatalogue/buildWalletConnectOptions/buildWalletConnectOptions.d.ts.map +1 -0
  107. package/dist/modules/walletOptionsCatalogue/buildWalletOption/buildWalletOption.d.ts +11 -4
  108. package/dist/modules/walletOptionsCatalogue/buildWalletOption/buildWalletOption.d.ts.map +1 -1
  109. package/dist/modules/walletOptionsCatalogue/buildWithWalletProviderOptions/buildWithWalletProviderOptions.d.ts.map +1 -1
  110. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/getInstallationLinkForCurrentPlatform.d.ts +35 -0
  111. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/getInstallationLinkForCurrentPlatform.d.ts.map +1 -0
  112. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/index.d.ts +2 -0
  113. package/dist/modules/walletOptionsCatalogue/getInstallationLinkForCurrentPlatform/index.d.ts.map +1 -0
  114. package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts +6 -1
  115. package/dist/modules/walletOptionsCatalogue/getWalletOptionsCatalogue/getWalletOptionsCatalogue.d.ts.map +1 -1
  116. package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts +11 -0
  117. package/dist/modules/walletOptionsCatalogue/walletOptionsCatalogue.types.d.ts.map +1 -1
  118. package/dist/modules/wallets/constants.d.ts +7 -0
  119. package/dist/modules/wallets/constants.d.ts.map +1 -1
  120. package/dist/modules/wallets/getAvailableWalletProvidersData/getAvailableWalletProvidersData.d.ts.map +1 -1
  121. package/dist/modules/wallets/hasWalletProviderConnectMethod/hasWalletProviderConnectMethod.d.ts +26 -0
  122. package/dist/modules/wallets/hasWalletProviderConnectMethod/hasWalletProviderConnectMethod.d.ts.map +1 -0
  123. package/dist/modules/wallets/hasWalletProviderConnectMethod/index.d.ts +2 -0
  124. package/dist/modules/wallets/hasWalletProviderConnectMethod/index.d.ts.map +1 -0
  125. package/dist/modules/wallets/isAnyWalletAccountConnected/index.d.ts +2 -0
  126. package/dist/modules/wallets/isAnyWalletAccountConnected/index.d.ts.map +1 -0
  127. package/dist/modules/wallets/isAnyWalletAccountConnected/isAnyWalletAccountConnected.d.ts +14 -0
  128. package/dist/modules/wallets/isAnyWalletAccountConnected/isAnyWalletAccountConnected.d.ts.map +1 -0
  129. package/dist/modules/wallets/networks/getBalance/getBalance.d.ts +6 -17
  130. package/dist/modules/wallets/networks/getBalance/getBalance.d.ts.map +1 -1
  131. package/dist/modules/wallets/networks/getNativeBalance/getNativeBalance.d.ts +24 -0
  132. package/dist/modules/wallets/networks/getNativeBalance/getNativeBalance.d.ts.map +1 -0
  133. package/dist/modules/wallets/networks/getNativeBalance/index.d.ts +2 -0
  134. package/dist/modules/wallets/networks/getNativeBalance/index.d.ts.map +1 -0
  135. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +10 -0
  136. package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
  137. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  138. package/dist/utils/getChainFromWalletBookIdentifier/getChainFromWalletBookIdentifier.d.ts +22 -0
  139. package/dist/utils/getChainFromWalletBookIdentifier/getChainFromWalletBookIdentifier.d.ts.map +1 -0
  140. package/dist/utils/getChainFromWalletBookIdentifier/index.d.ts +2 -0
  141. package/dist/utils/getChainFromWalletBookIdentifier/index.d.ts.map +1 -0
  142. package/dist/utils/getNativeLinkScheme/getNativeLinkScheme.d.ts +18 -0
  143. package/dist/utils/getNativeLinkScheme/getNativeLinkScheme.d.ts.map +1 -0
  144. package/dist/utils/getNativeLinkScheme/index.d.ts +3 -0
  145. package/dist/utils/getNativeLinkScheme/index.d.ts.map +1 -0
  146. package/dist/utils/isMobile/isMobile.d.ts +8 -0
  147. package/dist/utils/isMobile/isMobile.d.ts.map +1 -1
  148. package/dist/waas.cjs +8 -9
  149. package/dist/waas.cjs.map +1 -1
  150. package/dist/waas.esm.js +3 -3
  151. package/dist/waas.native.esm.js +3 -3
  152. package/dist/waasCore.cjs +3 -4
  153. package/dist/waasCore.cjs.map +1 -1
  154. package/dist/waasCore.esm.js +3 -3
  155. package/dist/waasCore.native.esm.js +3 -3
  156. package/package.json +4 -4
  157. package/dist/InvalidParamError-BPMi0iWC.esm.js.map +0 -1
  158. package/dist/InvalidParamError-CDmVW2DS.native.esm.js.map +0 -1
  159. package/dist/InvalidParamError-DEmLKJKZ.cjs.map +0 -1
  160. package/dist/NotWaasWalletAccountError-BZsBHRQe.cjs.map +0 -1
  161. package/dist/NotWaasWalletAccountError-Chpne8_Q.native.esm.js.map +0 -1
  162. package/dist/NotWaasWalletAccountError-Cntietge.esm.js.map +0 -1
  163. package/dist/getNetworkProviderFromNetworkId-CEeFL-gV.esm.js.map +0 -1
  164. package/dist/getNetworkProviderFromNetworkId-JGrKwBj7.native.esm.js.map +0 -1
  165. package/dist/getNetworkProviderFromNetworkId-szJOsbQN.cjs.map +0 -1
  166. package/dist/getVerifiedCredentialForWalletAccount-B46O0B48.cjs +0 -887
  167. package/dist/getVerifiedCredentialForWalletAccount-B46O0B48.cjs.map +0 -1
  168. package/dist/getVerifiedCredentialForWalletAccount-CyykSi-M.native.esm.js +0 -701
  169. package/dist/getVerifiedCredentialForWalletAccount-CyykSi-M.native.esm.js.map +0 -1
  170. package/dist/getVerifiedCredentialForWalletAccount-DzwIoeHm.esm.js +0 -701
  171. package/dist/getVerifiedCredentialForWalletAccount-DzwIoeHm.esm.js.map +0 -1
  172. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/buildUriDeeplinkOptions.d.ts +0 -28
  173. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/buildUriDeeplinkOptions.d.ts.map +0 -1
  174. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/index.d.ts +0 -2
  175. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/index.d.ts.map +0 -1
  176. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/resolveUriConnectionType/index.d.ts +0 -2
  177. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/resolveUriConnectionType/index.d.ts.map +0 -1
  178. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/resolveUriConnectionType/resolveUriConnectionType.d.ts +0 -17
  179. package/dist/modules/walletOptionsCatalogue/buildUriDeeplinkOptions/resolveUriConnectionType/resolveUriConnectionType.d.ts.map +0 -1
@@ -1,887 +0,0 @@
1
- const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-szJOsbQN.cjs');
2
- const require_InvalidParamError = require('./InvalidParamError-DEmLKJKZ.cjs');
3
- let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
4
-
5
- //#region src/utils/setCookie/setCookie.ts
6
- /**
7
- * Sefelly sets the cookie in the browser.
8
- * @not-instrumented
9
- */
10
- const setCookie = (cookie) => {
11
- document.cookie = cookie;
12
- };
13
-
14
- //#endregion
15
- //#region src/modules/clientEvents/clientEvents.ts
16
- /**
17
- * Adds an event listener for Dynamic client events.
18
- *
19
- * This function allows you to listen for various events emitted by the Dynamic client,
20
- * such as authentication state changes, wallet connections, and more.
21
- *
22
- * @param params.event - The event name to listen for.
23
- * @param params.listener - The callback function to execute when the event is fired.
24
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
25
- * @returns A function that can be called to remove the listener.
26
- * @not-instrumented
27
- */
28
- const onEvent = ({ event, listener }, client = require_InvalidParamError.getDefaultClient()) => {
29
- const { eventEmitter } = require_InvalidParamError.getCore(client);
30
- eventEmitter.on(event, listener);
31
- return () => {
32
- eventEmitter.off(event, listener);
33
- };
34
- };
35
- /**
36
- * Removes an event listener from Dynamic client events.
37
- *
38
- * This function unsubscribes a previously registered event listener
39
- * from the specified Dynamic client event.
40
- *
41
- * @param params.event - The event name to remove the listener from.
42
- * @param params.listener - The callback function to remove.
43
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
44
- * @not-instrumented
45
- */
46
- const offEvent = ({ event, listener }, client = require_InvalidParamError.getDefaultClient()) => {
47
- const { eventEmitter } = require_InvalidParamError.getCore(client);
48
- eventEmitter.off(event, listener);
49
- };
50
- /**
51
- * Adds a one-time event listener for Dynamic client events.
52
- *
53
- * This function listens for an event that will automatically remove itself
54
- * after being triggered once.
55
- *
56
- * @param params.event - The event name to listen for.
57
- * @param params.listener - The callback function to execute when the event is fired.
58
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
59
- * @returns A function that can be called to remove the listener before it fires.
60
- * @not-instrumented
61
- */
62
- const onceEvent = ({ event, listener }, client = require_InvalidParamError.getDefaultClient()) => {
63
- const { eventEmitter } = require_InvalidParamError.getCore(client);
64
- eventEmitter.once(event, listener);
65
- return () => {
66
- eventEmitter.off(event, listener);
67
- };
68
- };
69
- /**
70
- * Emits a Dynamic client event.
71
- *
72
- * This function triggers an event that will be received by all registered
73
- * listeners for the specified event type.
74
- *
75
- * @param params.event - The event name to emit.
76
- * @param params.args - The arguments to pass to event listeners.
77
- * @param client - The Dynamic client instance.
78
- * @not-instrumented
79
- */
80
- const emitEvent = ({ event, args }, client) => {
81
- const { eventEmitter } = require_InvalidParamError.getCore(client);
82
- eventEmitter.emit(event, args);
83
- };
84
-
85
- //#endregion
86
- //#region src/errors/InvalidWalletProviderKeyError.ts
87
- var InvalidWalletProviderKeyError = class extends require_InvalidParamError.BaseError {
88
- constructor(value) {
89
- super({
90
- cause: null,
91
- code: "invalid_wallet_provider_key",
92
- docsUrl: null,
93
- name: "InvalidWalletProviderKeyError",
94
- shortMessage: `Invalid wallet provider key: ${value}. Key must be in the format of <normalizedWalletNameWithChain>:<walletProviderType>[:<suffix>]`
95
- });
96
- }
97
- };
98
-
99
- //#endregion
100
- //#region src/modules/wallets/walletProvider/splitWalletProviderKey/splitWalletProviderKey.ts
101
- /** @not-instrumented */
102
- const splitWalletProviderKey = (walletProviderKey) => {
103
- const [normalizedWalletNameWithChain, walletProviderType, suffix, ...rest] = walletProviderKey.split(":");
104
- if (!normalizedWalletNameWithChain || !Object.values(_dynamic_labs_sdk_api_core.WalletProviderEnum).includes(walletProviderType) || rest.length > 0) throw new InvalidWalletProviderKeyError(walletProviderKey);
105
- return {
106
- normalizedWalletNameWithChain,
107
- suffix,
108
- walletProviderType
109
- };
110
- };
111
-
112
- //#endregion
113
- //#region src/modules/wallets/utils/normalizeAddress/normalizeAddress.ts
114
- /** @not-instrumented */
115
- const normalizeAddress = ({ address, chain }) => {
116
- let normalizedAddress = address;
117
- if (normalizedAddress?.startsWith("0x")) normalizedAddress = normalizedAddress.slice(2);
118
- normalizedAddress = ["EVM", "FLOW"].includes(chain) ? normalizedAddress?.toLowerCase() : normalizedAddress;
119
- return normalizedAddress;
120
- };
121
-
122
- //#endregion
123
- //#region src/modules/wallets/utils/formatWalletAccountId/formatWalletAccountId.ts
124
- /** @not-instrumented */
125
- const formatWalletAccountId = ({ address, chain, walletProviderKey }) => {
126
- const { normalizedWalletNameWithChain } = splitWalletProviderKey(walletProviderKey);
127
- return `${normalizedWalletNameWithChain}:${normalizeAddress({
128
- address,
129
- chain
130
- })}`;
131
- };
132
-
133
- //#endregion
134
- //#region src/modules/wallets/utils/convertUnverifiedWalletAccountToWalletAccount/convertUnverifiedWalletAccountToWalletAccount.ts
135
- /** @not-instrumented */
136
- const convertUnverifiedWalletAccountToWalletAccount = ({ unverifiedWalletAccount }) => ({
137
- address: unverifiedWalletAccount.address,
138
- addressesWithTypes: unverifiedWalletAccount.addressesWithTypes,
139
- chain: unverifiedWalletAccount.chain,
140
- id: formatWalletAccountId({
141
- address: unverifiedWalletAccount.address,
142
- chain: unverifiedWalletAccount.chain,
143
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
144
- }),
145
- lastSelectedAt: unverifiedWalletAccount.lastSelectedAt,
146
- verifiedCredentialId: null,
147
- walletProviderKey: unverifiedWalletAccount.walletProviderKey
148
- });
149
-
150
- //#endregion
151
- //#region src/modules/wallets/utils/normalizeWalletNameWithChain/normalizeWalletNameWithChain.ts
152
- /**
153
- * Format the raw wallet name and chain to get the value we can use for
154
- * verified credentials' `walletName` field.
155
- * @not-instrumented
156
- */
157
- const normalizeWalletNameWithChain = ({ displayName, chain }) => {
158
- const sanitizedWalletName = displayName.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
159
- const chainLowered = chain.toLocaleLowerCase();
160
- if (sanitizedWalletName.endsWith(chainLowered)) return sanitizedWalletName;
161
- return `${sanitizedWalletName}${chainLowered}`;
162
- };
163
-
164
- //#endregion
165
- //#region src/modules/wallets/utils/formatWalletProviderKey/formatWalletProviderKey.ts
166
- /**
167
- * Assembles the wallet provider key from the wallet name, chain, and wallet provider type.
168
- *
169
- * The suffix is optional and can be used to add a uniquely identifying string to the key, which
170
- * might be necessary for some wallet providers (like Wallet Connect).
171
- *
172
- * IMPORTANT: Do NOT add a suffix unless absolutely necessary, as it will cause the wallet account
173
- * to not be able to find its wallet provider when connecting to a new device (it won't be possible
174
- * to determine the full key just from the Verified Credential data).
175
- * @not-instrumented
176
- */
177
- const formatWalletProviderKey = ({ suffix, chain, displayName, walletProviderType }) => {
178
- return `${normalizeWalletNameWithChain({
179
- chain,
180
- displayName
181
- })}:${walletProviderType}${suffix ? `:${suffix}` : ""}`;
182
- };
183
-
184
- //#endregion
185
- //#region src/modules/wallets/walletProvider/walletProviderKeyMap/getWalletProviderKeyFromVerifiedCredential/getWalletProviderKeyFromVerifiedCredential.ts
186
- /** @not-instrumented */
187
- const getWalletProviderKeyFromVerifiedCredential = ({ verifiedCredential }, client) => {
188
- const { walletProviderKeyMap } = require_InvalidParamError.getCore(client).state.get();
189
- const storedWalletProviderKey = walletProviderKeyMap[verifiedCredential.id];
190
- if (storedWalletProviderKey) return { walletProviderKey: storedWalletProviderKey };
191
- /**
192
- * We fallback to comprising the wallet provider key from walletName and walletProvider.
193
- *
194
- * Some wallet provider types (like Wallet Connect) also use a special suffix for their wallet provider
195
- * keys, so this won't be enough for them.
196
- * Therefore, for those specific wallet providers, the wallet account will remain without a wallet provider
197
- * and will require reconnection.
198
- * Read walletProvider.types.ts for more info.
199
- */
200
- require_InvalidParamError.assertDefined(verifiedCredential.walletName, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletName`);
201
- require_InvalidParamError.assertDefined(verifiedCredential.walletProvider, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing walletProvider`);
202
- require_InvalidParamError.assertDefined(verifiedCredential.chain, `Failed to get wallet provider for verified credential with ID ${verifiedCredential.id}: missing chain`);
203
- return { walletProviderKey: formatWalletProviderKey({
204
- chain: require_InvalidParamError.getChainFromVerifiedCredentialChain(verifiedCredential.chain),
205
- displayName: verifiedCredential.walletName,
206
- walletProviderType: verifiedCredential.walletProvider
207
- }) };
208
- };
209
-
210
- //#endregion
211
- //#region src/modules/wallets/utils/convertVerifiedCredentialToWalletAccount/convertVerifiedCredentialToWalletAccount.ts
212
- /** @not-instrumented */
213
- const convertVerifiedCredentialToWalletAccount = ({ verifiedCredential }, client) => {
214
- require_InvalidParamError.assertDefined(verifiedCredential.address, "Missing address in verified credential");
215
- require_InvalidParamError.assertDefined(verifiedCredential.chain, "Missing chain in verified credential");
216
- const chain = require_InvalidParamError.getChainFromVerifiedCredentialChain(verifiedCredential.chain);
217
- const { walletProviderKey } = getWalletProviderKeyFromVerifiedCredential({ verifiedCredential }, client);
218
- const walletAccountId = formatWalletAccountId({
219
- address: verifiedCredential.address,
220
- chain,
221
- walletProviderKey
222
- });
223
- return {
224
- address: verifiedCredential.address,
225
- addressesWithTypes: verifiedCredential.walletAdditionalAddresses,
226
- chain,
227
- hardwareWalletVendor: verifiedCredential.walletProperties?.hardwareWallet,
228
- id: walletAccountId,
229
- lastSelectedAt: verifiedCredential.lastSelectedAt ?? null,
230
- verifiedCredentialId: verifiedCredential.id,
231
- walletProviderKey
232
- };
233
- };
234
-
235
- //#endregion
236
- //#region src/modules/wallets/getWalletAccounts/getWalletAccountsFromState/getWalletAccountsFromState.ts
237
- /** @not-instrumented */
238
- const getWalletAccountsFromState = ({ unverifiedWalletAccounts, user }, client) => {
239
- const walletAccountsMap = /* @__PURE__ */ new Map();
240
- /**
241
- * Handle the unverified wallet accounts before the user verified credentials
242
- * so the later verified wallet accounts can override the unverified wallet accounts
243
- */
244
- unverifiedWalletAccounts.forEach((unverifiedWalletAccount) => {
245
- const walletAccount = convertUnverifiedWalletAccountToWalletAccount({ unverifiedWalletAccount });
246
- walletAccountsMap.set(walletAccount.id, walletAccount);
247
- });
248
- (user?.verifiedCredentials ?? []).filter((verified) => verified.format === _dynamic_labs_sdk_api_core.JwtVerifiedCredentialFormatEnum.Blockchain).forEach((verifiedWalletAccount) => {
249
- const walletAccount = convertVerifiedCredentialToWalletAccount({ verifiedCredential: verifiedWalletAccount }, client);
250
- walletAccountsMap.set(walletAccount.id, walletAccount);
251
- });
252
- return Array.from(walletAccountsMap.values());
253
- };
254
-
255
- //#endregion
256
- //#region src/modules/wallets/getWalletAccounts/getWalletAccounts.ts
257
- /**
258
- * Retrieves all wallet accounts associated with the current session.
259
- *
260
- * This function returns both verified and unverified wallet accounts,
261
- * combining data from user credentials and local unverified accounts.
262
- * You can differentiate between verified and unverified wallet accounts by
263
- * checking the `verifiedCredentialId` property.
264
- *
265
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
266
- * @returns An array of wallet accounts associated with the session.
267
- * @not-instrumented
268
- */
269
- const getWalletAccounts = (client = require_InvalidParamError.getDefaultClient()) => {
270
- const { unverifiedWalletAccounts, user } = require_InvalidParamError.getCore(client).state.get();
271
- return getWalletAccountsFromState({
272
- unverifiedWalletAccounts,
273
- user
274
- }, client);
275
- };
276
-
277
- //#endregion
278
- //#region src/errors/NoWalletProviderFoundError.ts
279
- var NoWalletProviderFoundError = class extends require_InvalidParamError.BaseError {
280
- constructor({ walletProviderKey }) {
281
- super({
282
- cause: null,
283
- code: "no_wallet_provider_found_error",
284
- docsUrl: null,
285
- name: "NoWalletProviderFoundError",
286
- shortMessage: `No wallet provider found with key: ${walletProviderKey}`
287
- });
288
- }
289
- };
290
-
291
- //#endregion
292
- //#region src/services/runtimeServices/createRuntimeServiceAccessKey/createRuntimeServiceAccessKey.ts
293
- /**
294
- * Creates a service accessor function that manages service instantiation and caching.
295
- * The returned function will either retrieve an existing service from the registry or
296
- * create a new one using the provided builder function.
297
- *
298
- * @template - The type of service to be created/accessed
299
- * @param key - Unique identifier for the service in the registry
300
- * @param builder - Function that creates the service instance when called with a DynamicClient
301
- * @not-instrumented
302
- */
303
- const createRuntimeServiceAccessKey = (key, builder) => (client) => {
304
- const { runtimeServices } = require_InvalidParamError.getCore(client);
305
- const currentService = runtimeServices.getByKey(key);
306
- if (currentService) return currentService;
307
- const service = builder(client);
308
- runtimeServices.register(key, service);
309
- return service;
310
- };
311
-
312
- //#endregion
313
- //#region src/modules/wallets/walletProviderRegistry/createWalletProviderRegistry/createWalletProviderRegistry.ts
314
- /**
315
- * Creates a new wallet provider registry that manages wallet providers with priority-based registration.
316
- *
317
- * @returns The wallet provider registry instance
318
- *
319
- * @example
320
- * ```typescript
321
- * const registry = createWalletProviderRegistry();
322
- *
323
- * registry.register({
324
- * priority: WalletProviderPriority.WALLET_SDK,
325
- * walletProvider: myWalletProvider
326
- * });
327
- *
328
- * const provider = registry.getByKey('my-wallet-key');
329
- * const providers = registry.listProviders();
330
- * ```
331
- * @not-instrumented
332
- */
333
- const createWalletProviderRegistry = (client) => {
334
- const registry = /* @__PURE__ */ new Map();
335
- return {
336
- getByKey: (key) => registry.get(key)?.walletProvider,
337
- listProviderEntries: () => Array.from(registry.values()),
338
- listProviders: () => Array.from(registry.values()).map((v) => v.walletProvider),
339
- register: (args) => {
340
- const existingEntry = registry.get(args.walletProvider.key);
341
- if (existingEntry) {
342
- if (existingEntry.priority < args.priority) {
343
- registry.set(args.walletProvider.key, args);
344
- emitEvent({
345
- args: { walletProviderKey: args.walletProvider.key },
346
- event: "walletProviderChanged"
347
- }, client);
348
- }
349
- } else {
350
- registry.set(args.walletProvider.key, args);
351
- emitEvent({
352
- args: { walletProvider: args.walletProvider },
353
- event: "walletProviderRegistered"
354
- }, client);
355
- emitEvent({
356
- args: { walletProviderKey: args.walletProvider.key },
357
- event: "walletProviderChanged"
358
- }, client);
359
- }
360
- },
361
- unregister: (key) => {
362
- registry.delete(key);
363
- emitEvent({
364
- args: { walletProviderKey: key },
365
- event: "walletProviderUnregistered"
366
- }, client);
367
- }
368
- };
369
- };
370
-
371
- //#endregion
372
- //#region src/modules/wallets/walletProviderRegistry/getWalletProviderRegistry/getWalletProviderRegistry.ts
373
- /**
374
- * This function provides access to a shared instance of the wallet provider registry.
375
- *
376
- * It ensures that the same registry instance is used throughout the client to maintaining
377
- * consistency of registered wallet providers across different parts of the codebase.
378
- *
379
- * @returns The wallet provider registry instance
380
- *
381
- * @example
382
- * ```typescript
383
- * // Get the registry instance
384
- * const registry = getWalletProviderRegistry();
385
- *
386
- * // Register a wallet provider
387
- * registry.register({
388
- * priority: WalletProviderPriority.WALLET_SDK,
389
- * walletProvider: myWalletProvider
390
- * });
391
- *
392
- * // Retrieve a specific provider
393
- * const provider = registry.getByKey('metamaskevm');
394
- * ```
395
- */
396
- const getWalletProviderRegistry = createRuntimeServiceAccessKey("walletProviderRegistry", (client) => createWalletProviderRegistry(client));
397
-
398
- //#endregion
399
- //#region src/modules/wallets/walletProviderRegistry/walletProviderRegistry.types.ts
400
- let WalletProviderPriority = /* @__PURE__ */ function(WalletProviderPriority$1) {
401
- /**
402
- * Highest priority should be used by wallet providers that implement
403
- * the most reliable wallet integration.
404
- * example: The SDK provided by the wallet provider.
405
- */
406
- WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SDK"] = 100] = "WALLET_SDK";
407
- /**
408
- * Medium priority should be used by wallet providers that implement
409
- * a wallet integration via some reliable standard.
410
- * example: A wallet provider that uses EIP6963 announcement.
411
- */
412
- WalletProviderPriority$1[WalletProviderPriority$1["WALLET_SELF_ANNOUNCEMENT_STANDARD"] = 50] = "WALLET_SELF_ANNOUNCEMENT_STANDARD";
413
- /**
414
- * Low priority should be used by wallet providers that implement
415
- * a wallet integration on a less reliable standard.
416
- * example: A wallet provider that uses window.ethereum, where the
417
- * window key can be overridden by other extensions.
418
- */
419
- WalletProviderPriority$1[WalletProviderPriority$1["WINDOW_INJECT"] = 20] = "WINDOW_INJECT";
420
- return WalletProviderPriority$1;
421
- }({});
422
-
423
- //#endregion
424
- //#region src/modules/wallets/utils/getWalletProviderFromWalletAccount/getWalletProviderFromWalletAccount.ts
425
- /** @not-instrumented */
426
- const getWalletProviderFromWalletAccount = ({ walletAccount }, client) => {
427
- const walletProvider = getWalletProviderRegistry(client).getByKey(walletAccount.walletProviderKey);
428
- if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey: walletAccount.walletProviderKey });
429
- return walletProvider;
430
- };
431
-
432
- //#endregion
433
- //#region src/modules/auth/consts.ts
434
- const DYNAMIC_AUTH_COOKIE_NAME = "DYNAMIC_JWT_TOKEN";
435
-
436
- //#endregion
437
- //#region src/modules/wallets/emitWalletAccountsChangedEvent/emitWalletAccountsChangedEvent.ts
438
- /**
439
- * Emits the `walletAccountsChanged` event.
440
- * @not-instrumented
441
- */
442
- const emitWalletAccountsChangedEvent = (client) => {
443
- emitEvent({
444
- args: { walletAccounts: getWalletAccounts(client) },
445
- event: "walletAccountsChanged"
446
- }, client);
447
- };
448
-
449
- //#endregion
450
- //#region src/modules/auth/updateAuthFromVerifyResponse/checkAndRaiseWalletAccountsChangedEvent/checkAndRaiseWalletAccountsChangedEvent.ts
451
- /** @not-instrumented */
452
- const checkAndRaiseWalletAccountsChangedEvent = ({ previousState }, client) => {
453
- const core = require_InvalidParamError.getCore(client);
454
- if (getWalletAccountsHash(previousState, client) !== getWalletAccountsHash(core.state.get(), client)) emitWalletAccountsChangedEvent(client);
455
- };
456
- const getWalletAccountsHash = (state, client) => getWalletAccountsFromState(state, client).map((walletAccount) => JSON.stringify(walletAccount)).sort().join("-");
457
-
458
- //#endregion
459
- //#region src/modules/mfa/isUserMissingMfaAuth/isUserMissingMfaAuth.ts
460
- /**
461
- * Checks if the user requires additional MFA authentication.
462
- *
463
- * This function determines if the current user session requires
464
- * additional multi-factor authentication to access certain features.
465
- *
466
- * @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
467
- * @returns True if the user needs additional MFA authentication, false otherwise.
468
- * @not-instrumented
469
- */
470
- const isUserMissingMfaAuth = (client = require_InvalidParamError.getDefaultClient()) => {
471
- const user = client.user;
472
- require_InvalidParamError.assertDefined(user, "User not logged in");
473
- return Boolean(user.scope?.includes("requiresAdditionalAuth"));
474
- };
475
-
476
- //#endregion
477
- //#region src/modules/wallets/getWalletProviders/getWalletProviders.ts
478
- /**
479
- * Get all available wallet providers to interact with internally.
480
- * @not-instrumented
481
- */
482
- const getWalletProviders = (client) => {
483
- return getWalletProviderRegistry(client).listProviders();
484
- };
485
-
486
- //#endregion
487
- //#region src/modules/waas/isWaasWalletProvider/isWaasWalletProvider.ts
488
- /** @not-instrumented */
489
- const isWaasWalletProvider = (walletProvider) => {
490
- return walletProvider.key.includes(require_InvalidParamError.DYNAMIC_WAAS_METADATA.normalizedWalletName);
491
- };
492
-
493
- //#endregion
494
- //#region src/modules/waas/findWaasWalletProviderByChain/findWaasWalletProviderByChain.ts
495
- /** @not-instrumented */
496
- const findWaasWalletProviderByChain = ({ chain }, client) => {
497
- const providers = getWalletProviders(client);
498
- const waasProviderKey = formatWalletProviderKey({
499
- chain,
500
- displayName: require_InvalidParamError.DYNAMIC_WAAS_METADATA.displayName,
501
- walletProviderType: _dynamic_labs_sdk_api_core.WalletProviderEnum.EmbeddedWallet
502
- });
503
- const waasProvider = providers.find((provider) => provider.key === waasProviderKey && provider.chain === chain);
504
- if (!waasProvider || !isWaasWalletProvider(waasProvider)) return null;
505
- return waasProvider;
506
- };
507
-
508
- //#endregion
509
- //#region src/modules/waas/isWaasWalletAccount/isWaasWalletAccount.ts
510
- /**
511
- * This function determines whether the provided wallet account is a Dynamic
512
- * WaaS wallet account.
513
- *
514
- * @param params.walletAccount - The wallet account to check.
515
- * @returns True if the wallet account is a WaaS wallet account, false otherwise.
516
- * @not-instrumented
517
- */
518
- const isWaasWalletAccount = ({ walletAccount }) => {
519
- return walletAccount.walletProviderKey.includes(require_InvalidParamError.DYNAMIC_WAAS_METADATA.normalizedWalletName);
520
- };
521
-
522
- //#endregion
523
- //#region src/modules/waas/restoreUserSharesForAllWalletAccounts/restoreUserSharesForAllWalletAccounts.ts
524
- /** @not-instrumented */
525
- const restoreUserSharesForAllWalletAccounts = async (client) => {
526
- /**
527
- * Restoring the user shares will fails if the user is missing the MFA auth.
528
- * This early return prevents the attempt to restore the user shares to fail
529
- * when we know it will fails and just add noise to the logs.
530
- */
531
- if (isUserMissingMfaAuth(client)) return;
532
- const waasWalletAccounts = getWalletAccounts(client).filter((walletAccount) => isWaasWalletAccount({ walletAccount }));
533
- await Promise.all(waasWalletAccounts.map(async (walletAccount) => {
534
- const provider = findWaasWalletProviderByChain({ chain: walletAccount.chain }, client);
535
- /**
536
- * The environment might not have the embedded wallet extensions installed.
537
- * In that case there is no provider for the chain and we can skip restoring the user share.
538
- */
539
- if (!provider) return;
540
- return provider.restoreUserShareForWalletAccount({ walletAccount });
541
- }));
542
- };
543
-
544
- //#endregion
545
- //#region src/modules/auth/decodeJwt/decodeJwt.ts
546
- /**
547
- * Decodes a JWT token and returns the full payload.
548
- *
549
- * This function extracts and returns the complete JWT payload including scopes,
550
- * expiration time, and other claims.
551
- *
552
- * @param jwt - The JWT token string.
553
- * @returns The decoded JWT payload object.
554
- * @throws InvalidParamError if the token is invalid or cannot be decoded.
555
- *
556
- * @example
557
- * ```typescript
558
- * const payload = decodeJwt(jwt);
559
- * // Returns: { scopes: ['wallet:export'], exp: 1234567890, ... }
560
- * ```
561
- * @not-instrumented
562
- */
563
- const decodeJwt = (jwt) => {
564
- try {
565
- const parts = jwt.split(".");
566
- if (parts.length !== 3) throw new require_InvalidParamError.InvalidParamError("Invalid JWT format");
567
- const base64Payload = parts[1].replaceAll("-", "+").replaceAll("_", "/");
568
- const paddedPayload = base64Payload + "=".repeat((4 - base64Payload.length % 4) % 4);
569
- const decodedPayload = atob(paddedPayload);
570
- return JSON.parse(decodedPayload);
571
- } catch (error) {
572
- if (error instanceof require_InvalidParamError.InvalidParamError) throw error;
573
- throw new require_InvalidParamError.InvalidParamError(`Failed to decode JWT: ${error instanceof Error ? error.message : String(error)}`);
574
- }
575
- };
576
-
577
- //#endregion
578
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/normalizeScopes/normalizeScopes.ts
579
- /**
580
- * Normalizes scopes by deduplicating and sorting them.
581
- * This creates a canonical representation for comparison.
582
- *
583
- * @param scopes - Array of scope strings (may contain duplicates)
584
- * @returns Normalized, sorted array of unique scopes
585
- * @not-instrumented
586
- */
587
- const normalizeScopes = (scopes) => {
588
- return [...new Set(scopes)].sort((a, b) => a.localeCompare(b));
589
- };
590
-
591
- //#endregion
592
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/parseElevatedAccessToken/parseElevatedAccessToken.ts
593
- /**
594
- * Validates and parses an elevated access token from a JWT string.
595
- * Extracts scopes, expiration, and validates the token structure.
596
- *
597
- * Policy decisions:
598
- * - Tokens without scopes are rejected (returns null)
599
- * - Tokens with empty scopes array are rejected (returns null)
600
- * - Tokens without exp field are rejected (returns null)
601
- * - Expired tokens are rejected (returns null)
602
- *
603
- * @returns Parsed token data or null if token is invalid/expired
604
- * @not-instrumented
605
- */
606
- const parseElevatedAccessToken = ({ token }) => {
607
- const payload = decodeJwt(token);
608
- const filteredScopes = ((payload?.scope)?.split(" ") ?? []).filter((s) => s.length > 0);
609
- const singleUse = payload.singleUse ?? false;
610
- if (!filteredScopes || filteredScopes.length === 0) return null;
611
- if (!payload.exp) return null;
612
- const expiresAt = /* @__PURE__ */ new Date(payload.exp * 1e3);
613
- if (expiresAt <= /* @__PURE__ */ new Date()) return null;
614
- return {
615
- expiresAt,
616
- normalizedScopes: normalizeScopes(filteredScopes),
617
- scopes: filteredScopes,
618
- singleUse,
619
- token
620
- };
621
- };
622
-
623
- //#endregion
624
- //#region src/modules/auth/updateAuthFromVerifyResponse/elevatedAccessTokens/upsertElevatedAccessToken/upsertElevatedAccessToken.ts
625
- /**
626
- * Upserts an elevated access token into the current tokens array.
627
- *
628
- * Policy: Only one token per normalized scope-set is allowed.
629
- * If a token with the same normalized scopes exists, it is replaced.
630
- * This ensures we don't accumulate multiple tokens for the same scope combination.
631
- *
632
- * @param currentTokens - Current array of elevated access tokens
633
- * @param newToken - New token to upsert
634
- * @returns Updated array of tokens with the new token upserted
635
- * @not-instrumented
636
- */
637
- const upsertElevatedAccessToken = ({ currentTokens, newToken }) => {
638
- const newScopeKey = normalizeScopes(newToken.scopes).join(" ");
639
- return [...currentTokens.filter((existingToken) => {
640
- return normalizeScopes(existingToken.scopes).join(" ") !== newScopeKey;
641
- }), {
642
- expiresAt: newToken.expiresAt,
643
- scopes: newToken.scopes,
644
- singleUse: newToken.singleUse,
645
- token: newToken.token
646
- }];
647
- };
648
-
649
- //#endregion
650
- //#region src/modules/auth/updateAuthFromVerifyResponse/updateAuthFromVerifyResponse.ts
651
- /** @not-instrumented */
652
- const updateAuthFromVerifyResponse = ({ response }, client) => {
653
- const core = require_InvalidParamError.getCore(client);
654
- const previousState = { ...core.state.get() };
655
- const { user, minifiedJwt, jwt, expiresAt, mfaToken, elevatedAccessToken } = response;
656
- const sessionExpiresAt = /* @__PURE__ */ new Date(expiresAt * 1e3);
657
- const newState = {
658
- legacyToken: jwt ?? null,
659
- sessionExpiresAt,
660
- token: minifiedJwt ?? null,
661
- user
662
- };
663
- if (mfaToken) newState.mfaToken = mfaToken;
664
- const currentTokens = core.state.get().elevatedAccessTokens || [];
665
- newState.elevatedAccessTokens = currentTokens;
666
- if (elevatedAccessToken) {
667
- const parsedToken = parseElevatedAccessToken({ token: elevatedAccessToken });
668
- if (parsedToken) newState.elevatedAccessTokens = upsertElevatedAccessToken({
669
- currentTokens,
670
- newToken: parsedToken
671
- });
672
- }
673
- core.state.set(newState);
674
- /**
675
- * For customers using a sandbox environment with cookies enabled, we need to set the cookie
676
- * programmatically because Redcoast won't set the cookie via headers. We set the cookie programmatically
677
- * so customers can access the cookie from document.cookie consistently between sandbox and live environments.
678
- */
679
- if (minifiedJwt && require_InvalidParamError.isCookieEnabled(client)) setCookie(`${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${sessionExpiresAt.toUTCString()}; path=/; SameSite=Lax`);
680
- checkAndRaiseWalletAccountsChangedEvent({ previousState }, client);
681
- if (!previousState.user && Boolean(newState.user)) restoreUserSharesForAllWalletAccounts(client);
682
- };
683
-
684
- //#endregion
685
- //#region src/modules/wallets/getWalletProviderByKey/getWalletProviderByKey.ts
686
- /** @not-instrumented */
687
- const getWalletProviderByKey = ({ walletProviderKey }, client) => {
688
- const walletProvider = getWalletProviders(client).find((walletProvider$1) => walletProvider$1.key === walletProviderKey);
689
- if (!walletProvider) throw new NoWalletProviderFoundError({ walletProviderKey });
690
- return walletProvider;
691
- };
692
-
693
- //#endregion
694
- //#region src/modules/wallets/utils/getVerifiedCredentialForWalletAccount/getVerifiedCredentialForWalletAccount.ts
695
- /** @not-instrumented */
696
- const getVerifiedCredentialForWalletAccount = ({ walletAccount }, client) => {
697
- return client.user?.verifiedCredentials.find((vc) => vc.id === walletAccount.verifiedCredentialId);
698
- };
699
-
700
- //#endregion
701
- Object.defineProperty(exports, 'DYNAMIC_AUTH_COOKIE_NAME', {
702
- enumerable: true,
703
- get: function () {
704
- return DYNAMIC_AUTH_COOKIE_NAME;
705
- }
706
- });
707
- Object.defineProperty(exports, 'InvalidWalletProviderKeyError', {
708
- enumerable: true,
709
- get: function () {
710
- return InvalidWalletProviderKeyError;
711
- }
712
- });
713
- Object.defineProperty(exports, 'NoWalletProviderFoundError', {
714
- enumerable: true,
715
- get: function () {
716
- return NoWalletProviderFoundError;
717
- }
718
- });
719
- Object.defineProperty(exports, 'WalletProviderPriority', {
720
- enumerable: true,
721
- get: function () {
722
- return WalletProviderPriority;
723
- }
724
- });
725
- Object.defineProperty(exports, 'checkAndRaiseWalletAccountsChangedEvent', {
726
- enumerable: true,
727
- get: function () {
728
- return checkAndRaiseWalletAccountsChangedEvent;
729
- }
730
- });
731
- Object.defineProperty(exports, 'createRuntimeServiceAccessKey', {
732
- enumerable: true,
733
- get: function () {
734
- return createRuntimeServiceAccessKey;
735
- }
736
- });
737
- Object.defineProperty(exports, 'emitEvent', {
738
- enumerable: true,
739
- get: function () {
740
- return emitEvent;
741
- }
742
- });
743
- Object.defineProperty(exports, 'emitWalletAccountsChangedEvent', {
744
- enumerable: true,
745
- get: function () {
746
- return emitWalletAccountsChangedEvent;
747
- }
748
- });
749
- Object.defineProperty(exports, 'findWaasWalletProviderByChain', {
750
- enumerable: true,
751
- get: function () {
752
- return findWaasWalletProviderByChain;
753
- }
754
- });
755
- Object.defineProperty(exports, 'formatWalletAccountId', {
756
- enumerable: true,
757
- get: function () {
758
- return formatWalletAccountId;
759
- }
760
- });
761
- Object.defineProperty(exports, 'formatWalletProviderKey', {
762
- enumerable: true,
763
- get: function () {
764
- return formatWalletProviderKey;
765
- }
766
- });
767
- Object.defineProperty(exports, 'getVerifiedCredentialForWalletAccount', {
768
- enumerable: true,
769
- get: function () {
770
- return getVerifiedCredentialForWalletAccount;
771
- }
772
- });
773
- Object.defineProperty(exports, 'getWalletAccounts', {
774
- enumerable: true,
775
- get: function () {
776
- return getWalletAccounts;
777
- }
778
- });
779
- Object.defineProperty(exports, 'getWalletProviderByKey', {
780
- enumerable: true,
781
- get: function () {
782
- return getWalletProviderByKey;
783
- }
784
- });
785
- Object.defineProperty(exports, 'getWalletProviderFromWalletAccount', {
786
- enumerable: true,
787
- get: function () {
788
- return getWalletProviderFromWalletAccount;
789
- }
790
- });
791
- Object.defineProperty(exports, 'getWalletProviderRegistry', {
792
- enumerable: true,
793
- get: function () {
794
- return getWalletProviderRegistry;
795
- }
796
- });
797
- Object.defineProperty(exports, 'getWalletProviders', {
798
- enumerable: true,
799
- get: function () {
800
- return getWalletProviders;
801
- }
802
- });
803
- Object.defineProperty(exports, 'isUserMissingMfaAuth', {
804
- enumerable: true,
805
- get: function () {
806
- return isUserMissingMfaAuth;
807
- }
808
- });
809
- Object.defineProperty(exports, 'isWaasWalletAccount', {
810
- enumerable: true,
811
- get: function () {
812
- return isWaasWalletAccount;
813
- }
814
- });
815
- Object.defineProperty(exports, 'isWaasWalletProvider', {
816
- enumerable: true,
817
- get: function () {
818
- return isWaasWalletProvider;
819
- }
820
- });
821
- Object.defineProperty(exports, 'normalizeAddress', {
822
- enumerable: true,
823
- get: function () {
824
- return normalizeAddress;
825
- }
826
- });
827
- Object.defineProperty(exports, 'normalizeWalletNameWithChain', {
828
- enumerable: true,
829
- get: function () {
830
- return normalizeWalletNameWithChain;
831
- }
832
- });
833
- Object.defineProperty(exports, 'offEvent', {
834
- enumerable: true,
835
- get: function () {
836
- return offEvent;
837
- }
838
- });
839
- Object.defineProperty(exports, 'onEvent', {
840
- enumerable: true,
841
- get: function () {
842
- return onEvent;
843
- }
844
- });
845
- Object.defineProperty(exports, 'onceEvent', {
846
- enumerable: true,
847
- get: function () {
848
- return onceEvent;
849
- }
850
- });
851
- Object.defineProperty(exports, 'parseElevatedAccessToken', {
852
- enumerable: true,
853
- get: function () {
854
- return parseElevatedAccessToken;
855
- }
856
- });
857
- Object.defineProperty(exports, 'restoreUserSharesForAllWalletAccounts', {
858
- enumerable: true,
859
- get: function () {
860
- return restoreUserSharesForAllWalletAccounts;
861
- }
862
- });
863
- Object.defineProperty(exports, 'setCookie', {
864
- enumerable: true,
865
- get: function () {
866
- return setCookie;
867
- }
868
- });
869
- Object.defineProperty(exports, 'splitWalletProviderKey', {
870
- enumerable: true,
871
- get: function () {
872
- return splitWalletProviderKey;
873
- }
874
- });
875
- Object.defineProperty(exports, 'updateAuthFromVerifyResponse', {
876
- enumerable: true,
877
- get: function () {
878
- return updateAuthFromVerifyResponse;
879
- }
880
- });
881
- Object.defineProperty(exports, 'upsertElevatedAccessToken', {
882
- enumerable: true,
883
- get: function () {
884
- return upsertElevatedAccessToken;
885
- }
886
- });
887
- //# sourceMappingURL=getVerifiedCredentialForWalletAccount-B46O0B48.cjs.map