@metamask/snaps-utils 6.1.0 → 7.0.1

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 (560) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/array.js +8 -0
  3. package/dist/array.js.map +1 -0
  4. package/dist/array.mjs +8 -0
  5. package/dist/array.mjs.map +1 -0
  6. package/dist/auxiliary-files.js +12 -0
  7. package/dist/auxiliary-files.js.map +1 -0
  8. package/dist/auxiliary-files.mjs +12 -0
  9. package/dist/auxiliary-files.mjs.map +1 -0
  10. package/dist/base64.js +13 -0
  11. package/dist/base64.js.map +1 -0
  12. package/dist/base64.mjs +13 -0
  13. package/dist/base64.mjs.map +1 -0
  14. package/dist/bytes.js +10 -0
  15. package/dist/bytes.js.map +1 -0
  16. package/dist/bytes.mjs +10 -0
  17. package/dist/bytes.mjs.map +1 -0
  18. package/dist/caveats.js +8 -0
  19. package/dist/caveats.js.map +1 -0
  20. package/dist/caveats.mjs +8 -0
  21. package/dist/caveats.mjs.map +1 -0
  22. package/dist/checksum.js +13 -0
  23. package/dist/checksum.js.map +1 -0
  24. package/dist/checksum.mjs +13 -0
  25. package/dist/checksum.mjs.map +1 -0
  26. package/dist/chunk-224DMTNJ.mjs +409 -0
  27. package/dist/chunk-224DMTNJ.mjs.map +1 -0
  28. package/dist/chunk-2IWSQJKQ.mjs +193 -0
  29. package/dist/chunk-2IWSQJKQ.mjs.map +1 -0
  30. package/dist/chunk-2LBN5T56.js +64 -0
  31. package/dist/chunk-2LBN5T56.js.map +1 -0
  32. package/dist/chunk-2PCPD5XY.js +169 -0
  33. package/dist/chunk-2PCPD5XY.js.map +1 -0
  34. package/dist/chunk-3SOYDY4W.js +152 -0
  35. package/dist/chunk-3SOYDY4W.js.map +1 -0
  36. package/dist/chunk-44GPX66J.mjs +70 -0
  37. package/dist/chunk-44GPX66J.mjs.map +1 -0
  38. package/dist/chunk-44VFHYJO.js +249 -0
  39. package/dist/chunk-44VFHYJO.js.map +1 -0
  40. package/dist/chunk-473MIETW.js +18 -0
  41. package/dist/chunk-473MIETW.js.map +1 -0
  42. package/dist/chunk-4BDR6KRH.js +50 -0
  43. package/dist/chunk-4BDR6KRH.js.map +1 -0
  44. package/dist/chunk-4CMD46B2.js +1 -0
  45. package/dist/chunk-4CMD46B2.js.map +1 -0
  46. package/dist/chunk-5R7UF7KM.mjs +21 -0
  47. package/dist/chunk-5R7UF7KM.mjs.map +1 -0
  48. package/dist/chunk-63OXILAY.mjs +69 -0
  49. package/dist/chunk-63OXILAY.mjs.map +1 -0
  50. package/dist/chunk-6CHO3LOX.mjs +10 -0
  51. package/dist/chunk-6CHO3LOX.mjs.map +1 -0
  52. package/dist/chunk-6LOYTBS3.js +107 -0
  53. package/dist/chunk-6LOYTBS3.js.map +1 -0
  54. package/dist/chunk-6YRUDGNL.mjs +18 -0
  55. package/dist/chunk-6YRUDGNL.mjs.map +1 -0
  56. package/dist/chunk-772OPTGX.js +70 -0
  57. package/dist/chunk-772OPTGX.js.map +1 -0
  58. package/dist/chunk-7LG4D4XA.mjs +20 -0
  59. package/dist/chunk-7LG4D4XA.mjs.map +1 -0
  60. package/dist/chunk-7LOABHVW.js +1 -0
  61. package/dist/chunk-7LOABHVW.js.map +1 -0
  62. package/dist/chunk-7MTAHOWC.mjs +1 -0
  63. package/dist/chunk-7MTAHOWC.mjs.map +1 -0
  64. package/dist/chunk-7P62OIGX.js +69 -0
  65. package/dist/chunk-7P62OIGX.js.map +1 -0
  66. package/dist/chunk-7Y3WSN44.mjs +103 -0
  67. package/dist/chunk-7Y3WSN44.mjs.map +1 -0
  68. package/dist/chunk-A3RRMELT.mjs +1 -0
  69. package/dist/chunk-A3RRMELT.mjs.map +1 -0
  70. package/dist/chunk-A6E325SZ.js +211 -0
  71. package/dist/chunk-A6E325SZ.js.map +1 -0
  72. package/dist/chunk-AFQY2CNY.js +109 -0
  73. package/dist/chunk-AFQY2CNY.js.map +1 -0
  74. package/dist/chunk-AOGVLPQZ.js +18 -0
  75. package/dist/chunk-AOGVLPQZ.js.map +1 -0
  76. package/dist/chunk-AS5P6JRP.mjs +9 -0
  77. package/dist/chunk-AS5P6JRP.mjs.map +1 -0
  78. package/dist/chunk-ASZWZ7JT.js +20 -0
  79. package/dist/chunk-ASZWZ7JT.js.map +1 -0
  80. package/dist/chunk-BGSO2GQC.mjs +41 -0
  81. package/dist/chunk-BGSO2GQC.mjs.map +1 -0
  82. package/dist/chunk-CMOSYNZR.js +95 -0
  83. package/dist/chunk-CMOSYNZR.js.map +1 -0
  84. package/dist/chunk-CNNMLOQ6.js +409 -0
  85. package/dist/chunk-CNNMLOQ6.js.map +1 -0
  86. package/dist/chunk-CQRPSEH3.js +74 -0
  87. package/dist/chunk-CQRPSEH3.js.map +1 -0
  88. package/dist/chunk-DKDGMZFU.mjs +74 -0
  89. package/dist/chunk-DKDGMZFU.mjs.map +1 -0
  90. package/dist/chunk-E3BDBG6T.js +20 -0
  91. package/dist/chunk-E3BDBG6T.js.map +1 -0
  92. package/dist/chunk-EA2FOAEG.mjs +64 -0
  93. package/dist/chunk-EA2FOAEG.mjs.map +1 -0
  94. package/dist/chunk-EFRPCO3C.js +1 -0
  95. package/dist/chunk-EFRPCO3C.js.map +1 -0
  96. package/dist/chunk-ENKAY3PI.js +281 -0
  97. package/dist/chunk-ENKAY3PI.js.map +1 -0
  98. package/dist/chunk-EXUEHPZ4.mjs +107 -0
  99. package/dist/chunk-EXUEHPZ4.mjs.map +1 -0
  100. package/dist/chunk-FOWIC2SO.mjs +38 -0
  101. package/dist/chunk-FOWIC2SO.mjs.map +1 -0
  102. package/dist/chunk-GTAYOKI4.mjs +211 -0
  103. package/dist/chunk-GTAYOKI4.mjs.map +1 -0
  104. package/dist/chunk-HF7HUZ5Z.js +10 -0
  105. package/dist/chunk-HF7HUZ5Z.js.map +1 -0
  106. package/dist/chunk-HJRCBSNA.mjs +32 -0
  107. package/dist/chunk-HJRCBSNA.mjs.map +1 -0
  108. package/dist/chunk-HJYRGKCX.js +50 -0
  109. package/dist/chunk-HJYRGKCX.js.map +1 -0
  110. package/dist/chunk-HYF7Q6VY.mjs +1 -0
  111. package/dist/chunk-HYF7Q6VY.mjs.map +1 -0
  112. package/dist/chunk-I77AVJKV.mjs +152 -0
  113. package/dist/chunk-I77AVJKV.mjs.map +1 -0
  114. package/dist/chunk-IGMAXVPP.mjs +21 -0
  115. package/dist/chunk-IGMAXVPP.mjs.map +1 -0
  116. package/dist/chunk-IHQPAJ2B.js +38 -0
  117. package/dist/chunk-IHQPAJ2B.js.map +1 -0
  118. package/dist/chunk-IJX3CXOY.js +9 -0
  119. package/dist/chunk-IJX3CXOY.js.map +1 -0
  120. package/dist/chunk-IPOE62V4.js +30 -0
  121. package/dist/chunk-IPOE62V4.js.map +1 -0
  122. package/dist/chunk-IV3FSWZ7.mjs +9 -0
  123. package/dist/chunk-IV3FSWZ7.mjs.map +1 -0
  124. package/dist/chunk-IXBJNVHK.js +22 -0
  125. package/dist/chunk-IXBJNVHK.js.map +1 -0
  126. package/dist/chunk-JI5NQ2C3.mjs +1 -0
  127. package/dist/chunk-JI5NQ2C3.mjs.map +1 -0
  128. package/dist/chunk-JMDSN227.mjs +25 -0
  129. package/dist/chunk-JMDSN227.mjs.map +1 -0
  130. package/dist/chunk-K6BCBPXF.js +151 -0
  131. package/dist/chunk-K6BCBPXF.js.map +1 -0
  132. package/dist/chunk-KMLVVVK3.mjs +22 -0
  133. package/dist/chunk-KMLVVVK3.mjs.map +1 -0
  134. package/dist/chunk-LBRWAC27.js +56 -0
  135. package/dist/chunk-LBRWAC27.js.map +1 -0
  136. package/dist/chunk-LCWDLIK5.mjs +281 -0
  137. package/dist/chunk-LCWDLIK5.mjs.map +1 -0
  138. package/dist/chunk-LEKZPKS2.js +21 -0
  139. package/dist/chunk-LEKZPKS2.js.map +1 -0
  140. package/dist/chunk-LSPOXPJJ.mjs +63 -0
  141. package/dist/chunk-LSPOXPJJ.mjs.map +1 -0
  142. package/dist/chunk-MCEKOGEG.mjs +50 -0
  143. package/dist/chunk-MCEKOGEG.mjs.map +1 -0
  144. package/dist/chunk-MLOQHUOY.js +32 -0
  145. package/dist/chunk-MLOQHUOY.js.map +1 -0
  146. package/dist/chunk-N722KRZW.js +41 -0
  147. package/dist/chunk-N722KRZW.js.map +1 -0
  148. package/dist/chunk-NUCLSR2G.js +8 -0
  149. package/dist/chunk-NUCLSR2G.js.map +1 -0
  150. package/dist/chunk-P252LKUT.mjs +9 -0
  151. package/dist/chunk-P252LKUT.mjs.map +1 -0
  152. package/dist/chunk-PHUTP7NB.js +25 -0
  153. package/dist/chunk-PHUTP7NB.js.map +1 -0
  154. package/dist/chunk-PJMEJVOB.mjs +29 -0
  155. package/dist/chunk-PJMEJVOB.mjs.map +1 -0
  156. package/dist/chunk-PLBSSUVY.js +29 -0
  157. package/dist/chunk-PLBSSUVY.js.map +1 -0
  158. package/dist/chunk-Q7RCL5IE.js +30 -0
  159. package/dist/chunk-Q7RCL5IE.js.map +1 -0
  160. package/dist/chunk-QSCKTRRU.js +21 -0
  161. package/dist/chunk-QSCKTRRU.js.map +1 -0
  162. package/dist/chunk-QX6MAFJU.mjs +169 -0
  163. package/dist/chunk-QX6MAFJU.mjs.map +1 -0
  164. package/dist/chunk-QYPLUMB7.mjs +249 -0
  165. package/dist/chunk-QYPLUMB7.mjs.map +1 -0
  166. package/dist/chunk-RAZ7XG4Z.mjs +1 -0
  167. package/dist/chunk-RAZ7XG4Z.mjs.map +1 -0
  168. package/dist/chunk-SRMDDOVO.mjs +20 -0
  169. package/dist/chunk-SRMDDOVO.mjs.map +1 -0
  170. package/dist/chunk-T3VM5YXY.js +1 -0
  171. package/dist/chunk-T3VM5YXY.js.map +1 -0
  172. package/dist/chunk-T3YY4JIJ.js +9 -0
  173. package/dist/chunk-T3YY4JIJ.js.map +1 -0
  174. package/dist/chunk-T6FWIDA6.mjs +95 -0
  175. package/dist/chunk-T6FWIDA6.mjs.map +1 -0
  176. package/dist/chunk-TFP64TMV.js +1 -0
  177. package/dist/chunk-TFP64TMV.js.map +1 -0
  178. package/dist/chunk-TG4BDSYJ.js +193 -0
  179. package/dist/chunk-TG4BDSYJ.js.map +1 -0
  180. package/dist/chunk-UMZNVWEM.mjs +30 -0
  181. package/dist/chunk-UMZNVWEM.mjs.map +1 -0
  182. package/dist/chunk-UW74NLTC.mjs +18 -0
  183. package/dist/chunk-UW74NLTC.mjs.map +1 -0
  184. package/dist/chunk-VWGXNUMD.mjs +151 -0
  185. package/dist/chunk-VWGXNUMD.mjs.map +1 -0
  186. package/dist/chunk-WEOCOYES.mjs +109 -0
  187. package/dist/chunk-WEOCOYES.mjs.map +1 -0
  188. package/dist/chunk-WF56W2AR.mjs +30 -0
  189. package/dist/chunk-WF56W2AR.mjs.map +1 -0
  190. package/dist/chunk-X44Z53IG.js +103 -0
  191. package/dist/chunk-X44Z53IG.js.map +1 -0
  192. package/dist/chunk-Z2JQNSVL.mjs +8 -0
  193. package/dist/chunk-Z2JQNSVL.mjs.map +1 -0
  194. package/dist/chunk-ZJRWU4AJ.mjs +50 -0
  195. package/dist/chunk-ZJRWU4AJ.mjs.map +1 -0
  196. package/dist/chunk-ZT3KKTS2.js +9 -0
  197. package/dist/chunk-ZT3KKTS2.js.map +1 -0
  198. package/dist/cronjob.js +20 -0
  199. package/dist/cronjob.js.map +1 -0
  200. package/dist/cronjob.mjs +20 -0
  201. package/dist/cronjob.mjs.map +1 -0
  202. package/dist/deep-clone.js +8 -0
  203. package/dist/deep-clone.js.map +1 -0
  204. package/dist/deep-clone.mjs +8 -0
  205. package/dist/deep-clone.mjs.map +1 -0
  206. package/dist/default-endowments.js +8 -0
  207. package/dist/default-endowments.js.map +1 -0
  208. package/dist/default-endowments.mjs +8 -0
  209. package/dist/default-endowments.mjs.map +1 -0
  210. package/dist/derivation-paths.js +13 -0
  211. package/dist/derivation-paths.js.map +1 -0
  212. package/dist/derivation-paths.mjs +13 -0
  213. package/dist/derivation-paths.mjs.map +1 -0
  214. package/dist/entropy.js +10 -0
  215. package/dist/entropy.js.map +1 -0
  216. package/dist/entropy.mjs +10 -0
  217. package/dist/entropy.mjs.map +1 -0
  218. package/dist/errors.js +20 -0
  219. package/dist/errors.js.map +1 -0
  220. package/dist/errors.mjs +20 -0
  221. package/dist/errors.mjs.map +1 -0
  222. package/dist/eval-worker.js +43 -0
  223. package/dist/eval-worker.js.map +1 -0
  224. package/dist/eval-worker.mjs +43 -0
  225. package/dist/eval-worker.mjs.map +1 -0
  226. package/dist/eval.js +17 -0
  227. package/dist/eval.js.map +1 -0
  228. package/dist/eval.mjs +17 -0
  229. package/dist/eval.mjs.map +1 -0
  230. package/dist/fs.js +28 -0
  231. package/dist/fs.js.map +1 -0
  232. package/dist/fs.mjs +28 -0
  233. package/dist/fs.mjs.map +1 -0
  234. package/dist/handler-types.js +10 -0
  235. package/dist/handler-types.js.map +1 -0
  236. package/dist/handler-types.mjs +10 -0
  237. package/dist/handler-types.mjs.map +1 -0
  238. package/dist/handlers.js +35 -0
  239. package/dist/handlers.js.map +1 -0
  240. package/dist/handlers.mjs +35 -0
  241. package/dist/handlers.mjs.map +1 -0
  242. package/dist/icon.js +14 -0
  243. package/dist/icon.js.map +1 -0
  244. package/dist/icon.mjs +14 -0
  245. package/dist/icon.mjs.map +1 -0
  246. package/dist/iframe.js +8 -0
  247. package/dist/iframe.js.map +1 -0
  248. package/dist/iframe.mjs +8 -0
  249. package/dist/iframe.mjs.map +1 -0
  250. package/dist/index.executionenv.js +134 -0
  251. package/dist/index.executionenv.js.map +1 -0
  252. package/dist/index.executionenv.mjs +134 -0
  253. package/dist/index.executionenv.mjs.map +1 -0
  254. package/dist/index.js +378 -0
  255. package/dist/index.js.map +1 -0
  256. package/dist/index.mjs +378 -0
  257. package/dist/index.mjs.map +1 -0
  258. package/dist/json-rpc.js +18 -0
  259. package/dist/json-rpc.js.map +1 -0
  260. package/dist/json-rpc.mjs +18 -0
  261. package/dist/json-rpc.mjs.map +1 -0
  262. package/dist/json.js +8 -0
  263. package/dist/json.js.map +1 -0
  264. package/dist/json.mjs +8 -0
  265. package/dist/json.mjs.map +1 -0
  266. package/dist/localization.js +23 -0
  267. package/dist/localization.js.map +1 -0
  268. package/dist/localization.mjs +23 -0
  269. package/dist/localization.mjs.map +1 -0
  270. package/dist/logging.js +14 -0
  271. package/dist/logging.js.map +1 -0
  272. package/dist/logging.mjs +14 -0
  273. package/dist/logging.mjs.map +1 -0
  274. package/dist/manifest/index.js +59 -0
  275. package/dist/manifest/index.js.map +1 -0
  276. package/dist/manifest/index.mjs +59 -0
  277. package/dist/manifest/index.mjs.map +1 -0
  278. package/dist/manifest/manifest.js +42 -0
  279. package/dist/manifest/manifest.js.map +1 -0
  280. package/dist/manifest/manifest.mjs +42 -0
  281. package/dist/manifest/manifest.mjs.map +1 -0
  282. package/dist/manifest/node.js +85 -0
  283. package/dist/manifest/node.js.map +1 -0
  284. package/dist/manifest/node.mjs +85 -0
  285. package/dist/manifest/node.mjs.map +1 -0
  286. package/dist/manifest/validation.js +58 -0
  287. package/dist/manifest/validation.js.map +1 -0
  288. package/dist/manifest/validation.mjs +58 -0
  289. package/dist/manifest/validation.mjs.map +1 -0
  290. package/dist/mock.js +13 -0
  291. package/dist/mock.js.map +1 -0
  292. package/dist/mock.mjs +13 -0
  293. package/dist/mock.mjs.map +1 -0
  294. package/dist/namespace.js +44 -0
  295. package/dist/namespace.js.map +1 -0
  296. package/dist/namespace.mjs +44 -0
  297. package/dist/namespace.mjs.map +1 -0
  298. package/dist/node.js +448 -0
  299. package/dist/node.js.map +1 -0
  300. package/dist/node.mjs +448 -0
  301. package/dist/node.mjs.map +1 -0
  302. package/dist/npm.js +32 -0
  303. package/dist/npm.js.map +1 -0
  304. package/dist/npm.mjs +32 -0
  305. package/dist/npm.mjs.map +1 -0
  306. package/dist/path.js +8 -0
  307. package/dist/path.js.map +1 -0
  308. package/dist/path.mjs +8 -0
  309. package/dist/path.mjs.map +1 -0
  310. package/dist/post-process.js +10 -0
  311. package/dist/post-process.js.map +1 -0
  312. package/dist/post-process.mjs +10 -0
  313. package/dist/post-process.mjs.map +1 -0
  314. package/dist/snaps.js +48 -0
  315. package/dist/snaps.js.map +1 -0
  316. package/dist/snaps.mjs +48 -0
  317. package/dist/snaps.mjs.map +1 -0
  318. package/dist/strings.js +8 -0
  319. package/dist/strings.js.map +1 -0
  320. package/dist/strings.mjs +8 -0
  321. package/dist/strings.mjs.map +1 -0
  322. package/dist/structs.js +31 -0
  323. package/dist/structs.js.map +1 -0
  324. package/dist/structs.mjs +31 -0
  325. package/dist/structs.mjs.map +1 -0
  326. package/dist/tsconfig.build.tsbuildinfo +1 -0
  327. package/dist/types/bytes.d.ts +1 -1
  328. package/dist/types/checksum.d.ts +1 -1
  329. package/dist/types/index.d.ts +1 -6
  330. package/dist/types/json-rpc.d.ts +1 -1
  331. package/dist/types/localization.d.ts +1 -1
  332. package/dist/types/manifest/index.d.ts +0 -1
  333. package/dist/types/manifest/manifest.d.ts +1 -1
  334. package/dist/types/manifest/node.d.ts +2 -0
  335. package/dist/types/manifest/validation.d.ts +5 -5
  336. package/dist/types/node.d.ts +8 -0
  337. package/dist/types/structs.d.ts +0 -20
  338. package/dist/types/ui.d.ts +7 -0
  339. package/dist/types/virtual-file/index.d.ts +0 -1
  340. package/dist/types/virtual-file/node.d.ts +2 -0
  341. package/dist/types.js +28 -0
  342. package/dist/types.js.map +1 -0
  343. package/dist/types.mjs +28 -0
  344. package/dist/types.mjs.map +1 -0
  345. package/dist/ui.js +12 -0
  346. package/dist/ui.js.map +1 -0
  347. package/dist/ui.mjs +12 -0
  348. package/dist/ui.mjs.map +1 -0
  349. package/dist/validation.js +24 -0
  350. package/dist/validation.js.map +1 -0
  351. package/dist/validation.mjs +24 -0
  352. package/dist/validation.mjs.map +1 -0
  353. package/dist/versions.js +12 -0
  354. package/dist/versions.js.map +1 -0
  355. package/dist/versions.mjs +12 -0
  356. package/dist/versions.mjs.map +1 -0
  357. package/dist/virtual-file/VirtualFile.js +9 -0
  358. package/dist/virtual-file/VirtualFile.js.map +1 -0
  359. package/dist/virtual-file/VirtualFile.mjs +9 -0
  360. package/dist/virtual-file/VirtualFile.mjs.map +1 -0
  361. package/dist/virtual-file/index.js +10 -0
  362. package/dist/virtual-file/index.js.map +1 -0
  363. package/dist/virtual-file/index.mjs +10 -0
  364. package/dist/virtual-file/index.mjs.map +1 -0
  365. package/dist/virtual-file/node.js +17 -0
  366. package/dist/virtual-file/node.js.map +1 -0
  367. package/dist/virtual-file/node.mjs +17 -0
  368. package/dist/virtual-file/node.mjs.map +1 -0
  369. package/dist/virtual-file/toVirtualFile.js +12 -0
  370. package/dist/virtual-file/toVirtualFile.js.map +1 -0
  371. package/dist/virtual-file/toVirtualFile.mjs +12 -0
  372. package/dist/virtual-file/toVirtualFile.mjs.map +1 -0
  373. package/package.json +23 -38
  374. package/dist/cjs/array.js +0 -23
  375. package/dist/cjs/array.js.map +0 -1
  376. package/dist/cjs/auxiliary-files.js +0 -27
  377. package/dist/cjs/auxiliary-files.js.map +0 -1
  378. package/dist/cjs/base64.js +0 -44
  379. package/dist/cjs/base64.js.map +0 -1
  380. package/dist/cjs/bytes.js +0 -23
  381. package/dist/cjs/bytes.js.map +0 -1
  382. package/dist/cjs/caveats.js +0 -48
  383. package/dist/cjs/caveats.js.map +0 -1
  384. package/dist/cjs/checksum.js +0 -43
  385. package/dist/cjs/checksum.js.map +0 -1
  386. package/dist/cjs/cronjob.js +0 -77
  387. package/dist/cjs/cronjob.js.map +0 -1
  388. package/dist/cjs/deep-clone.js +0 -22
  389. package/dist/cjs/deep-clone.js.map +0 -1
  390. package/dist/cjs/default-endowments.js +0 -49
  391. package/dist/cjs/default-endowments.js.map +0 -1
  392. package/dist/cjs/derivation-paths.js +0 -300
  393. package/dist/cjs/derivation-paths.js.map +0 -1
  394. package/dist/cjs/entropy.js +0 -23
  395. package/dist/cjs/entropy.js.map +0 -1
  396. package/dist/cjs/errors.js +0 -221
  397. package/dist/cjs/errors.js.map +0 -1
  398. package/dist/cjs/eval-worker.js +0 -44
  399. package/dist/cjs/eval-worker.js.map +0 -1
  400. package/dist/cjs/eval.js +0 -77
  401. package/dist/cjs/eval.js.map +0 -1
  402. package/dist/cjs/fs.js +0 -126
  403. package/dist/cjs/fs.js.map +0 -1
  404. package/dist/cjs/handler-types.js +0 -34
  405. package/dist/cjs/handler-types.js.map +0 -1
  406. package/dist/cjs/handlers.js +0 -173
  407. package/dist/cjs/handlers.js.map +0 -1
  408. package/dist/cjs/icon.js +0 -66
  409. package/dist/cjs/icon.js.map +0 -1
  410. package/dist/cjs/iframe.js +0 -59
  411. package/dist/cjs/iframe.js.map +0 -1
  412. package/dist/cjs/index.browser.js +0 -49
  413. package/dist/cjs/index.browser.js.map +0 -1
  414. package/dist/cjs/index.executionenv.js +0 -27
  415. package/dist/cjs/index.executionenv.js.map +0 -1
  416. package/dist/cjs/index.js +0 -54
  417. package/dist/cjs/index.js.map +0 -1
  418. package/dist/cjs/json-rpc.js +0 -81
  419. package/dist/cjs/json-rpc.js.map +0 -1
  420. package/dist/cjs/json.js +0 -16
  421. package/dist/cjs/json.js.map +0 -1
  422. package/dist/cjs/localization.js +0 -113
  423. package/dist/cjs/localization.js.map +0 -1
  424. package/dist/cjs/logging.js +0 -40
  425. package/dist/cjs/logging.js.map +0 -1
  426. package/dist/cjs/manifest/index.browser.js +0 -20
  427. package/dist/cjs/manifest/index.browser.js.map +0 -1
  428. package/dist/cjs/manifest/index.js +0 -21
  429. package/dist/cjs/manifest/index.js.map +0 -1
  430. package/dist/cjs/manifest/manifest.js +0 -283
  431. package/dist/cjs/manifest/manifest.js.map +0 -1
  432. package/dist/cjs/manifest/validation.js +0 -244
  433. package/dist/cjs/manifest/validation.js.map +0 -1
  434. package/dist/cjs/mock.js +0 -128
  435. package/dist/cjs/mock.js.map +0 -1
  436. package/dist/cjs/namespace.js +0 -136
  437. package/dist/cjs/namespace.js.map +0 -1
  438. package/dist/cjs/npm.js +0 -96
  439. package/dist/cjs/npm.js.map +0 -1
  440. package/dist/cjs/path.js +0 -21
  441. package/dist/cjs/path.js.map +0 -1
  442. package/dist/cjs/post-process.js +0 -328
  443. package/dist/cjs/post-process.js.map +0 -1
  444. package/dist/cjs/snaps.js +0 -232
  445. package/dist/cjs/snaps.js.map +0 -1
  446. package/dist/cjs/strings.js +0 -21
  447. package/dist/cjs/strings.js.map +0 -1
  448. package/dist/cjs/structs.js +0 -210
  449. package/dist/cjs/structs.js.map +0 -1
  450. package/dist/cjs/types.js +0 -104
  451. package/dist/cjs/types.js.map +0 -1
  452. package/dist/cjs/ui.js +0 -53
  453. package/dist/cjs/ui.js.map +0 -1
  454. package/dist/cjs/validation.js +0 -24
  455. package/dist/cjs/validation.js.map +0 -1
  456. package/dist/cjs/versions.js +0 -47
  457. package/dist/cjs/versions.js.map +0 -1
  458. package/dist/cjs/virtual-file/VirtualFile.js +0 -92
  459. package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
  460. package/dist/cjs/virtual-file/index.browser.js +0 -20
  461. package/dist/cjs/virtual-file/index.browser.js.map +0 -1
  462. package/dist/cjs/virtual-file/index.js +0 -21
  463. package/dist/cjs/virtual-file/index.js.map +0 -1
  464. package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
  465. package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
  466. package/dist/esm/array.js +0 -13
  467. package/dist/esm/array.js.map +0 -1
  468. package/dist/esm/auxiliary-files.js +0 -23
  469. package/dist/esm/auxiliary-files.js.map +0 -1
  470. package/dist/esm/base64.js +0 -36
  471. package/dist/esm/base64.js.map +0 -1
  472. package/dist/esm/bytes.js +0 -18
  473. package/dist/esm/bytes.js.map +0 -1
  474. package/dist/esm/caveats.js +0 -38
  475. package/dist/esm/caveats.js.map +0 -1
  476. package/dist/esm/checksum.js +0 -41
  477. package/dist/esm/checksum.js.map +0 -1
  478. package/dist/esm/cronjob.js +0 -59
  479. package/dist/esm/cronjob.js.map +0 -1
  480. package/dist/esm/deep-clone.js +0 -7
  481. package/dist/esm/deep-clone.js.map +0 -1
  482. package/dist/esm/default-endowments.js +0 -39
  483. package/dist/esm/default-endowments.js.map +0 -1
  484. package/dist/esm/derivation-paths.js +0 -287
  485. package/dist/esm/derivation-paths.js.map +0 -1
  486. package/dist/esm/entropy.js +0 -6
  487. package/dist/esm/entropy.js.map +0 -1
  488. package/dist/esm/errors.js +0 -211
  489. package/dist/esm/errors.js.map +0 -1
  490. package/dist/esm/eval-worker.js +0 -40
  491. package/dist/esm/eval-worker.js.map +0 -1
  492. package/dist/esm/eval.js +0 -65
  493. package/dist/esm/eval.js.map +0 -1
  494. package/dist/esm/fs.js +0 -136
  495. package/dist/esm/fs.js.map +0 -1
  496. package/dist/esm/handler-types.js +0 -16
  497. package/dist/esm/handler-types.js.map +0 -1
  498. package/dist/esm/handlers.js +0 -119
  499. package/dist/esm/handlers.js.map +0 -1
  500. package/dist/esm/icon.js +0 -51
  501. package/dist/esm/icon.js.map +0 -1
  502. package/dist/esm/iframe.js +0 -49
  503. package/dist/esm/iframe.js.map +0 -1
  504. package/dist/esm/index.browser.js +0 -32
  505. package/dist/esm/index.browser.js.map +0 -1
  506. package/dist/esm/index.executionenv.js +0 -10
  507. package/dist/esm/index.executionenv.js.map +0 -1
  508. package/dist/esm/index.js +0 -37
  509. package/dist/esm/index.js.map +0 -1
  510. package/dist/esm/json-rpc.js +0 -79
  511. package/dist/esm/json-rpc.js.map +0 -1
  512. package/dist/esm/json.js +0 -17
  513. package/dist/esm/json.js.map +0 -1
  514. package/dist/esm/localization.js +0 -115
  515. package/dist/esm/localization.js.map +0 -1
  516. package/dist/esm/logging.js +0 -59
  517. package/dist/esm/logging.js.map +0 -1
  518. package/dist/esm/manifest/index.browser.js +0 -3
  519. package/dist/esm/manifest/index.browser.js.map +0 -1
  520. package/dist/esm/manifest/index.js +0 -4
  521. package/dist/esm/manifest/index.js.map +0 -1
  522. package/dist/esm/manifest/manifest.js +0 -307
  523. package/dist/esm/manifest/manifest.js.map +0 -1
  524. package/dist/esm/manifest/validation.js +0 -190
  525. package/dist/esm/manifest/validation.js.map +0 -1
  526. package/dist/esm/mock.js +0 -111
  527. package/dist/esm/mock.js.map +0 -1
  528. package/dist/esm/namespace.js +0 -113
  529. package/dist/esm/namespace.js.map +0 -1
  530. package/dist/esm/npm.js +0 -85
  531. package/dist/esm/npm.js.map +0 -1
  532. package/dist/esm/path.js +0 -17
  533. package/dist/esm/path.js.map +0 -1
  534. package/dist/esm/post-process.js +0 -333
  535. package/dist/esm/post-process.js.map +0 -1
  536. package/dist/esm/snaps.js +0 -217
  537. package/dist/esm/snaps.js.map +0 -1
  538. package/dist/esm/strings.js +0 -11
  539. package/dist/esm/strings.js.map +0 -1
  540. package/dist/esm/structs.js +0 -295
  541. package/dist/esm/structs.js.map +0 -1
  542. package/dist/esm/types.js +0 -78
  543. package/dist/esm/types.js.map +0 -1
  544. package/dist/esm/ui.js +0 -50
  545. package/dist/esm/ui.js.map +0 -1
  546. package/dist/esm/validation.js +0 -19
  547. package/dist/esm/validation.js.map +0 -1
  548. package/dist/esm/versions.js +0 -41
  549. package/dist/esm/versions.js.map +0 -1
  550. package/dist/esm/virtual-file/VirtualFile.js +0 -82
  551. package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
  552. package/dist/esm/virtual-file/index.browser.js +0 -3
  553. package/dist/esm/virtual-file/index.browser.js.map +0 -1
  554. package/dist/esm/virtual-file/index.js +0 -4
  555. package/dist/esm/virtual-file/index.js.map +0 -1
  556. package/dist/esm/virtual-file/toVirtualFile.js +0 -26
  557. package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
  558. package/dist/types/index.browser.d.ts +0 -30
  559. package/dist/types/manifest/index.browser.d.ts +0 -1
  560. package/dist/types/virtual-file/index.browser.d.ts +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\nimport { assertStruct, VersionStruct } from '@metamask/utils';\nimport type { Infer, Struct } from 'superstruct';\nimport {\n instance,\n is,\n object,\n optional,\n pattern,\n refine,\n size,\n string,\n type,\n union,\n assert as assertSuperstruct,\n} from 'superstruct';\n\nimport type { SnapCaveatType } from './caveats';\nimport type { SnapFunctionExports, SnapRpcHookArgs } from './handlers';\nimport type { LocalizationFile } from './localization';\nimport type { SnapManifest } from './manifest';\nimport type { VirtualFile } from './virtual-file';\n\nexport enum NpmSnapFileNames {\n PackageJson = 'package.json',\n Manifest = 'snap.manifest.json',\n}\n\nexport const NameStruct = size(\n pattern(\n string(),\n /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/u,\n ),\n 1,\n 214,\n);\n\n// Note we use `type` instead of `object` here, because the latter does not\n// allow unknown keys.\nexport const NpmSnapPackageJsonStruct = type({\n version: VersionStruct,\n name: NameStruct,\n main: optional(size(string(), 1, Infinity)),\n repository: optional(\n object({\n type: size(string(), 1, Infinity),\n url: size(string(), 1, Infinity),\n }),\n ),\n});\n\nexport type NpmSnapPackageJson = Infer<typeof NpmSnapPackageJsonStruct> &\n Record<string, any>;\n\n/**\n * Check if the given value is a valid {@link NpmSnapPackageJson} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link NpmSnapPackageJson} object.\n */\nexport function isNpmSnapPackageJson(\n value: unknown,\n): value is NpmSnapPackageJson {\n return is(value, NpmSnapPackageJsonStruct);\n}\n\n/**\n * Asserts that the given value is a valid {@link NpmSnapPackageJson} object.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid {@link NpmSnapPackageJson} object.\n */\nexport function assertIsNpmSnapPackageJson(\n value: unknown,\n): asserts value is NpmSnapPackageJson {\n assertStruct(\n value,\n NpmSnapPackageJsonStruct,\n `\"${NpmSnapFileNames.PackageJson}\" is invalid`,\n );\n}\n\n/**\n * An object for storing parsed but unvalidated Snap file contents.\n */\nexport type UnvalidatedSnapFiles = {\n manifest?: VirtualFile<Json>;\n packageJson?: VirtualFile<Json>;\n sourceCode?: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile[];\n};\n\n/**\n * An object for storing the contents of Snap files that have passed JSON\n * Schema validation, or are non-empty if they are strings.\n */\nexport type SnapFiles = {\n manifest: VirtualFile<SnapManifest>;\n packageJson: VirtualFile<NpmSnapPackageJson>;\n sourceCode: VirtualFile;\n svgIcon?: VirtualFile;\n auxiliaryFiles: VirtualFile[];\n localizationFiles: VirtualFile<LocalizationFile>[];\n};\n\n/**\n * A subset of snap files extracted from a fetched snap.\n */\nexport type FetchedSnapFiles = Pick<\n SnapFiles,\n 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles' | 'localizationFiles'\n>;\n\n/**\n * The possible prefixes for snap ids.\n */\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SnapIdPrefixes {\n npm = 'npm:',\n local = 'local:',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n/**\n * Snap validation failure reason codes that are programmatically fixable\n * if validation occurs during development.\n */\nexport enum SnapValidationFailureReason {\n NameMismatch = '\"name\" field mismatch',\n VersionMismatch = '\"version\" field mismatch',\n RepositoryMismatch = '\"repository\" field mismatch',\n ShasumMismatch = '\"shasum\" field mismatch',\n}\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum SNAP_STREAM_NAMES {\n JSON_RPC = 'jsonRpc',\n COMMAND = 'command',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\n// The snap is the callee\nexport type SnapRpcHook = (options: SnapRpcHookArgs) => Promise<unknown>;\n\ntype ObjectParameters<\n Type extends Record<string, (...args: any[]) => unknown>,\n> = Parameters<Type[keyof Type]>;\n\nexport type SnapExportsParameters = ObjectParameters<SnapFunctionExports>;\n\ntype UriOptions<Type extends string> = {\n protocol?: Struct<Type>;\n hash?: Struct<Type>;\n port?: Struct<Type>;\n hostname?: Struct<Type>;\n pathname?: Struct<Type>;\n search?: Struct<Type>;\n};\n\nexport const uri = (opts: UriOptions<any> = {}) =>\n refine(union([string(), instance(URL)]), 'uri', (value) => {\n try {\n const url = new URL(value);\n\n const UrlStruct = type(opts);\n assertSuperstruct(url, UrlStruct);\n return true;\n } catch {\n return `Expected URL, got \"${value.toString()}\".`;\n }\n });\n\n/**\n * Returns whether a given value is a valid URL.\n *\n * @param url - The value to check.\n * @param opts - Optional constraints for url checking.\n * @returns Whether `url` is valid URL or not.\n */\nexport function isValidUrl(\n url: unknown,\n opts: UriOptions<any> = {},\n): url is string | URL {\n return is(url, uri(opts));\n}\n\n// redefining here to avoid circular dependency\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\nexport type SnapsPermissionRequest = {\n [WALLET_SNAP_PERMISSION_KEY]: {\n caveats: [\n {\n type: SnapCaveatType.SnapIds;\n value: Record<string, Json>;\n },\n ];\n };\n};\n"],"names":["NameStruct","NpmSnapPackageJsonStruct","isNpmSnapPackageJson","assertIsNpmSnapPackageJson","uri","isValidUrl","WALLET_SNAP_PERMISSION_KEY","NpmSnapFileNames","PackageJson","Manifest","size","pattern","string","type","version","VersionStruct","name","main","optional","Infinity","repository","object","url","value","is","assertStruct","SnapIdPrefixes","npm","local","SnapValidationFailureReason","NameMismatch","VersionMismatch","RepositoryMismatch","ShasumMismatch","SNAP_STREAM_NAMES","JSON_RPC","COMMAND","opts","refine","union","instance","URL","UrlStruct","assertSuperstruct","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;IA4BaA,UAAU;eAAVA;;IAWAC,wBAAwB;eAAxBA;;IAqBGC,oBAAoB;eAApBA;;IAYAC,0BAA0B;eAA1BA;;IAyFHC,GAAG;eAAHA;;IAoBGC,UAAU;eAAVA;;IAQHC,0BAA0B;eAA1BA;;;uBA5L+B;6BAcrC;IAQA;UAAKC,gBAAgB;IAAhBA,iBACVC,iBAAc;IADJD,iBAEVE,cAAW;GAFDF,qBAAAA;AAKL,MAAMP,aAAaU,IAAAA,iBAAI,EAC5BC,IAAAA,oBAAO,EACLC,IAAAA,mBAAM,KACN,gEAEF,GACA;AAKK,MAAMX,2BAA2BY,IAAAA,iBAAI,EAAC;IAC3CC,SAASC,oBAAa;IACtBC,MAAMhB;IACNiB,MAAMC,IAAAA,qBAAQ,EAACR,IAAAA,iBAAI,EAACE,IAAAA,mBAAM,KAAI,GAAGO;IACjCC,YAAYF,IAAAA,qBAAQ,EAClBG,IAAAA,mBAAM,EAAC;QACLR,MAAMH,IAAAA,iBAAI,EAACE,IAAAA,mBAAM,KAAI,GAAGO;QACxBG,KAAKZ,IAAAA,iBAAI,EAACE,IAAAA,mBAAM,KAAI,GAAGO;IACzB;AAEJ;AAWO,SAASjB,qBACdqB,KAAc;IAEd,OAAOC,IAAAA,eAAE,EAACD,OAAOtB;AACnB;AAQO,SAASE,2BACdoB,KAAc;IAEdE,IAAAA,mBAAY,EACVF,OACAtB,0BACA,CAAC,CAAC,EAAEM,iBAAiBC,WAAW,CAAC,YAAY,CAAC;AAElD;IAuCO;UAAKkB,cAAc;IAAdA,eACVC,SAAM;IADID,eAEVE,WAAQ;GAFEF,mBAAAA;IAUL;UAAKG,2BAA2B;IAA3BA,4BACVC,kBAAe;IADLD,4BAEVE,qBAAkB;IAFRF,4BAGVG,wBAAqB;IAHXH,4BAIVI,oBAAiB;GAJPJ,gCAAAA;IAQL;UAAKK,iBAAiB;IAAjBA,kBACVC,cAAW;IADDD,kBAEVE,aAAU;GAFAF,sBAAAA;AAwBL,MAAM9B,MAAM,CAACiC,OAAwB,CAAC,CAAC,GAC5CC,IAAAA,mBAAM,EAACC,IAAAA,kBAAK,EAAC;QAAC3B,IAAAA,mBAAM;QAAI4B,IAAAA,qBAAQ,EAACC;KAAK,GAAG,OAAO,CAAClB;QAC/C,IAAI;YACF,MAAMD,MAAM,IAAImB,IAAIlB;YAEpB,MAAMmB,YAAY7B,IAAAA,iBAAI,EAACwB;YACvBM,IAAAA,mBAAiB,EAACrB,KAAKoB;YACvB,OAAO;QACT,EAAE,OAAM;YACN,OAAO,CAAC,mBAAmB,EAAEnB,MAAMqB,QAAQ,GAAG,EAAE,CAAC;QACnD;IACF;AASK,SAASvC,WACdiB,GAAY,EACZe,OAAwB,CAAC,CAAC;IAE1B,OAAOb,IAAAA,eAAE,EAACF,KAAKlB,IAAIiC;AACrB;AAGO,MAAM/B,6BAA6B"}
