@metamask/snaps-utils 1.0.2 → 2.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 (268) hide show
  1. package/CHANGELOG.md +36 -221
  2. package/dist/cjs/array.js +23 -0
  3. package/dist/cjs/array.js.map +1 -0
  4. package/dist/cjs/caveats.js +36 -0
  5. package/dist/cjs/caveats.js.map +1 -0
  6. package/dist/cjs/checksum.js +38 -0
  7. package/dist/cjs/checksum.js.map +1 -0
  8. package/dist/cjs/cronjob.js +84 -0
  9. package/dist/cjs/cronjob.js.map +1 -0
  10. package/dist/cjs/deep-clone.js +22 -0
  11. package/dist/cjs/deep-clone.js.map +1 -0
  12. package/dist/cjs/default-endowments.js +49 -0
  13. package/dist/cjs/default-endowments.js.map +1 -0
  14. package/dist/cjs/entropy.js +23 -0
  15. package/dist/cjs/entropy.js.map +1 -0
  16. package/dist/cjs/enum.js +16 -0
  17. package/dist/cjs/enum.js.map +1 -0
  18. package/dist/cjs/errors.js +19 -0
  19. package/dist/cjs/errors.js.map +1 -0
  20. package/dist/{eval-worker.js → cjs/eval-worker.js} +22 -21
  21. package/dist/cjs/eval-worker.js.map +1 -0
  22. package/dist/cjs/eval.js +77 -0
  23. package/dist/cjs/eval.js.map +1 -0
  24. package/dist/cjs/fs.js +126 -0
  25. package/dist/cjs/fs.js.map +1 -0
  26. package/dist/cjs/handlers.js +80 -0
  27. package/dist/cjs/handlers.js.map +1 -0
  28. package/dist/cjs/icon.js +37 -0
  29. package/dist/cjs/icon.js.map +1 -0
  30. package/dist/cjs/iframe.js +59 -0
  31. package/dist/cjs/iframe.js.map +1 -0
  32. package/dist/cjs/index.browser.js +43 -0
  33. package/dist/cjs/index.browser.js.map +1 -0
  34. package/dist/cjs/index.executionenv.js +24 -0
  35. package/dist/cjs/index.executionenv.js.map +1 -0
  36. package/dist/cjs/index.js +48 -0
  37. package/dist/cjs/index.js.map +1 -0
  38. package/dist/cjs/json-rpc.js +46 -0
  39. package/dist/cjs/json-rpc.js.map +1 -0
  40. package/dist/cjs/json.js +16 -0
  41. package/dist/cjs/json.js.map +1 -0
  42. package/dist/cjs/logging.js +40 -0
  43. package/dist/cjs/logging.js.map +1 -0
  44. package/dist/cjs/manifest/index.browser.js +20 -0
  45. package/dist/cjs/manifest/index.browser.js.map +1 -0
  46. package/dist/cjs/manifest/index.js +21 -0
  47. package/dist/cjs/manifest/index.js.map +1 -0
  48. package/dist/cjs/manifest/manifest.js +239 -0
  49. package/dist/cjs/manifest/manifest.js.map +1 -0
  50. package/dist/cjs/manifest/validation.js +188 -0
  51. package/dist/cjs/manifest/validation.js.map +1 -0
  52. package/dist/cjs/mock.js +128 -0
  53. package/dist/cjs/mock.js.map +1 -0
  54. package/dist/cjs/namespace.js +132 -0
  55. package/dist/cjs/namespace.js.map +1 -0
  56. package/dist/cjs/npm.js +81 -0
  57. package/dist/cjs/npm.js.map +1 -0
  58. package/dist/cjs/path.js +21 -0
  59. package/dist/cjs/path.js.map +1 -0
  60. package/dist/cjs/post-process.js +328 -0
  61. package/dist/cjs/post-process.js.map +1 -0
  62. package/dist/cjs/snaps.js +230 -0
  63. package/dist/cjs/snaps.js.map +1 -0
  64. package/dist/cjs/strings.js +21 -0
  65. package/dist/cjs/strings.js.map +1 -0
  66. package/dist/cjs/structs.js +163 -0
  67. package/dist/cjs/structs.js.map +1 -0
  68. package/dist/cjs/types.js +109 -0
  69. package/dist/cjs/types.js.map +1 -0
  70. package/dist/cjs/validation.js +22 -0
  71. package/dist/cjs/validation.js.map +1 -0
  72. package/dist/cjs/versions.js +47 -0
  73. package/dist/cjs/versions.js.map +1 -0
  74. package/dist/cjs/virtual-file/VirtualFile.js +85 -0
  75. package/dist/cjs/virtual-file/VirtualFile.js.map +1 -0
  76. package/dist/cjs/virtual-file/index.browser.js +20 -0
  77. package/dist/cjs/virtual-file/index.browser.js.map +1 -0
  78. package/dist/cjs/virtual-file/index.js +21 -0
  79. package/dist/cjs/virtual-file/index.js.map +1 -0
  80. package/dist/cjs/virtual-file/toVirtualFile.js +33 -0
  81. package/dist/cjs/virtual-file/toVirtualFile.js.map +1 -0
  82. package/dist/{array.js → esm/array.js} +3 -7
  83. package/dist/esm/array.js.map +1 -0
  84. package/dist/esm/caveats.js +26 -0
  85. package/dist/esm/caveats.js.map +1 -0
  86. package/dist/esm/checksum.js +36 -0
  87. package/dist/esm/checksum.js.map +1 -0
  88. package/dist/esm/cronjob.js +66 -0
  89. package/dist/esm/cronjob.js.map +1 -0
  90. package/dist/esm/deep-clone.js +7 -0
  91. package/dist/esm/deep-clone.js.map +1 -0
  92. package/dist/{default-endowments.js → esm/default-endowments.js} +3 -6
  93. package/dist/esm/default-endowments.js.map +1 -0
  94. package/dist/esm/entropy.js +6 -0
  95. package/dist/esm/entropy.js.map +1 -0
  96. package/dist/esm/enum.js +12 -0
  97. package/dist/esm/enum.js.map +1 -0
  98. package/dist/esm/errors.js +17 -0
  99. package/dist/esm/errors.js.map +1 -0
  100. package/dist/esm/eval-worker.js +47 -0
  101. package/dist/esm/eval-worker.js.map +1 -0
  102. package/dist/esm/eval.js +65 -0
  103. package/dist/esm/eval.js.map +1 -0
  104. package/dist/{fs.js → esm/fs.js} +33 -56
  105. package/dist/esm/fs.js.map +1 -0
  106. package/dist/esm/handlers.js +59 -0
  107. package/dist/esm/handlers.js.map +1 -0
  108. package/dist/esm/icon.js +11 -0
  109. package/dist/esm/icon.js.map +1 -0
  110. package/dist/{iframe.js → esm/iframe.js} +16 -18
  111. package/dist/esm/iframe.js.map +1 -0
  112. package/dist/esm/index.browser.js +26 -0
  113. package/dist/esm/index.browser.js.map +1 -0
  114. package/dist/esm/index.executionenv.js +7 -0
  115. package/dist/esm/index.executionenv.js.map +1 -0
  116. package/dist/esm/index.js +31 -0
  117. package/dist/esm/index.js.map +1 -0
  118. package/dist/esm/json-rpc.js +39 -0
  119. package/dist/esm/json-rpc.js.map +1 -0
  120. package/dist/esm/json.js +17 -0
  121. package/dist/esm/json.js.map +1 -0
  122. package/dist/{logging.js → esm/logging.js} +6 -14
  123. package/dist/esm/logging.js.map +1 -0
  124. package/dist/esm/manifest/index.browser.js +3 -0
  125. package/dist/esm/manifest/index.browser.js.map +1 -0
  126. package/dist/esm/manifest/index.js +4 -0
  127. package/dist/esm/manifest/index.js.map +1 -0
  128. package/dist/{manifest → esm/manifest}/manifest.js +101 -115
  129. package/dist/esm/manifest/manifest.js.map +1 -0
  130. package/dist/esm/manifest/validation.js +154 -0
  131. package/dist/esm/manifest/validation.js.map +1 -0
  132. package/dist/{mock.js → esm/mock.js} +42 -40
  133. package/dist/esm/mock.js.map +1 -0
  134. package/dist/esm/namespace.js +112 -0
  135. package/dist/esm/namespace.js.map +1 -0
  136. package/dist/esm/npm.js +70 -0
  137. package/dist/esm/npm.js.map +1 -0
  138. package/dist/esm/path.js +17 -0
  139. package/dist/esm/path.js.map +1 -0
  140. package/dist/{post-process.js → esm/post-process.js} +110 -99
  141. package/dist/esm/post-process.js.map +1 -0
  142. package/dist/esm/snaps.js +215 -0
  143. package/dist/esm/snaps.js.map +1 -0
  144. package/dist/esm/strings.js +11 -0
  145. package/dist/esm/strings.js.map +1 -0
  146. package/dist/esm/structs.js +230 -0
  147. package/dist/esm/structs.js.map +1 -0
  148. package/dist/esm/types.js +80 -0
  149. package/dist/esm/types.js.map +1 -0
  150. package/dist/esm/validation.js +17 -0
  151. package/dist/esm/validation.js.map +1 -0
  152. package/dist/{versions.js → esm/versions.js} +15 -18
  153. package/dist/esm/versions.js.map +1 -0
  154. package/dist/{virtual-file → esm/virtual-file}/VirtualFile.js +47 -33
  155. package/dist/esm/virtual-file/VirtualFile.js.map +1 -0
  156. package/dist/esm/virtual-file/index.browser.js +3 -0
  157. package/dist/esm/virtual-file/index.browser.js.map +1 -0
  158. package/dist/esm/virtual-file/index.js +4 -0
  159. package/dist/esm/virtual-file/index.js.map +1 -0
  160. package/dist/esm/virtual-file/toVirtualFile.js +26 -0
  161. package/dist/esm/virtual-file/toVirtualFile.js.map +1 -0
  162. package/dist/{caveats.d.ts → types/caveats.d.ts} +5 -5
  163. package/dist/{cronjob.d.ts → types/cronjob.d.ts} +1 -1
  164. package/dist/types/enum.d.ts +30 -0
  165. package/dist/types/errors.d.ts +10 -0
  166. package/dist/{eval.d.ts → types/eval.d.ts} +9 -1
  167. package/dist/{fs.d.ts → types/fs.d.ts} +2 -2
  168. package/dist/types/handlers.d.ts +196 -0
  169. package/dist/types/icon.d.ts +4 -0
  170. package/dist/{iframe.d.ts → types/iframe.d.ts} +3 -2
  171. package/dist/{index.browser.d.ts → types/index.browser.d.ts} +5 -1
  172. package/dist/{index.d.ts → types/index.d.ts} +5 -1
  173. package/dist/{json-rpc.d.ts → types/json-rpc.d.ts} +2 -2
  174. package/dist/types/json.d.ts +13 -0
  175. package/dist/{manifest → types/manifest}/manifest.d.ts +6 -4
  176. package/dist/{manifest → types/manifest}/validation.d.ts +40 -81
  177. package/dist/types/namespace.d.ts +128 -0
  178. package/dist/{npm.d.ts → types/npm.d.ts} +2 -3
  179. package/dist/{snaps.d.ts → types/snaps.d.ts} +17 -9
  180. package/dist/types/strings.d.ts +8 -0
  181. package/dist/types/structs.d.ts +158 -0
  182. package/dist/{types.d.ts → types/types.d.ts} +15 -22
  183. package/dist/types/validation.d.ts +8 -0
  184. package/dist/{versions.d.ts → types/versions.d.ts} +1 -1
  185. package/package.json +67 -47
  186. package/dist/array.js.map +0 -1
  187. package/dist/caveats.js +0 -35
  188. package/dist/caveats.js.map +0 -1
  189. package/dist/checksum.js +0 -42
  190. package/dist/checksum.js.map +0 -1
  191. package/dist/cronjob.js +0 -71
  192. package/dist/cronjob.js.map +0 -1
  193. package/dist/deep-clone.js +0 -9
  194. package/dist/deep-clone.js.map +0 -1
  195. package/dist/default-endowments.js.map +0 -1
  196. package/dist/entropy.js +0 -8
  197. package/dist/entropy.js.map +0 -1
  198. package/dist/eval-worker.js.map +0 -1
  199. package/dist/eval.js +0 -27
  200. package/dist/eval.js.map +0 -1
  201. package/dist/fs.js.map +0 -1
  202. package/dist/handlers.d.ts +0 -105
  203. package/dist/handlers.js +0 -3
  204. package/dist/handlers.js.map +0 -1
  205. package/dist/iframe.js.map +0 -1
  206. package/dist/iframe.test.browser.js +0 -15
  207. package/dist/iframe.test.browser.js.map +0 -1
  208. package/dist/index.browser.js +0 -37
  209. package/dist/index.browser.js.map +0 -1
  210. package/dist/index.executionenv.js +0 -22
  211. package/dist/index.executionenv.js.map +0 -1
  212. package/dist/index.js +0 -42
  213. package/dist/index.js.map +0 -1
  214. package/dist/json-rpc.js +0 -46
  215. package/dist/json-rpc.js.map +0 -1
  216. package/dist/json.d.ts +0 -9
  217. package/dist/json.js +0 -18
  218. package/dist/json.js.map +0 -1
  219. package/dist/logging.js.map +0 -1
  220. package/dist/manifest/index.browser.js +0 -18
  221. package/dist/manifest/index.browser.js.map +0 -1
  222. package/dist/manifest/index.js +0 -19
  223. package/dist/manifest/index.js.map +0 -1
  224. package/dist/manifest/manifest.js.map +0 -1
  225. package/dist/manifest/validation.js +0 -141
  226. package/dist/manifest/validation.js.map +0 -1
  227. package/dist/mock.js.map +0 -1
  228. package/dist/namespace.d.ts +0 -275
  229. package/dist/namespace.js +0 -225
  230. package/dist/namespace.js.map +0 -1
  231. package/dist/notification.d.ts +0 -66
  232. package/dist/notification.js +0 -58
  233. package/dist/notification.js.map +0 -1
  234. package/dist/npm.js +0 -74
  235. package/dist/npm.js.map +0 -1
  236. package/dist/path.js +0 -21
  237. package/dist/path.js.map +0 -1
  238. package/dist/post-process.js.map +0 -1
  239. package/dist/snaps.js +0 -202
  240. package/dist/snaps.js.map +0 -1
  241. package/dist/types.js +0 -103
  242. package/dist/types.js.map +0 -1
  243. package/dist/versions.js.map +0 -1
  244. package/dist/virtual-file/VirtualFile.js.map +0 -1
  245. package/dist/virtual-file/index.browser.js +0 -18
  246. package/dist/virtual-file/index.browser.js.map +0 -1
  247. package/dist/virtual-file/index.js +0 -19
  248. package/dist/virtual-file/index.js.map +0 -1
  249. package/dist/virtual-file/toVirtualFile.js +0 -30
  250. package/dist/virtual-file/toVirtualFile.js.map +0 -1
  251. /package/dist/{array.d.ts → types/array.d.ts} +0 -0
  252. /package/dist/{checksum.d.ts → types/checksum.d.ts} +0 -0
  253. /package/dist/{deep-clone.d.ts → types/deep-clone.d.ts} +0 -0
  254. /package/dist/{default-endowments.d.ts → types/default-endowments.d.ts} +0 -0
  255. /package/dist/{entropy.d.ts → types/entropy.d.ts} +0 -0
  256. /package/dist/{eval-worker.d.ts → types/eval-worker.d.ts} +0 -0
  257. /package/dist/{iframe.test.browser.d.ts → types/iframe.test.browser.d.ts} +0 -0
  258. /package/dist/{index.executionenv.d.ts → types/index.executionenv.d.ts} +0 -0
  259. /package/dist/{logging.d.ts → types/logging.d.ts} +0 -0
  260. /package/dist/{manifest → types/manifest}/index.browser.d.ts +0 -0
  261. /package/dist/{manifest → types/manifest}/index.d.ts +0 -0
  262. /package/dist/{mock.d.ts → types/mock.d.ts} +0 -0
  263. /package/dist/{path.d.ts → types/path.d.ts} +0 -0
  264. /package/dist/{post-process.d.ts → types/post-process.d.ts} +0 -0
  265. /package/dist/{virtual-file → types/virtual-file}/VirtualFile.d.ts +0 -0
  266. /package/dist/{virtual-file → types/virtual-file}/index.browser.d.ts +0 -0
  267. /package/dist/{virtual-file → types/virtual-file}/index.d.ts +0 -0
  268. /package/dist/{virtual-file → types/virtual-file}/toVirtualFile.d.ts +0 -0
