@metamask/snaps-utils 0.38.0-flask.1 → 1.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 (268) hide show
  1. package/CHANGELOG.md +222 -11
  2. package/dist/{esm/array.js → array.js} +7 -3
  3. package/dist/array.js.map +1 -0
  4. package/dist/{types/caveats.d.ts → caveats.d.ts} +4 -0
  5. package/dist/caveats.js +35 -0
  6. package/dist/caveats.js.map +1 -0
  7. package/dist/checksum.js +42 -0
  8. package/dist/checksum.js.map +1 -0
  9. package/dist/{types/cronjob.d.ts → cronjob.d.ts} +1 -1
  10. package/dist/cronjob.js +71 -0
  11. package/dist/cronjob.js.map +1 -0
  12. package/dist/deep-clone.js +9 -0
  13. package/dist/deep-clone.js.map +1 -0
  14. package/dist/{esm/default-endowments.js → default-endowments.js} +6 -3
  15. package/dist/default-endowments.js.map +1 -0
  16. package/dist/entropy.js +8 -0
  17. package/dist/entropy.js.map +1 -0
  18. package/dist/{cjs/eval-worker.js → eval-worker.js} +21 -22
  19. package/dist/eval-worker.js.map +1 -0
  20. package/dist/{types/eval.d.ts → eval.d.ts} +1 -9
  21. package/dist/eval.js +27 -0
  22. package/dist/eval.js.map +1 -0
  23. package/dist/{types/fs.d.ts → fs.d.ts} +2 -2
  24. package/dist/{esm/fs.js → fs.js} +56 -33
  25. package/dist/fs.js.map +1 -0
  26. package/dist/handlers.d.ts +105 -0
  27. package/dist/handlers.js +3 -0
  28. package/dist/handlers.js.map +1 -0
  29. package/dist/{types/iframe.d.ts → iframe.d.ts} +2 -3
  30. package/dist/{esm/iframe.js → iframe.js} +18 -16
  31. package/dist/iframe.js.map +1 -0
  32. package/dist/iframe.test.browser.js +15 -0
  33. package/dist/iframe.test.browser.js.map +1 -0
  34. package/dist/{types/index.browser.d.ts → index.browser.d.ts} +1 -5
  35. package/dist/index.browser.js +37 -0
  36. package/dist/index.browser.js.map +1 -0
  37. package/dist/{types/index.d.ts → index.d.ts} +1 -5
  38. package/dist/index.executionenv.js +22 -0
  39. package/dist/index.executionenv.js.map +1 -0
  40. package/dist/index.js +42 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/{types/json-rpc.d.ts → json-rpc.d.ts} +2 -2
  43. package/dist/json-rpc.js +46 -0
  44. package/dist/json-rpc.js.map +1 -0
  45. package/dist/json.d.ts +9 -0
  46. package/dist/json.js +18 -0
  47. package/dist/json.js.map +1 -0
  48. package/dist/{esm/logging.js → logging.js} +14 -6
  49. package/dist/logging.js.map +1 -0
  50. package/dist/manifest/index.browser.js +18 -0
  51. package/dist/manifest/index.browser.js.map +1 -0
  52. package/dist/manifest/index.js +19 -0
  53. package/dist/manifest/index.js.map +1 -0
  54. package/dist/{types/manifest → manifest}/manifest.d.ts +4 -6
  55. package/dist/{esm/manifest → manifest}/manifest.js +115 -101
  56. package/dist/manifest/manifest.js.map +1 -0
  57. package/dist/{types/manifest → manifest}/validation.d.ts +76 -34
  58. package/dist/manifest/validation.js +141 -0
  59. package/dist/manifest/validation.js.map +1 -0
  60. package/dist/{esm/mock.js → mock.js} +40 -42
  61. package/dist/mock.js.map +1 -0
  62. package/dist/namespace.d.ts +275 -0
  63. package/dist/namespace.js +225 -0
  64. package/dist/namespace.js.map +1 -0
  65. package/dist/notification.d.ts +66 -0
  66. package/dist/notification.js +58 -0
  67. package/dist/notification.js.map +1 -0
  68. package/dist/{types/npm.d.ts → npm.d.ts} +3 -2
  69. package/dist/npm.js +74 -0
  70. package/dist/npm.js.map +1 -0
  71. package/dist/path.js +21 -0
  72. package/dist/path.js.map +1 -0
  73. package/dist/{esm/post-process.js → post-process.js} +99 -110
  74. package/dist/post-process.js.map +1 -0
  75. package/dist/{types/snaps.d.ts → snaps.d.ts} +9 -17
  76. package/dist/snaps.js +202 -0
  77. package/dist/snaps.js.map +1 -0
  78. package/dist/{types/types.d.ts → types.d.ts} +22 -15
  79. package/dist/types.js +103 -0
  80. package/dist/types.js.map +1 -0
  81. package/dist/{types/versions.d.ts → versions.d.ts} +1 -1
  82. package/dist/{esm/versions.js → versions.js} +18 -15
  83. package/dist/versions.js.map +1 -0
  84. package/dist/{esm/virtual-file → virtual-file}/VirtualFile.js +33 -47
  85. package/dist/virtual-file/VirtualFile.js.map +1 -0
  86. package/dist/virtual-file/index.browser.js +18 -0
  87. package/dist/virtual-file/index.browser.js.map +1 -0
  88. package/dist/virtual-file/index.js +19 -0
  89. package/dist/virtual-file/index.js.map +1 -0
  90. package/dist/virtual-file/toVirtualFile.js +30 -0
  91. package/dist/virtual-file/toVirtualFile.js.map +1 -0
  92. package/package.json +40 -59
  93. package/dist/cjs/array.js +0 -23
  94. package/dist/cjs/array.js.map +0 -1
  95. package/dist/cjs/caveats.js +0 -33
  96. package/dist/cjs/caveats.js.map +0 -1
  97. package/dist/cjs/checksum.js +0 -38
  98. package/dist/cjs/checksum.js.map +0 -1
  99. package/dist/cjs/cronjob.js +0 -84
  100. package/dist/cjs/cronjob.js.map +0 -1
  101. package/dist/cjs/deep-clone.js +0 -22
  102. package/dist/cjs/deep-clone.js.map +0 -1
  103. package/dist/cjs/default-endowments.js +0 -49
  104. package/dist/cjs/default-endowments.js.map +0 -1
  105. package/dist/cjs/entropy.js +0 -23
  106. package/dist/cjs/entropy.js.map +0 -1
  107. package/dist/cjs/enum.js +0 -16
  108. package/dist/cjs/enum.js.map +0 -1
  109. package/dist/cjs/errors.js +0 -19
  110. package/dist/cjs/errors.js.map +0 -1
  111. package/dist/cjs/eval-worker.js.map +0 -1
  112. package/dist/cjs/eval.js +0 -77
  113. package/dist/cjs/eval.js.map +0 -1
  114. package/dist/cjs/fs.js +0 -126
  115. package/dist/cjs/fs.js.map +0 -1
  116. package/dist/cjs/handlers.js +0 -65
  117. package/dist/cjs/handlers.js.map +0 -1
  118. package/dist/cjs/icon.js +0 -37
  119. package/dist/cjs/icon.js.map +0 -1
  120. package/dist/cjs/iframe.js +0 -59
  121. package/dist/cjs/iframe.js.map +0 -1
  122. package/dist/cjs/index.browser.js +0 -43
  123. package/dist/cjs/index.browser.js.map +0 -1
  124. package/dist/cjs/index.executionenv.js +0 -24
  125. package/dist/cjs/index.executionenv.js.map +0 -1
  126. package/dist/cjs/index.js +0 -48
  127. package/dist/cjs/index.js.map +0 -1
  128. package/dist/cjs/json-rpc.js +0 -46
  129. package/dist/cjs/json-rpc.js.map +0 -1
  130. package/dist/cjs/json.js +0 -16
  131. package/dist/cjs/json.js.map +0 -1
  132. package/dist/cjs/logging.js +0 -40
  133. package/dist/cjs/logging.js.map +0 -1
  134. package/dist/cjs/manifest/index.browser.js +0 -20
  135. package/dist/cjs/manifest/index.browser.js.map +0 -1
  136. package/dist/cjs/manifest/index.js +0 -21
  137. package/dist/cjs/manifest/index.js.map +0 -1
  138. package/dist/cjs/manifest/manifest.js +0 -239
  139. package/dist/cjs/manifest/manifest.js.map +0 -1
  140. package/dist/cjs/manifest/validation.js +0 -183
  141. package/dist/cjs/manifest/validation.js.map +0 -1
  142. package/dist/cjs/mock.js +0 -128
  143. package/dist/cjs/mock.js.map +0 -1
  144. package/dist/cjs/namespace.js +0 -124
  145. package/dist/cjs/namespace.js.map +0 -1
  146. package/dist/cjs/npm.js +0 -81
  147. package/dist/cjs/npm.js.map +0 -1
  148. package/dist/cjs/path.js +0 -21
  149. package/dist/cjs/path.js.map +0 -1
  150. package/dist/cjs/post-process.js +0 -328
  151. package/dist/cjs/post-process.js.map +0 -1
  152. package/dist/cjs/snaps.js +0 -230
  153. package/dist/cjs/snaps.js.map +0 -1
  154. package/dist/cjs/strings.js +0 -21
  155. package/dist/cjs/strings.js.map +0 -1
  156. package/dist/cjs/structs.js +0 -163
  157. package/dist/cjs/structs.js.map +0 -1
  158. package/dist/cjs/types.js +0 -109
  159. package/dist/cjs/types.js.map +0 -1
  160. package/dist/cjs/validation.js +0 -22
  161. package/dist/cjs/validation.js.map +0 -1
  162. package/dist/cjs/versions.js +0 -47
  163. package/dist/cjs/versions.js.map +0 -1
  164. package/dist/cjs/virtual-file/VirtualFile.js +0 -85
  165. package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
  166. package/dist/cjs/virtual-file/index.browser.js +0 -20
  167. package/dist/cjs/virtual-file/index.browser.js.map +0 -1
  168. package/dist/cjs/virtual-file/index.js +0 -21
  169. package/dist/cjs/virtual-file/index.js.map +0 -1
  170. package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
  171. package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
  172. package/dist/esm/array.js.map +0 -1
  173. package/dist/esm/caveats.js +0 -23
  174. package/dist/esm/caveats.js.map +0 -1
  175. package/dist/esm/checksum.js +0 -36
  176. package/dist/esm/checksum.js.map +0 -1
  177. package/dist/esm/cronjob.js +0 -66
  178. package/dist/esm/cronjob.js.map +0 -1
  179. package/dist/esm/deep-clone.js +0 -7
  180. package/dist/esm/deep-clone.js.map +0 -1
  181. package/dist/esm/default-endowments.js.map +0 -1
  182. package/dist/esm/entropy.js +0 -6
  183. package/dist/esm/entropy.js.map +0 -1
  184. package/dist/esm/enum.js +0 -12
  185. package/dist/esm/enum.js.map +0 -1
  186. package/dist/esm/errors.js +0 -17
  187. package/dist/esm/errors.js.map +0 -1
  188. package/dist/esm/eval-worker.js +0 -47
  189. package/dist/esm/eval-worker.js.map +0 -1
  190. package/dist/esm/eval.js +0 -65
  191. package/dist/esm/eval.js.map +0 -1
  192. package/dist/esm/fs.js.map +0 -1
  193. package/dist/esm/handlers.js +0 -47
  194. package/dist/esm/handlers.js.map +0 -1
  195. package/dist/esm/icon.js +0 -11
  196. package/dist/esm/icon.js.map +0 -1
  197. package/dist/esm/iframe.js.map +0 -1
  198. package/dist/esm/index.browser.js +0 -26
  199. package/dist/esm/index.browser.js.map +0 -1
  200. package/dist/esm/index.executionenv.js +0 -7
  201. package/dist/esm/index.executionenv.js.map +0 -1
  202. package/dist/esm/index.js +0 -31
  203. package/dist/esm/index.js.map +0 -1
  204. package/dist/esm/json-rpc.js +0 -39
  205. package/dist/esm/json-rpc.js.map +0 -1
  206. package/dist/esm/json.js +0 -17
  207. package/dist/esm/json.js.map +0 -1
  208. package/dist/esm/logging.js.map +0 -1
  209. package/dist/esm/manifest/index.browser.js +0 -3
  210. package/dist/esm/manifest/index.browser.js.map +0 -1
  211. package/dist/esm/manifest/index.js +0 -4
  212. package/dist/esm/manifest/index.js.map +0 -1
  213. package/dist/esm/manifest/manifest.js.map +0 -1
  214. package/dist/esm/manifest/validation.js +0 -152
  215. package/dist/esm/manifest/validation.js.map +0 -1
  216. package/dist/esm/mock.js.map +0 -1
  217. package/dist/esm/namespace.js +0 -110
  218. package/dist/esm/namespace.js.map +0 -1
  219. package/dist/esm/npm.js +0 -70
  220. package/dist/esm/npm.js.map +0 -1
  221. package/dist/esm/path.js +0 -17
  222. package/dist/esm/path.js.map +0 -1
  223. package/dist/esm/post-process.js.map +0 -1
  224. package/dist/esm/snaps.js +0 -215
  225. package/dist/esm/snaps.js.map +0 -1
  226. package/dist/esm/strings.js +0 -11
  227. package/dist/esm/strings.js.map +0 -1
  228. package/dist/esm/structs.js +0 -230
  229. package/dist/esm/structs.js.map +0 -1
  230. package/dist/esm/types.js +0 -80
  231. package/dist/esm/types.js.map +0 -1
  232. package/dist/esm/validation.js +0 -17
  233. package/dist/esm/validation.js.map +0 -1
  234. package/dist/esm/versions.js.map +0 -1
  235. package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
  236. package/dist/esm/virtual-file/index.browser.js +0 -3
  237. package/dist/esm/virtual-file/index.browser.js.map +0 -1
  238. package/dist/esm/virtual-file/index.js +0 -4
  239. package/dist/esm/virtual-file/index.js.map +0 -1
  240. package/dist/esm/virtual-file/toVirtualFile.js +0 -26
  241. package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
  242. package/dist/types/enum.d.ts +0 -30
  243. package/dist/types/errors.d.ts +0 -10
  244. package/dist/types/handlers.d.ts +0 -144
  245. package/dist/types/icon.d.ts +0 -4
  246. package/dist/types/json.d.ts +0 -13
  247. package/dist/types/namespace.d.ts +0 -124
  248. package/dist/types/strings.d.ts +0 -8
  249. package/dist/types/structs.d.ts +0 -158
  250. package/dist/types/validation.d.ts +0 -8
  251. /package/dist/{types/array.d.ts → array.d.ts} +0 -0
  252. /package/dist/{types/checksum.d.ts → checksum.d.ts} +0 -0
  253. /package/dist/{types/deep-clone.d.ts → deep-clone.d.ts} +0 -0
  254. /package/dist/{types/default-endowments.d.ts → default-endowments.d.ts} +0 -0
  255. /package/dist/{types/entropy.d.ts → entropy.d.ts} +0 -0
  256. /package/dist/{types/eval-worker.d.ts → eval-worker.d.ts} +0 -0
  257. /package/dist/{types/iframe.test.browser.d.ts → iframe.test.browser.d.ts} +0 -0
  258. /package/dist/{types/index.executionenv.d.ts → index.executionenv.d.ts} +0 -0
  259. /package/dist/{types/logging.d.ts → logging.d.ts} +0 -0
  260. /package/dist/{types/manifest → manifest}/index.browser.d.ts +0 -0
  261. /package/dist/{types/manifest → manifest}/index.d.ts +0 -0
  262. /package/dist/{types/mock.d.ts → mock.d.ts} +0 -0
  263. /package/dist/{types/path.d.ts → path.d.ts} +0 -0
  264. /package/dist/{types/post-process.d.ts → post-process.d.ts} +0 -0
  265. /package/dist/{types/virtual-file → virtual-file}/VirtualFile.d.ts +0 -0
  266. /package/dist/{types/virtual-file → virtual-file}/index.browser.d.ts +0 -0
  267. /package/dist/{types/virtual-file → virtual-file}/index.d.ts +0 -0
  268. /package/dist/{types/virtual-file → virtual-file}/toVirtualFile.d.ts +0 -0
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./toVirtualFile"), exports);
18
+ __exportStar(require("./VirtualFile"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/virtual-file/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,gDAA8B","sourcesContent":["export * from './toVirtualFile';\nexport * from './VirtualFile';\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeVirtualFile = exports.readVirtualFile = void 0;
4
+ const fs_1 = require("fs");
5
+ const VirtualFile_1 = require("./VirtualFile");
6
+ /**
7
+ * Reads a file from filesystem and creates a vfile.
8
+ *
9
+ * @param path - Filesystem path to load the contents from.
10
+ * @param encoding - Optional encoding to pass down to fs.readFile.
11
+ * @returns Promise returning VFile with loaded file contents.
12
+ */
13
+ async function readVirtualFile(path, encoding = null) {
14
+ return new VirtualFile_1.VirtualFile({
15
+ path,
16
+ value: await fs_1.promises.readFile(path, { encoding }),
17
+ });
18
+ }
19
+ exports.readVirtualFile = readVirtualFile;
20
+ /**
21
+ * Writes vfile to filesystem.
22
+ *
23
+ * @param vfile - The vfile to write.
24
+ * @param options - Options to pass down to fs.writeFile.
25
+ */
26
+ async function writeVirtualFile(vfile, options) {
27
+ return fs_1.promises.writeFile(vfile.path, vfile.value, options);
28
+ }
29
+ exports.writeVirtualFile = writeVirtualFile;
30
+ //# sourceMappingURL=toVirtualFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toVirtualFile.js","sourceRoot":"","sources":["../../src/virtual-file/toVirtualFile.ts"],"names":[],"mappings":";;;AAAA,2BAA4C;AAE5C,+CAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,WAAkC,IAAI;IAEtC,OAAO,IAAI,yBAAW,CAAC;QACrB,IAAI;QACJ,KAAK,EAAE,MAAM,aAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC;KACrD,CAAC,CAAC;AACL,CAAC;AARD,0CAQC;AAOD;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CACpC,KAAkB,EAClB,OAA2B;IAE3B,OAAO,aAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC;AALD,4CAKC","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"]}
package/package.json CHANGED
@@ -1,146 +1,127 @@
1
1
  {
2
2
  "name": "@metamask/snaps-utils",
3
- "version": "0.38.0-flask.1",
3
+ "version": "1.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
7
7
  },
8
- "sideEffects": false,
9
8
  "exports": {
10
9
  ".": {
11
10
  "browser": {
12
- "import": "./dist/esm/index.browser.js",
13
- "require": "./dist/cjs/index.browser.js"
11
+ "default": "./dist/index.browser.js"
14
12
  },
15
- "import": "./dist/esm/index.js",
16
- "require": "./dist/cjs/index.js"
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.js"
17
15
  },
18
16
  "./test-utils": {
19
- "import": "./dist/esm/test-utils/index.js",
20
- "require": "./dist/cjs/test-utils/index.js",
21
- "types": "./dist/types/test-utils/index.d.ts"
17
+ "import": "./dist/test-utils/index.js",
18
+ "require": "./dist/test-utils/index.js"
22
19
  }
23
20
  },
24
- "main": "./dist/cjs/index.js",
25
- "module": "./dist/esm/index.js",
21
+ "main": "dist/index.js",
26
22
  "browser": {
27
- "./dist/cjs/index.js": "./dist/cjs/index.browser.js",
28
- "./dist/esm/index.js": "./dist/esm/index.browser.js"
23
+ "./dist/index.js": "./dist/index.browser.js"
29
24
  },
30
- "types": "./dist/types/index.d.ts",
31
25
  "typesVersions": {
32
26
  "*": {
33
27
  "*": [
34
- "./dist/types/index.d.ts"
28
+ "dist/index.d.ts"
35
29
  ],
36
30
  "test-utils": [
37
- "./dist/types/test-utils/index.d.ts"
31
+ "dist/test-utils/index.d.ts"
38
32
  ]
39
33
  }
40
34
  },
41
35
  "files": [
42
- "dist/cjs/**",
43
- "dist/esm/**",
44
- "dist/types/**"
36
+ "dist/"
45
37
  ],
46
38
  "scripts": {
47
39
  "test": "rimraf coverage && jest && yarn test:browser && yarn posttest",
48
40
  "posttest": "ts-node scripts/coverage.ts && rimraf coverage/jest coverage/wdio",
49
41
  "test:browser": "wdio run wdio.config.ts",
50
42
  "test:ci": "yarn test",
51
- "lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
52
- "lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
53
- "lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog",
43
+ "lint:eslint": "eslint . --cache --ext js,ts",
44
+ "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",
45
+ "lint": "yarn lint:eslint && yarn lint:misc --check",
54
46
  "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
55
- "lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-utils",
56
- "build": "yarn build:source && yarn build:types",
57
- "build:source": "yarn build:esm && yarn build:cjs",
58
- "build:types": "tsc --project tsconfig.build.json",
59
- "build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
60
- "build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
47
+ "lint:changelog": "yarn auto-changelog validate",
48
+ "build": "tsc --project tsconfig.build.json",
61
49
  "build:clean": "yarn clean && yarn build",
62
- "clean": "rimraf '*.tsbuildinfo' 'dist'",
50
+ "clean": "rimraf '*.tsbuildinfo' 'dist/*'",
63
51
  "prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
64
52
  "publish:preview": "yarn npm publish --tag preview",
65
- "lint:ci": "yarn lint"
53
+ "publish:package": "../../scripts/publish-package.sh"
66
54
  },
67
55
  "dependencies": {
68
- "@babel/core": "^7.20.12",
56
+ "@babel/core": "^7.18.6",
69
57
  "@babel/types": "^7.18.7",
70
58
  "@metamask/base-controller": "^3.0.0",
71
- "@metamask/key-tree": "^9.0.0",
59
+ "@metamask/key-tree": "^7.1.1",
72
60
  "@metamask/permission-controller": "^4.0.0",
73
- "@metamask/providers": "^11.0.0",
61
+ "@metamask/providers": "^10.2.1",
74
62
  "@metamask/snaps-registry": "^1.2.1",
75
- "@metamask/snaps-ui": "^0.37.3-flask.1",
63
+ "@metamask/snaps-ui": "^1.0.0",
76
64
  "@metamask/utils": "^6.0.1",
77
- "@noble/hashes": "^1.3.1",
65
+ "@noble/hashes": "^1.1.3",
78
66
  "@scure/base": "^1.1.1",
79
- "chalk": "^4.1.2",
80
67
  "cron-parser": "^4.5.0",
81
68
  "eth-rpc-errors": "^4.0.3",
82
69
  "fast-deep-equal": "^3.1.3",
83
70
  "fast-json-stable-stringify": "^2.1.0",
84
- "is-svg": "^4.4.0",
85
71
  "rfdc": "^1.3.0",
86
72
  "semver": "^7.5.4",
87
- "ses": "^0.18.1",
73
+ "ses": "^0.18.7",
88
74
  "superstruct": "^1.0.3",
89
75
  "validate-npm-package-name": "^5.0.0"
90
76
  },
91
77
  "devDependencies": {
92
78
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
93
79
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
94
- "@lavamoat/allow-scripts": "^2.3.1",
80
+ "@lavamoat/allow-scripts": "^2.0.3",
95
81
  "@metamask/auto-changelog": "^3.1.0",
96
- "@metamask/eslint-config": "^12.1.0",
97
- "@metamask/eslint-config-jest": "^12.1.0",
98
- "@metamask/eslint-config-nodejs": "^12.1.0",
99
- "@metamask/eslint-config-typescript": "^12.1.0",
100
- "@metamask/post-message-stream": "^6.1.2",
101
- "@swc/cli": "^0.1.62",
102
- "@swc/core": "^1.3.66",
103
- "@swc/jest": "^0.2.26",
82
+ "@metamask/eslint-config": "^11.0.0",
83
+ "@metamask/eslint-config-jest": "^11.0.0",
84
+ "@metamask/eslint-config-nodejs": "^11.0.1",
85
+ "@metamask/eslint-config-typescript": "^11.0.0",
86
+ "@metamask/post-message-stream": "^6.1.1",
104
87
  "@types/jest": "^27.5.1",
105
88
  "@types/mocha": "^10.0.1",
106
- "@types/node": "^20.3.1",
107
89
  "@types/semver": "^7.5.0",
108
90
  "@types/validate-npm-package-name": "^4.0.0",
109
91
  "@typescript-eslint/eslint-plugin": "^5.42.1",
110
92
  "@typescript-eslint/parser": "^5.42.1",
111
93
  "@wdio/browser-runner": "^8.5.2",
112
- "@wdio/cli": "^8.5.2",
113
- "@wdio/globals": "^8.5.2",
114
- "@wdio/mocha-framework": "^8.5.2",
115
- "@wdio/spec-reporter": "^8.5.2",
116
- "@wdio/static-server-service": "^8.5.2",
94
+ "@wdio/cli": "^8.5.1",
95
+ "@wdio/globals": "^8.5.1",
96
+ "@wdio/mocha-framework": "^8.4.0",
97
+ "@wdio/spec-reporter": "^8.4.0",
98
+ "@wdio/static-server-service": "^8.4.0",
117
99
  "deepmerge": "^4.2.2",
118
- "esbuild": "^0.17.15",
119
100
  "eslint": "^8.27.0",
120
101
  "eslint-config-prettier": "^8.5.0",
121
102
  "eslint-plugin-import": "^2.26.0",
122
103
  "eslint-plugin-jest": "^27.1.5",
123
104
  "eslint-plugin-jsdoc": "^39.6.2",
124
- "eslint-plugin-n": "^15.7.0",
105
+ "eslint-plugin-node": "^11.1.0",
125
106
  "eslint-plugin-prettier": "^4.2.1",
126
- "eslint-plugin-promise": "^6.1.1",
127
107
  "expect-webdriverio": "^4.1.2",
128
108
  "istanbul-lib-coverage": "^3.2.0",
129
109
  "istanbul-lib-report": "^3.0.0",
130
110
  "istanbul-reports": "^3.1.5",
131
111
  "jest": "^29.0.2",
132
- "memfs": "^3.4.13",
112
+ "memfs": "^3.4.12",
133
113
  "prettier": "^2.7.1",
134
114
  "prettier-plugin-packagejson": "^2.2.11",
135
- "rimraf": "^4.1.2",
115
+ "rimraf": "^3.0.2",
136
116
  "serve-handler": "^6.1.5",
117
+ "ts-jest": "^29.0.0",
137
118
  "ts-node": "^10.9.1",
138
119
  "typescript": "~4.8.4",
139
120
  "vite": "^4.3.9",
140
121
  "vite-tsconfig-paths": "^4.0.5",
141
122
  "wdio-chromedriver-service": "^8.1.1",
142
123
  "wdio-geckodriver-service": "^4.1.0",
143
- "webdriverio": "^8.5.2"
124
+ "webdriverio": "^8.5.1"
144
125
  },
145
126
  "engines": {
146
127
  "node": ">=16.0.0"
package/dist/cjs/array.js DELETED
@@ -1,23 +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
- */ "use strict";
10
- Object.defineProperty(exports, "__esModule", {
11
- value: true
12
- });
13
- Object.defineProperty(exports, "isEqual", {
14
- enumerable: true,
15
- get: function() {
16
- return isEqual;
17
- }
18
- });
19
- function isEqual(a, b) {
20
- return a.length === b.length && a.every((value, index)=>value === b[index]);
21
- }
22
-
23
- //# 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;;;;+BACeA;;;eAAAA;;;AAAT,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,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "SnapCaveatType", {
6
- enumerable: true,
7
- get: function() {
8
- return SnapCaveatType;
9
- }
10
- });
11
- var SnapCaveatType;
12
- (function(SnapCaveatType) {
13
- SnapCaveatType[/**
14
- * Permitted derivation paths, used by `snap_getBip32Entropy`.
15
- */ "PermittedDerivationPaths"] = 'permittedDerivationPaths';
16
- SnapCaveatType[/**
17
- * Permitted coin types, used by `snap_getBip44Entropy`.
18
- */ "PermittedCoinTypes"] = 'permittedCoinTypes';
19
- SnapCaveatType[/**
20
- * Caveat specifying a snap cronjob.
21
- */ "SnapCronjob"] = 'snapCronjob';
22
- SnapCaveatType[/**
23
- * Caveat specifying access to the transaction origin, used by `endowment:transaction-insight`.
24
- */ "TransactionOrigin"] = 'transactionOrigin';
25
- SnapCaveatType[/**
26
- * The origins that a Snap can receive JSON-RPC messages from.
27
- */ "RpcOrigin"] = 'rpcOrigin';
28
- SnapCaveatType[/**
29
- * Caveat specifying the snap IDs that can be interacted with.
30
- */ "SnapIds"] = 'snapIds';
31
- })(SnapCaveatType || (SnapCaveatType = {}));
32
-
33
- //# 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 * The origins that a Snap can receive JSON-RPC messages from.\n */\n RpcOrigin = 'rpcOrigin',\n\n /**\n * Caveat specifying the snap IDs that can be interacted with.\n */\n SnapIds = 'snapIds',\n}\n"],"names":["SnapCaveatType","PermittedDerivationPaths","PermittedCoinTypes","SnapCronjob","TransactionOrigin","RpcOrigin","SnapIds"],"mappings":";;;;;;;;;;IAAO;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,eAAY;IAxBFL,eA0BV;;GAEC,GACDM,aAAU;GA7BAN,mBAAAA"}
@@ -1,38 +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
- checksum: function() {
13
- return checksum;
14
- },
15
- checksumFiles: function() {
16
- return checksumFiles;
17
- }
18
- });
19
- const _utils = require("@metamask/utils");
20
- const _sha256 = require("@noble/hashes/sha256");
21
- const _VirtualFile = require("./virtual-file/VirtualFile");
22
- function checksum(bytes) {
23
- const value = bytes instanceof _VirtualFile.VirtualFile ? bytes.value : bytes;
24
- return (0, _sha256.sha256)(value);
25
- }
26
- function checksumFiles(files) {
27
- return checksum((0, _utils.concatBytes)([
28
- ...files
29
- ].sort((a, b)=>{
30
- (0, _utils.assert)(a.path !== b.path, 'Tried to sort files with non-unique paths.');
31
- if (a.path < b.path) {
32
- return -1;
33
- }
34
- return 1;
35
- }).map((file)=>checksum(file))));
36
- }
37
-
38
- //# 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 { 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 function checksum(bytes: VirtualFile | Uint8Array | string): Uint8Array {\n const value = bytes instanceof VirtualFile ? bytes.value : bytes;\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 function checksumFiles(files: VirtualFile[]) {\n return checksum(\n concatBytes(\n [...files]\n .sort((a, b) => {\n assert(\n a.path !== b.path,\n 'Tried to sort files with non-unique paths.',\n );\n if (a.path < b.path) {\n return -1;\n }\n return 1;\n })\n .map((file) => checksum(file)),\n ),\n );\n}\n"],"names":["checksum","checksumFiles","bytes","value","VirtualFile","sha256","files","concatBytes","sort","a","b","assert","path","map","file"],"mappings":";;;;;;;;;;;IAWgBA,QAAQ;eAARA;;IAiBAC,aAAa;eAAbA;;;uBA5BoB;wBACb;6BAEK;AAQrB,SAASD,SAASE,KAAwC;IAC/D,MAAMC,QAAQD,iBAAiBE,wBAAW,GAAGF,MAAMC,KAAK,GAAGD;IAC3D,OAAOG,IAAAA,cAAM,EAACF;AAChB;AAcO,SAASF,cAAcK,KAAoB;IAChD,OAAON,SACLO,IAAAA,kBAAW,EACT;WAAID;KAAM,CACPE,IAAI,CAAC,CAACC,GAAGC;QACRC,IAAAA,aAAM,EACJF,EAAEG,IAAI,KAAKF,EAAEE,IAAI,EACjB;QAEF,IAAIH,EAAEG,IAAI,GAAGF,EAAEE,IAAI,EAAE;YACnB,OAAO,CAAC;QACV;QACA,OAAO;IACT,GACCC,GAAG,CAAC,CAACC,OAASd,SAASc;AAGhC"}
@@ -1,84 +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
- CronjobRpcRequestStruct: function() {
13
- return CronjobRpcRequestStruct;
14
- },
15
- CronExpressionStruct: function() {
16
- return CronExpressionStruct;
17
- },
18
- parseCronExpression: function() {
19
- return parseCronExpression;
20
- },
21
- CronjobSpecificationStruct: function() {
22
- return CronjobSpecificationStruct;
23
- },
24
- isCronjobSpecification: function() {
25
- return isCronjobSpecification;
26
- },
27
- CronjobSpecificationArrayStruct: function() {
28
- return CronjobSpecificationArrayStruct;
29
- },
30
- isCronjobSpecificationArray: function() {
31
- return isCronjobSpecificationArray;
32
- }
33
- });
34
- const _utils = require("@metamask/utils");
35
- const _cronparser = require("cron-parser");
36
- const _superstruct = require("superstruct");
37
- const CronjobRpcRequestStruct = (0, _superstruct.assign)((0, _superstruct.partial)((0, _superstruct.pick)(_utils.JsonRpcRequestStruct, [
38
- 'id',
39
- 'jsonrpc'
40
- ])), (0, _superstruct.omit)(_utils.JsonRpcRequestStruct, [
41
- 'id',
42
- 'jsonrpc'
43
- ]));
44
- const CronExpressionStruct = (0, _superstruct.refine)((0, _superstruct.coerce)((0, _superstruct.string)(), (0, _superstruct.object)({
45
- minute: (0, _superstruct.optional)((0, _superstruct.string)()),
46
- hour: (0, _superstruct.optional)((0, _superstruct.string)()),
47
- dayOfMonth: (0, _superstruct.optional)((0, _superstruct.string)()),
48
- month: (0, _superstruct.optional)((0, _superstruct.string)()),
49
- dayOfWeek: (0, _superstruct.optional)((0, _superstruct.string)())
50
- }), (value)=>`${value.minute ?? '*'} ${value.hour ?? '*'} ${value.dayOfMonth ?? '*'} ${value.month ?? '*'} ${value.dayOfWeek ?? '*'}`), 'CronExpression', (value)=>{
51
- try {
52
- (0, _cronparser.parseExpression)(value);
53
- return true;
54
- } catch {
55
- return false;
56
- }
57
- });
58
- function parseCronExpression(expression) {
59
- const ensureStringExpression = (0, _superstruct.create)(expression, CronExpressionStruct);
60
- return (0, _cronparser.parseExpression)(ensureStringExpression);
61
- }
62
- const CronjobSpecificationStruct = (0, _superstruct.object)({
63
- expression: CronExpressionStruct,
64
- request: CronjobRpcRequestStruct
65
- });
66
- function isCronjobSpecification(value) {
67
- try {
68
- (0, _superstruct.create)(value, CronjobSpecificationStruct);
69
- return true;
70
- } catch {
71
- return false;
72
- }
73
- }
74
- const CronjobSpecificationArrayStruct = (0, _superstruct.array)(CronjobSpecificationStruct);
75
- function isCronjobSpecificationArray(value) {
76
- try {
77
- (0, _superstruct.create)(value, CronjobSpecificationArrayStruct);
78
- return true;
79
- } catch {
80
- return false;
81
- }
82
- }
83
-
84
- //# sourceMappingURL=cronjob.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import { JsonRpcRequestStruct } from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n assign,\n coerce,\n create,\n object,\n omit,\n optional,\n partial,\n pick,\n refine,\n string,\n} from 'superstruct';\n\nexport const CronjobRpcRequestStruct = assign(\n partial(pick(JsonRpcRequestStruct, ['id', 'jsonrpc'])),\n omit(JsonRpcRequestStruct, ['id', 'jsonrpc']),\n);\nexport type CronjobRpcRequest = Infer<typeof CronjobRpcRequestStruct>;\n\nexport const CronExpressionStruct = refine(\n coerce(\n string(),\n object({\n minute: optional(string()),\n hour: optional(string()),\n dayOfMonth: optional(string()),\n month: optional(string()),\n dayOfWeek: optional(string()),\n }),\n (value) =>\n `${value.minute ?? '*'} ${value.hour ?? '*'} ${value.dayOfMonth ?? '*'} ${\n value.month ?? '*'\n } ${value.dayOfWeek ?? '*'}`,\n ),\n 'CronExpression',\n (value) => {\n try {\n parseExpression(value);\n return true;\n } catch {\n return false;\n }\n },\n);\n\nexport type CronExpression = Infer<typeof CronExpressionStruct>;\n\n/**\n * Parses a cron expression.\n *\n * @param expression - Expression to parse.\n * @returns A CronExpression class instance.\n */\nexport function parseCronExpression(expression: string | object) {\n const ensureStringExpression = create(expression, CronExpressionStruct);\n return parseExpression(ensureStringExpression);\n}\n\nexport const CronjobSpecificationStruct = object({\n expression: CronExpressionStruct,\n request: CronjobRpcRequestStruct,\n});\nexport type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;\n\n/**\n * Check if the given value is a {@link CronjobSpecification} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link CronjobSpecification} object.\n */\nexport function isCronjobSpecification(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationStruct);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const CronjobSpecificationArrayStruct = array(\n CronjobSpecificationStruct,\n);\n\n/**\n * Check if the given value is an array of {@link CronjobSpecification} objects.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid array of {@link CronjobSpecification} objects.\n */\nexport function isCronjobSpecificationArray(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationArrayStruct);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["CronjobRpcRequestStruct","CronExpressionStruct","parseCronExpression","CronjobSpecificationStruct","isCronjobSpecification","CronjobSpecificationArrayStruct","isCronjobSpecificationArray","assign","partial","pick","JsonRpcRequestStruct","omit","refine","coerce","string","object","minute","optional","hour","dayOfMonth","month","dayOfWeek","value","parseExpression","expression","ensureStringExpression","create","request","array"],"mappings":";;;;;;;;;;;IAiBaA,uBAAuB;eAAvBA;;IAMAC,oBAAoB;eAApBA;;IAkCGC,mBAAmB;eAAnBA;;IAKHC,0BAA0B;eAA1BA;;IAYGC,sBAAsB;eAAtBA;;IASHC,+BAA+B;eAA/BA;;IAUGC,2BAA2B;eAA3BA;;;uBA7FqB;4BACL;6BAczB;AAEA,MAAMN,0BAA0BO,IAAAA,mBAAM,EAC3CC,IAAAA,oBAAO,EAACC,IAAAA,iBAAI,EAACC,2BAAoB,EAAE;IAAC;IAAM;CAAU,IACpDC,IAAAA,iBAAI,EAACD,2BAAoB,EAAE;IAAC;IAAM;CAAU;AAIvC,MAAMT,uBAAuBW,IAAAA,mBAAM,EACxCC,IAAAA,mBAAM,EACJC,IAAAA,mBAAM,KACNC,IAAAA,mBAAM,EAAC;IACLC,QAAQC,IAAAA,qBAAQ,EAACH,IAAAA,mBAAM;IACvBI,MAAMD,IAAAA,qBAAQ,EAACH,IAAAA,mBAAM;IACrBK,YAAYF,IAAAA,qBAAQ,EAACH,IAAAA,mBAAM;IAC3BM,OAAOH,IAAAA,qBAAQ,EAACH,IAAAA,mBAAM;IACtBO,WAAWJ,IAAAA,qBAAQ,EAACH,IAAAA,mBAAM;AAC5B,IACA,CAACQ,QACC,CAAC,EAAEA,MAAMN,MAAM,IAAI,IAAI,CAAC,EAAEM,MAAMJ,IAAI,IAAI,IAAI,CAAC,EAAEI,MAAMH,UAAU,IAAI,IAAI,CAAC,EACtEG,MAAMF,KAAK,IAAI,IAChB,CAAC,EAAEE,MAAMD,SAAS,IAAI,IAAI,CAAC,GAEhC,kBACA,CAACC;IACC,IAAI;QACFC,IAAAA,2BAAe,EAACD;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAWK,SAASpB,oBAAoBsB,UAA2B;IAC7D,MAAMC,yBAAyBC,IAAAA,mBAAM,EAACF,YAAYvB;IAClD,OAAOsB,IAAAA,2BAAe,EAACE;AACzB;AAEO,MAAMtB,6BAA6BY,IAAAA,mBAAM,EAAC;IAC/CS,YAAYvB;IACZ0B,SAAS3B;AACX;AASO,SAASI,uBAAuBkB,KAAc;IACnD,IAAI;QACFI,IAAAA,mBAAM,EAACJ,OAAOnB;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEO,MAAME,kCAAkCuB,IAAAA,kBAAK,EAClDzB;AASK,SAASG,4BAA4BgB,KAAc;IACxD,IAAI;QACFI,IAAAA,mBAAM,EAACJ,OAAOjB;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "deepClone", {
6
- enumerable: true,
7
- get: function() {
8
- return deepClone;
9
- }
10
- });
11
- const _rfdc = /*#__PURE__*/ _interop_require_default(require("rfdc"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- const deepClone = (0, _rfdc.default)({
18
- proto: false,
19
- circles: false
20
- });
21
-
22
- //# sourceMappingURL=deep-clone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/deep-clone.ts"],"sourcesContent":["import rfdc from 'rfdc';\n\nexport const deepClone = rfdc({ proto: false, circles: false });\n"],"names":["deepClone","rfdc","proto","circles"],"mappings":";;;;+BAEaA;;;eAAAA;;;6DAFI;;;;;;AAEV,MAAMA,YAAYC,IAAAA,aAAI,EAAC;IAAEC,OAAO;IAAOC,SAAS;AAAM"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Global JavaScript APIs exposed by default to all snaps.
3
- */ "use strict";
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "DEFAULT_ENDOWMENTS", {
8
- enumerable: true,
9
- get: function() {
10
- return DEFAULT_ENDOWMENTS;
11
- }
12
- });
13
- const DEFAULT_ENDOWMENTS = Object.freeze([
14
- 'atob',
15
- 'btoa',
16
- 'BigInt',
17
- 'console',
18
- 'crypto',
19
- 'Date',
20
- 'Math',
21
- 'setTimeout',
22
- 'clearTimeout',
23
- 'SubtleCrypto',
24
- 'TextDecoder',
25
- 'TextEncoder',
26
- 'URL',
27
- 'setInterval',
28
- 'clearInterval',
29
- 'Int8Array',
30
- 'Uint8Array',
31
- 'Uint8ClampedArray',
32
- 'Int16Array',
33
- 'Uint16Array',
34
- 'Int32Array',
35
- 'Uint32Array',
36
- 'Float32Array',
37
- 'Float64Array',
38
- 'BigInt64Array',
39
- 'BigUint64Array',
40
- 'DataView',
41
- 'ArrayBuffer',
42
- // Used by fetch, but also as API for some packages that don't do network connections
43
- // https://github.com/MetaMask/snaps-monorepo/issues/662
44
- // https://github.com/MetaMask/snaps-monorepo/discussions/678
45
- 'AbortController',
46
- 'AbortSignal'
47
- ]);
48
-
49
- //# sourceMappingURL=default-endowments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/default-endowments.ts"],"sourcesContent":["/**\n * Global JavaScript APIs exposed by default to all snaps.\n */\nexport const DEFAULT_ENDOWMENTS: readonly string[] = Object.freeze([\n 'atob',\n 'btoa',\n 'BigInt',\n 'console',\n 'crypto',\n 'Date',\n 'Math',\n 'setTimeout',\n 'clearTimeout',\n 'SubtleCrypto',\n 'TextDecoder',\n 'TextEncoder',\n 'URL',\n 'setInterval',\n 'clearInterval',\n 'Int8Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array',\n 'DataView',\n 'ArrayBuffer',\n // Used by fetch, but also as API for some packages that don't do network connections\n // https://github.com/MetaMask/snaps-monorepo/issues/662\n // https://github.com/MetaMask/snaps-monorepo/discussions/678\n 'AbortController',\n 'AbortSignal',\n]);\n"],"names":["DEFAULT_ENDOWMENTS","Object","freeze"],"mappings":"AAAA;;CAEC;;;;+BACYA;;;eAAAA;;;AAAN,MAAMA,qBAAwCC,OAAOC,MAAM,CAAC;IACjE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,qFAAqF;IACrF,wDAAwD;IACxD,6DAA6D;IAC7D;IACA;CACD"}
@@ -1,23 +0,0 @@
1
- // 0xd36e6170 - 0x80000000
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- function _export(target, all) {
7
- for(var name in all)Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- SIP_6_MAGIC_VALUE: function() {
14
- return SIP_6_MAGIC_VALUE;
15
- },
16
- STATE_ENCRYPTION_MAGIC_VALUE: function() {
17
- return STATE_ENCRYPTION_MAGIC_VALUE;
18
- }
19
- });
20
- const SIP_6_MAGIC_VALUE = `1399742832'`;
21
- const STATE_ENCRYPTION_MAGIC_VALUE = `572232532'`;
22
-
23
- //# sourceMappingURL=entropy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/entropy.ts"],"sourcesContent":["// 0xd36e6170 - 0x80000000\nexport const SIP_6_MAGIC_VALUE = `1399742832'` as `${number}'`;\n\n// `${bytesToNumber(keccak256('Snaps state encryption').slice(0, 4))}'`\nexport const STATE_ENCRYPTION_MAGIC_VALUE = `572232532'` as `${number}'`;\n\nexport type MagicValue =\n | typeof SIP_6_MAGIC_VALUE\n | typeof STATE_ENCRYPTION_MAGIC_VALUE;\n"],"names":["SIP_6_MAGIC_VALUE","STATE_ENCRYPTION_MAGIC_VALUE"],"mappings":"AAAA,0BAA0B;;;;;;;;;;;;IACbA,iBAAiB;eAAjBA;;IAGAC,4BAA4B;eAA5BA;;;AAHN,MAAMD,oBAAoB,CAAC,WAAW,CAAC;AAGvC,MAAMC,+BAA+B,CAAC,UAAU,CAAC"}
package/dist/cjs/enum.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "enumValue", {
6
- enumerable: true,
7
- get: function() {
8
- return enumValue;
9
- }
10
- });
11
- const _structs = require("./structs");
12
- function enumValue(constant) {
13
- return (0, _structs.literal)(constant);
14
- }
15
-
16
- //# sourceMappingURL=enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/enum.ts"],"sourcesContent":["import type { Struct } from 'superstruct';\n\nimport { literal } from './structs';\n\n/**\n * Get the enum values as union type. This allows using both the enum string\n * values and the enum itself as values.\n *\n * Note: This only works for string enums.\n *\n * @example\n * ```typescript\n * enum Foo {\n * Bar = 'bar',\n * Baz = 'baz',\n * }\n *\n * type FooValue = EnumToUnion<Foo>;\n * // FooValue is 'bar' | 'baz'\n *\n * const foo: FooValue = Foo.Bar; // Works\n * const foo: FooValue = 'bar'; // Also works\n * ```\n */\nexport type EnumToUnion<Type extends string> = `${Type}`;\n\n/**\n * Superstruct struct for validating an enum value. This allows using both the\n * enum string values and the enum itself as values.\n *\n * @param constant - The enum to validate against.\n * @returns The superstruct struct.\n */\nexport function enumValue<Type extends string>(\n constant: Type,\n): Struct<EnumToUnion<Type>, null> {\n return literal(constant as EnumToUnion<Type>);\n}\n"],"names":["enumValue","constant","literal"],"mappings":";;;;+BAiCgBA;;;eAAAA;;;yBA/BQ;AA+BjB,SAASA,UACdC,QAAc;IAEd,OAAOC,IAAAA,gBAAO,EAACD;AACjB"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getErrorMessage", {
6
- enumerable: true,
7
- get: function() {
8
- return getErrorMessage;
9
- }
10
- });
11
- const _utils = require("@metamask/utils");
12
- function getErrorMessage(error) {
13
- if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'message') && typeof error.message === 'string') {
14
- return error.message;
15
- }
16
- return String(error);
17
- }
18
-
19
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n"],"names":["getErrorMessage","error","isObject","hasProperty","message","String"],"mappings":";;;;+BAWgBA;;;eAAAA;;;uBAXsB;AAW/B,SAASA,gBAAgBC,KAAc;IAC5C,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,cACnB,OAAOA,MAAMG,OAAO,KAAK,UACzB;QACA,OAAOH,MAAMG,OAAO;IACtB;IAEA,OAAOC,OAAOJ;AAChB"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handlers';\nimport { generateMockEndowments } from './mock';\nimport { SNAP_EXPORT_NAMES } from './types';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\n/**\n * Get mock endowments that don't do anything. This is useful for running the\n * eval, for snaps that try to communicate with the extension on initialisation,\n * for example.\n *\n * @returns The mock endowments.\n */\nfunction getMockEndowments() {\n const endowments = generateMockEndowments();\n return {\n ...endowments,\n window: endowments,\n self: endowments,\n };\n}\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nnew Compartment({\n ...getMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n}).evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\nsetTimeout(() => process.exit(0), 1000); // Hack to ensure worker exits\n"],"names":["lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","domainTaming","getMockEndowments","endowments","generateMockEndowments","window","self","snapFilePath","process","argv","snapModule","exports","Compartment","module","evaluate","readFileSync","invalidExports","Object","keys","filter","snapExport","SNAP_EXPORT_NAMES","includes","length","console","warn","join","setTimeout","exit"],"mappings":"AAAA,uDAAuD;;;;;QAChD;oBAEsB;sBAGU;uBACL;AAIlCA,SAAS;IACPC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAEhB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClCC,cAAc;AAChB;AAEA;;;;;;CAMC,GACD,SAASC;IACP,MAAMC,aAAaC,IAAAA,4BAAsB;IACzC,OAAO;QACL,GAAGD,UAAU;QACbE,QAAQF;QACRG,MAAMH;IACR;AACF;AAEA,MAAMI,eAAeC,QAAQC,IAAI,CAAC,EAAE;AAEpC,MAAMC,aAAgC;IAAEC,SAAS,CAAC;AAAE;AAEpD,IAAIC,YAAY;IACd,GAAGV,mBAAmB;IACtBW,QAAQH;IACRC,SAASD,WAAWC,OAAO;AAC7B,GAAGG,QAAQ,CAACC,IAAAA,gBAAY,EAACR,cAAc;AAEvC,MAAMS,iBAAiBC,OAAOC,IAAI,CAACR,WAAWC,OAAO,EAAEQ,MAAM,CAC3D,CAACC,aAAe,CAACC,wBAAiB,CAACC,QAAQ,CAACF;AAG9C,IAAIJ,eAAeO,MAAM,GAAG,GAAG;IAC7B,sCAAsC;IACtCC,QAAQC,IAAI,CAAC,CAAC,gCAAgC,EAAET,eAAeU,IAAI,CAAC,MAAM,CAAC;AAC7E;AAEAC,WAAW,IAAMnB,QAAQoB,IAAI,CAAC,IAAI,OAAO,8BAA8B"}