package/dist/cjs/ui.js DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- validateTextLinks: function() {
13
- return validateTextLinks;
14
- },
15
- validateComponentLinks: function() {
16
- return validateComponentLinks;
17
- }
18
- });
19
- const _snapssdk = require("@metamask/snaps-sdk");
20
- const _utils = require("@metamask/utils");
21
- const MARKDOWN_LINK_REGEX = RegExp("\\[(?<name>[^\\]]*)\\]\\((?<url>[^)]+)\\)", "giu");
22
- const ALLOWED_PROTOCOLS = [
23
- 'https:',
24
- 'mailto:'
25
- ];
26
- function validateTextLinks(text, isOnPhishingList) {
27
- const matches = String.prototype.matchAll.call(text, MARKDOWN_LINK_REGEX);
28
- for (const { groups } of matches){
29
- const link = groups?.url;
30
- /* This case should never happen with the regex but the TS type allows for undefined */ /* istanbul ignore next */ if (!link) {
31
- continue;
32
- }
33
- try {
34
- const url = new URL(link);
35
- (0, _utils.assert)(ALLOWED_PROTOCOLS.includes(url.protocol), `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`);
36
- const hostname = url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;
37
- (0, _utils.assert)(!isOnPhishingList(hostname), 'The specified URL is not allowed.');
38
- } catch (error) {
39
- throw new Error(`Invalid URL: ${error instanceof _utils.AssertionError ? error.message : 'Unable to parse URL.'}`);
40
- }
41
- }
42
- }
43
- function validateComponentLinks(component, isOnPhishingList) {
44
- const { type } = component;
45
- if (type === _snapssdk.NodeType.Panel) {
46
- component.children.forEach((node)=>validateComponentLinks(node, isOnPhishingList));
47
- }
48
- if (type === _snapssdk.NodeType.Text) {
49
- validateTextLinks(component.value, isOnPhishingList);
50
- }
51
- }
52
-
53
- //# sourceMappingURL=ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ui.ts"],"sourcesContent":["import type { Component } from '@metamask/snaps-sdk';\nimport { NodeType } from '@metamask/snaps-sdk';\nimport { assert, AssertionError } from '@metamask/utils';\n\nconst MARKDOWN_LINK_REGEX = /\\[(?<name>[^\\]]*)\\]\\((?<url>[^)]+)\\)/giu;\n\nconst ALLOWED_PROTOCOLS = ['https:', 'mailto:'];\n\n/**\n * Searches for markdown links in a string and checks them against the phishing list.\n *\n * @param text - The text to verify.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the text contains a link that is not allowed.\n */\nexport function validateTextLinks(\n text: string,\n isOnPhishingList: (url: string) => boolean,\n) {\n const matches = String.prototype.matchAll.call(text, MARKDOWN_LINK_REGEX);\n\n for (const { groups } of matches) {\n const link = groups?.url;\n\n /* This case should never happen with the regex but the TS type allows for undefined */\n /* istanbul ignore next */\n if (!link) {\n continue;\n }\n\n try {\n const url = new URL(link);\n assert(\n ALLOWED_PROTOCOLS.includes(url.protocol),\n `Protocol must be one of: ${ALLOWED_PROTOCOLS.join(', ')}.`,\n );\n\n const hostname =\n url.protocol === 'mailto:' ? url.pathname.split('@')[1] : url.hostname;\n\n assert(!isOnPhishingList(hostname), 'The specified URL is not allowed.');\n } catch (error) {\n throw new Error(\n `Invalid URL: ${\n error instanceof AssertionError\n ? error.message\n : 'Unable to parse URL.'\n }`,\n );\n }\n }\n}\n\n/**\n * Search for links in UI components and check that the URL they are trying to\n * pass in is not in the phishing list.\n *\n * @param component - The custom UI component.\n * @param isOnPhishingList - The function that checks the link against the\n * phishing list.\n * @throws If the component contains a link that is not allowed.\n */\nexport function validateComponentLinks(\n component: Component,\n isOnPhishingList: (url: string) => boolean,\n) {\n const { type } = component;\n if (type === NodeType.Panel) {\n component.children.forEach((node) =>\n validateComponentLinks(node, isOnPhishingList),\n );\n }\n\n if (type === NodeType.Text) {\n validateTextLinks(component.value, isOnPhishingList);\n }\n}\n"],"names":["validateTextLinks","validateComponentLinks","MARKDOWN_LINK_REGEX","ALLOWED_PROTOCOLS","text","isOnPhishingList","matches","String","prototype","matchAll","call","groups","link","url","URL","assert","includes","protocol","join","hostname","pathname","split","error","Error","AssertionError","message","component","type","NodeType","Panel","children","forEach","node","Text","value"],"mappings":";;;;;;;;;;;IAgBgBA,iBAAiB;eAAjBA;;IA+CAC,sBAAsB;eAAtBA;;;0BA9DS;uBACc;AAEvC,MAAMC,sBAAsB;AAE5B,MAAMC,oBAAoB;IAAC;IAAU;CAAU;AAUxC,SAASH,kBACdI,IAAY,EACZC,gBAA0C;IAE1C,MAAMC,UAAUC,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACN,MAAMF;IAErD,KAAK,MAAM,EAAES,MAAM,EAAE,IAAIL,QAAS;QAChC,MAAMM,OAAOD,QAAQE;QAErB,qFAAqF,GACrF,wBAAwB,GACxB,IAAI,CAACD,MAAM;YACT;QACF;QAEA,IAAI;YACF,MAAMC,MAAM,IAAIC,IAAIF;YACpBG,IAAAA,aAAM,EACJZ,kBAAkBa,QAAQ,CAACH,IAAII,QAAQ,GACvC,CAAC,yBAAyB,EAAEd,kBAAkBe,IAAI,CAAC,MAAM,CAAC,CAAC;YAG7D,MAAMC,WACJN,IAAII,QAAQ,KAAK,YAAYJ,IAAIO,QAAQ,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAGR,IAAIM,QAAQ;YAExEJ,IAAAA,aAAM,EAAC,CAACV,iBAAiBc,WAAW;QACtC,EAAE,OAAOG,OAAO;YACd,MAAM,IAAIC,MACR,CAAC,aAAa,EACZD,iBAAiBE,qBAAc,GAC3BF,MAAMG,OAAO,GACb,uBACL,CAAC;QAEN;IACF;AACF;AAWO,SAASxB,uBACdyB,SAAoB,EACpBrB,gBAA0C;IAE1C,MAAM,EAAEsB,IAAI,EAAE,GAAGD;IACjB,IAAIC,SAASC,kBAAQ,CAACC,KAAK,EAAE;QAC3BH,UAAUI,QAAQ,CAACC,OAAO,CAAC,CAACC,OAC1B/B,uBAAuB+B,MAAM3B;IAEjC;IAEA,IAAIsB,SAASC,kBAAQ,CAACK,IAAI,EAAE;QAC1BjC,kBAAkB0B,UAAUQ,KAAK,EAAE7B;IACrC;AACF"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "validateFetchedSnap", {
6
- enumerable: true,
7
- get: function() {
8
- return validateFetchedSnap;
9
- }
10
- });
11
- const _icon = require("./icon");
12
- const _localization = require("./localization");
13
- const _validation = require("./manifest/validation");
14
- const _snaps = require("./snaps");
15
- async function validateFetchedSnap(files) {
16
- (0, _validation.assertIsSnapManifest)(files.manifest.result);
17
- await (0, _snaps.validateSnapShasum)(files);
18
- (0, _localization.validateSnapManifestLocalizations)(files.manifest.result, files.localizationFiles.map((file)=>file.result));
19
- if (files.svgIcon) {
20
- (0, _icon.assertIsSnapIcon)(files.svgIcon);
21
- }
22
- }
23
-
24
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/validation.ts"],"sourcesContent":["import { assertIsSnapIcon } from './icon';\nimport { validateSnapManifestLocalizations } from './localization';\nimport { assertIsSnapManifest } from './manifest/validation';\nimport { validateSnapShasum } from './snaps';\nimport type { FetchedSnapFiles } from './types';\n\n/**\n * Validates the files contained in a fetched snap.\n *\n * @param files - All potentially included files in a fetched snap.\n * @throws If any of the files are considered invalid.\n */\nexport async function validateFetchedSnap(\n files: FetchedSnapFiles,\n): Promise<void> {\n assertIsSnapManifest(files.manifest.result);\n await validateSnapShasum(files);\n validateSnapManifestLocalizations(\n files.manifest.result,\n files.localizationFiles.map((file) => file.result),\n );\n\n if (files.svgIcon) {\n assertIsSnapIcon(files.svgIcon);\n }\n}\n"],"names":["validateFetchedSnap","files","assertIsSnapManifest","manifest","result","validateSnapShasum","validateSnapManifestLocalizations","localizationFiles","map","file","svgIcon","assertIsSnapIcon"],"mappings":";;;;+BAYsBA;;;eAAAA;;;sBAZW;8BACiB;4BACb;uBACF;AAS5B,eAAeA,oBACpBC,KAAuB;IAEvBC,IAAAA,gCAAoB,EAACD,MAAME,QAAQ,CAACC,MAAM;IAC1C,MAAMC,IAAAA,yBAAkB,EAACJ;IACzBK,IAAAA,+CAAiC,EAC/BL,MAAME,QAAQ,CAACC,MAAM,EACrBH,MAAMM,iBAAiB,CAACC,GAAG,CAAC,CAACC,OAASA,KAAKL,MAAM;IAGnD,IAAIH,MAAMS,OAAO,EAAE;QACjBC,IAAAA,sBAAgB,EAACV,MAAMS,OAAO;IAChC;AACF"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- DEFAULT_REQUESTED_SNAP_VERSION: function() {
13
- return DEFAULT_REQUESTED_SNAP_VERSION;
14
- },
15
- getTargetVersion: function() {
16
- return getTargetVersion;
17
- },
18
- resolveVersionRange: function() {
19
- return resolveVersionRange;
20
- }
21
- });
22
- const _utils = require("@metamask/utils");
23
- const _semver = require("semver");
24
- const _superstruct = require("superstruct");
25
- const DEFAULT_REQUESTED_SNAP_VERSION = '*';
26
- function getTargetVersion(versions, versionRange) {
27
- const maxSatisfyingNonPreRelease = (0, _semver.maxSatisfying)(versions, versionRange);
28
- // By default don't use pre-release versions
29
- if (maxSatisfyingNonPreRelease) {
30
- return maxSatisfyingNonPreRelease;
31
- }
32
- // If no satisfying release version is found by default, try pre-release versions
33
- return (0, _semver.maxSatisfying)(versions, versionRange, {
34
- includePrerelease: true
35
- });
36
- }
37
- function resolveVersionRange(version) {
38
- if (version === undefined || version === 'latest') {
39
- return [
40
- undefined,
41
- DEFAULT_REQUESTED_SNAP_VERSION
42
- ];
43
- }
44
- return (0, _superstruct.validate)(version, _utils.VersionRangeStruct);
45
- }
46
-
47
- //# sourceMappingURL=versions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/versions.ts"],"sourcesContent":["import type { Json, SemVerVersion, SemVerRange } from '@metamask/utils';\nimport { VersionRangeStruct } from '@metamask/utils';\nimport { maxSatisfying as maxSatisfyingSemver } from 'semver';\nimport { validate } from 'superstruct';\n\nexport const DEFAULT_REQUESTED_SNAP_VERSION = '*' as SemVerRange;\n\n/**\n * Return the highest version in the list that satisfies the range, or `null` if\n * none of them do. For the satisfaction check, pre-release versions will only\n * be checked if no satisfactory non-prerelease version is found first.\n *\n * @param versions - The list of version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns The highest version in the list that satisfies the range,\n * or `null` if none of them do.\n */\nexport function getTargetVersion(\n versions: SemVerVersion[],\n versionRange: SemVerRange,\n): SemVerVersion | null {\n const maxSatisfyingNonPreRelease = maxSatisfyingSemver(\n versions,\n versionRange,\n );\n\n // By default don't use pre-release versions\n if (maxSatisfyingNonPreRelease) {\n return maxSatisfyingNonPreRelease;\n }\n\n // If no satisfying release version is found by default, try pre-release versions\n return maxSatisfyingSemver(versions, versionRange, {\n includePrerelease: true,\n });\n}\n\n/**\n * Parse a version received by some subject attempting to access a snap.\n *\n * @param version - The received version value.\n * @returns `*` if the version is `undefined` or `latest\", otherwise returns\n * the specified version.\n */\nexport function resolveVersionRange(\n version?: Json,\n): [error: undefined, range: SemVerRange] | [error: Error, range: undefined] {\n if (version === undefined || version === 'latest') {\n return [undefined, DEFAULT_REQUESTED_SNAP_VERSION];\n }\n return validate(version, VersionRangeStruct);\n}\n"],"names":["DEFAULT_REQUESTED_SNAP_VERSION","getTargetVersion","resolveVersionRange","versions","versionRange","maxSatisfyingNonPreRelease","maxSatisfyingSemver","includePrerelease","version","undefined","validate","VersionRangeStruct"],"mappings":";;;;;;;;;;;IAKaA,8BAA8B;eAA9BA;;IAYGC,gBAAgB;eAAhBA;;IA2BAC,mBAAmB;eAAnBA;;;uBA3CmB;wBACkB;6BAC5B;AAElB,MAAMF,iCAAiC;AAYvC,SAASC,iBACdE,QAAyB,EACzBC,YAAyB;IAEzB,MAAMC,6BAA6BC,IAAAA,qBAAmB,EACpDH,UACAC;IAGF,4CAA4C;IAC5C,IAAIC,4BAA4B;QAC9B,OAAOA;IACT;IAEA,iFAAiF;IACjF,OAAOC,IAAAA,qBAAmB,EAACH,UAAUC,cAAc;QACjDG,mBAAmB;IACrB;AACF;AASO,SAASL,oBACdM,OAAc;IAEd,IAAIA,YAAYC,aAAaD,YAAY,UAAU;QACjD,OAAO;YAACC;YAAWT;SAA+B;IACpD;IACA,OAAOU,IAAAA,qBAAQ,EAACF,SAASG,yBAAkB;AAC7C"}
@@ -1,92 +0,0 @@
1
- // TODO(ritave): Move into separate package @metamask/vfile / @metamask/utils + @metamask/to-vfile when passes code review
2
- // TODO(ritave): Streaming vfile contents similar to vinyl maybe?
3
- // TODO(ritave): Move fixing manifest in cli and bundler plugins to write messages to vfile
4
- // similar to unified instead of throwing "ProgrammaticallyFixableErrors".
5
- //
6
- // Using https://github.com/vfile/vfile would be helpful, but they only support ESM and we need to support CommonJS.
7
- // https://github.com/gulpjs/vinyl is also good, but they normalize paths, which we can't do, because
8
- // we're calculating checksums based on original path.
9
- "use strict";
10
- Object.defineProperty(exports, "__esModule", {
11
- value: true
12
- });
13
- Object.defineProperty(exports, "VirtualFile", {
14
- enumerable: true,
15
- get: function() {
16
- return VirtualFile;
17
- }
18
- });
19
- const _utils = require("@metamask/utils");
20
- const _base = require("@scure/base");
21
- const _deepclone = require("../deep-clone");
22
- function _define_property(obj, key, value) {
23
- if (key in obj) {
24
- Object.defineProperty(obj, key, {
25
- value: value,
26
- enumerable: true,
27
- configurable: true,
28
- writable: true
29
- });
30
- } else {
31
- obj[key] = value;
32
- }
33
- return obj;
34
- }
35
- class VirtualFile {
36
- toString(encoding) {
37
- if (typeof this.value === 'string') {
38
- (0, _utils.assert)(encoding === undefined, 'Tried to encode string.');
39
- return this.value;
40
- } else if (this.value instanceof Uint8Array && encoding === 'hex') {
41
- return (0, _utils.bytesToHex)(this.value);
42
- } else if (this.value instanceof Uint8Array && encoding === 'base64') {
43
- // For large files, this is quite slow, instead use `encodeBase64()`
44
- // TODO: Use @metamask/utils for this
45
- return _base.base64.encode(this.value);
46
- }
47
- const decoder = new TextDecoder(encoding);
48
- return decoder.decode(this.value);
49
- }
50
- clone() {
51
- const vfile = new VirtualFile();
52
- if (typeof this.value === 'string') {
53
- vfile.value = this.value;
54
- } else {
55
- // deep-clone doesn't clone Buffer properly, even if it's a sub-class of Uint8Array
56
- vfile.value = this.value.slice(0);
57
- }
58
- vfile.result = (0, _deepclone.deepClone)(this.result);
59
- vfile.data = (0, _deepclone.deepClone)(this.data);
60
- vfile.path = this.path;
61
- return vfile;
62
- }
63
- constructor(value){
64
- _define_property(this, "value", void 0);
65
- _define_property(this, "result", void 0);
66
- _define_property(this, "data", void 0);
67
- _define_property(this, "path", void 0);
68
- let options;
69
- if (typeof value === 'string' || value instanceof Uint8Array) {
70
- options = {
71
- value
72
- };
73
- } else {
74
- options = value;
75
- }
76
- this.value = options?.value ?? '';
77
- // This situations happens when there's no .result used,
78
- // we expect the file to have default generic in that situation:
79
- // VirtualFile<unknown> which will handle undefined properly
80
- //
81
- // While not 100% type safe, it'll be way less frustrating to work with.
82
- // The alternative would be to have VirtualFile.result be Result | undefined
83
- // and that would result in needing to branch out and check in all situations.
84
- //
85
- // In short, optimizing for most common use case.
86
- this.result = options?.result ?? undefined;
87
- this.data = options?.data ?? {};
88
- this.path = options?.path ?? '/';
89
- }
90
- }
91
-
92
- //# sourceMappingURL=VirtualFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/virtual-file/VirtualFile.ts"],"sourcesContent":["// TODO(ritave): Move into separate package @metamask/vfile / @metamask/utils + @metamask/to-vfile when passes code review\n// TODO(ritave): Streaming vfile contents similar to vinyl maybe?\n// TODO(ritave): Move fixing manifest in cli and bundler plugins to write messages to vfile\n// similar to unified instead of throwing \"ProgrammaticallyFixableErrors\".\n//\n// Using https://github.com/vfile/vfile would be helpful, but they only support ESM and we need to support CommonJS.\n// https://github.com/gulpjs/vinyl is also good, but they normalize paths, which we can't do, because\n// we're calculating checksums based on original path.\nimport { assert, bytesToHex } from '@metamask/utils';\nimport { base64 } from '@scure/base';\n\nimport { deepClone } from '../deep-clone';\n\n/**\n * This map registers the type of the {@link VirtualFile.data} key of a {@link VirtualFile}.\n *\n * This type can be augmented to register custom `data` types.\n *\n * @example\n * declare module '@metamask/snaps-utils' {\n * interface DataMap {\n * // `file.data.name` is typed as `string`\n * name: string\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-interface\nexport interface DataMap {}\n\nexport type Value = string | Uint8Array;\nexport type Compatible<Result = unknown> =\n | string\n | Uint8Array\n | Options<Result>;\nexport type Data = Record<string, unknown> & Partial<DataMap>;\nexport type Options<Result = unknown> = {\n value: Value;\n path?: string;\n data?: Data;\n result?: Result;\n};\n\nexport class VirtualFile<Result = unknown> {\n constructor(value?: Compatible<Result>) {\n let options: Options | undefined;\n if (typeof value === 'string' || value instanceof Uint8Array) {\n options = { value };\n } else {\n options = value;\n }\n\n this.value = options?.value ?? '';\n // This situations happens when there's no .result used,\n // we expect the file to have default generic in that situation:\n // VirtualFile<unknown> which will handle undefined properly\n //\n // While not 100% type safe, it'll be way less frustrating to work with.\n // The alternative would be to have VirtualFile.result be Result | undefined\n // and that would result in needing to branch out and check in all situations.\n //\n // In short, optimizing for most common use case.\n this.result = options?.result ?? (undefined as any);\n this.data = options?.data ?? {};\n this.path = options?.path ?? '/';\n }\n\n value: Value;\n\n result: Result;\n\n data: Data;\n\n path: string;\n\n toString(encoding?: string) {\n if (typeof this.value === 'string') {\n assert(encoding === undefined, 'Tried to encode string.');\n return this.value;\n } else if (this.value instanceof Uint8Array && encoding === 'hex') {\n return bytesToHex(this.value);\n } else if (this.value instanceof Uint8Array && encoding === 'base64') {\n // For large files, this is quite slow, instead use `encodeBase64()`\n // TODO: Use @metamask/utils for this\n return base64.encode(this.value);\n }\n const decoder = new TextDecoder(encoding);\n return decoder.decode(this.value);\n }\n\n clone() {\n const vfile = new VirtualFile<Result>();\n if (typeof this.value === 'string') {\n vfile.value = this.value;\n } else {\n // deep-clone doesn't clone Buffer properly, even if it's a sub-class of Uint8Array\n vfile.value = this.value.slice(0);\n }\n vfile.result = deepClone(this.result);\n vfile.data = deepClone(this.data);\n vfile.path = this.path;\n return vfile;\n }\n}\n"],"names":["VirtualFile","toString","encoding","value","assert","undefined","Uint8Array","bytesToHex","base64","encode","decoder","TextDecoder","decode","clone","vfile","slice","result","deepClone","data","path","constructor","options"],"mappings":"AAAA,0HAA0H;AAC1H,iEAAiE;AACjE,2FAA2F;AAC3F,wFAAwF;AACxF,EAAE;AACF,oHAAoH;AACpH,qGAAqG;AACrG,sDAAsD;;;;;+BAmCzCA;;;eAAAA;;;uBAlCsB;sBACZ;2BAEG;;;;;;;;;;;;;;AA+BnB,MAAMA;IAgCXC,SAASC,QAAiB,EAAE;QAC1B,IAAI,OAAO,IAAI,CAACC,KAAK,KAAK,UAAU;YAClCC,IAAAA,aAAM,EAACF,aAAaG,WAAW;YAC/B,OAAO,IAAI,CAACF,KAAK;QACnB,OAAO,IAAI,IAAI,CAACA,KAAK,YAAYG,cAAcJ,aAAa,OAAO;YACjE,OAAOK,IAAAA,iBAAU,EAAC,IAAI,CAACJ,KAAK;QAC9B,OAAO,IAAI,IAAI,CAACA,KAAK,YAAYG,cAAcJ,aAAa,UAAU;YACpE,oEAAoE;YACpE,qCAAqC;YACrC,OAAOM,YAAM,CAACC,MAAM,CAAC,IAAI,CAACN,KAAK;QACjC;QACA,MAAMO,UAAU,IAAIC,YAAYT;QAChC,OAAOQ,QAAQE,MAAM,CAAC,IAAI,CAACT,KAAK;IAClC;IAEAU,QAAQ;QACN,MAAMC,QAAQ,IAAId;QAClB,IAAI,OAAO,IAAI,CAACG,KAAK,KAAK,UAAU;YAClCW,MAAMX,KAAK,GAAG,IAAI,CAACA,KAAK;QAC1B,OAAO;YACL,mFAAmF;YACnFW,MAAMX,KAAK,GAAG,IAAI,CAACA,KAAK,CAACY,KAAK,CAAC;QACjC;QACAD,MAAME,MAAM,GAAGC,IAAAA,oBAAS,EAAC,IAAI,CAACD,MAAM;QACpCF,MAAMI,IAAI,GAAGD,IAAAA,oBAAS,EAAC,IAAI,CAACC,IAAI;QAChCJ,MAAMK,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,OAAOL;IACT;IA1DAM,YAAYjB,KAA0B,CAAE;QAuBxCA,uBAAAA,SAAAA,KAAAA;QAEAa,uBAAAA,UAAAA,KAAAA;QAEAE,uBAAAA,QAAAA,KAAAA;QAEAC,uBAAAA,QAAAA,KAAAA;QA5BE,IAAIE;QACJ,IAAI,OAAOlB,UAAU,YAAYA,iBAAiBG,YAAY;YAC5De,UAAU;gBAAElB;YAAM;QACpB,OAAO;YACLkB,UAAUlB;QACZ;QAEA,IAAI,CAACA,KAAK,GAAGkB,SAASlB,SAAS;QAC/B,wDAAwD;QACxD,gEAAgE;QAChE,4DAA4D;QAC5D,EAAE;QACF,wEAAwE;QACxE,4EAA4E;QAC5E,8EAA8E;QAC9E,EAAE;QACF,iDAAiD;QACjD,IAAI,CAACa,MAAM,GAAGK,SAASL,UAAWX;QAClC,IAAI,CAACa,IAAI,GAAGG,SAASH,QAAQ,CAAC;QAC9B,IAAI,CAACC,IAAI,GAAGE,SAASF,QAAQ;IAC/B;AAsCF"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./VirtualFile"), exports);
6
- function _export_star(from, to) {
7
- Object.keys(from).forEach(function(k) {
8
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
- Object.defineProperty(to, k, {
10
- enumerable: true,
11
- get: function() {
12
- return from[k];
13
- }
14
- });
15
- }
16
- });
17
- return from;
18
- }
19
-
20
- //# sourceMappingURL=index.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/virtual-file/index.browser.ts"],"sourcesContent":["export * from './VirtualFile';\n"],"names":[],"mappings":";;;;qBAAc"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./toVirtualFile"), exports);
6
- _export_star(require("./VirtualFile"), exports);
7
- function _export_star(from, to) {
8
- Object.keys(from).forEach(function(k) {
9
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
- Object.defineProperty(to, k, {
11
- enumerable: true,
12
- get: function() {
13
- return from[k];
14
- }
15
- });
16
- }
17
- });
18
- return from;
19
- }
20
-
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/virtual-file/index.ts"],"sourcesContent":["export * from './toVirtualFile';\nexport * from './VirtualFile';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- readVirtualFile: function() {
13
- return readVirtualFile;
14
- },
15
- writeVirtualFile: function() {
16
- return writeVirtualFile;
17
- }
18
- });
19
- const _fs = require("fs");
20
- const _VirtualFile = require("./VirtualFile");
21
- async function readVirtualFile(path, encoding = null) {
22
- return new _VirtualFile.VirtualFile({
23
- path,
24
- value: await _fs.promises.readFile(path, {
25
- encoding
26
- })
27
- });
28
- }
29
- async function writeVirtualFile(vfile, options) {
30
- return _fs.promises.writeFile(vfile.path, vfile.value, options);
31
- }
32
-
33
- //# sourceMappingURL=toVirtualFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/virtual-file/toVirtualFile.ts"],"sourcesContent":["import { promises as fsPromises } from 'fs';\n\nimport { VirtualFile } from './VirtualFile';\n\n/**\n * Reads a file from filesystem and creates a vfile.\n *\n * @param path - Filesystem path to load the contents from.\n * @param encoding - Optional encoding to pass down to fs.readFile.\n * @returns Promise returning VFile with loaded file contents.\n */\nexport async function readVirtualFile(\n path: string,\n encoding: BufferEncoding | null = null,\n) {\n return new VirtualFile({\n path,\n value: await fsPromises.readFile(path, { encoding }),\n });\n}\n\ntype WriteVFileOptions = Exclude<\n Parameters<(typeof fsPromises)['writeFile']>[2],\n undefined\n>;\n\n/**\n * Writes vfile to filesystem.\n *\n * @param vfile - The vfile to write.\n * @param options - Options to pass down to fs.writeFile.\n */\nexport async function writeVirtualFile(\n vfile: VirtualFile,\n options?: WriteVFileOptions,\n) {\n return fsPromises.writeFile(vfile.path, vfile.value, options);\n}\n"],"names":["readVirtualFile","writeVirtualFile","path","encoding","VirtualFile","value","fsPromises","readFile","vfile","options","writeFile"],"mappings":";;;;;;;;;;;IAWsBA,eAAe;eAAfA;;IAqBAC,gBAAgB;eAAhBA;;;oBAhCiB;6BAEX;AASrB,eAAeD,gBACpBE,IAAY,EACZC,WAAkC,IAAI;IAEtC,OAAO,IAAIC,wBAAW,CAAC;QACrBF;QACAG,OAAO,MAAMC,YAAU,CAACC,QAAQ,CAACL,MAAM;YAAEC;QAAS;IACpD;AACF;AAaO,eAAeF,iBACpBO,KAAkB,EAClBC,OAA2B;IAE3B,OAAOH,YAAU,CAACI,SAAS,CAACF,MAAMN,IAAI,EAAEM,MAAMH,KAAK,EAAEI;AACvD"}
package/dist/esm/array.js DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Checks if array `a` is equal to array `b`. Note that this does not do a deep
3
- * equality check. It only checks if the arrays are the same length and if each
4
- * element in `a` is equal to (`===`) the corresponding element in `b`.
5
- *
6
- * @param a - The first array to compare.
7
- * @param b - The second array to compare.
8
- * @returns `true` if the arrays are equal, `false` otherwise.
9
- */ export function isEqual(a, b) {
10
- return a.length === b.length && a.every((value, index)=>value === b[index]);
11
- }
12
-
13
- //# sourceMappingURL=array.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/array.ts"],"sourcesContent":["/**\n * Checks if array `a` is equal to array `b`. Note that this does not do a deep\n * equality check. It only checks if the arrays are the same length and if each\n * element in `a` is equal to (`===`) the corresponding element in `b`.\n *\n * @param a - The first array to compare.\n * @param b - The second array to compare.\n * @returns `true` if the arrays are equal, `false` otherwise.\n */\nexport function isEqual(a: unknown[], b: unknown[]): boolean {\n return a.length === b.length && a.every((value, index) => value === b[index]);\n}\n"],"names":["isEqual","a","b","length","every","value","index"],"mappings":"AAAA;;;;;;;;CAQC,GACD,OAAO,SAASA,QAAQC,CAAY,EAAEC,CAAY;IAChD,OAAOD,EAAEE,MAAM,KAAKD,EAAEC,MAAM,IAAIF,EAAEG,KAAK,CAAC,CAACC,OAAOC,QAAUD,UAAUH,CAAC,CAACI,MAAM;AAC9E"}
@@ -1,23 +0,0 @@
1
- import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';
2
- import { bytesToHex, bytesToString } from '@metamask/utils';
3
- import { decodeBase64 } from './base64';
4
- /**
5
- * Re-encodes an auxiliary file if needed depending on the requested file encoding.
6
- *
7
- * @param value - The base64 value stored for the auxiliary file.
8
- * @param encoding - The chosen encoding.
9
- * @returns The file encoded in the requested encoding.
10
- */ export async function encodeAuxiliaryFile(value, encoding) {
11
- // Input is assumed to be the stored file in base64.
12
- if (encoding === AuxiliaryFileEncoding.Base64) {
13
- return value;
14
- }
15
- // TODO: Use @metamask/utils for this
16
- const decoded = await decodeBase64(value);
17
- if (encoding === AuxiliaryFileEncoding.Utf8) {
18
- return bytesToString(decoded);
19
- }
20
- return bytesToHex(decoded);
21
- }
22
-
23
- //# sourceMappingURL=auxiliary-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/auxiliary-files.ts"],"sourcesContent":["import { AuxiliaryFileEncoding } from '@metamask/snaps-sdk';\nimport { bytesToHex, bytesToString } from '@metamask/utils';\n\nimport { decodeBase64 } from './base64';\n\n/**\n * Re-encodes an auxiliary file if needed depending on the requested file encoding.\n *\n * @param value - The base64 value stored for the auxiliary file.\n * @param encoding - The chosen encoding.\n * @returns The file encoded in the requested encoding.\n */\nexport async function encodeAuxiliaryFile(\n value: string,\n encoding: AuxiliaryFileEncoding,\n) {\n // Input is assumed to be the stored file in base64.\n if (encoding === AuxiliaryFileEncoding.Base64) {\n return value;\n }\n\n // TODO: Use @metamask/utils for this\n const decoded = await decodeBase64(value);\n if (encoding === AuxiliaryFileEncoding.Utf8) {\n return bytesToString(decoded);\n }\n\n return bytesToHex(decoded);\n}\n"],"names":["AuxiliaryFileEncoding","bytesToHex","bytesToString","decodeBase64","encodeAuxiliaryFile","value","encoding","Base64","decoded","Utf8"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,sBAAsB;AAC5D,SAASC,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAE5D,SAASC,YAAY,QAAQ,WAAW;AAExC;;;;;;CAMC,GACD,OAAO,eAAeC,oBACpBC,KAAa,EACbC,QAA+B;IAE/B,oDAAoD;IACpD,IAAIA,aAAaN,sBAAsBO,MAAM,EAAE;QAC7C,OAAOF;IACT;IAEA,qCAAqC;IACrC,MAAMG,UAAU,MAAML,aAAaE;IACnC,IAAIC,aAAaN,sBAAsBS,IAAI,EAAE;QAC3C,OAAOP,cAAcM;IACvB;IAEA,OAAOP,WAAWO;AACpB"}
@@ -1,36 +0,0 @@
1
- import { bytesToBase64 } from '@metamask/utils';
2
- import { getBytes } from './bytes';
3
- /**
4
- * Provides fast, asynchronous base64 encoding.
5
- *
6
- * @param input - The input value, assumed to be coercable to bytes.
7
- * @returns A base64 string.
8
- */ export async function encodeBase64(input) {
9
- const bytes = getBytes(input);
10
- // In the browser, FileReader is much faster than bytesToBase64.
11
- if ('FileReader' in globalThis) {
12
- return await new Promise((resolve, reject)=>{
13
- const reader = Object.assign(new FileReader(), {
14
- onload: ()=>resolve(reader.result.replace('data:application/octet-stream;base64,', '')),
15
- onerror: ()=>reject(reader.error)
16
- });
17
- reader.readAsDataURL(new File([
18
- bytes
19
- ], '', {
20
- type: 'application/octet-stream'
21
- }));
22
- });
23
- }
24
- return bytesToBase64(bytes);
25
- }
26
- /**
27
- * Provides fast, asynchronous base64 decoding.
28
- *
29
- * @param base64 - A base64 string.
30
- * @returns A Uint8Array of bytes.
31
- */ export async function decodeBase64(base64) {
32
- const response = await fetch(`data:application/octet-stream;base64,${base64}`);
33
- return new Uint8Array(await response.arrayBuffer());
34
- }
35
-
36
- //# sourceMappingURL=base64.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/base64.ts"],"sourcesContent":["import { bytesToBase64 } from '@metamask/utils';\n\nimport { getBytes } from './bytes';\nimport type { VirtualFile } from './virtual-file';\n\n/**\n * Provides fast, asynchronous base64 encoding.\n *\n * @param input - The input value, assumed to be coercable to bytes.\n * @returns A base64 string.\n */\nexport async function encodeBase64(input: Uint8Array | VirtualFile | string) {\n const bytes = getBytes(input);\n // In the browser, FileReader is much faster than bytesToBase64.\n if ('FileReader' in globalThis) {\n return await new Promise((resolve, reject) => {\n const reader = Object.assign(new FileReader(), {\n onload: () =>\n resolve(\n (reader.result as string).replace(\n 'data:application/octet-stream;base64,',\n '',\n ),\n ),\n onerror: () => reject(reader.error),\n });\n reader.readAsDataURL(\n new File([bytes], '', { type: 'application/octet-stream' }),\n );\n });\n }\n return bytesToBase64(bytes);\n}\n\n/**\n * Provides fast, asynchronous base64 decoding.\n *\n * @param base64 - A base64 string.\n * @returns A Uint8Array of bytes.\n */\nexport async function decodeBase64(base64: string) {\n const response = await fetch(\n `data:application/octet-stream;base64,${base64}`,\n );\n return new Uint8Array(await response.arrayBuffer());\n}\n"],"names":["bytesToBase64","getBytes","encodeBase64","input","bytes","globalThis","Promise","resolve","reject","reader","Object","assign","FileReader","onload","result","replace","onerror","error","readAsDataURL","File","type","decodeBase64","base64","response","fetch","Uint8Array","arrayBuffer"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,QAAQ,QAAQ,UAAU;AAGnC;;;;;CAKC,GACD,OAAO,eAAeC,aAAaC,KAAwC;IACzE,MAAMC,QAAQH,SAASE;IACvB,gEAAgE;IAChE,IAAI,gBAAgBE,YAAY;QAC9B,OAAO,MAAM,IAAIC,QAAQ,CAACC,SAASC;YACjC,MAAMC,SAASC,OAAOC,MAAM,CAAC,IAAIC,cAAc;gBAC7CC,QAAQ,IACNN,QACE,AAACE,OAAOK,MAAM,CAAYC,OAAO,CAC/B,yCACA;gBAGNC,SAAS,IAAMR,OAAOC,OAAOQ,KAAK;YACpC;YACAR,OAAOS,aAAa,CAClB,IAAIC,KAAK;gBAACf;aAAM,EAAE,IAAI;gBAAEgB,MAAM;YAA2B;QAE7D;IACF;IACA,OAAOpB,cAAcI;AACvB;AAEA;;;;;CAKC,GACD,OAAO,eAAeiB,aAAaC,MAAc;IAC/C,MAAMC,WAAW,MAAMC,MACrB,CAAC,qCAAqC,EAAEF,OAAO,CAAC;IAElD,OAAO,IAAIG,WAAW,MAAMF,SAASG,WAAW;AAClD"}
package/dist/esm/bytes.js DELETED
@@ -1,18 +0,0 @@
1
- import { stringToBytes } from '@metamask/utils';
2
- import { VirtualFile } from './virtual-file';
3
- /**
4
- * Convert a bytes-like input value to a Uint8Array.
5
- *
6
- * @param bytes - A bytes-like value.
7
- * @returns The input value converted to a Uint8Array if necessary.
8
- */ export function getBytes(bytes) {
9
- // Unwrap VirtualFiles to extract the content
10
- // The content is then either a string or Uint8Array
11
- const unwrapped = bytes instanceof VirtualFile ? bytes.value : bytes;
12
- if (typeof unwrapped === 'string') {
13
- return stringToBytes(unwrapped);
14
- }
15
- return unwrapped;
16
- }
17
-
18
- //# sourceMappingURL=bytes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bytes.ts"],"sourcesContent":["import { stringToBytes } from '@metamask/utils';\n\nimport { VirtualFile } from './virtual-file';\n\n/**\n * Convert a bytes-like input value to a Uint8Array.\n *\n * @param bytes - A bytes-like value.\n * @returns The input value converted to a Uint8Array if necessary.\n */\nexport function getBytes(bytes: VirtualFile | Uint8Array | string): Uint8Array {\n // Unwrap VirtualFiles to extract the content\n // The content is then either a string or Uint8Array\n const unwrapped = bytes instanceof VirtualFile ? bytes.value : bytes;\n\n if (typeof unwrapped === 'string') {\n return stringToBytes(unwrapped);\n }\n\n return unwrapped;\n}\n"],"names":["stringToBytes","VirtualFile","getBytes","bytes","unwrapped","value"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,WAAW,QAAQ,iBAAiB;AAE7C;;;;;CAKC,GACD,OAAO,SAASC,SAASC,KAAwC;IAC/D,6CAA6C;IAC7C,oDAAoD;IACpD,MAAMC,YAAYD,iBAAiBF,cAAcE,MAAME,KAAK,GAAGF;IAE/D,IAAI,OAAOC,cAAc,UAAU;QACjC,OAAOJ,cAAcI;IACvB;IAEA,OAAOA;AACT"}
@@ -1,38 +0,0 @@
1
- export var SnapCaveatType;
2
- (function(SnapCaveatType) {
3
- SnapCaveatType[/**
4
- * Permitted derivation paths, used by `snap_getBip32Entropy`.
5
- */ "PermittedDerivationPaths"] = 'permittedDerivationPaths';
6
- SnapCaveatType[/**
7
- * Permitted coin types, used by `snap_getBip44Entropy`.
8
- */ "PermittedCoinTypes"] = 'permittedCoinTypes';
9
- SnapCaveatType[/**
10
- * Caveat specifying a snap cronjob.
11
- */ "SnapCronjob"] = 'snapCronjob';
12
- SnapCaveatType[/**
13
- * Caveat specifying access to the transaction origin, used by `endowment:transaction-insight`.
14
- */ "TransactionOrigin"] = 'transactionOrigin';
15
- SnapCaveatType[/**
16
- * Caveat specifying access to the signature origin, used by `endowment:signature-insight`.
17
- */ "SignatureOrigin"] = 'signatureOrigin';
18
- SnapCaveatType[/**
19
- * The origins that a Snap can receive JSON-RPC messages from.
20
- */ "RpcOrigin"] = 'rpcOrigin';
21
- SnapCaveatType[/**
22
- * The origins that a Snap can receive keyring messages from.
23
- */ "KeyringOrigin"] = 'keyringOrigin';
24
- SnapCaveatType[/**
25
- * Caveat specifying the snap IDs that can be interacted with.
26
- */ "SnapIds"] = 'snapIds';
27
- SnapCaveatType[/**
28
- * Caveat specifying the CAIP-2 chain IDs that a snap can service, currently limited to `endowment:name-lookup`.
29
- */ "ChainIds"] = 'chainIds';
30
- SnapCaveatType[/**
31
- * Caveat specifying the input that a name lookup snap can service, currently limited to `endowment:name-lookup`.
32
- */ "LookupMatchers"] = 'lookupMatchers';
33
- SnapCaveatType[/**
34
- * Caveat specifying the max request time for a handler endowment.
35
- */ "MaxRequestTime"] = 'maxRequestTime';
36
- })(SnapCaveatType || (SnapCaveatType = {}));
37
-
38
- //# sourceMappingURL=caveats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/caveats.ts"],"sourcesContent":["export enum SnapCaveatType {\n /**\n * Permitted derivation paths, used by `snap_getBip32Entropy`.\n */\n PermittedDerivationPaths = 'permittedDerivationPaths',\n\n /**\n * Permitted coin types, used by `snap_getBip44Entropy`.\n */\n PermittedCoinTypes = 'permittedCoinTypes',\n\n /**\n * Caveat specifying a snap cronjob.\n */\n SnapCronjob = 'snapCronjob',\n\n /**\n * Caveat specifying access to the transaction origin, used by `endowment:transaction-insight`.\n */\n TransactionOrigin = 'transactionOrigin',\n\n /**\n * Caveat specifying access to the signature origin, used by `endowment:signature-insight`.\n */\n SignatureOrigin = 'signatureOrigin',\n\n /**\n * The origins that a Snap can receive JSON-RPC messages from.\n */\n RpcOrigin = 'rpcOrigin',\n\n /**\n * The origins that a Snap can receive keyring messages from.\n */\n KeyringOrigin = 'keyringOrigin',\n\n /**\n * Caveat specifying the snap IDs that can be interacted with.\n */\n SnapIds = 'snapIds',\n\n /**\n * Caveat specifying the CAIP-2 chain IDs that a snap can service, currently limited to `endowment:name-lookup`.\n */\n ChainIds = 'chainIds',\n\n /**\n * Caveat specifying the input that a name lookup snap can service, currently limited to `endowment:name-lookup`.\n */\n LookupMatchers = 'lookupMatchers',\n\n /**\n * Caveat specifying the max request time for a handler endowment.\n */\n MaxRequestTime = 'maxRequestTime',\n}\n"],"names":["SnapCaveatType","PermittedDerivationPaths","PermittedCoinTypes","SnapCronjob","TransactionOrigin","SignatureOrigin","RpcOrigin","KeyringOrigin","SnapIds","ChainIds","LookupMatchers","MaxRequestTime"],"mappings":"WAAO;UAAKA,cAAc;IAAdA,eACV;;GAEC,GACDC,8BAA2B;IAJjBD,eAMV;;GAEC,GACDE,wBAAqB;IATXF,eAWV;;GAEC,GACDG,iBAAc;IAdJH,eAgBV;;GAEC,GACDI,uBAAoB;IAnBVJ,eAqBV;;GAEC,GACDK,qBAAkB;IAxBRL,eA0BV;;GAEC,GACDM,eAAY;IA7BFN,eA+BV;;GAEC,GACDO,mBAAgB;IAlCNP,eAoCV;;GAEC,GACDQ,aAAU;IAvCAR,eAyCV;;GAEC,GACDS,cAAW;IA5CDT,eA8CV;;GAEC,GACDU,oBAAiB;IAjDPV,eAmDV;;GAEC,GACDW,oBAAiB;GAtDPX,mBAAAA"}
@@ -1,41 +0,0 @@
1
- import { assert, concatBytes } from '@metamask/utils';
2
- import { sha256 } from '@noble/hashes/sha256';
3
- import { getBytes } from './bytes';
4
- /**
5
- * Calculates checksum for a single byte array.
6
- *
7
- * @param bytes - The byte array to calculate the checksum for.
8
- * @returns A single sha-256 checksum.
9
- */ export async function checksum(bytes) {
10
- const value = getBytes(bytes);
11
- // Use crypto.subtle.digest whenever possible as it is faster.
12
- if ('crypto' in globalThis && typeof globalThis.crypto === 'object' && crypto.subtle?.digest) {
13
- return new Uint8Array(await crypto.subtle.digest('SHA-256', value));
14
- }
15
- return sha256(value);
16
- }
17
- /**
18
- * Calculates checksum over multiple files in a reproducible way.
19
- *
20
- * 1. Sort all the files by their paths.
21
- * 2. Calculate sha-256 checksum of each file separately.
22
- * 3. Concatenate all the checksums into one buffer and sha-256 that buffer.
23
- *
24
- * The sorting of paths is done using {@link https://tc39.es/ecma262/#sec-islessthan UTF-16 Code Units}.
25
- *
26
- * @param files - The files over which to calculate the checksum.
27
- * @returns A single sha-256 checksum.
28
- */ export async function checksumFiles(files) {
29
- const checksums = await Promise.all([
30
- ...files
31
- ].sort((a, b)=>{
32
- assert(a.path !== b.path, 'Tried to sort files with non-unique paths.');
33
- if (a.path < b.path) {
34
- return -1;
35
- }
36
- return 1;
37
- }).map(async (file)=>checksum(file)));
38
- return checksum(concatBytes(checksums));
39
- }
40
-
41
- //# sourceMappingURL=checksum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/checksum.ts"],"sourcesContent":["import { assert, concatBytes } from '@metamask/utils';\nimport { sha256 } from '@noble/hashes/sha256';\n\nimport { getBytes } from './bytes';\nimport type { VirtualFile } from './virtual-file/VirtualFile';\n\n/**\n * Calculates checksum for a single byte array.\n *\n * @param bytes - The byte array to calculate the checksum for.\n * @returns A single sha-256 checksum.\n */\nexport async function checksum(\n bytes: VirtualFile | Uint8Array | string,\n): Promise<Uint8Array> {\n const value = getBytes(bytes);\n // Use crypto.subtle.digest whenever possible as it is faster.\n if (\n 'crypto' in globalThis &&\n typeof globalThis.crypto === 'object' &&\n crypto.subtle?.digest\n ) {\n return new Uint8Array(await crypto.subtle.digest('SHA-256', value));\n }\n return sha256(value);\n}\n\n/**\n * Calculates checksum over multiple files in a reproducible way.\n *\n * 1. Sort all the files by their paths.\n * 2. Calculate sha-256 checksum of each file separately.\n * 3. Concatenate all the checksums into one buffer and sha-256 that buffer.\n *\n * The sorting of paths is done using {@link https://tc39.es/ecma262/#sec-islessthan UTF-16 Code Units}.\n *\n * @param files - The files over which to calculate the checksum.\n * @returns A single sha-256 checksum.\n */\nexport async function checksumFiles(files: VirtualFile[]) {\n const checksums = await Promise.all(\n [...files]\n .sort((a, b) => {\n assert(a.path !== b.path, 'Tried to sort files with non-unique paths.');\n if (a.path < b.path) {\n return -1;\n }\n return 1;\n })\n .map(async (file) => checksum(file)),\n );\n\n return checksum(concatBytes(checksums));\n}\n"],"names":["assert","concatBytes","sha256","getBytes","checksum","bytes","value","globalThis","crypto","subtle","digest","Uint8Array","checksumFiles","files","checksums","Promise","all","sort","a","b","path","map","file"],"mappings":"AAAA,SAASA,MAAM,EAAEC,WAAW,QAAQ,kBAAkB;AACtD,SAASC,MAAM,QAAQ,uBAAuB;AAE9C,SAASC,QAAQ,QAAQ,UAAU;AAGnC;;;;;CAKC,GACD,OAAO,eAAeC,SACpBC,KAAwC;IAExC,MAAMC,QAAQH,SAASE;IACvB,8DAA8D;IAC9D,IACE,YAAYE,cACZ,OAAOA,WAAWC,MAAM,KAAK,YAC7BA,OAAOC,MAAM,EAAEC,QACf;QACA,OAAO,IAAIC,WAAW,MAAMH,OAAOC,MAAM,CAACC,MAAM,CAAC,WAAWJ;IAC9D;IACA,OAAOJ,OAAOI;AAChB;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,eAAeM,cAAcC,KAAoB;IACtD,MAAMC,YAAY,MAAMC,QAAQC,GAAG,CACjC;WAAIH;KAAM,CACPI,IAAI,CAAC,CAACC,GAAGC;QACRnB,OAAOkB,EAAEE,IAAI,KAAKD,EAAEC,IAAI,EAAE;QAC1B,IAAIF,EAAEE,IAAI,GAAGD,EAAEC,IAAI,EAAE;YACnB,OAAO,CAAC;QACV;QACA,OAAO;IACT,GACCC,GAAG,CAAC,OAAOC,OAASlB,SAASkB;IAGlC,OAAOlB,SAASH,YAAYa;AAC9B"}