@@ -0,0 +1 @@
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,23 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  // eslint-disable-next-line import/no-unassigned-import
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
4
6
  require("ses/lockdown");
5
- const fs_1 = require("fs");
6
- const mock_1 = require("./mock");
7
- const types_1 = require("./types");
7
+ const _fs = require("fs");
8
+ const _mock = require("./mock");
9
+ const _types = require("./types");
8
10
  lockdown({
9
11
  consoleTaming: 'unsafe',
10
12
  errorTaming: 'unsafe',
11
13
  mathTaming: 'unsafe',
12
14
  dateTaming: 'unsafe',
13
15
  overrideTaming: 'severe',
14
- // TODO: See if there's an easier way to do this. This file is ran in a
15
- // separate process, so we can't mock SES with Jest.
16
- ...(process.env.NODE_ENV === 'test'
17
- ? {
18
- domainTaming: 'unsafe',
19
- }
20
- : {}),
16
+ // We disable domain taming, because it does not work in certain cases when
17
+ // running tests. This is unlikely to be a problem in production, because
18
+ // Node.js domains are deprecated.
19
+ domainTaming: 'unsafe'
21
20
  });
22
21
  /**
23
22
  * Get mock endowments that don't do anything. This is useful for running the
@@ -25,26 +24,28 @@ lockdown({
25
24
  * for example.
26
25
  *
27
26
  * @returns The mock endowments.
28
- */
29
- function getMockEndowments() {
30
- const endowments = (0, mock_1.generateMockEndowments)();
27
+ */ function getMockEndowments() {
28
+ const endowments = (0, _mock.generateMockEndowments)();
31
29
  return {
32
30
  ...endowments,
33
31
  window: endowments,
34
- self: endowments,
32
+ self: endowments
35
33
  };
36
34
  }
37
35
  const snapFilePath = process.argv[2];
38
- const snapModule = { exports: {} };
36
+ const snapModule = {
37
+ exports: {}
38
+ };
39
39
  new Compartment({
40
40
  ...getMockEndowments(),
41
41
  module: snapModule,
42
- exports: snapModule.exports,
43
- }).evaluate((0, fs_1.readFileSync)(snapFilePath, 'utf8'));
44
- const invalidExports = Object.keys(snapModule.exports).filter((snapExport) => !types_1.SNAP_EXPORT_NAMES.includes(snapExport));
42
+ exports: snapModule.exports
43
+ }).evaluate((0, _fs.readFileSync)(snapFilePath, 'utf8'));
44
+ const invalidExports = Object.keys(snapModule.exports).filter((snapExport)=>!_types.SNAP_EXPORT_NAMES.includes(snapExport));
45
45
  if (invalidExports.length > 0) {
46
46
  // eslint-disable-next-line no-console
47
47
  console.warn(`Invalid snap exports detected:\n${invalidExports.join('\n')}`);
48
48
  }
