@metamask/snap-networks-utils 1.0.0 → 2.0.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 (360) hide show
  1. package/CHANGELOG.md +63 -1
  2. package/README.md +4 -10
  3. package/dist/index.cjs +102 -5
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +51 -2
  6. package/dist/index.d.cts.map +1 -1
  7. package/dist/index.d.mts +51 -2
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +32 -1
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/providers/assets/AssetsProvider.cjs +36 -18
  12. package/dist/providers/assets/AssetsProvider.cjs.map +1 -1
  13. package/dist/providers/assets/AssetsProvider.d.cts +30 -2
  14. package/dist/providers/assets/AssetsProvider.d.cts.map +1 -1
  15. package/dist/providers/assets/AssetsProvider.d.mts +30 -2
  16. package/dist/providers/assets/AssetsProvider.d.mts.map +1 -1
  17. package/dist/providers/assets/AssetsProvider.mjs +36 -18
  18. package/dist/providers/assets/AssetsProvider.mjs.map +1 -1
  19. package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.cjs +4 -17
  20. package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.cjs.map +1 -1
  21. package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.mjs +4 -17
  22. package/dist/providers/remote-feature-flags/RemoteFeatureFlagsProvider.mjs.map +1 -1
  23. package/dist/services/analytics/AnalyticsService.cjs +225 -0
  24. package/dist/services/analytics/AnalyticsService.cjs.map +1 -0
  25. package/dist/services/analytics/AnalyticsService.d.cts +175 -0
  26. package/dist/services/analytics/AnalyticsService.d.cts.map +1 -0
  27. package/dist/services/analytics/AnalyticsService.d.mts +175 -0
  28. package/dist/services/analytics/AnalyticsService.d.mts.map +1 -0
  29. package/dist/services/analytics/AnalyticsService.mjs +221 -0
  30. package/dist/services/analytics/AnalyticsService.mjs.map +1 -0
  31. package/dist/ui/ActionHeader/ActionHeader.cjs +23 -0
  32. package/dist/ui/ActionHeader/ActionHeader.cjs.map +1 -0
  33. package/dist/ui/ActionHeader/ActionHeader.d.cts +27 -0
  34. package/dist/ui/ActionHeader/ActionHeader.d.cts.map +1 -0
  35. package/dist/ui/ActionHeader/ActionHeader.d.mts +27 -0
  36. package/dist/ui/ActionHeader/ActionHeader.d.mts.map +1 -0
  37. package/dist/ui/ActionHeader/ActionHeader.mjs +19 -0
  38. package/dist/ui/ActionHeader/ActionHeader.mjs.map +1 -0
  39. package/dist/ui/Asset/Asset.cjs +68 -0
  40. package/dist/ui/Asset/Asset.cjs.map +1 -0
  41. package/dist/ui/Asset/Asset.d.cts +83 -0
  42. package/dist/ui/Asset/Asset.d.cts.map +1 -0
  43. package/dist/ui/Asset/Asset.d.mts +83 -0
  44. package/dist/ui/Asset/Asset.d.mts.map +1 -0
  45. package/dist/ui/Asset/Asset.mjs +60 -0
  46. package/dist/ui/Asset/Asset.mjs.map +1 -0
  47. package/dist/ui/Asset/question-mark.svg +3 -0
  48. package/dist/ui/EstimatedChanges/EstimatedChanges.cjs +57 -0
  49. package/dist/ui/EstimatedChanges/EstimatedChanges.cjs.map +1 -0
  50. package/dist/ui/EstimatedChanges/EstimatedChanges.d.cts +50 -0
  51. package/dist/ui/EstimatedChanges/EstimatedChanges.d.cts.map +1 -0
  52. package/dist/ui/EstimatedChanges/EstimatedChanges.d.mts +50 -0
  53. package/dist/ui/EstimatedChanges/EstimatedChanges.d.mts.map +1 -0
  54. package/dist/ui/EstimatedChanges/EstimatedChanges.mjs +53 -0
  55. package/dist/ui/EstimatedChanges/EstimatedChanges.mjs.map +1 -0
  56. package/dist/ui/TransactionAlert/TransactionAlert.cjs +72 -0
  57. package/dist/ui/TransactionAlert/TransactionAlert.cjs.map +1 -0
  58. package/dist/ui/TransactionAlert/TransactionAlert.d.cts +58 -0
  59. package/dist/ui/TransactionAlert/TransactionAlert.d.cts.map +1 -0
  60. package/dist/ui/TransactionAlert/TransactionAlert.d.mts +58 -0
  61. package/dist/ui/TransactionAlert/TransactionAlert.d.mts.map +1 -0
  62. package/dist/ui/TransactionAlert/TransactionAlert.mjs +68 -0
  63. package/dist/ui/TransactionAlert/TransactionAlert.mjs.map +1 -0
  64. package/dist/utils/async/async.cjs +95 -0
  65. package/dist/utils/async/async.cjs.map +1 -0
  66. package/dist/utils/async/async.d.cts +51 -0
  67. package/dist/utils/async/async.d.cts.map +1 -0
  68. package/dist/utils/async/async.d.mts +51 -0
  69. package/dist/utils/async/async.d.mts.map +1 -0
  70. package/dist/utils/async/async.mjs +88 -0
  71. package/dist/utils/async/async.mjs.map +1 -0
  72. package/dist/utils/buildUrl/buildUrl.cjs +54 -0
  73. package/dist/utils/buildUrl/buildUrl.cjs.map +1 -0
  74. package/dist/utils/buildUrl/buildUrl.d.cts +15 -0
  75. package/dist/utils/buildUrl/buildUrl.d.cts.map +1 -0
  76. package/dist/utils/buildUrl/buildUrl.d.mts +15 -0
  77. package/dist/utils/buildUrl/buildUrl.d.mts.map +1 -0
  78. package/dist/utils/buildUrl/buildUrl.mjs +51 -0
  79. package/dist/utils/buildUrl/buildUrl.mjs.map +1 -0
  80. package/dist/utils/cache/InMemoryCache.cjs +134 -0
  81. package/dist/utils/cache/InMemoryCache.cjs.map +1 -0
  82. package/dist/utils/cache/InMemoryCache.d.cts +29 -0
  83. package/dist/utils/cache/InMemoryCache.d.cts.map +1 -0
  84. package/dist/utils/cache/InMemoryCache.d.mts +29 -0
  85. package/dist/utils/cache/InMemoryCache.d.mts.map +1 -0
  86. package/dist/utils/cache/InMemoryCache.mjs +130 -0
  87. package/dist/utils/cache/InMemoryCache.mjs.map +1 -0
  88. package/dist/utils/cache/StateCache.cjs +193 -0
  89. package/dist/utils/cache/StateCache.cjs.map +1 -0
  90. package/dist/utils/cache/StateCache.d.cts +96 -0
  91. package/dist/utils/cache/StateCache.d.cts.map +1 -0
  92. package/dist/utils/cache/StateCache.d.mts +96 -0
  93. package/dist/utils/cache/StateCache.d.mts.map +1 -0
  94. package/dist/utils/cache/StateCache.mjs +189 -0
  95. package/dist/utils/cache/StateCache.mjs.map +1 -0
  96. package/dist/utils/cache/types.cjs +3 -0
  97. package/dist/utils/cache/types.cjs.map +1 -0
  98. package/dist/utils/cache/types.d.cts +99 -0
  99. package/dist/utils/cache/types.d.cts.map +1 -0
  100. package/dist/utils/cache/types.d.mts +99 -0
  101. package/dist/utils/cache/types.d.mts.map +1 -0
  102. package/dist/utils/cache/types.mjs +2 -0
  103. package/dist/utils/cache/types.mjs.map +1 -0
  104. package/dist/utils/cache/useCache.cjs +82 -0
  105. package/dist/utils/cache/useCache.cjs.map +1 -0
  106. package/dist/utils/cache/useCache.d.cts +57 -0
  107. package/dist/utils/cache/useCache.d.cts.map +1 -0
  108. package/dist/utils/cache/useCache.d.mts +57 -0
  109. package/dist/utils/cache/useCache.d.mts.map +1 -0
  110. package/dist/utils/cache/useCache.mjs +78 -0
  111. package/dist/utils/cache/useCache.mjs.map +1 -0
  112. package/dist/utils/cache/useCacheUntil.cjs +80 -0
  113. package/dist/utils/cache/useCacheUntil.cjs.map +1 -0
  114. package/dist/utils/cache/useCacheUntil.d.cts +54 -0
  115. package/dist/utils/cache/useCacheUntil.d.cts.map +1 -0
  116. package/dist/utils/cache/useCacheUntil.d.mts +54 -0
  117. package/dist/utils/cache/useCacheUntil.d.mts.map +1 -0
  118. package/dist/utils/cache/useCacheUntil.mjs +76 -0
  119. package/dist/utils/cache/useCacheUntil.mjs.map +1 -0
  120. package/dist/utils/config/BaseConfigProvider.cjs +62 -0
  121. package/dist/utils/config/BaseConfigProvider.cjs.map +1 -0
  122. package/dist/utils/config/BaseConfigProvider.d.cts +54 -0
  123. package/dist/utils/config/BaseConfigProvider.d.cts.map +1 -0
  124. package/dist/utils/config/BaseConfigProvider.d.mts +54 -0
  125. package/dist/utils/config/BaseConfigProvider.d.mts.map +1 -0
  126. package/dist/utils/config/BaseConfigProvider.mjs +58 -0
  127. package/dist/utils/config/BaseConfigProvider.mjs.map +1 -0
  128. package/dist/utils/config/envStructs.cjs +69 -0
  129. package/dist/utils/config/envStructs.cjs.map +1 -0
  130. package/dist/utils/config/envStructs.d.cts +57 -0
  131. package/dist/utils/config/envStructs.d.cts.map +1 -0
  132. package/dist/utils/config/envStructs.d.mts +57 -0
  133. package/dist/utils/config/envStructs.d.mts.map +1 -0
  134. package/dist/utils/config/envStructs.mjs +61 -0
  135. package/dist/utils/config/envStructs.mjs.map +1 -0
  136. package/dist/utils/config/environmentStruct.cjs +19 -0
  137. package/dist/utils/config/environmentStruct.cjs.map +1 -0
  138. package/dist/utils/config/environmentStruct.d.cts +20 -0
  139. package/dist/utils/config/environmentStruct.d.cts.map +1 -0
  140. package/dist/utils/config/environmentStruct.d.mts +20 -0
  141. package/dist/utils/config/environmentStruct.d.mts.map +1 -0
  142. package/dist/utils/config/environmentStruct.mjs +16 -0
  143. package/dist/utils/config/environmentStruct.mjs.map +1 -0
  144. package/dist/utils/config/logLevelStruct.cjs +14 -0
  145. package/dist/utils/config/logLevelStruct.cjs.map +1 -0
  146. package/dist/utils/config/logLevelStruct.d.cts +17 -0
  147. package/dist/utils/config/logLevelStruct.d.cts.map +1 -0
  148. package/dist/utils/config/logLevelStruct.d.mts +17 -0
  149. package/dist/utils/config/logLevelStruct.d.mts.map +1 -0
  150. package/dist/utils/config/logLevelStruct.mjs +11 -0
  151. package/dist/utils/config/logLevelStruct.mjs.map +1 -0
  152. package/dist/utils/config/parseEnv.cjs +30 -0
  153. package/dist/utils/config/parseEnv.cjs.map +1 -0
  154. package/dist/utils/config/parseEnv.d.cts +19 -0
  155. package/dist/utils/config/parseEnv.d.cts.map +1 -0
  156. package/dist/utils/config/parseEnv.d.mts +19 -0
  157. package/dist/utils/config/parseEnv.d.mts.map +1 -0
  158. package/dist/utils/config/parseEnv.mjs +26 -0
  159. package/dist/utils/config/parseEnv.mjs.map +1 -0
  160. package/dist/utils/dedupe/InFlightCoalescer.cjs +28 -0
  161. package/dist/utils/dedupe/InFlightCoalescer.cjs.map +1 -0
  162. package/dist/utils/dedupe/InFlightCoalescer.d.cts +12 -0
  163. package/dist/utils/dedupe/InFlightCoalescer.d.cts.map +1 -0
  164. package/dist/utils/dedupe/InFlightCoalescer.d.mts +12 -0
  165. package/dist/utils/dedupe/InFlightCoalescer.d.mts.map +1 -0
  166. package/dist/utils/dedupe/InFlightCoalescer.mjs +24 -0
  167. package/dist/utils/dedupe/InFlightCoalescer.mjs.map +1 -0
  168. package/dist/utils/errors/errors.cjs +44 -0
  169. package/dist/utils/errors/errors.cjs.map +1 -0
  170. package/dist/utils/errors/errors.d.cts +37 -0
  171. package/dist/utils/errors/errors.d.cts.map +1 -0
  172. package/dist/utils/errors/errors.d.mts +37 -0
  173. package/dist/utils/errors/errors.d.mts.map +1 -0
  174. package/dist/utils/errors/errors.mjs +40 -0
  175. package/dist/utils/errors/errors.mjs.map +1 -0
  176. package/dist/utils/errors/index.cjs +18 -0
  177. package/dist/utils/errors/index.cjs.map +1 -0
  178. package/dist/utils/errors/index.d.cts +10 -0
  179. package/dist/utils/errors/index.d.cts.map +1 -0
  180. package/dist/utils/errors/index.d.mts +10 -0
  181. package/dist/utils/errors/index.d.mts.map +1 -0
  182. package/dist/utils/errors/index.mjs +6 -0
  183. package/dist/utils/errors/index.mjs.map +1 -0
  184. package/dist/utils/errors/snapRpcError.cjs +33 -0
  185. package/dist/utils/errors/snapRpcError.cjs.map +1 -0
  186. package/dist/utils/errors/snapRpcError.d.cts +11 -0
  187. package/dist/utils/errors/snapRpcError.d.cts.map +1 -0
  188. package/dist/utils/errors/snapRpcError.d.mts +11 -0
  189. package/dist/utils/errors/snapRpcError.d.mts.map +1 -0
  190. package/dist/utils/errors/snapRpcError.mjs +30 -0
  191. package/dist/utils/errors/snapRpcError.mjs.map +1 -0
  192. package/dist/utils/errors/stringifyReason.cjs +36 -0
  193. package/dist/utils/errors/stringifyReason.cjs.map +1 -0
  194. package/dist/utils/errors/stringifyReason.d.cts +15 -0
  195. package/dist/utils/errors/stringifyReason.d.cts.map +1 -0
  196. package/dist/utils/errors/stringifyReason.d.mts +15 -0
  197. package/dist/utils/errors/stringifyReason.d.mts.map +1 -0
  198. package/dist/utils/errors/stringifyReason.mjs +33 -0
  199. package/dist/utils/errors/stringifyReason.mjs.map +1 -0
  200. package/dist/utils/errors/syncError.cjs +98 -0
  201. package/dist/utils/errors/syncError.cjs.map +1 -0
  202. package/dist/utils/errors/syncError.d.cts +60 -0
  203. package/dist/utils/errors/syncError.d.cts.map +1 -0
  204. package/dist/utils/errors/syncError.d.mts +60 -0
  205. package/dist/utils/errors/syncError.d.mts.map +1 -0
  206. package/dist/utils/errors/syncError.mjs +92 -0
  207. package/dist/utils/errors/syncError.mjs.map +1 -0
  208. package/dist/utils/errors/trackError.cjs +76 -0
  209. package/dist/utils/errors/trackError.cjs.map +1 -0
  210. package/dist/utils/errors/trackError.d.cts +64 -0
  211. package/dist/utils/errors/trackError.d.cts.map +1 -0
  212. package/dist/utils/errors/trackError.d.mts +64 -0
  213. package/dist/utils/errors/trackError.d.mts.map +1 -0
  214. package/dist/utils/errors/trackError.mjs +72 -0
  215. package/dist/utils/errors/trackError.mjs.map +1 -0
  216. package/dist/utils/handlers/wrapSnapHandlers.cjs +57 -0
  217. package/dist/utils/handlers/wrapSnapHandlers.cjs.map +1 -0
  218. package/dist/utils/handlers/wrapSnapHandlers.d.cts +74 -0
  219. package/dist/utils/handlers/wrapSnapHandlers.d.cts.map +1 -0
  220. package/dist/utils/handlers/wrapSnapHandlers.d.mts +74 -0
  221. package/dist/utils/handlers/wrapSnapHandlers.d.mts.map +1 -0
  222. package/dist/utils/handlers/wrapSnapHandlers.mjs +53 -0
  223. package/dist/utils/handlers/wrapSnapHandlers.mjs.map +1 -0
  224. package/dist/utils/keyringAccount/keyringAccount.cjs +25 -0
  225. package/dist/utils/keyringAccount/keyringAccount.cjs.map +1 -0
  226. package/dist/utils/keyringAccount/keyringAccount.d.cts +29 -0
  227. package/dist/utils/keyringAccount/keyringAccount.d.cts.map +1 -0
  228. package/dist/utils/keyringAccount/keyringAccount.d.mts +29 -0
  229. package/dist/utils/keyringAccount/keyringAccount.d.mts.map +1 -0
  230. package/dist/utils/keyringAccount/keyringAccount.mjs +22 -0
  231. package/dist/utils/keyringAccount/keyringAccount.mjs.map +1 -0
  232. package/dist/utils/logger/Logger.cjs +140 -0
  233. package/dist/utils/logger/Logger.cjs.map +1 -0
  234. package/dist/utils/logger/Logger.d.cts +118 -0
  235. package/dist/utils/logger/Logger.d.cts.map +1 -0
  236. package/dist/utils/logger/Logger.d.mts +118 -0
  237. package/dist/utils/logger/Logger.d.mts.map +1 -0
  238. package/dist/utils/logger/Logger.mjs +136 -0
  239. package/dist/utils/logger/Logger.mjs.map +1 -0
  240. package/dist/utils/logger/__mocks__/Logger.cjs +26 -0
  241. package/dist/utils/logger/__mocks__/Logger.cjs.map +1 -0
  242. package/dist/utils/logger/__mocks__/Logger.d.cts +3 -0
  243. package/dist/utils/logger/__mocks__/Logger.d.cts.map +1 -0
  244. package/dist/utils/logger/__mocks__/Logger.d.mts +3 -0
  245. package/dist/utils/logger/__mocks__/Logger.d.mts.map +1 -0
  246. package/dist/utils/logger/__mocks__/Logger.mjs +23 -0
  247. package/dist/utils/logger/__mocks__/Logger.mjs.map +1 -0
  248. package/dist/utils/originPermissions/createOriginPermissions.cjs +30 -0
  249. package/dist/utils/originPermissions/createOriginPermissions.cjs.map +1 -0
  250. package/dist/utils/originPermissions/createOriginPermissions.d.cts +24 -0
  251. package/dist/utils/originPermissions/createOriginPermissions.d.cts.map +1 -0
  252. package/dist/utils/originPermissions/createOriginPermissions.d.mts +24 -0
  253. package/dist/utils/originPermissions/createOriginPermissions.d.mts.map +1 -0
  254. package/dist/utils/originPermissions/createOriginPermissions.mjs +26 -0
  255. package/dist/utils/originPermissions/createOriginPermissions.mjs.map +1 -0
  256. package/dist/utils/originPermissions/validateOrigin.cjs +23 -0
  257. package/dist/utils/originPermissions/validateOrigin.cjs.map +1 -0
  258. package/dist/utils/originPermissions/validateOrigin.d.cts +10 -0
  259. package/dist/utils/originPermissions/validateOrigin.d.cts.map +1 -0
  260. package/dist/utils/originPermissions/validateOrigin.d.mts +10 -0
  261. package/dist/utils/originPermissions/validateOrigin.d.mts.map +1 -0
  262. package/dist/utils/originPermissions/validateOrigin.mjs +19 -0
  263. package/dist/utils/originPermissions/validateOrigin.mjs.map +1 -0
  264. package/dist/utils/proofOfOwnership/proofOfOwnership.cjs +89 -0
  265. package/dist/utils/proofOfOwnership/proofOfOwnership.cjs.map +1 -0
  266. package/dist/utils/proofOfOwnership/proofOfOwnership.d.cts +143 -0
  267. package/dist/utils/proofOfOwnership/proofOfOwnership.d.cts.map +1 -0
  268. package/dist/utils/proofOfOwnership/proofOfOwnership.d.mts +143 -0
  269. package/dist/utils/proofOfOwnership/proofOfOwnership.d.mts.map +1 -0
  270. package/dist/utils/proofOfOwnership/proofOfOwnership.mjs +85 -0
  271. package/dist/utils/proofOfOwnership/proofOfOwnership.mjs.map +1 -0
  272. package/dist/utils/safeMerge/safeMerge.cjs +26 -0
  273. package/dist/utils/safeMerge/safeMerge.cjs.map +1 -0
  274. package/dist/utils/safeMerge/safeMerge.d.cts +17 -0
  275. package/dist/utils/safeMerge/safeMerge.d.cts.map +1 -0
  276. package/dist/utils/safeMerge/safeMerge.d.mts +17 -0
  277. package/dist/utils/safeMerge/safeMerge.d.mts.map +1 -0
  278. package/dist/utils/safeMerge/safeMerge.mjs +22 -0
  279. package/dist/utils/safeMerge/safeMerge.mjs.map +1 -0
  280. package/dist/utils/sanitize/sanitize.cjs +42 -0
  281. package/dist/utils/sanitize/sanitize.cjs.map +1 -0
  282. package/dist/utils/sanitize/sanitize.d.cts +15 -0
  283. package/dist/utils/sanitize/sanitize.d.cts.map +1 -0
  284. package/dist/utils/sanitize/sanitize.d.mts +15 -0
  285. package/dist/utils/sanitize/sanitize.d.mts.map +1 -0
  286. package/dist/utils/sanitize/sanitize.mjs +38 -0
  287. package/dist/utils/sanitize/sanitize.mjs.map +1 -0
  288. package/dist/utils/serialization/serialization.cjs +73 -0
  289. package/dist/utils/serialization/serialization.cjs.map +1 -0
  290. package/dist/utils/serialization/serialization.d.cts +19 -0
  291. package/dist/utils/serialization/serialization.d.cts.map +1 -0
  292. package/dist/utils/serialization/serialization.d.mts +19 -0
  293. package/dist/utils/serialization/serialization.d.mts.map +1 -0
  294. package/dist/utils/serialization/serialization.mjs +69 -0
  295. package/dist/utils/serialization/serialization.mjs.map +1 -0
  296. package/dist/utils/serialization/types.cjs +3 -0
  297. package/dist/utils/serialization/types.cjs.map +1 -0
  298. package/dist/utils/serialization/types.d.cts +8 -0
  299. package/dist/utils/serialization/types.d.cts.map +1 -0
  300. package/dist/utils/serialization/types.d.mts +8 -0
  301. package/dist/utils/serialization/types.d.mts.map +1 -0
  302. package/dist/utils/serialization/types.mjs +2 -0
  303. package/dist/utils/serialization/types.mjs.map +1 -0
  304. package/dist/utils/state/IStateManager.cjs +3 -0
  305. package/dist/utils/state/IStateManager.cjs.map +1 -0
  306. package/dist/utils/state/IStateManager.d.cts +69 -0
  307. package/dist/utils/state/IStateManager.d.cts.map +1 -0
  308. package/dist/utils/state/IStateManager.d.mts +69 -0
  309. package/dist/utils/state/IStateManager.d.mts.map +1 -0
  310. package/dist/utils/state/IStateManager.mjs +2 -0
  311. package/dist/utils/state/IStateManager.mjs.map +1 -0
  312. package/dist/utils/state/InMemoryState.cjs +41 -0
  313. package/dist/utils/state/InMemoryState.cjs.map +1 -0
  314. package/dist/utils/state/InMemoryState.d.cts +18 -0
  315. package/dist/utils/state/InMemoryState.d.cts.map +1 -0
  316. package/dist/utils/state/InMemoryState.d.mts +18 -0
  317. package/dist/utils/state/InMemoryState.d.mts.map +1 -0
  318. package/dist/utils/state/InMemoryState.mjs +38 -0
  319. package/dist/utils/state/InMemoryState.mjs.map +1 -0
  320. package/dist/utils/state/State.cjs +159 -0
  321. package/dist/utils/state/State.cjs.map +1 -0
  322. package/dist/utils/state/State.d.cts +25 -0
  323. package/dist/utils/state/State.d.cts.map +1 -0
  324. package/dist/utils/state/State.d.mts +25 -0
  325. package/dist/utils/state/State.d.mts.map +1 -0
  326. package/dist/utils/state/State.mjs +156 -0
  327. package/dist/utils/state/State.mjs.map +1 -0
  328. package/dist/utils/transactionType/transactionType.cjs +32 -0
  329. package/dist/utils/transactionType/transactionType.cjs.map +1 -0
  330. package/dist/utils/transactionType/transactionType.d.cts +17 -0
  331. package/dist/utils/transactionType/transactionType.d.cts.map +1 -0
  332. package/dist/utils/transactionType/transactionType.d.mts +17 -0
  333. package/dist/utils/transactionType/transactionType.d.mts.map +1 -0
  334. package/dist/utils/transactionType/transactionType.mjs +28 -0
  335. package/dist/utils/transactionType/transactionType.mjs.map +1 -0
  336. package/dist/utils/urlStruct/urlStruct.cjs +96 -0
  337. package/dist/utils/urlStruct/urlStruct.cjs.map +1 -0
  338. package/dist/utils/urlStruct/urlStruct.d.cts +25 -0
  339. package/dist/utils/urlStruct/urlStruct.d.cts.map +1 -0
  340. package/dist/utils/urlStruct/urlStruct.d.mts +25 -0
  341. package/dist/utils/urlStruct/urlStruct.d.mts.map +1 -0
  342. package/dist/utils/urlStruct/urlStruct.mjs +93 -0
  343. package/dist/utils/urlStruct/urlStruct.mjs.map +1 -0
  344. package/dist/utils/uuidStruct/uuidStruct.cjs +12 -0
  345. package/dist/utils/uuidStruct/uuidStruct.cjs.map +1 -0
  346. package/dist/utils/uuidStruct/uuidStruct.d.cts +8 -0
  347. package/dist/utils/uuidStruct/uuidStruct.d.cts.map +1 -0
  348. package/dist/utils/uuidStruct/uuidStruct.d.mts +8 -0
  349. package/dist/utils/uuidStruct/uuidStruct.d.mts.map +1 -0
  350. package/dist/utils/uuidStruct/uuidStruct.mjs +9 -0
  351. package/dist/utils/uuidStruct/uuidStruct.mjs.map +1 -0
  352. package/package.json +33 -13
  353. package/dist/logger.cjs +0 -57
  354. package/dist/logger.cjs.map +0 -1
  355. package/dist/logger.d.cts +0 -30
  356. package/dist/logger.d.cts.map +0 -1
  357. package/dist/logger.d.mts +0 -30
  358. package/dist/logger.d.mts.map +0 -1
  359. package/dist/logger.mjs +0 -53
  360. package/dist/logger.mjs.map +0 -1
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProofOfOwnershipBatchResponseStruct = exports.ProofOfOwnershipBatchItemResponseStruct = exports.ProofOfOwnershipBatchErrorStruct = exports.ProofOfOwnershipBatchSuccessStruct = exports.ProofOfOwnershipBatchRequestParamsStruct = exports.ProofOfOwnershipBatchRequestItemStruct = exports.ProofOfOwnershipMessageStruct = exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = void 0;
4
+ exports.parseProofOfOwnershipMessage = parseProofOfOwnershipMessage;
5
+ const superstruct_1 = require("@metamask/superstruct");
6
+ const uuidStruct_1 = require("../uuidStruct/uuidStruct.cjs");
7
+ /**
8
+ * Prefix for proof-of-ownership messages signed by network snaps.
9
+ */
10
+ exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = 'metamask:proof-of-ownership:';
11
+ /**
12
+ * Validates parsed proof-of-ownership message fields.
13
+ */
14
+ exports.ProofOfOwnershipMessageStruct = (0, superstruct_1.object)({
15
+ nonce: (0, superstruct_1.nonempty)((0, superstruct_1.string)()),
16
+ address: (0, superstruct_1.nonempty)((0, superstruct_1.string)()),
17
+ });
18
+ /**
19
+ * Validates one proof-of-ownership batch request item.
20
+ */
21
+ exports.ProofOfOwnershipBatchRequestItemStruct = (0, superstruct_1.object)({
22
+ accountId: uuidStruct_1.UuidStruct,
23
+ message: (0, superstruct_1.string)(),
24
+ });
25
+ /**
26
+ * Validates proof-of-ownership batch request params.
27
+ */
28
+ exports.ProofOfOwnershipBatchRequestParamsStruct = (0, superstruct_1.object)({
29
+ items: (0, superstruct_1.array)(exports.ProofOfOwnershipBatchRequestItemStruct),
30
+ });
31
+ /**
32
+ * Validates one successful proof-of-ownership batch result.
33
+ */
34
+ exports.ProofOfOwnershipBatchSuccessStruct = (0, superstruct_1.object)({
35
+ accountId: uuidStruct_1.UuidStruct,
36
+ signature: (0, superstruct_1.string)(),
37
+ });
38
+ /**
39
+ * Validates one failed proof-of-ownership batch result.
40
+ */
41
+ exports.ProofOfOwnershipBatchErrorStruct = (0, superstruct_1.object)({
42
+ accountId: uuidStruct_1.UuidStruct,
43
+ error: (0, superstruct_1.nonempty)((0, superstruct_1.string)()),
44
+ });
45
+ /**
46
+ * Validates one proof-of-ownership batch result.
47
+ */
48
+ exports.ProofOfOwnershipBatchItemResponseStruct = (0, superstruct_1.union)([
49
+ exports.ProofOfOwnershipBatchSuccessStruct,
50
+ exports.ProofOfOwnershipBatchErrorStruct,
51
+ ]);
52
+ /**
53
+ * Validates a proof-of-ownership batch response.
54
+ */
55
+ exports.ProofOfOwnershipBatchResponseStruct = (0, superstruct_1.object)({
56
+ results: (0, superstruct_1.array)(exports.ProofOfOwnershipBatchItemResponseStruct),
57
+ });
58
+ /**
59
+ * Parses a plaintext proof-of-ownership message in the format
60
+ * `metamask:proof-of-ownership:{nonce}:{address}`.
61
+ *
62
+ * Address validity is intentionally not checked here because it is
63
+ * chain-specific. Callers should validate the returned address with the
64
+ * relevant network/address validator.
65
+ *
66
+ * @param message - The plaintext message to parse.
67
+ * @returns The parsed nonce and address.
68
+ * @throws Error if the message format is invalid.
69
+ */
70
+ function parseProofOfOwnershipMessage(message) {
71
+ if (!message.startsWith(exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX)) {
72
+ throw new Error(`Message must start with "${exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX}"`);
73
+ }
74
+ const remainder = message.slice(exports.PROOF_OF_OWNERSHIP_MESSAGE_PREFIX.length);
75
+ const separatorIndex = remainder.lastIndexOf(':');
76
+ if (separatorIndex === -1) {
77
+ throw new Error('Message must follow the format "metamask:proof-of-ownership:{nonce}:{address}"');
78
+ }
79
+ const nonce = remainder.slice(0, separatorIndex);
80
+ const address = remainder.slice(separatorIndex + 1);
81
+ if (nonce.length === 0) {
82
+ throw new Error('Message must include a non-empty nonce');
83
+ }
84
+ if (address.length === 0) {
85
+ throw new Error('Message must include a non-empty address');
86
+ }
87
+ return { nonce, address };
88
+ }
89
+ //# sourceMappingURL=proofOfOwnership.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofOfOwnership.cjs","sourceRoot":"","sources":["../../../src/utils/proofOfOwnership/proofOfOwnership.ts"],"names":[],"mappings":";;;AA6HA,oEA6BC;AAzJD,uDAA+E;AAE/E,6DAAsD;AAEtD;;GAEG;AACU,QAAA,iCAAiC,GAAG,8BAA8B,CAAC;AAEhF;;GAEG;AACU,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACzB,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC5B,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,sCAAsC,GAAG,IAAA,oBAAM,EAAC;IAC3D,SAAS,EAAE,uBAAU;IACrB,OAAO,EAAE,IAAA,oBAAM,GAAE;CAClB,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,wCAAwC,GAAG,IAAA,oBAAM,EAAC;IAC7D,KAAK,EAAE,IAAA,mBAAK,EAAC,8CAAsC,CAAC;CACrD,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,kCAAkC,GAAG,IAAA,oBAAM,EAAC;IACvD,SAAS,EAAE,uBAAU;IACrB,SAAS,EAAE,IAAA,oBAAM,GAAE;CACpB,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,SAAS,EAAE,uBAAU;IACrB,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC1B,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,uCAAuC,GAAG,IAAA,mBAAK,EAAC;IAC3D,0CAAkC;IAClC,wCAAgC;CACjC,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,mCAAmC,GAAG,IAAA,oBAAM,EAAC;IACxD,OAAO,EAAE,IAAA,mBAAK,EAAC,+CAAuC,CAAC;CACxD,CAAC,CAAC;AASH;;;;;;;;;;;GAWG;AACH,SAAgB,4BAA4B,CAC1C,OAAe;IAEf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,yCAAiC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CACb,4BAA4B,yCAAiC,GAAG,CACjE,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,yCAAiC,CAAC,MAAM,CAAC,CAAC;IAC1E,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IAEpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, nonempty, object, string, union } from '@metamask/superstruct';\n\nimport { UuidStruct } from '../uuidStruct/uuidStruct';\n\n/**\n * Prefix for proof-of-ownership messages signed by network snaps.\n */\nexport const PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = 'metamask:proof-of-ownership:';\n\n/**\n * Validates parsed proof-of-ownership message fields.\n */\nexport const ProofOfOwnershipMessageStruct = object({\n nonce: nonempty(string()),\n address: nonempty(string()),\n});\n\n/**\n * Parsed proof-of-ownership message fields.\n */\nexport type ProofOfOwnershipMessage = Infer<\n typeof ProofOfOwnershipMessageStruct\n>;\n\n/**\n * Validates one proof-of-ownership batch request item.\n */\nexport const ProofOfOwnershipBatchRequestItemStruct = object({\n accountId: UuidStruct,\n message: string(),\n});\n\n/**\n * One proof-of-ownership batch request item.\n */\nexport type ProofOfOwnershipBatchRequestItem = Infer<\n typeof ProofOfOwnershipBatchRequestItemStruct\n>;\n\n/**\n * Validates proof-of-ownership batch request params.\n */\nexport const ProofOfOwnershipBatchRequestParamsStruct = object({\n items: array(ProofOfOwnershipBatchRequestItemStruct),\n});\n\n/**\n * Proof-of-ownership batch request params.\n */\nexport type ProofOfOwnershipBatchRequestParams = Infer<\n typeof ProofOfOwnershipBatchRequestParamsStruct\n>;\n\n/**\n * Validates one successful proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchSuccessStruct = object({\n accountId: UuidStruct,\n signature: string(),\n});\n\n/**\n * One successful proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchSuccess = Infer<\n typeof ProofOfOwnershipBatchSuccessStruct\n>;\n\n/**\n * Validates one failed proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchErrorStruct = object({\n accountId: UuidStruct,\n error: nonempty(string()),\n});\n\n/**\n * One failed proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchError = Infer<\n typeof ProofOfOwnershipBatchErrorStruct\n>;\n\n/**\n * Validates one proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchItemResponseStruct = union([\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipBatchErrorStruct,\n]);\n\n/**\n * One proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchItemResponse = Infer<\n typeof ProofOfOwnershipBatchItemResponseStruct\n>;\n\n/**\n * Validates a proof-of-ownership batch response.\n */\nexport const ProofOfOwnershipBatchResponseStruct = object({\n results: array(ProofOfOwnershipBatchItemResponseStruct),\n});\n\n/**\n * Proof-of-ownership batch response shape.\n */\nexport type ProofOfOwnershipBatchResponse = Infer<\n typeof ProofOfOwnershipBatchResponseStruct\n>;\n\n/**\n * Parses a plaintext proof-of-ownership message in the format\n * `metamask:proof-of-ownership:{nonce}:{address}`.\n *\n * Address validity is intentionally not checked here because it is\n * chain-specific. Callers should validate the returned address with the\n * relevant network/address validator.\n *\n * @param message - The plaintext message to parse.\n * @returns The parsed nonce and address.\n * @throws Error if the message format is invalid.\n */\nexport function parseProofOfOwnershipMessage(\n message: string,\n): ProofOfOwnershipMessage {\n if (!message.startsWith(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX)) {\n throw new Error(\n `Message must start with \"${PROOF_OF_OWNERSHIP_MESSAGE_PREFIX}\"`,\n );\n }\n\n const remainder = message.slice(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX.length);\n const separatorIndex = remainder.lastIndexOf(':');\n if (separatorIndex === -1) {\n throw new Error(\n 'Message must follow the format \"metamask:proof-of-ownership:{nonce}:{address}\"',\n );\n }\n\n const nonce = remainder.slice(0, separatorIndex);\n const address = remainder.slice(separatorIndex + 1);\n\n if (nonce.length === 0) {\n throw new Error('Message must include a non-empty nonce');\n }\n\n if (address.length === 0) {\n throw new Error('Message must include a non-empty address');\n }\n\n return { nonce, address };\n}\n"]}
@@ -0,0 +1,143 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Prefix for proof-of-ownership messages signed by network snaps.
4
+ */
5
+ export declare const PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = "metamask:proof-of-ownership:";
6
+ /**
7
+ * Validates parsed proof-of-ownership message fields.
8
+ */
9
+ export declare const ProofOfOwnershipMessageStruct: import("@metamask/superstruct").Struct<{
10
+ address: string;
11
+ nonce: string;
12
+ }, {
13
+ nonce: import("@metamask/superstruct").Struct<string, null>;
14
+ address: import("@metamask/superstruct").Struct<string, null>;
15
+ }>;
16
+ /**
17
+ * Parsed proof-of-ownership message fields.
18
+ */
19
+ export type ProofOfOwnershipMessage = Infer<typeof ProofOfOwnershipMessageStruct>;
20
+ /**
21
+ * Validates one proof-of-ownership batch request item.
22
+ */
23
+ export declare const ProofOfOwnershipBatchRequestItemStruct: import("@metamask/superstruct").Struct<{
24
+ message: string;
25
+ accountId: string;
26
+ }, {
27
+ accountId: import("@metamask/superstruct").Struct<string, null>;
28
+ message: import("@metamask/superstruct").Struct<string, null>;
29
+ }>;
30
+ /**
31
+ * One proof-of-ownership batch request item.
32
+ */
33
+ export type ProofOfOwnershipBatchRequestItem = Infer<typeof ProofOfOwnershipBatchRequestItemStruct>;
34
+ /**
35
+ * Validates proof-of-ownership batch request params.
36
+ */
37
+ export declare const ProofOfOwnershipBatchRequestParamsStruct: import("@metamask/superstruct").Struct<{
38
+ items: {
39
+ message: string;
40
+ accountId: string;
41
+ }[];
42
+ }, {
43
+ items: import("@metamask/superstruct").Struct<{
44
+ message: string;
45
+ accountId: string;
46
+ }[], import("@metamask/superstruct").Struct<{
47
+ message: string;
48
+ accountId: string;
49
+ }, {
50
+ accountId: import("@metamask/superstruct").Struct<string, null>;
51
+ message: import("@metamask/superstruct").Struct<string, null>;
52
+ }>>;
53
+ }>;
54
+ /**
55
+ * Proof-of-ownership batch request params.
56
+ */
57
+ export type ProofOfOwnershipBatchRequestParams = Infer<typeof ProofOfOwnershipBatchRequestParamsStruct>;
58
+ /**
59
+ * Validates one successful proof-of-ownership batch result.
60
+ */
61
+ export declare const ProofOfOwnershipBatchSuccessStruct: import("@metamask/superstruct").Struct<{
62
+ accountId: string;
63
+ signature: string;
64
+ }, {
65
+ accountId: import("@metamask/superstruct").Struct<string, null>;
66
+ signature: import("@metamask/superstruct").Struct<string, null>;
67
+ }>;
68
+ /**
69
+ * One successful proof-of-ownership batch result.
70
+ */
71
+ export type ProofOfOwnershipBatchSuccess = Infer<typeof ProofOfOwnershipBatchSuccessStruct>;
72
+ /**
73
+ * Validates one failed proof-of-ownership batch result.
74
+ */
75
+ export declare const ProofOfOwnershipBatchErrorStruct: import("@metamask/superstruct").Struct<{
76
+ error: string;
77
+ accountId: string;
78
+ }, {
79
+ accountId: import("@metamask/superstruct").Struct<string, null>;
80
+ error: import("@metamask/superstruct").Struct<string, null>;
81
+ }>;
82
+ /**
83
+ * One failed proof-of-ownership batch result.
84
+ */
85
+ export type ProofOfOwnershipBatchError = Infer<typeof ProofOfOwnershipBatchErrorStruct>;
86
+ /**
87
+ * Validates one proof-of-ownership batch result.
88
+ */
89
+ export declare const ProofOfOwnershipBatchItemResponseStruct: import("@metamask/superstruct").Struct<{
90
+ accountId: string;
91
+ signature: string;
92
+ } | {
93
+ error: string;
94
+ accountId: string;
95
+ }, null>;
96
+ /**
97
+ * One proof-of-ownership batch result.
98
+ */
99
+ export type ProofOfOwnershipBatchItemResponse = Infer<typeof ProofOfOwnershipBatchItemResponseStruct>;
100
+ /**
101
+ * Validates a proof-of-ownership batch response.
102
+ */
103
+ export declare const ProofOfOwnershipBatchResponseStruct: import("@metamask/superstruct").Struct<{
104
+ results: ({
105
+ accountId: string;
106
+ signature: string;
107
+ } | {
108
+ error: string;
109
+ accountId: string;
110
+ })[];
111
+ }, {
112
+ results: import("@metamask/superstruct").Struct<({
113
+ accountId: string;
114
+ signature: string;
115
+ } | {
116
+ error: string;
117
+ accountId: string;
118
+ })[], import("@metamask/superstruct").Struct<{
119
+ accountId: string;
120
+ signature: string;
121
+ } | {
122
+ error: string;
123
+ accountId: string;
124
+ }, null>>;
125
+ }>;
126
+ /**
127
+ * Proof-of-ownership batch response shape.
128
+ */
129
+ export type ProofOfOwnershipBatchResponse = Infer<typeof ProofOfOwnershipBatchResponseStruct>;
130
+ /**
131
+ * Parses a plaintext proof-of-ownership message in the format
132
+ * `metamask:proof-of-ownership:{nonce}:{address}`.
133
+ *
134
+ * Address validity is intentionally not checked here because it is
135
+ * chain-specific. Callers should validate the returned address with the
136
+ * relevant network/address validator.
137
+ *
138
+ * @param message - The plaintext message to parse.
139
+ * @returns The parsed nonce and address.
140
+ * @throws Error if the message format is invalid.
141
+ */
142
+ export declare function parseProofOfOwnershipMessage(message: string): ProofOfOwnershipMessage;
143
+ //# sourceMappingURL=proofOfOwnership.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofOfOwnership.d.cts","sourceRoot":"","sources":["../../../src/utils/proofOfOwnership/proofOfOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;GAEG;AACH,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;EAGxC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CACzC,OAAO,6BAA6B,CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sCAAsC;;;;;;EAGjD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG,KAAK,CAClD,OAAO,sCAAsC,CAC9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;EAEnD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CACpD,OAAO,wCAAwC,CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;EAG7C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;EAG3C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;;QAGlD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;EAE9C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAC/C,OAAO,mCAAmC,CAC3C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,GACd,uBAAuB,CA2BzB"}
@@ -0,0 +1,143 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Prefix for proof-of-ownership messages signed by network snaps.
4
+ */
5
+ export declare const PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = "metamask:proof-of-ownership:";
6
+ /**
7
+ * Validates parsed proof-of-ownership message fields.
8
+ */
9
+ export declare const ProofOfOwnershipMessageStruct: import("@metamask/superstruct").Struct<{
10
+ address: string;
11
+ nonce: string;
12
+ }, {
13
+ nonce: import("@metamask/superstruct").Struct<string, null>;
14
+ address: import("@metamask/superstruct").Struct<string, null>;
15
+ }>;
16
+ /**
17
+ * Parsed proof-of-ownership message fields.
18
+ */
19
+ export type ProofOfOwnershipMessage = Infer<typeof ProofOfOwnershipMessageStruct>;
20
+ /**
21
+ * Validates one proof-of-ownership batch request item.
22
+ */
23
+ export declare const ProofOfOwnershipBatchRequestItemStruct: import("@metamask/superstruct").Struct<{
24
+ message: string;
25
+ accountId: string;
26
+ }, {
27
+ accountId: import("@metamask/superstruct").Struct<string, null>;
28
+ message: import("@metamask/superstruct").Struct<string, null>;
29
+ }>;
30
+ /**
31
+ * One proof-of-ownership batch request item.
32
+ */
33
+ export type ProofOfOwnershipBatchRequestItem = Infer<typeof ProofOfOwnershipBatchRequestItemStruct>;
34
+ /**
35
+ * Validates proof-of-ownership batch request params.
36
+ */
37
+ export declare const ProofOfOwnershipBatchRequestParamsStruct: import("@metamask/superstruct").Struct<{
38
+ items: {
39
+ message: string;
40
+ accountId: string;
41
+ }[];
42
+ }, {
43
+ items: import("@metamask/superstruct").Struct<{
44
+ message: string;
45
+ accountId: string;
46
+ }[], import("@metamask/superstruct").Struct<{
47
+ message: string;
48
+ accountId: string;
49
+ }, {
50
+ accountId: import("@metamask/superstruct").Struct<string, null>;
51
+ message: import("@metamask/superstruct").Struct<string, null>;
52
+ }>>;
53
+ }>;
54
+ /**
55
+ * Proof-of-ownership batch request params.
56
+ */
57
+ export type ProofOfOwnershipBatchRequestParams = Infer<typeof ProofOfOwnershipBatchRequestParamsStruct>;
58
+ /**
59
+ * Validates one successful proof-of-ownership batch result.
60
+ */
61
+ export declare const ProofOfOwnershipBatchSuccessStruct: import("@metamask/superstruct").Struct<{
62
+ accountId: string;
63
+ signature: string;
64
+ }, {
65
+ accountId: import("@metamask/superstruct").Struct<string, null>;
66
+ signature: import("@metamask/superstruct").Struct<string, null>;
67
+ }>;
68
+ /**
69
+ * One successful proof-of-ownership batch result.
70
+ */
71
+ export type ProofOfOwnershipBatchSuccess = Infer<typeof ProofOfOwnershipBatchSuccessStruct>;
72
+ /**
73
+ * Validates one failed proof-of-ownership batch result.
74
+ */
75
+ export declare const ProofOfOwnershipBatchErrorStruct: import("@metamask/superstruct").Struct<{
76
+ error: string;
77
+ accountId: string;
78
+ }, {
79
+ accountId: import("@metamask/superstruct").Struct<string, null>;
80
+ error: import("@metamask/superstruct").Struct<string, null>;
81
+ }>;
82
+ /**
83
+ * One failed proof-of-ownership batch result.
84
+ */
85
+ export type ProofOfOwnershipBatchError = Infer<typeof ProofOfOwnershipBatchErrorStruct>;
86
+ /**
87
+ * Validates one proof-of-ownership batch result.
88
+ */
89
+ export declare const ProofOfOwnershipBatchItemResponseStruct: import("@metamask/superstruct").Struct<{
90
+ accountId: string;
91
+ signature: string;
92
+ } | {
93
+ error: string;
94
+ accountId: string;
95
+ }, null>;
96
+ /**
97
+ * One proof-of-ownership batch result.
98
+ */
99
+ export type ProofOfOwnershipBatchItemResponse = Infer<typeof ProofOfOwnershipBatchItemResponseStruct>;
100
+ /**
101
+ * Validates a proof-of-ownership batch response.
102
+ */
103
+ export declare const ProofOfOwnershipBatchResponseStruct: import("@metamask/superstruct").Struct<{
104
+ results: ({
105
+ accountId: string;
106
+ signature: string;
107
+ } | {
108
+ error: string;
109
+ accountId: string;
110
+ })[];
111
+ }, {
112
+ results: import("@metamask/superstruct").Struct<({
113
+ accountId: string;
114
+ signature: string;
115
+ } | {
116
+ error: string;
117
+ accountId: string;
118
+ })[], import("@metamask/superstruct").Struct<{
119
+ accountId: string;
120
+ signature: string;
121
+ } | {
122
+ error: string;
123
+ accountId: string;
124
+ }, null>>;
125
+ }>;
126
+ /**
127
+ * Proof-of-ownership batch response shape.
128
+ */
129
+ export type ProofOfOwnershipBatchResponse = Infer<typeof ProofOfOwnershipBatchResponseStruct>;
130
+ /**
131
+ * Parses a plaintext proof-of-ownership message in the format
132
+ * `metamask:proof-of-ownership:{nonce}:{address}`.
133
+ *
134
+ * Address validity is intentionally not checked here because it is
135
+ * chain-specific. Callers should validate the returned address with the
136
+ * relevant network/address validator.
137
+ *
138
+ * @param message - The plaintext message to parse.
139
+ * @returns The parsed nonce and address.
140
+ * @throws Error if the message format is invalid.
141
+ */
142
+ export declare function parseProofOfOwnershipMessage(message: string): ProofOfOwnershipMessage;
143
+ //# sourceMappingURL=proofOfOwnership.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofOfOwnership.d.mts","sourceRoot":"","sources":["../../../src/utils/proofOfOwnership/proofOfOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;GAEG;AACH,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;EAGxC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CACzC,OAAO,6BAA6B,CACrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sCAAsC;;;;;;EAGjD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG,KAAK,CAClD,OAAO,sCAAsC,CAC9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;EAEnD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,KAAK,CACpD,OAAO,wCAAwC,CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;EAG7C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;;;;EAG3C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC;;;;;;QAGlD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;EAE9C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAC/C,OAAO,mCAAmC,CAC3C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,GACd,uBAAuB,CA2BzB"}
@@ -0,0 +1,85 @@
1
+ import { array, nonempty, object, string, union } from "@metamask/superstruct";
2
+ import { UuidStruct } from "../uuidStruct/uuidStruct.mjs";
3
+ /**
4
+ * Prefix for proof-of-ownership messages signed by network snaps.
5
+ */
6
+ export const PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = 'metamask:proof-of-ownership:';
7
+ /**
8
+ * Validates parsed proof-of-ownership message fields.
9
+ */
10
+ export const ProofOfOwnershipMessageStruct = object({
11
+ nonce: nonempty(string()),
12
+ address: nonempty(string()),
13
+ });
14
+ /**
15
+ * Validates one proof-of-ownership batch request item.
16
+ */
17
+ export const ProofOfOwnershipBatchRequestItemStruct = object({
18
+ accountId: UuidStruct,
19
+ message: string(),
20
+ });
21
+ /**
22
+ * Validates proof-of-ownership batch request params.
23
+ */
24
+ export const ProofOfOwnershipBatchRequestParamsStruct = object({
25
+ items: array(ProofOfOwnershipBatchRequestItemStruct),
26
+ });
27
+ /**
28
+ * Validates one successful proof-of-ownership batch result.
29
+ */
30
+ export const ProofOfOwnershipBatchSuccessStruct = object({
31
+ accountId: UuidStruct,
32
+ signature: string(),
33
+ });
34
+ /**
35
+ * Validates one failed proof-of-ownership batch result.
36
+ */
37
+ export const ProofOfOwnershipBatchErrorStruct = object({
38
+ accountId: UuidStruct,
39
+ error: nonempty(string()),
40
+ });
41
+ /**
42
+ * Validates one proof-of-ownership batch result.
43
+ */
44
+ export const ProofOfOwnershipBatchItemResponseStruct = union([
45
+ ProofOfOwnershipBatchSuccessStruct,
46
+ ProofOfOwnershipBatchErrorStruct,
47
+ ]);
48
+ /**
49
+ * Validates a proof-of-ownership batch response.
50
+ */
51
+ export const ProofOfOwnershipBatchResponseStruct = object({
52
+ results: array(ProofOfOwnershipBatchItemResponseStruct),
53
+ });
54
+ /**
55
+ * Parses a plaintext proof-of-ownership message in the format
56
+ * `metamask:proof-of-ownership:{nonce}:{address}`.
57
+ *
58
+ * Address validity is intentionally not checked here because it is
59
+ * chain-specific. Callers should validate the returned address with the
60
+ * relevant network/address validator.
61
+ *
62
+ * @param message - The plaintext message to parse.
63
+ * @returns The parsed nonce and address.
64
+ * @throws Error if the message format is invalid.
65
+ */
66
+ export function parseProofOfOwnershipMessage(message) {
67
+ if (!message.startsWith(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX)) {
68
+ throw new Error(`Message must start with "${PROOF_OF_OWNERSHIP_MESSAGE_PREFIX}"`);
69
+ }
70
+ const remainder = message.slice(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX.length);
71
+ const separatorIndex = remainder.lastIndexOf(':');
72
+ if (separatorIndex === -1) {
73
+ throw new Error('Message must follow the format "metamask:proof-of-ownership:{nonce}:{address}"');
74
+ }
75
+ const nonce = remainder.slice(0, separatorIndex);
76
+ const address = remainder.slice(separatorIndex + 1);
77
+ if (nonce.length === 0) {
78
+ throw new Error('Message must include a non-empty nonce');
79
+ }
80
+ if (address.length === 0) {
81
+ throw new Error('Message must include a non-empty address');
82
+ }
83
+ return { nonce, address };
84
+ }
85
+ //# sourceMappingURL=proofOfOwnership.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proofOfOwnership.mjs","sourceRoot":"","sources":["../../../src/utils/proofOfOwnership/proofOfOwnership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;AAE/E,OAAO,EAAE,UAAU,EAAE,qCAAiC;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,8BAA8B,CAAC;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;IAClD,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CAC5B,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC;IAC3D,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,MAAM,EAAE;CAClB,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,MAAM,CAAC;IAC7D,KAAK,EAAE,KAAK,CAAC,sCAAsC,CAAC;CACrD,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,MAAM,CAAC;IACvD,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,MAAM,EAAE;CACpB,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,SAAS,EAAE,UAAU;IACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CAC1B,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,CAAC;IAC3D,kCAAkC;IAClC,gCAAgC;CACjC,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,MAAM,CAAC;IACxD,OAAO,EAAE,KAAK,CAAC,uCAAuC,CAAC;CACxD,CAAC,CAAC;AASH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAe;IAEf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iCAAiC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CACb,4BAA4B,iCAAiC,GAAG,CACjE,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,MAAM,CAAC,CAAC;IAC1E,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IAEpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, nonempty, object, string, union } from '@metamask/superstruct';\n\nimport { UuidStruct } from '../uuidStruct/uuidStruct';\n\n/**\n * Prefix for proof-of-ownership messages signed by network snaps.\n */\nexport const PROOF_OF_OWNERSHIP_MESSAGE_PREFIX = 'metamask:proof-of-ownership:';\n\n/**\n * Validates parsed proof-of-ownership message fields.\n */\nexport const ProofOfOwnershipMessageStruct = object({\n nonce: nonempty(string()),\n address: nonempty(string()),\n});\n\n/**\n * Parsed proof-of-ownership message fields.\n */\nexport type ProofOfOwnershipMessage = Infer<\n typeof ProofOfOwnershipMessageStruct\n>;\n\n/**\n * Validates one proof-of-ownership batch request item.\n */\nexport const ProofOfOwnershipBatchRequestItemStruct = object({\n accountId: UuidStruct,\n message: string(),\n});\n\n/**\n * One proof-of-ownership batch request item.\n */\nexport type ProofOfOwnershipBatchRequestItem = Infer<\n typeof ProofOfOwnershipBatchRequestItemStruct\n>;\n\n/**\n * Validates proof-of-ownership batch request params.\n */\nexport const ProofOfOwnershipBatchRequestParamsStruct = object({\n items: array(ProofOfOwnershipBatchRequestItemStruct),\n});\n\n/**\n * Proof-of-ownership batch request params.\n */\nexport type ProofOfOwnershipBatchRequestParams = Infer<\n typeof ProofOfOwnershipBatchRequestParamsStruct\n>;\n\n/**\n * Validates one successful proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchSuccessStruct = object({\n accountId: UuidStruct,\n signature: string(),\n});\n\n/**\n * One successful proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchSuccess = Infer<\n typeof ProofOfOwnershipBatchSuccessStruct\n>;\n\n/**\n * Validates one failed proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchErrorStruct = object({\n accountId: UuidStruct,\n error: nonempty(string()),\n});\n\n/**\n * One failed proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchError = Infer<\n typeof ProofOfOwnershipBatchErrorStruct\n>;\n\n/**\n * Validates one proof-of-ownership batch result.\n */\nexport const ProofOfOwnershipBatchItemResponseStruct = union([\n ProofOfOwnershipBatchSuccessStruct,\n ProofOfOwnershipBatchErrorStruct,\n]);\n\n/**\n * One proof-of-ownership batch result.\n */\nexport type ProofOfOwnershipBatchItemResponse = Infer<\n typeof ProofOfOwnershipBatchItemResponseStruct\n>;\n\n/**\n * Validates a proof-of-ownership batch response.\n */\nexport const ProofOfOwnershipBatchResponseStruct = object({\n results: array(ProofOfOwnershipBatchItemResponseStruct),\n});\n\n/**\n * Proof-of-ownership batch response shape.\n */\nexport type ProofOfOwnershipBatchResponse = Infer<\n typeof ProofOfOwnershipBatchResponseStruct\n>;\n\n/**\n * Parses a plaintext proof-of-ownership message in the format\n * `metamask:proof-of-ownership:{nonce}:{address}`.\n *\n * Address validity is intentionally not checked here because it is\n * chain-specific. Callers should validate the returned address with the\n * relevant network/address validator.\n *\n * @param message - The plaintext message to parse.\n * @returns The parsed nonce and address.\n * @throws Error if the message format is invalid.\n */\nexport function parseProofOfOwnershipMessage(\n message: string,\n): ProofOfOwnershipMessage {\n if (!message.startsWith(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX)) {\n throw new Error(\n `Message must start with \"${PROOF_OF_OWNERSHIP_MESSAGE_PREFIX}\"`,\n );\n }\n\n const remainder = message.slice(PROOF_OF_OWNERSHIP_MESSAGE_PREFIX.length);\n const separatorIndex = remainder.lastIndexOf(':');\n if (separatorIndex === -1) {\n throw new Error(\n 'Message must follow the format \"metamask:proof-of-ownership:{nonce}:{address}\"',\n );\n }\n\n const nonce = remainder.slice(0, separatorIndex);\n const address = remainder.slice(separatorIndex + 1);\n\n if (nonce.length === 0) {\n throw new Error('Message must include a non-empty nonce');\n }\n\n if (address.length === 0) {\n throw new Error('Message must include a non-empty address');\n }\n\n return { nonce, address };\n}\n"]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeMerge = void 0;
4
+ /**
5
+ * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's
6
+ * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider
7
+ * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects
8
+ * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.
9
+ *
10
+ * @param overridee - The object to override.
11
+ * @param overrider - The object to override with.
12
+ * @returns The merged object (using shallow, top-level merge semantics).
13
+ * @example
14
+ * const overridee = { name: 'John' };
15
+ * const overrider = { name: undefined, age: 30 };
16
+ * const merged = safeMerge(overridee, overrider);
17
+ * // merged is { name: 'John', age: 30 }
18
+ */
19
+ const safeMerge = (overridee, overrider) => ({
20
+ ...overridee,
21
+ ...Object.fromEntries(Object.entries(overrider).filter(([_key, value]) => value !== undefined &&
22
+ value !== null &&
23
+ (!value || typeof value !== 'object' || Object.keys(value).length > 0))),
24
+ });
25
+ exports.safeMerge = safeMerge;
26
+ //# sourceMappingURL=safeMerge.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeMerge.cjs","sourceRoot":"","sources":["../../../src/utils/safeMerge/safeMerge.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACI,MAAM,SAAS,GAAG,CACvB,SAAqB,EACrB,SAAqB,EACI,EAAE,CAAC,CAAC;IAC7B,GAAG,SAAS;IACZ,GAAI,MAAM,CAAC,WAAW,CACpB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC9B,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAChB,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACzE,CACa;CACjB,CAAC,CAAC;AAbU,QAAA,SAAS,aAanB","sourcesContent":["/**\n * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's\n * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider\n * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects\n * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.\n *\n * @param overridee - The object to override.\n * @param overrider - The object to override with.\n * @returns The merged object (using shallow, top-level merge semantics).\n * @example\n * const overridee = { name: 'John' };\n * const overrider = { name: undefined, age: 30 };\n * const merged = safeMerge(overridee, overrider);\n * // merged is { name: 'John', age: 30 }\n */\nexport const safeMerge = <TOverridee extends object, TOverrider extends object>(\n overridee: TOverridee,\n overrider: TOverrider,\n): TOverridee & TOverrider => ({\n ...overridee,\n ...(Object.fromEntries(\n Object.entries(overrider).filter(\n ([_key, value]) =>\n value !== undefined &&\n value !== null &&\n (!value || typeof value !== 'object' || Object.keys(value).length > 0),\n ),\n ) as TOverrider),\n});\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's
3
+ * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider
4
+ * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects
5
+ * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.
6
+ *
7
+ * @param overridee - The object to override.
8
+ * @param overrider - The object to override with.
9
+ * @returns The merged object (using shallow, top-level merge semantics).
10
+ * @example
11
+ * const overridee = { name: 'John' };
12
+ * const overrider = { name: undefined, age: 30 };
13
+ * const merged = safeMerge(overridee, overrider);
14
+ * // merged is { name: 'John', age: 30 }
15
+ */
16
+ export declare const safeMerge: <TOverridee extends object, TOverrider extends object>(overridee: TOverridee, overrider: TOverrider) => TOverridee & TOverrider;
17
+ //# sourceMappingURL=safeMerge.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeMerge.d.cts","sourceRoot":"","sources":["../../../src/utils/safeMerge/safeMerge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM,EAC5E,WAAW,UAAU,EACrB,WAAW,UAAU,KACpB,UAAU,GAAG,UAUd,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's
3
+ * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider
4
+ * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects
5
+ * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.
6
+ *
7
+ * @param overridee - The object to override.
8
+ * @param overrider - The object to override with.
9
+ * @returns The merged object (using shallow, top-level merge semantics).
10
+ * @example
11
+ * const overridee = { name: 'John' };
12
+ * const overrider = { name: undefined, age: 30 };
13
+ * const merged = safeMerge(overridee, overrider);
14
+ * // merged is { name: 'John', age: 30 }
15
+ */
16
+ export declare const safeMerge: <TOverridee extends object, TOverrider extends object>(overridee: TOverridee, overrider: TOverrider) => TOverridee & TOverrider;
17
+ //# sourceMappingURL=safeMerge.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeMerge.d.mts","sourceRoot":"","sources":["../../../src/utils/safeMerge/safeMerge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM,EAC5E,WAAW,UAAU,EACrB,WAAW,UAAU,KACpB,UAAU,GAAG,UAUd,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's
3
+ * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider
4
+ * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects
5
+ * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.
6
+ *
7
+ * @param overridee - The object to override.
8
+ * @param overrider - The object to override with.
9
+ * @returns The merged object (using shallow, top-level merge semantics).
10
+ * @example
11
+ * const overridee = { name: 'John' };
12
+ * const overrider = { name: undefined, age: 30 };
13
+ * const merged = safeMerge(overridee, overrider);
14
+ * // merged is { name: 'John', age: 30 }
15
+ */
16
+ export const safeMerge = (overridee, overrider) => ({
17
+ ...overridee,
18
+ ...Object.fromEntries(Object.entries(overrider).filter(([_key, value]) => value !== undefined &&
19
+ value !== null &&
20
+ (!value || typeof value !== 'object' || Object.keys(value).length > 0))),
21
+ });
22
+ //# sourceMappingURL=safeMerge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeMerge.mjs","sourceRoot":"","sources":["../../../src/utils/safeMerge/safeMerge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,SAAqB,EACrB,SAAqB,EACI,EAAE,CAAC,CAAC;IAC7B,GAAG,SAAS;IACZ,GAAI,MAAM,CAAC,WAAW,CACpB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAC9B,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAChB,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACzE,CACa;CACjB,CAAC,CAAC","sourcesContent":["/**\n * Shallowly merges two objects at the top level, keeping values from the overridee object when the overrider's\n * corresponding top-level properties are undefined, null, or empty objects. Non-undefined values from the overrider\n * take precedence. Empty objects in the overrider are filtered out to preserve the overridee's values. Nested objects\n * are not merged recursively: if a nested property exists in the overrider, it replaces the overridee's value entirely.\n *\n * @param overridee - The object to override.\n * @param overrider - The object to override with.\n * @returns The merged object (using shallow, top-level merge semantics).\n * @example\n * const overridee = { name: 'John' };\n * const overrider = { name: undefined, age: 30 };\n * const merged = safeMerge(overridee, overrider);\n * // merged is { name: 'John', age: 30 }\n */\nexport const safeMerge = <TOverridee extends object, TOverrider extends object>(\n overridee: TOverridee,\n overrider: TOverrider,\n): TOverridee & TOverrider => ({\n ...overridee,\n ...(Object.fromEntries(\n Object.entries(overrider).filter(\n ([_key, value]) =>\n value !== undefined &&\n value !== null &&\n (!value || typeof value !== 'object' || Object.keys(value).length > 0),\n ),\n ) as TOverrider),\n});\n"]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeControlCharacters = sanitizeControlCharacters;
4
+ exports.sanitizeUri = sanitizeUri;
5
+ /**
6
+ * Removes control characters from a string.
7
+ *
8
+ * @param input - The string to sanitize.
9
+ * @returns The sanitized string.
10
+ */
11
+ function sanitizeControlCharacters(input) {
12
+ if (!input || typeof input !== 'string') {
13
+ return '';
14
+ }
15
+ // Remove all control characters except tab.
16
+ // eslint-disable-next-line no-control-regex
17
+ return input.replace(/[\u0000-\u0008\u000A-\u001F\u007F]/gu, '');
18
+ }
19
+ /**
20
+ * Validates and sanitizes a URI.
21
+ *
22
+ * @param uri - The URI to validate and sanitize.
23
+ * @returns The sanitized URI or an empty string if invalid.
24
+ */
25
+ function sanitizeUri(uri) {
26
+ if (!uri || typeof uri !== 'string') {
27
+ return '';
28
+ }
29
+ const sanitized = sanitizeControlCharacters(uri);
30
+ try {
31
+ const url = new URL(sanitized);
32
+ const allowedProtocols = ['http:', 'https:', 'wss:', 'ipfs:'];
33
+ if (!allowedProtocols.includes(url.protocol) || sanitized.length > 2048) {
34
+ return '';
35
+ }
36
+ return sanitized;
37
+ }
38
+ catch {
39
+ return '';
40
+ }
41
+ }
42
+ //# sourceMappingURL=sanitize.cjs.map