49
- setTimeout(() => process.exit(0), 1000); // Hack to ensure worker exits
49
+ setTimeout(()=>process.exit(0), 1000); // Hack to ensure worker exits
50
+
50
51
  //# sourceMappingURL=eval-worker.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,77 @@
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
+ SnapEvalError: function() {
13
+ return SnapEvalError;
14
+ },
15
+ evalBundle: function() {
16
+ return evalBundle;
17
+ }
18
+ });
19
+ const _utils = require("@metamask/utils");
20
+ const _child_process = require("child_process");
21
+ const _path = require("path");
22
+ const _fs = require("./fs");
23
+ function _define_property(obj, key, value) {
24
+ if (key in obj) {
25
+ Object.defineProperty(obj, key, {
26
+ value: value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ } else {
32
+ obj[key] = value;
33
+ }
34
+ return obj;
35
+ }
36
+ class SnapEvalError extends Error {
37
+ constructor(message, output){
38
+ super(message);
39
+ _define_property(this, "output", void 0);
40
+ this.name = 'SnapEvalError';
41
+ this.output = output;
42
+ }
43
+ }
44
+ async function evalBundle(bundlePath) {
45
+ await (0, _fs.validateFilePath)(bundlePath);
46
+ return new Promise((resolve, reject)=>{
47
+ const worker = (0, _child_process.fork)((0, _path.join)(__dirname, 'eval-worker.js'), [
48
+ bundlePath
49
+ ], {
50
+ // To avoid printing the output of the worker to the console, we set
51
+ // `stdio` to `pipe` and handle the output ourselves.
52
+ stdio: 'pipe'
53
+ });
54
+ let stdout = '';
55
+ let stderr = '';
56
+ (0, _utils.assert)(worker.stdout, '`stdout` should be defined.');
57
+ (0, _utils.assert)(worker.stderr, '`stderr` should be defined.');
58
+ worker.stdout.on('data', (data)=>{
59
+ stdout += data.toString();
60
+ });
61
+ worker.stderr.on('data', (data)=>{
62
+ stderr += data.toString();
63
+ });
64
+ worker.on('exit', (exitCode)=>{
65
+ const output = {
66
+ stdout,
67
+ stderr
68
+ };
69
+ if (exitCode === 0) {
70
+ return resolve(output);
71
+ }
72
+ return reject(new SnapEvalError(`Process exited with non-zero exit code: ${exitCode}.`, output));
73
+ });
74
+ });
75
+ }
76
+
77
+ //# sourceMappingURL=eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/eval.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport { fork } from 'child_process';\nimport { join } from 'path';\n\nimport { validateFilePath } from './fs';\n\nexport type EvalOutput = {\n stdout: string;\n stderr: string;\n};\n\nexport class SnapEvalError extends Error {\n readonly output: EvalOutput;\n\n constructor(message: string, output: EvalOutput) {\n super(message);\n\n this.name = 'SnapEvalError';\n this.output = output;\n }\n}\n\n/**\n * Spawn a new process to run the provided bundle in.\n *\n * @param bundlePath - The path to the bundle to run.\n * @returns `null` if the worker ran successfully.\n * @throws If the worker failed to run successfully.\n */\nexport async function evalBundle(bundlePath: string): Promise<EvalOutput> {\n await validateFilePath(bundlePath);\n\n return new Promise((resolve, reject) => {\n const worker = fork(join(__dirname, 'eval-worker.js'), [bundlePath], {\n // To avoid printing the output of the worker to the console, we set\n // `stdio` to `pipe` and handle the output ourselves.\n stdio: 'pipe',\n });\n\n let stdout = '';\n let stderr = '';\n\n assert(worker.stdout, '`stdout` should be defined.');\n assert(worker.stderr, '`stderr` should be defined.');\n\n worker.stdout.on('data', (data: Buffer) => {\n stdout += data.toString();\n });\n\n worker.stderr.on('data', (data: Buffer) => {\n stderr += data.toString();\n });\n\n worker.on('exit', (exitCode: number) => {\n const output = {\n stdout,\n stderr,\n };\n\n if (exitCode === 0) {\n return resolve(output);\n }\n\n return reject(\n new SnapEvalError(\n `Process exited with non-zero exit code: ${exitCode}.`,\n output,\n ),\n );\n });\n });\n}\n"],"names":["SnapEvalError","evalBundle","Error","constructor","message","output","name","bundlePath","validateFilePath","Promise","resolve","reject","worker","fork","join","__dirname","stdio","stdout","stderr","assert","on","data","toString","exitCode"],"mappings":";;;;;;;;;;;IAWaA,aAAa;eAAbA;;IAkBSC,UAAU;eAAVA;;;uBA7BC;+BACF;sBACA;oBAEY;;;;;;;;;;;;;;AAO1B,MAAMD,sBAAsBE;IAGjCC,YAAYC,OAAe,EAAEC,MAAkB,CAAE;QAC/C,KAAK,CAACD;QAHR,uBAASC,UAAT,KAAA;QAKE,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACD,MAAM,GAAGA;IAChB;AACF;AASO,eAAeJ,WAAWM,UAAkB;IACjD,MAAMC,IAAAA,oBAAgB,EAACD;IAEvB,OAAO,IAAIE,QAAQ,CAACC,SAASC;QAC3B,MAAMC,SAASC,IAAAA,mBAAI,EAACC,IAAAA,UAAI,EAACC,WAAW,mBAAmB;YAACR;SAAW,EAAE;YACnE,oEAAoE;YACpE,qDAAqD;YACrDS,OAAO;QACT;QAEA,IAAIC,SAAS;QACb,IAAIC,SAAS;QAEbC,IAAAA,aAAM,EAACP,OAAOK,MAAM,EAAE;QACtBE,IAAAA,aAAM,EAACP,OAAOM,MAAM,EAAE;QAEtBN,OAAOK,MAAM,CAACG,EAAE,CAAC,QAAQ,CAACC;YACxBJ,UAAUI,KAAKC,QAAQ;QACzB;QAEAV,OAAOM,MAAM,CAACE,EAAE,CAAC,QAAQ,CAACC;YACxBH,UAAUG,KAAKC,QAAQ;QACzB;QAEAV,OAAOQ,EAAE,CAAC,QAAQ,CAACG;YACjB,MAAMlB,SAAS;gBACbY;gBACAC;YACF;YAEA,IAAIK,aAAa,GAAG;gBAClB,OAAOb,QAAQL;YACjB;YAEA,OAAOM,OACL,IAAIX,cACF,CAAC,wCAAwC,EAAEuB,SAAS,CAAC,CAAC,EACtDlB;QAGN;IACF;AACF"}
package/dist/cjs/fs.js ADDED
@@ -0,0 +1,126 @@
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
+ isDirectory: function() {
13
+ return isDirectory;
14
+ },
15
+ isFile: function() {
16
+ return isFile;
17
+ },
18
+ readJsonFile: function() {
19
+ return readJsonFile;
20
+ },
21
+ getOutfilePath: function() {
22
+ return getOutfilePath;
23
+ },
24
+ validateOutfileName: function() {
25
+ return validateOutfileName;
26
+ },
27
+ validateFilePath: function() {
28
+ return validateFilePath;
29
+ },
30
+ validateDirPath: function() {
31
+ return validateDirPath;
32
+ },
33
+ useTemporaryFile: function() {
34
+ return useTemporaryFile;
35
+ }
36
+ });
37
+ const _fs = require("fs");
38
+ const _os = /*#__PURE__*/ _interop_require_default(require("os"));
39
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
40
+ const _json = require("./json");
41
+ const _virtualfile = require("./virtual-file");
42
+ function _interop_require_default(obj) {
43
+ return obj && obj.__esModule ? obj : {
44
+ default: obj
45
+ };
46
+ }
47
+ async function isDirectory(pathString, createDir) {
48
+ try {
49
+ const stats = await _fs.promises.stat(pathString);
50
+ return stats.isDirectory();
51
+ } catch (error) {
52
+ if (error.code === 'ENOENT') {
53
+ if (!createDir) {
54
+ return false;
55
+ }
56
+ await _fs.promises.mkdir(pathString, {
57
+ recursive: true
58
+ });
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+ }
64
+ async function isFile(pathString) {
65
+ try {
66
+ const stats = await _fs.promises.stat(pathString);
67
+ return stats.isFile();
68
+ } catch (error) {
69
+ return false;
70
+ }
71
+ }
72
+ async function readJsonFile(pathString) {
73
+ if (!pathString.endsWith('.json')) {
74
+ throw new Error('The specified file must be a ".json" file.');
75
+ }
76
+ let file;
77
+ try {
78
+ file = await (0, _virtualfile.readVirtualFile)(pathString, 'utf8');
79
+ } catch (error) {
80
+ if (error.code === 'ENOENT') {
81
+ throw new Error(`Could not find '${pathString}'. Please ensure that the file exists.`);
82
+ }
83
+ throw error;
84
+ }
85
+ file.result = (0, _json.parseJson)(file.toString());
86
+ return file;
87
+ }
88
+ function getOutfilePath(outDir, outFileName) {
89
+ return _path.default.join(outDir, outFileName || 'bundle.js');
90
+ }
91
+ function validateOutfileName(filename) {
92
+ if (!filename.endsWith('.js') || filename === '.js' || _path.default.basename(filename) !== filename) {
93
+ throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);
94
+ }
95
+ return true;
96
+ }
97
+ async function validateFilePath(filePath) {
98
+ const exists = await isFile(filePath);
99
+ if (!exists) {
100
+ throw new Error(`Invalid params: '${filePath}' is not a file or does not exist.`);
101
+ }
102
+ return true;
103
+ }
104
+ async function validateDirPath(dirPath, createDir) {
105
+ const exists = await isDirectory(dirPath, createDir);
106
+ if (!exists) {
107
+ throw new Error(`Invalid params: '${dirPath}' is not a directory or could not be created.`);
108
+ }
109
+ return true;
110
+ }
111
+ async function useTemporaryFile(fileName, fileContents, fn) {
112
+ const filePath = _path.default.join(_os.default.tmpdir(), fileName);
113
+ await _fs.promises.mkdir(_path.default.dirname(filePath), {
114
+ recursive: true
115
+ });
116
+ await _fs.promises.writeFile(filePath, fileContents);
117
+ try {
118
+ await fn(filePath);
119
+ } finally{
120
+ if (await isFile(filePath)) {
121
+ await _fs.promises.unlink(filePath);
122
+ }
123
+ }
124
+ }
125
+
126
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs.ts"],"sourcesContent":["import type { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport type { VirtualFile } from './virtual-file';\nimport { readVirtualFile } from './virtual-file';\n\n/**\n * Checks whether the given path string resolves to an existing directory, and\n * optionally creates the directory if it doesn't exist.\n *\n * @param pathString - The path string to check.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns Whether the given path is an existing directory.\n */\nexport async function isDirectory(\n pathString: string,\n createDir: boolean,\n): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n if (!createDir) {\n return false;\n }\n\n await fs.mkdir(pathString, { recursive: true });\n return true;\n }\n\n return false;\n }\n}\n\n/**\n * Checks whether the given path string resolves to an existing file.\n *\n * @param pathString - The path string to check.\n * @returns Whether the given path is an existing file.\n */\nexport async function isFile(pathString: string): Promise<boolean> {\n try {\n const stats = await fs.stat(pathString);\n return stats.isFile();\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Reads a `.json` file, parses its contents, and returns them.\n *\n * @param pathString - The path to the JSON file.\n * @returns The parsed contents of the JSON file.\n */\nexport async function readJsonFile<Type extends Json = Json>(\n pathString: string,\n): Promise<VirtualFile<Type>> {\n if (!pathString.endsWith('.json')) {\n throw new Error('The specified file must be a \".json\" file.');\n }\n\n let file;\n try {\n file = await readVirtualFile(pathString, 'utf8');\n } catch (error) {\n if (error.code === 'ENOENT') {\n throw new Error(\n `Could not find '${pathString}'. Please ensure that the file exists.`,\n );\n }\n\n throw error;\n }\n file.result = parseJson(file.toString());\n return file as VirtualFile<Type>;\n}\n\n/**\n * Gets the complete out file path from an output file name and parent\n * directory path.\n *\n * @param outDir - The path to the out file's parent directory.\n * @param outFileName - The out file's name.\n * @returns The complete path to the out file.\n */\nexport function getOutfilePath(outDir: string, outFileName: string): string {\n return pathUtils.join(outDir, outFileName || 'bundle.js');\n}\n\n/**\n * Ensures that the outfile name is just a `.js` file name.\n * Throws on validation failure.\n *\n * @param filename - The file name to validate.\n * @returns `true` if validation succeeded.\n * @throws If the file name is invalid.\n */\nexport function validateOutfileName(filename: string): boolean {\n if (\n !filename.endsWith('.js') ||\n filename === '.js' ||\n pathUtils.basename(filename) !== filename\n ) {\n throw new Error(`Invalid outfile name: ${filename}. Must be a .js file`);\n }\n return true;\n}\n\n/**\n * Validates a file path. Throws on validation failure.\n *\n * @param filePath - The file path to validate.\n * @returns `true` if validation succeeded.\n * @throws If the path does not resolve to a file.\n */\nexport async function validateFilePath(filePath: string): Promise<boolean> {\n const exists = await isFile(filePath);\n if (!exists) {\n throw new Error(\n `Invalid params: '${filePath}' is not a file or does not exist.`,\n );\n }\n return true;\n}\n\n/**\n * Validates a directory path. Throws on validation failure.\n *\n * @param dirPath - The directory path to validate.\n * @param createDir - Whether to create the directory if it doesn't exist.\n * @returns `true` if validation succeeded or the directory was created.\n * @throws If the directory does not exist or could not be created.\n */\nexport async function validateDirPath(\n dirPath: string,\n createDir: boolean,\n): Promise<boolean> {\n const exists = await isDirectory(dirPath, createDir);\n if (!exists) {\n throw new Error(\n `Invalid params: '${dirPath}' is not a directory or could not be created.`,\n );\n }\n return true;\n}\n\n/**\n * Creates a temporary file with a given name and content, writes it to disk and calls the provided function.\n * This function handles deletion of the temporary file after usage.\n *\n * @param fileName - The name of the temporary file.\n * @param fileContents - The content of the temporary file.\n * @param fn - The callback function to call when the temporary file has been created.\n */\nexport async function useTemporaryFile(\n fileName: string,\n fileContents: string,\n fn: (path: string) => Promise<unknown>,\n): Promise<void> {\n const filePath = pathUtils.join(os.tmpdir(), fileName);\n await fs.mkdir(pathUtils.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, fileContents);\n try {\n await fn(filePath);\n } finally {\n if (await isFile(filePath)) {\n await fs.unlink(filePath);\n }\n }\n}\n"],"names":["isDirectory","isFile","readJsonFile","getOutfilePath","validateOutfileName","validateFilePath","validateDirPath","useTemporaryFile","pathString","createDir","stats","fs","stat","error","code","mkdir","recursive","endsWith","Error","file","readVirtualFile","result","parseJson","toString","outDir","outFileName","pathUtils","join","filename","basename","filePath","exists","dirPath","fileName","fileContents","fn","os","tmpdir","dirname","writeFile","unlink"],"mappings":";;;;;;;;;;;IAiBsBA,WAAW;eAAXA;;IA2BAC,MAAM;eAANA;;IAeAC,YAAY;eAAZA;;IA+BNC,cAAc;eAAdA;;IAYAC,mBAAmB;eAAnBA;;IAkBMC,gBAAgB;eAAhBA;;IAkBAC,eAAe;eAAfA;;IAqBAC,gBAAgB;eAAhBA;;;oBA9JS;2DAChB;6DACO;sBAEI;6BAEM;;;;;;AAUzB,eAAeP,YACpBQ,UAAkB,EAClBC,SAAkB;IAElB,IAAI;QACF,MAAMC,QAAQ,MAAMC,YAAE,CAACC,IAAI,CAACJ;QAC5B,OAAOE,MAAMV,WAAW;IAC1B,EAAE,OAAOa,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,IAAI,CAACL,WAAW;gBACd,OAAO;YACT;YAEA,MAAME,YAAE,CAACI,KAAK,CAACP,YAAY;gBAAEQ,WAAW;YAAK;YAC7C,OAAO;QACT;QAEA,OAAO;IACT;AACF;AAQO,eAAef,OAAOO,UAAkB;IAC7C,IAAI;QACF,MAAME,QAAQ,MAAMC,YAAE,CAACC,IAAI,CAACJ;QAC5B,OAAOE,MAAMT,MAAM;IACrB,EAAE,OAAOY,OAAO;QACd,OAAO;IACT;AACF;AAQO,eAAeX,aACpBM,UAAkB;IAElB,IAAI,CAACA,WAAWS,QAAQ,CAAC,UAAU;QACjC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIC;IACJ,IAAI;QACFA,OAAO,MAAMC,IAAAA,4BAAe,EAACZ,YAAY;IAC3C,EAAE,OAAOK,OAAO;QACd,IAAIA,MAAMC,IAAI,KAAK,UAAU;YAC3B,MAAM,IAAII,MACR,CAAC,gBAAgB,EAAEV,WAAW,sCAAsC,CAAC;QAEzE;QAEA,MAAMK;IACR;IACAM,KAAKE,MAAM,GAAGC,IAAAA,eAAS,EAACH,KAAKI,QAAQ;IACrC,OAAOJ;AACT;AAUO,SAAShB,eAAeqB,MAAc,EAAEC,WAAmB;IAChE,OAAOC,aAAS,CAACC,IAAI,CAACH,QAAQC,eAAe;AAC/C;AAUO,SAASrB,oBAAoBwB,QAAgB;IAClD,IACE,CAACA,SAASX,QAAQ,CAAC,UACnBW,aAAa,SACbF,aAAS,CAACG,QAAQ,CAACD,cAAcA,UACjC;QACA,MAAM,IAAIV,MAAM,CAAC,sBAAsB,EAAEU,SAAS,oBAAoB,CAAC;IACzE;IACA,OAAO;AACT;AASO,eAAevB,iBAAiByB,QAAgB;IACrD,MAAMC,SAAS,MAAM9B,OAAO6B;IAC5B,IAAI,CAACC,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEY,SAAS,kCAAkC,CAAC;IAEpE;IACA,OAAO;AACT;AAUO,eAAexB,gBACpB0B,OAAe,EACfvB,SAAkB;IAElB,MAAMsB,SAAS,MAAM/B,YAAYgC,SAASvB;IAC1C,IAAI,CAACsB,QAAQ;QACX,MAAM,IAAIb,MACR,CAAC,iBAAiB,EAAEc,QAAQ,6CAA6C,CAAC;IAE9E;IACA,OAAO;AACT;AAUO,eAAezB,iBACpB0B,QAAgB,EAChBC,YAAoB,EACpBC,EAAsC;IAEtC,MAAML,WAAWJ,aAAS,CAACC,IAAI,CAACS,WAAE,CAACC,MAAM,IAAIJ;IAC7C,MAAMtB,YAAE,CAACI,KAAK,CAACW,aAAS,CAACY,OAAO,CAACR,WAAW;QAAEd,WAAW;IAAK;IAC9D,MAAML,YAAE,CAAC4B,SAAS,CAACT,UAAUI;IAC7B,IAAI;QACF,MAAMC,GAAGL;IACX,SAAU;QACR,IAAI,MAAM7B,OAAO6B,WAAW;YAC1B,MAAMnB,YAAE,CAAC6B,MAAM,CAACV;QAClB;IACF;AACF"}
@@ -0,0 +1,80 @@
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
+ HandlerType: function() {
13
+ return HandlerType;
14
+ },
15
+ SeverityLevel: function() {
16
+ return SeverityLevel;
17
+ },
18
+ SNAP_EXPORTS: function() {
19
+ return SNAP_EXPORTS;
20
+ }
21
+ });
22
+ var HandlerType;
23
+ (function(HandlerType) {
24
+ HandlerType["OnRpcRequest"] = 'onRpcRequest';
25
+ HandlerType["OnTransaction"] = 'onTransaction';
26
+ HandlerType["OnCronjob"] = 'onCronjob';
27
+ HandlerType["OnInstall"] = 'onInstall';
28
+ HandlerType["OnUpdate"] = 'onUpdate';
29
+ HandlerType["OnNameLookup"] = 'onNameLookup';
30
+ })(HandlerType || (HandlerType = {}));
31
+ const SNAP_EXPORTS = {
32
+ [HandlerType.OnRpcRequest]: {
33
+ type: HandlerType.OnRpcRequest,
34
+ required: true,
35
+ validator: (snapExport)=>{
36
+ return typeof snapExport === 'function';
37
+ }
38
+ },
39
+ [HandlerType.OnTransaction]: {
40
+ type: HandlerType.OnTransaction,
41
+ required: true,
42
+ validator: (snapExport)=>{
43
+ return typeof snapExport === 'function';
44
+ }
45
+ },
46
+ [HandlerType.OnCronjob]: {
47
+ type: HandlerType.OnCronjob,
48
+ required: true,
49
+ validator: (snapExport)=>{
50
+ return typeof snapExport === 'function';
51
+ }
52
+ },
53
+ [HandlerType.OnNameLookup]: {
54
+ type: HandlerType.OnNameLookup,
55
+ required: true,
56
+ validator: (snapExport)=>{
57
+ return typeof snapExport === 'function';
58
+ }
59
+ },
60
+ [HandlerType.OnInstall]: {
61
+ type: HandlerType.OnInstall,
62
+ required: false,
63
+ validator: (snapExport)=>{
64
+ return typeof snapExport === 'function';
65
+ }
66
+ },
67
+ [HandlerType.OnUpdate]: {
68
+ type: HandlerType.OnUpdate,
69
+ required: false,
70
+ validator: (snapExport)=>{
71
+ return typeof snapExport === 'function';
72
+ }
73
+ }
74
+ };
75
+ var SeverityLevel;
76
+ (function(SeverityLevel) {
77
+ SeverityLevel["Critical"] = 'critical';
78
+ })(SeverityLevel || (SeverityLevel = {}));
79
+
80
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/handlers.ts"],"sourcesContent":["import type { Component } from '@metamask/snaps-ui';\nimport type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\nimport type { EnumToUnion } from './enum';\nimport type { AccountAddress, Caip2ChainId } from './namespace';\n\nexport enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n}\n\ntype SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\n/**\n * The `onRpcRequest` handler. This is called whenever a JSON-RPC request is\n * made to the snap.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * snap, or the URL of a dapp.\n * @param args.request - The JSON-RPC request sent to the snap.\n * @returns The JSON-RPC response. This must be a JSON-serializable value.\n */\nexport type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: {\n origin: string;\n request: JsonRpcRequest<Params>;\n }) => Promise<unknown>;\n\n/**\n * Enum used to specify the severity level of content being returned from a transaction insight.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * The response from a snap's `onTransaction` handler.\n *\n * @property content - A custom UI component, that will be shown in MetaMask. Can be created using `@metamask/snaps-ui`.\n *\n * If the snap has no insights about the transaction, this should be `null`.\n */\nexport type OnTransactionResponse = {\n content: Component | null;\n severity?: EnumToUnion<SeverityLevel>;\n};\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the dapp that submitted the transaction.\n * @returns Insights about the transaction. See {@link OnTransactionResponse}.\n */\n// TODO: Improve type.\nexport type OnTransactionHandler = (args: {\n transaction: { [key: string]: Json };\n chainId: string;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse>;\n\n/**\n * The `onCronjob` handler. This is called on a regular interval, as defined by\n * the snap's manifest.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the snap.\n */\nexport type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: { request: JsonRpcRequest<Params> }) => Promise<unknown>;\n\n/**\n * A handler that can be used for the lifecycle hooks.\n */\nexport type LifecycleEventHandler = (args: {\n request: JsonRpcRequest;\n}) => Promise<unknown>;\n\n/**\n * The `onInstall` handler. This is called after the snap is installed.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnInstallHandler = LifecycleEventHandler;\n\n/**\n * The `onUpdate` handler. This is called after the snap is updated.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnUpdateHandler = LifecycleEventHandler;\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * The response from a snap's `onNameLookup` handler.\n *\n * @property resolvedAddress - The resolved address for a given domain.\n * @property resolvedDomain - The resolved domain for a given address.\n *\n *\n * If the snap has no resolved address/domain from its lookup, this should be `null`.\n */\nexport type OnNameLookupResponse =\n | {\n resolvedAddress: AccountAddress;\n resolvedDomain?: never;\n }\n | { resolvedDomain: string; resolvedAddress?: never }\n | null;\n\nexport type OnNameLookupArgs = {\n chainId: Caip2ChainId;\n} & ({ domain: string; address?: never } | { address: string; domain?: never });\n\n/**\n * The `onNameLookup` handler. This is called whenever content is entered\n * into the send to field for sending assets to an EOA address.\n *\n * @param args - The request arguments.\n * @param args.domain - The human-readable address that is to be resolved.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.address - The address that is to be resolved.\n * @returns Resolved address/domain from the lookup. See {@link OnNameLookupResponse}.\n */\nexport type OnNameLookupHandler = (\n args: OnNameLookupArgs,\n) => Promise<OnNameLookupResponse>;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n typeof SNAP_EXPORTS[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"],"names":["SNAP_EXPORTS","HandlerType","OnRpcRequest","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","type","required","validator","snapExport","SeverityLevel","Critical"],"mappings":";;;;;;;;;;;;;;;;;IAuCaA,YAAY;eAAZA;;;IAjCN;UAAKC,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,mBAAgB;IAFNF,YAGVG,eAAY;IAHFH,YAIVI,eAAY;IAJFJ,YAKVK,cAAW;IALDL,YAMVM,kBAAe;GANLN,gBAAAA;AAiCL,MAAMD,eAAe;IAC1B,CAACC,YAAYC,YAAY,CAAC,EAAE;QAC1BM,MAAMP,YAAYC,YAAY;QAC9BO,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYE,aAAa,CAAC,EAAE;QAC3BK,MAAMP,YAAYE,aAAa;QAC/BM,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYG,SAAS,CAAC,EAAE;QACvBI,MAAMP,YAAYG,SAAS;QAC3BK,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYM,YAAY,CAAC,EAAE;QAC1BC,MAAMP,YAAYM,YAAY;QAC9BE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYI,SAAS,CAAC,EAAE;QACvBG,MAAMP,YAAYI,SAAS;QAC3BI,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYK,QAAQ,CAAC,EAAE;QACtBE,MAAMP,YAAYK,QAAQ;QAC1BG,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF;IAqBO;UAAKC,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
@@ -0,0 +1,37 @@
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
+ SVG_MAX_BYTE_SIZE: function() {
13
+ return SVG_MAX_BYTE_SIZE;
14
+ },
15
+ SVG_MAX_BYTE_SIZE_TEXT: function() {
16
+ return SVG_MAX_BYTE_SIZE_TEXT;
17
+ },
18
+ assertIsSnapIcon: function() {
19
+ return assertIsSnapIcon;
20
+ }
21
+ });
22
+ const _utils = require("@metamask/utils");
23
+ const _issvg = /*#__PURE__*/ _interop_require_default(require("is-svg"));
24
+ function _interop_require_default(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ const SVG_MAX_BYTE_SIZE = 100000;
30
+ const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(SVG_MAX_BYTE_SIZE / 1000)}kb`;
31
+ const assertIsSnapIcon = (icon)=>{
32
+ (0, _utils.assert)(icon.path.endsWith('.svg'), 'Expected snap icon to end in ".svg".');
33
+ (0, _utils.assert)(Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE, `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`);
34
+ (0, _utils.assert)((0, _issvg.default)(icon.toString()), 'Snap icon must be a valid SVG.');
35
+ };
36
+
37
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/icon.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport isSvg from 'is-svg';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\nexport const assertIsSnapIcon = (icon: VirtualFile) => {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n assert(\n Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n};\n"],"names":["SVG_MAX_BYTE_SIZE","SVG_MAX_BYTE_SIZE_TEXT","assertIsSnapIcon","Math","floor","icon","assert","path","endsWith","Buffer","byteLength","value","isSvg","toString"],"mappings":";;;;;;;;;;;IAKaA,iBAAiB;eAAjBA;;IACAC,sBAAsB;eAAtBA;;IAIAC,gBAAgB;eAAhBA;;;uBAVU;8DACL;;;;;;AAIX,MAAMF,oBAAoB;AAC1B,MAAMC,yBAAyB,CAAC,EAAEE,KAAKC,KAAK,CACjDJ,oBAAoB,MACpB,EAAE,CAAC;AAEE,MAAME,mBAAmB,CAACG;IAC/BC,IAAAA,aAAM,EAACD,KAAKE,IAAI,CAACC,QAAQ,CAAC,SAAS;IAEnCF,IAAAA,aAAM,EACJG,OAAOC,UAAU,CAACL,KAAKM,KAAK,EAAE,WAAWX,mBACzC,CAAC,mDAAmD,EAAEC,uBAAuB,CAAC,CAAC;IAGjFK,IAAAA,aAAM,EAACM,IAAAA,cAAK,EAACP,KAAKQ,QAAQ,KAAK;AACjC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Creates the iframe to be used as the execution environment. This may run
3
+ * forever if the iframe never loads, but the promise should be wrapped in
4
+ * an initialization timeout in the SnapController.
5
+ *
6
+ * @param uri - The iframe URI.
7
+ * @param id - The ID to assign to the iframe.
8
+ * @param sandbox - Whether to enable the sandbox attribute.
9
+ * @returns A promise that resolves to the contentWindow of the iframe.
10
+ */ "use strict";
11
+ Object.defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+ Object.defineProperty(exports, "createWindow", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return createWindow;
18
+ }
19
+ });
20
+ async function createWindow(uri, id, sandbox = true) {
21
+ return await new Promise((resolve, reject)=>{
22
+ const iframe = document.createElement('iframe');
23
+ // The order of operations appears to matter for everything except this
24
+ // attribute. We may as well set it here.
25
+ iframe.setAttribute('id', id);
26
+ iframe.setAttribute('data-testid', 'snaps-iframe');
27
+ if (sandbox) {
28
+ // For the sandbox property to have any effect it needs to be set before the iframe is appended.
29
+ // We apply this property as a principle of least authority (POLA)
30
+ // measure.
31
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox
32
+ iframe.setAttribute('sandbox', 'allow-scripts');
33
+ }
34
+ // In the past, we've had problems that appear to be symptomatic of the
35
+ // iframe firing the `load` event before its scripts are actually loaded,
36
+ // which has prevented snaps from executing properly. Therefore, we set
37
+ // the `src` attribute and append the iframe to the DOM before attaching
38
+ // the `load` listener.
39
+ //
40
+ // `load` should only fire when "all dependent resources" have been
41
+ // loaded, which includes scripts.
42
+ //
43
+ // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
44
+ // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489
45
+ iframe.setAttribute('src', uri);
46
+ document.body.appendChild(iframe);
47
+ iframe.addEventListener('load', ()=>{
48
+ if (iframe.contentWindow) {
49
+ resolve(iframe.contentWindow);
50
+ } else {
51
+ // We don't know of a case when this would happen, but better to fail
52
+ // fast if it does.
53
+ reject(new Error(`iframe.contentWindow not present on load for job "${id}".`));
54
+ }
55
+ });
56
+ });
57
+ }
58
+
59
+ //# sourceMappingURL=iframe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/iframe.ts"],"sourcesContent":["/**\n * Creates the iframe to be used as the execution environment. This may run\n * forever if the iframe never loads, but the promise should be wrapped in\n * an initialization timeout in the SnapController.\n *\n * @param uri - The iframe URI.\n * @param id - The ID to assign to the iframe.\n * @param sandbox - Whether to enable the sandbox attribute.\n * @returns A promise that resolves to the contentWindow of the iframe.\n */\nexport async function createWindow(\n uri: string,\n id: string,\n sandbox = true,\n): Promise<Window> {\n return await new Promise((resolve, reject) => {\n const iframe = document.createElement('iframe');\n // The order of operations appears to matter for everything except this\n // attribute. We may as well set it here.\n iframe.setAttribute('id', id);\n iframe.setAttribute('data-testid', 'snaps-iframe');\n\n if (sandbox) {\n // For the sandbox property to have any effect it needs to be set before the iframe is appended.\n // We apply this property as a principle of least authority (POLA)\n // measure.\n // Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n iframe.setAttribute('sandbox', 'allow-scripts');\n }\n\n // In the past, we've had problems that appear to be symptomatic of the\n // iframe firing the `load` event before its scripts are actually loaded,\n // which has prevented snaps from executing properly. Therefore, we set\n // the `src` attribute and append the iframe to the DOM before attaching\n // the `load` listener.\n //\n // `load` should only fire when \"all dependent resources\" have been\n // loaded, which includes scripts.\n //\n // MDN article for `load` event: https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event\n // Re: `load` firing twice: https://stackoverflow.com/questions/10781880/dynamically-created-iframe-triggers-onload-event-twice/15880489#15880489\n iframe.setAttribute('src', uri);\n document.body.appendChild(iframe);\n\n iframe.addEventListener('load', () => {\n if (iframe.contentWindow) {\n resolve(iframe.contentWindow);\n } else {\n // We don't know of a case when this would happen, but better to fail\n // fast if it does.\n reject(\n new Error(\n `iframe.contentWindow not present on load for job \"${id}\".`,\n ),\n );\n }\n });\n });\n}\n"],"names":["createWindow","uri","id","sandbox","Promise","resolve","reject","iframe","document","createElement","setAttribute","body","appendChild","addEventListener","contentWindow","Error"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BACqBA;;;eAAAA;;;AAAf,eAAeA,aACpBC,GAAW,EACXC,EAAU,EACVC,UAAU,IAAI;IAEd,OAAO,MAAM,IAAIC,QAAQ,CAACC,SAASC;QACjC,MAAMC,SAASC,SAASC,aAAa,CAAC;QACtC,uEAAuE;QACvE,yCAAyC;QACzCF,OAAOG,YAAY,CAAC,MAAMR;QAC1BK,OAAOG,YAAY,CAAC,eAAe;QAEnC,IAAIP,SAAS;YACX,gGAAgG;YAChG,kEAAkE;YAClE,WAAW;YACX,qFAAqF;YACrFI,OAAOG,YAAY,CAAC,WAAW;QACjC;QAEA,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,uBAAuB;QACvB,EAAE;QACF,mEAAmE;QACnE,kCAAkC;QAClC,EAAE;QACF,mGAAmG;QACnG,iJAAiJ;QACjJH,OAAOG,YAAY,CAAC,OAAOT;QAC3BO,SAASG,IAAI,CAACC,WAAW,CAACL;QAE1BA,OAAOM,gBAAgB,CAAC,QAAQ;YAC9B,IAAIN,OAAOO,aAAa,EAAE;gBACxBT,QAAQE,OAAOO,aAAa;YAC9B,OAAO;gBACL,qEAAqE;gBACrE,mBAAmB;gBACnBR,OACE,IAAIS,MACF,CAAC,kDAAkD,EAAEb,GAAG,EAAE,CAAC;YAGjE;QACF;IACF;AACF"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./array"), exports);
6
+ _export_star(require("./caveats"), exports);
7
+ _export_star(require("./checksum"), exports);
8
+ _export_star(require("./cronjob"), exports);
9
+ _export_star(require("./deep-clone"), exports);
10
+ _export_star(require("./default-endowments"), exports);
11
+ _export_star(require("./entropy"), exports);
12
+ _export_star(require("./enum"), exports);
13
+ _export_star(require("./errors"), exports);
14
+ _export_star(require("./handlers"), exports);
15
+ _export_star(require("./iframe"), exports);
16
+ _export_star(require("./json"), exports);
17
+ _export_star(require("./json-rpc"), exports);
18
+ _export_star(require("./logging"), exports);
19
+ _export_star(require("./manifest/index.browser"), exports);
20
+ _export_star(require("./namespace"), exports);
21
+ _export_star(require("./path"), exports);
22
+ _export_star(require("./snaps"), exports);
23
+ _export_star(require("./strings"), exports);
24
+ _export_star(require("./structs"), exports);
25
+ _export_star(require("./types"), exports);
26
+ _export_star(require("./validation"), exports);
27
+ _export_star(require("./versions"), exports);
28
+ _export_star(require("./virtual-file/index.browser"), exports);
29
+ function _export_star(from, to) {
30
+ Object.keys(from).forEach(function(k) {
31
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
32
+ Object.defineProperty(to, k, {
33
+ enumerable: true,
34
+ get: function() {
35
+ return from[k];
36
+ }
37
+ });
38
+ }
39
+ });
40
+ return from;
41
+ }
42
+
43
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './errors';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -0,0 +1,24 @@
1
+ // Special entrypoint for execution environments for bundle sizing reasons
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ _export_star(require("./handlers"), exports);
7
+ _export_star(require("./logging"), exports);
8
+ _export_star(require("./namespace"), exports);
9
+ _export_star(require("./types"), exports);
10
+ function _export_star(from, to) {
11
+ Object.keys(from).forEach(function(k) {
12
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
13
+ Object.defineProperty(to, k, {
14
+ enumerable: true,
15
+ get: function() {
16
+ return from[k];
17
+ }
18
+ });
19
+ }
20
+ });
21
+ return from;
22
+ }
23
+
24
+ //# sourceMappingURL=index.executionenv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './handlers';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;;;;;qBAC5D;qBACA;qBACA;qBACA"}