@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
package/dist/cjs/mock.js DELETED
@@ -1,128 +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
- ALL_APIS: function() {
13
- return ALL_APIS;
14
- },
15
- isConstructor: function() {
16
- return isConstructor;
17
- },
18
- generateMockEndowments: function() {
19
- return generateMockEndowments;
20
- }
21
- });
22
- const _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
23
- const _events = /*#__PURE__*/ _interop_require_default(require("events"));
24
- const _defaultendowments = require("./default-endowments");
25
- function _interop_require_default(obj) {
26
- return obj && obj.__esModule ? obj : {
27
- default: obj
28
- };
29
- }
30
- const NETWORK_APIS = [
31
- 'fetch',
32
- 'Request',
33
- 'Headers',
34
- 'Response'
35
- ];
36
- const ALL_APIS = [
37
- ..._defaultendowments.DEFAULT_ENDOWMENTS,
38
- ...NETWORK_APIS,
39
- 'WebAssembly'
40
- ];
41
- /**
42
- * Get a mock snap API, that always returns `true` for requests.
43
- *
44
- * @returns A mocked snap provider.
45
- */ function getMockSnapGlobal() {
46
- // eslint-disable-next-line @typescript-eslint/require-await
47
- return {
48
- request: async ()=>true
49
- };
50
- }
51
- /**
52
- * Get a mock Ethereum provider, that always returns `true` for requests.
53
- *
54
- * @returns A mocked ethereum provider.
55
- */ function getMockEthereumProvider() {
56
- const mockProvider = new _events.default();
57
- // eslint-disable-next-line @typescript-eslint/require-await
58
- mockProvider.request = async ()=>true;
59
- return mockProvider;
60
- }
61
- const isConstructor = (value)=>Boolean(typeof value?.prototype?.constructor?.name === 'string');
62
- /**
63
- * A function that always returns `true`.
64
- *
65
- * @returns `true`.
66
- */ const mockFunction = ()=>true;
67
- class MockClass {
68
- }
69
- const handler = {
70
- // eslint-disable-next-line @typescript-eslint/naming-convention
71
- construct (Target, args) {
72
- return new Proxy(new Target(...args), handler);
73
- },
74
- get (_target, _prop) {
75
- return mockFunction;
76
- }
77
- };
78
- /**
79
- * Generate a mock class for a given value. The value is wrapped in a Proxy, and
80
- * all methods are replaced with a mock function.
81
- *
82
- * @param value - The value to mock.
83
- * @returns A mock class.
84
- */ const generateMockClass = (value)=>{
85
- return new Proxy(value, handler);
86
- };
87
- // Things not currently auto-mocked because of NodeJS, by adding them here we
88
- // have types for them and can use that to generate mocks if needed.
89
- const mockWindow = {
90
- crypto: _crypto.default,
91
- SubtleCrypto: MockClass
92
- };
93
- /**
94
- * Generate a mock endowment for a certain class or function on the `globalThis`
95
- * object.
96
- *
97
- * @param key - The key to generate the mock endowment for.
98
- * @returns A mocked class or function. If the key is part of the default
99
- * endowments, the original value is returned.
100
- */ const generateMockEndowment = (key)=>{
101
- const globalValue = globalThis[key];
102
- // Default exposed APIs don't need to be mocked
103
- if (globalValue && _defaultendowments.DEFAULT_ENDOWMENTS.includes(key)) {
104
- return globalValue;
105
- }
106
- // Fall back to mockWindow for certain APIs not exposed in global in Node.JS
107
- const globalOrMocked = globalValue ?? mockWindow[key];
108
- const type = typeof globalOrMocked;
109
- const isFunction = type === 'function';
110
- if (isFunction && isConstructor(globalOrMocked)) {
111
- return generateMockClass(globalOrMocked);
112
- } else if (isFunction || !globalOrMocked) {
113
- // Fall back to function mock for now
114
- return mockFunction;
115
- }
116
- return globalOrMocked;
117
- };
118
- const generateMockEndowments = ()=>{
119
- return ALL_APIS.reduce((acc, cur)=>({
120
- ...acc,
121
- [cur]: generateMockEndowment(cur)
122
- }), {
123
- snap: getMockSnapGlobal(),
124
- ethereum: getMockEthereumProvider()
125
- });
126
- };
127
-
128
- //# sourceMappingURL=mock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/mock.ts"],"sourcesContent":["import crypto from 'crypto';\nimport EventEmitter from 'events';\n\nimport { DEFAULT_ENDOWMENTS } from './default-endowments';\n\nconst NETWORK_APIS = ['fetch', 'Request', 'Headers', 'Response'];\n\nexport const ALL_APIS: string[] = [\n ...DEFAULT_ENDOWMENTS,\n ...NETWORK_APIS,\n 'WebAssembly',\n];\n\ntype MockSnapGlobal = {\n request: () => Promise<any>;\n};\n\ntype MockEthereumProvider = EventEmitter & {\n request: () => Promise<any>;\n};\n\n/**\n * Get a mock snap API, that always returns `true` for requests.\n *\n * @returns A mocked snap provider.\n */\nfunction getMockSnapGlobal(): MockSnapGlobal {\n // eslint-disable-next-line @typescript-eslint/require-await\n return { request: async () => true };\n}\n\n/**\n * Get a mock Ethereum provider, that always returns `true` for requests.\n *\n * @returns A mocked ethereum provider.\n */\nfunction getMockEthereumProvider(): MockEthereumProvider {\n const mockProvider = new EventEmitter() as Partial<MockEthereumProvider>;\n // eslint-disable-next-line @typescript-eslint/require-await\n mockProvider.request = async () => true;\n return mockProvider as MockEthereumProvider;\n}\n\n/**\n * Check if a value is a constructor.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a constructor, or `false` otherwise.\n */\nexport const isConstructor = (value: any) =>\n Boolean(typeof value?.prototype?.constructor?.name === 'string');\n\n/**\n * A function that always returns `true`.\n *\n * @returns `true`.\n */\nconst mockFunction = () => true;\nclass MockClass {}\n\nconst handler = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n construct(Target: any, args: any[]): any {\n return new Proxy(new Target(...args), handler);\n },\n get(_target: any, _prop: any) {\n return mockFunction;\n },\n};\n\n/**\n * Generate a mock class for a given value. The value is wrapped in a Proxy, and\n * all methods are replaced with a mock function.\n *\n * @param value - The value to mock.\n * @returns A mock class.\n */\nconst generateMockClass = (value: any) => {\n return new Proxy(value, handler);\n};\n\n// Things not currently auto-mocked because of NodeJS, by adding them here we\n// have types for them and can use that to generate mocks if needed.\nconst mockWindow: Record<string, unknown> = {\n crypto,\n SubtleCrypto: MockClass,\n};\n\n/**\n * Generate a mock endowment for a certain class or function on the `globalThis`\n * object.\n *\n * @param key - The key to generate the mock endowment for.\n * @returns A mocked class or function. If the key is part of the default\n * endowments, the original value is returned.\n */\nconst generateMockEndowment = (key: string) => {\n const globalValue = (globalThis as any)[key];\n\n // Default exposed APIs don't need to be mocked\n if (globalValue && DEFAULT_ENDOWMENTS.includes(key)) {\n return globalValue;\n }\n\n // Fall back to mockWindow for certain APIs not exposed in global in Node.JS\n const globalOrMocked = globalValue ?? mockWindow[key];\n\n const type = typeof globalOrMocked;\n const isFunction = type === 'function';\n if (isFunction && isConstructor(globalOrMocked)) {\n return generateMockClass(globalOrMocked);\n } else if (isFunction || !globalOrMocked) {\n // Fall back to function mock for now\n return mockFunction;\n }\n return globalOrMocked;\n};\n\n/**\n * Generate mock endowments for all the APIs as defined in {@link ALL_APIS}.\n *\n * @returns A map of endowments.\n */\nexport const generateMockEndowments = () => {\n return ALL_APIS.reduce<Record<string, any>>(\n (acc, cur) => ({ ...acc, [cur]: generateMockEndowment(cur) }),\n { snap: getMockSnapGlobal(), ethereum: getMockEthereumProvider() },\n );\n};\n"],"names":["ALL_APIS","isConstructor","generateMockEndowments","NETWORK_APIS","DEFAULT_ENDOWMENTS","getMockSnapGlobal","request","getMockEthereumProvider","mockProvider","EventEmitter","value","Boolean","prototype","constructor","name","mockFunction","MockClass","handler","construct","Target","args","Proxy","get","_target","_prop","generateMockClass","mockWindow","crypto","SubtleCrypto","generateMockEndowment","key","globalValue","globalThis","includes","globalOrMocked","type","isFunction","reduce","acc","cur","snap","ethereum"],"mappings":";;;;;;;;;;;IAOaA,QAAQ;eAARA;;IA0CAC,aAAa;eAAbA;;IA0EAC,sBAAsB;eAAtBA;;;+DA3HM;+DACM;mCAEU;;;;;;AAEnC,MAAMC,eAAe;IAAC;IAAS;IAAW;IAAW;CAAW;AAEzD,MAAMH,WAAqB;OAC7BI,qCAAkB;OAClBD;IACH;CACD;AAUD;;;;CAIC,GACD,SAASE;IACP,4DAA4D;IAC5D,OAAO;QAAEC,SAAS,UAAY;IAAK;AACrC;AAEA;;;;CAIC,GACD,SAASC;IACP,MAAMC,eAAe,IAAIC,eAAY;IACrC,4DAA4D;IAC5DD,aAAaF,OAAO,GAAG,UAAY;IACnC,OAAOE;AACT;AAQO,MAAMP,gBAAgB,CAACS,QAC5BC,QAAQ,OAAOD,OAAOE,WAAWC,aAAaC,SAAS;AAEzD;;;;CAIC,GACD,MAAMC,eAAe,IAAM;AAC3B,MAAMC;AAAW;AAEjB,MAAMC,UAAU;IACd,gEAAgE;IAChEC,WAAUC,MAAW,EAAEC,IAAW;QAChC,OAAO,IAAIC,MAAM,IAAIF,UAAUC,OAAOH;IACxC;IACAK,KAAIC,OAAY,EAAEC,KAAU;QAC1B,OAAOT;IACT;AACF;AAEA;;;;;;CAMC,GACD,MAAMU,oBAAoB,CAACf;IACzB,OAAO,IAAIW,MAAMX,OAAOO;AAC1B;AAEA,6EAA6E;AAC7E,oEAAoE;AACpE,MAAMS,aAAsC;IAC1CC,QAAAA,eAAM;IACNC,cAAcZ;AAChB;AAEA;;;;;;;CAOC,GACD,MAAMa,wBAAwB,CAACC;IAC7B,MAAMC,cAAc,AAACC,UAAkB,CAACF,IAAI;IAE5C,+CAA+C;IAC/C,IAAIC,eAAe3B,qCAAkB,CAAC6B,QAAQ,CAACH,MAAM;QACnD,OAAOC;IACT;IAEA,4EAA4E;IAC5E,MAAMG,iBAAiBH,eAAeL,UAAU,CAACI,IAAI;IAErD,MAAMK,OAAO,OAAOD;IACpB,MAAME,aAAaD,SAAS;IAC5B,IAAIC,cAAcnC,cAAciC,iBAAiB;QAC/C,OAAOT,kBAAkBS;IAC3B,OAAO,IAAIE,cAAc,CAACF,gBAAgB;QACxC,qCAAqC;QACrC,OAAOnB;IACT;IACA,OAAOmB;AACT;AAOO,MAAMhC,yBAAyB;IACpC,OAAOF,SAASqC,MAAM,CACpB,CAACC,KAAKC,MAAS,CAAA;YAAE,GAAGD,GAAG;YAAE,CAACC,IAAI,EAAEV,sBAAsBU;QAAK,CAAA,GAC3D;QAAEC,MAAMnC;QAAqBoC,UAAUlC;IAA0B;AAErE"}
@@ -1,124 +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
- CHAIN_ID_REGEX: function() {
13
- return CHAIN_ID_REGEX;
14
- },
15
- ACCOUNT_ID_REGEX: function() {
16
- return ACCOUNT_ID_REGEX;
17
- },
18
- parseChainId: function() {
19
- return parseChainId;
20
- },
21
- parseAccountId: function() {
22
- return parseAccountId;
23
- },
24
- LimitedString: function() {
25
- return LimitedString;
26
- },
27
- ChainIdStruct: function() {
28
- return ChainIdStruct;
29
- },
30
- AccountIdStruct: function() {
31
- return AccountIdStruct;
32
- },
33
- AccountIdArrayStruct: function() {
34
- return AccountIdArrayStruct;
35
- },
36
- ChainStruct: function() {
37
- return ChainStruct;
38
- },
39
- NamespaceStruct: function() {
40
- return NamespaceStruct;
41
- },
42
- NamespaceIdStruct: function() {
43
- return NamespaceIdStruct;
44
- },
45
- isNamespaceId: function() {
46
- return isNamespaceId;
47
- },
48
- isChainId: function() {
49
- return isChainId;
50
- },
51
- isAccountId: function() {
52
- return isAccountId;
53
- },
54
- isAccountIdArray: function() {
55
- return isAccountIdArray;
56
- },
57
- isNamespace: function() {
58
- return isNamespace;
59
- }
60
- });
61
- const _superstruct = require("superstruct");
62
- const CHAIN_ID_REGEX = RegExp("^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$", "u");
63
- const ACCOUNT_ID_REGEX = RegExp("^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})):(?<accountAddress>[a-zA-Z0-9]{1,64})$", "u");
64
- function parseChainId(chainId) {
65
- const match = CHAIN_ID_REGEX.exec(chainId);
66
- if (!match?.groups) {
67
- throw new Error('Invalid chain ID.');
68
- }
69
- return {
70
- namespace: match.groups.namespace,
71
- reference: match.groups.reference
72
- };
73
- }
74
- function parseAccountId(accountId) {
75
- const match = ACCOUNT_ID_REGEX.exec(accountId);
76
- if (!match?.groups) {
77
- throw new Error('Invalid account ID.');
78
- }
79
- return {
80
- address: match.groups.accountAddress,
81
- chainId: match.groups.chainId,
82
- chain: {
83
- namespace: match.groups.namespace,
84
- reference: match.groups.reference
85
- }
86
- };
87
- }
88
- const LimitedString = (0, _superstruct.size)((0, _superstruct.string)(), 1, 40);
89
- const ChainIdStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), CHAIN_ID_REGEX);
90
- const AccountIdStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), ACCOUNT_ID_REGEX);
91
- const AccountIdArrayStruct = (0, _superstruct.array)(AccountIdStruct);
92
- const ChainStruct = (0, _superstruct.object)({
93
- id: ChainIdStruct,
94
- name: LimitedString
95
- });
96
- const NamespaceStruct = (0, _superstruct.object)({
97
- /**
98
- * A list of supported chains in the namespace.
99
- */ chains: (0, _superstruct.array)(ChainStruct),
100
- /**
101
- * A list of supported RPC methods on the namespace, that a DApp can call.
102
- */ methods: (0, _superstruct.optional)((0, _superstruct.array)(LimitedString)),
103
- /**
104
- * A list of supported RPC events on the namespace, that a DApp can listen to.
105
- */ events: (0, _superstruct.optional)((0, _superstruct.array)(LimitedString))
106
- });
107
- const NamespaceIdStruct = (0, _superstruct.pattern)((0, _superstruct.string)(), /^[-a-z0-9]{3,8}$/u);
108
- function isNamespaceId(value) {
109
- return (0, _superstruct.is)(value, NamespaceIdStruct);
110
- }
111
- function isChainId(value) {
112
- return (0, _superstruct.is)(value, ChainIdStruct);
113
- }
114
- function isAccountId(value) {
115
- return (0, _superstruct.is)(value, AccountIdStruct);
116
- }
117
- function isAccountIdArray(value) {
118
- return (0, _superstruct.is)(value, AccountIdArrayStruct);
119
- }
120
- function isNamespace(value) {
121
- return (0, _superstruct.is)(value, NamespaceStruct);
122
- }
123
-
124
- //# sourceMappingURL=namespace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/namespace.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n array,\n is,\n object,\n optional,\n pattern,\n size,\n string,\n} from 'superstruct';\n\nexport const CHAIN_ID_REGEX =\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$/u;\n\nexport const ACCOUNT_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})):(?<accountAddress>[a-zA-Z0-9]{1,64})$/u;\n\n/**\n * Parse a chain ID string to an object containing the namespace and reference.\n * This validates the chain ID before parsing it.\n *\n * @param chainId - The chain ID to validate and parse.\n * @returns The parsed chain ID.\n */\nexport function parseChainId(chainId: ChainId): {\n namespace: NamespaceId;\n reference: string;\n} {\n const match = CHAIN_ID_REGEX.exec(chainId);\n if (!match?.groups) {\n throw new Error('Invalid chain ID.');\n }\n\n return {\n namespace: match.groups.namespace,\n reference: match.groups.reference,\n };\n}\n\n/**\n * Parse an account ID to an object containing the chain, chain ID and address.\n * This validates the account ID before parsing it.\n *\n * @param accountId - The account ID to validate and parse.\n * @returns The parsed account ID.\n */\nexport function parseAccountId(accountId: AccountId): {\n chain: { namespace: NamespaceId; reference: string };\n chainId: ChainId;\n address: string;\n} {\n const match = ACCOUNT_ID_REGEX.exec(accountId);\n if (!match?.groups) {\n throw new Error('Invalid account ID.');\n }\n\n return {\n address: match.groups.accountAddress,\n chainId: match.groups.chainId as ChainId,\n chain: {\n namespace: match.groups.namespace,\n reference: match.groups.reference,\n },\n };\n}\n\n/**\n * A helper struct for a string with a minimum length of 1 and a maximum length\n * of 40.\n */\nexport const LimitedString = size(string(), 1, 40);\n\n/**\n * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.\n */\nexport const ChainIdStruct = pattern(string(), CHAIN_ID_REGEX);\nexport type ChainId = `${string}:${string}`;\n\nexport const AccountIdStruct = pattern(string(), ACCOUNT_ID_REGEX);\nexport type AccountId = `${ChainId}:${string}`;\n\nexport const AccountIdArrayStruct = array(AccountIdStruct);\n\n/**\n * A chain descriptor.\n */\nexport const ChainStruct = object({\n id: ChainIdStruct,\n name: LimitedString,\n});\nexport type Chain = Infer<typeof ChainStruct>;\n\nexport const NamespaceStruct = object({\n /**\n * A list of supported chains in the namespace.\n */\n chains: array(ChainStruct),\n\n /**\n * A list of supported RPC methods on the namespace, that a DApp can call.\n */\n methods: optional(array(LimitedString)),\n\n /**\n * A list of supported RPC events on the namespace, that a DApp can listen to.\n */\n events: optional(array(LimitedString)),\n});\nexport type Namespace = Infer<typeof NamespaceStruct>;\n\n/**\n * A CAIP-2 namespace, i.e., the first part of a chain ID.\n */\nexport const NamespaceIdStruct = pattern(string(), /^[-a-z0-9]{3,8}$/u);\nexport type NamespaceId = Infer<typeof NamespaceIdStruct>;\n\n/**\n * Check if the given value is a CAIP-2 namespace ID.\n *\n * @param value - The value to check.\n * @returns Whether the value is a CAIP-2 namespace ID.\n */\nexport function isNamespaceId(value: unknown): value is NamespaceId {\n return is(value, NamespaceIdStruct);\n}\n\n/**\n * Check if the given value is a CAIP-2 chain ID.\n *\n * @param value - The value to check.\n * @returns Whether the value is a CAIP-2 chain ID.\n */\nexport function isChainId(value: unknown): value is ChainId {\n return is(value, ChainIdStruct);\n}\n\n/**\n * Check if the given value is a CAIP-10 account ID.\n *\n * @param value - The value to check.\n * @returns Whether the value is a CAIP-10 account ID.\n */\nexport function isAccountId(value: unknown): value is AccountId {\n return is(value, AccountIdStruct);\n}\n\n/**\n * Check if the given value is an array of CAIP-10 account IDs.\n *\n * @param value - The value to check.\n * @returns Whether the value is an array of CAIP-10 account IDs.\n */\nexport function isAccountIdArray(value: unknown): value is AccountId[] {\n return is(value, AccountIdArrayStruct);\n}\n\n/**\n * Check if a value is a {@link Namespace}.\n *\n * @param value - The value to validate.\n * @returns True if the value is a valid {@link Namespace}.\n */\nexport function isNamespace(value: unknown): value is Namespace {\n return is(value, NamespaceStruct);\n}\n"],"names":["CHAIN_ID_REGEX","ACCOUNT_ID_REGEX","parseChainId","parseAccountId","LimitedString","ChainIdStruct","AccountIdStruct","AccountIdArrayStruct","ChainStruct","NamespaceStruct","NamespaceIdStruct","isNamespaceId","isChainId","isAccountId","isAccountIdArray","isNamespace","chainId","match","exec","groups","Error","namespace","reference","accountId","address","accountAddress","chain","size","string","pattern","array","object","id","name","chains","methods","optional","events","value","is"],"mappings":";;;;;;;;;;;IAWaA,cAAc;eAAdA;;IAGAC,gBAAgB;eAAhBA;;IAUGC,YAAY;eAAZA;;IAsBAC,cAAc;eAAdA;;IAwBHC,aAAa;eAAbA;;IAKAC,aAAa;eAAbA;;IAGAC,eAAe;eAAfA;;IAGAC,oBAAoB;eAApBA;;IAKAC,WAAW;eAAXA;;IAMAC,eAAe;eAAfA;;IAqBAC,iBAAiB;eAAjBA;;IASGC,aAAa;eAAbA;;IAUAC,SAAS;eAATA;;IAUAC,WAAW;eAAXA;;IAUAC,gBAAgB;eAAhBA;;IAUAC,WAAW;eAAXA;;;6BAzJT;AAEA,MAAMf,iBACX;AAEK,MAAMC,mBACX;AASK,SAASC,aAAac,OAAgB;IAI3C,MAAMC,QAAQjB,eAAekB,IAAI,CAACF;IAClC,IAAI,CAACC,OAAOE,QAAQ;QAClB,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAO;QACLC,WAAWJ,MAAME,MAAM,CAACE,SAAS;QACjCC,WAAWL,MAAME,MAAM,CAACG,SAAS;IACnC;AACF;AASO,SAASnB,eAAeoB,SAAoB;IAKjD,MAAMN,QAAQhB,iBAAiBiB,IAAI,CAACK;IACpC,IAAI,CAACN,OAAOE,QAAQ;QAClB,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAO;QACLI,SAASP,MAAME,MAAM,CAACM,cAAc;QACpCT,SAASC,MAAME,MAAM,CAACH,OAAO;QAC7BU,OAAO;YACLL,WAAWJ,MAAME,MAAM,CAACE,SAAS;YACjCC,WAAWL,MAAME,MAAM,CAACG,SAAS;QACnC;IACF;AACF;AAMO,MAAMlB,gBAAgBuB,IAAAA,iBAAI,EAACC,IAAAA,mBAAM,KAAI,GAAG;AAKxC,MAAMvB,gBAAgBwB,IAAAA,oBAAO,EAACD,IAAAA,mBAAM,KAAI5B;AAGxC,MAAMM,kBAAkBuB,IAAAA,oBAAO,EAACD,IAAAA,mBAAM,KAAI3B;AAG1C,MAAMM,uBAAuBuB,IAAAA,kBAAK,EAACxB;AAKnC,MAAME,cAAcuB,IAAAA,mBAAM,EAAC;IAChCC,IAAI3B;IACJ4B,MAAM7B;AACR;AAGO,MAAMK,kBAAkBsB,IAAAA,mBAAM,EAAC;IACpC;;GAEC,GACDG,QAAQJ,IAAAA,kBAAK,EAACtB;IAEd;;GAEC,GACD2B,SAASC,IAAAA,qBAAQ,EAACN,IAAAA,kBAAK,EAAC1B;IAExB;;GAEC,GACDiC,QAAQD,IAAAA,qBAAQ,EAACN,IAAAA,kBAAK,EAAC1B;AACzB;AAMO,MAAMM,oBAAoBmB,IAAAA,oBAAO,EAACD,IAAAA,mBAAM,KAAI;AAS5C,SAASjB,cAAc2B,KAAc;IAC1C,OAAOC,IAAAA,eAAE,EAACD,OAAO5B;AACnB;AAQO,SAASE,UAAU0B,KAAc;IACtC,OAAOC,IAAAA,eAAE,EAACD,OAAOjC;AACnB;AAQO,SAASQ,YAAYyB,KAAc;IACxC,OAAOC,IAAAA,eAAE,EAACD,OAAOhC;AACnB;AAQO,SAASQ,iBAAiBwB,KAAc;IAC7C,OAAOC,IAAAA,eAAE,EAACD,OAAO/B;AACnB;AAQO,SAASQ,YAAYuB,KAAc;IACxC,OAAOC,IAAAA,eAAE,EAACD,OAAO7B;AACnB"}
package/dist/cjs/npm.js DELETED
@@ -1,81 +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
- EXPECTED_SNAP_FILES: function() {
13
- return EXPECTED_SNAP_FILES;
14
- },
15
- SnapFileNameFromKey: function() {
16
- return SnapFileNameFromKey;
17
- },
18
- validateNpmSnap: function() {
19
- return validateNpmSnap;
20
- }
21
- });
22
- const _icon = require("./icon");
23
- const _manifest = require("./manifest/manifest");
24
- const _validation = require("./manifest/validation");
25
- const _types = require("./types");
26
- const EXPECTED_SNAP_FILES = [
27
- 'manifest',
28
- 'packageJson',
29
- 'sourceCode'
30
- ];
31
- const SnapFileNameFromKey = {
32
- manifest: _types.NpmSnapFileNames.Manifest,
33
- packageJson: _types.NpmSnapFileNames.PackageJson,
34
- sourceCode: 'source code bundle'
35
- };
36
- function validateNpmSnap(snapFiles, errorPrefix) {
37
- EXPECTED_SNAP_FILES.forEach((key)=>{
38
- if (!snapFiles[key]) {
39
- throw new Error(`${errorPrefix ?? ''}Missing file "${SnapFileNameFromKey[key]}".`);
40
- }
41
- });
42
- // Typecast: We are assured that the required files exist if we get here.
43
- const { manifest, packageJson, sourceCode, svgIcon } = snapFiles;
44
- try {
45
- (0, _validation.assertIsSnapManifest)(manifest.result);
46
- } catch (error) {
47
- throw new Error(`${errorPrefix ?? ''}${error.message}`);
48
- }
49
- const validatedManifest = manifest;
50
- const { iconPath } = validatedManifest.result.source.location.npm;
51
- if (iconPath && !svgIcon) {
52
- throw new Error(`Missing file "${iconPath}".`);
53
- }
54
- try {
55
- (0, _types.assertIsNpmSnapPackageJson)(packageJson.result);
56
- } catch (error) {
57
- throw new Error(`${errorPrefix ?? ''}${error.message}`);
58
- }
59
- const validatedPackageJson = packageJson;
60
- (0, _manifest.validateNpmSnapManifest)({
61
- manifest: validatedManifest,
62
- packageJson: validatedPackageJson,
63
- sourceCode,
64
- svgIcon
65
- });
66
- if (svgIcon) {
67
- try {
68
- (0, _icon.assertIsSnapIcon)(svgIcon);
69
- } catch (error) {
70
- throw new Error(`${errorPrefix ?? ''}${error.message}`);
71
- }
72
- }
73
- return {
74
- manifest: validatedManifest,
75
- packageJson: validatedPackageJson,
76
- sourceCode,
77
- svgIcon
78
- };
79
- }
80
-
81
- //# sourceMappingURL=npm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/npm.ts"],"sourcesContent":["import { assertIsSnapIcon } from './icon';\nimport { validateNpmSnapManifest } from './manifest/manifest';\nimport { assertIsSnapManifest } from './manifest/validation';\nimport type { SnapFiles, UnvalidatedSnapFiles } from './types';\nimport { assertIsNpmSnapPackageJson, NpmSnapFileNames } from './types';\n\nexport const EXPECTED_SNAP_FILES = [\n 'manifest',\n 'packageJson',\n 'sourceCode',\n] as const;\n\nexport const SnapFileNameFromKey = {\n manifest: NpmSnapFileNames.Manifest,\n packageJson: NpmSnapFileNames.PackageJson,\n sourceCode: 'source code bundle',\n} as const;\n\n// TODO: Refactor this to be more shared with other validation.\n\n/**\n * Validates the files extracted from an npm Snap package tarball by ensuring\n * that they're non-empty and that the Json files match their respective schemas\n * and the Snaps publishing specification.\n *\n * @param snapFiles - The object containing the expected Snap file contents,\n * if any.\n * @param errorPrefix - The prefix of the error message.\n * @returns A tuple of the Snap manifest object and the Snap source code.\n */\nexport function validateNpmSnap(\n snapFiles: UnvalidatedSnapFiles,\n errorPrefix?: `${string}: `,\n): SnapFiles {\n EXPECTED_SNAP_FILES.forEach((key) => {\n if (!snapFiles[key]) {\n throw new Error(\n `${errorPrefix ?? ''}Missing file \"${SnapFileNameFromKey[key]}\".`,\n );\n }\n });\n\n // Typecast: We are assured that the required files exist if we get here.\n const { manifest, packageJson, sourceCode, svgIcon } = snapFiles as SnapFiles;\n try {\n assertIsSnapManifest(manifest.result);\n } catch (error) {\n throw new Error(`${errorPrefix ?? ''}${error.message}`);\n }\n const validatedManifest = manifest;\n\n const { iconPath } = validatedManifest.result.source.location.npm;\n if (iconPath && !svgIcon) {\n throw new Error(`Missing file \"${iconPath}\".`);\n }\n\n try {\n assertIsNpmSnapPackageJson(packageJson.result);\n } catch (error) {\n throw new Error(`${errorPrefix ?? ''}${error.message}`);\n }\n const validatedPackageJson = packageJson;\n\n validateNpmSnapManifest({\n manifest: validatedManifest,\n packageJson: validatedPackageJson,\n sourceCode,\n svgIcon,\n });\n\n if (svgIcon) {\n try {\n assertIsSnapIcon(svgIcon);\n } catch (error) {\n throw new Error(`${errorPrefix ?? ''}${error.message}`);\n }\n }\n\n return {\n manifest: validatedManifest,\n packageJson: validatedPackageJson,\n sourceCode,\n svgIcon,\n };\n}\n"],"names":["EXPECTED_SNAP_FILES","SnapFileNameFromKey","validateNpmSnap","manifest","NpmSnapFileNames","Manifest","packageJson","PackageJson","sourceCode","snapFiles","errorPrefix","forEach","key","Error","svgIcon","assertIsSnapManifest","result","error","message","validatedManifest","iconPath","source","location","npm","assertIsNpmSnapPackageJson","validatedPackageJson","validateNpmSnapManifest","assertIsSnapIcon"],"mappings":";;;;;;;;;;;IAMaA,mBAAmB;eAAnBA;;IAMAC,mBAAmB;eAAnBA;;IAkBGC,eAAe;eAAfA;;;sBA9BiB;0BACO;4BACH;uBAEwB;AAEtD,MAAMF,sBAAsB;IACjC;IACA;IACA;CACD;AAEM,MAAMC,sBAAsB;IACjCE,UAAUC,uBAAgB,CAACC,QAAQ;IACnCC,aAAaF,uBAAgB,CAACG,WAAW;IACzCC,YAAY;AACd;AAcO,SAASN,gBACdO,SAA+B,EAC/BC,WAA2B;IAE3BV,oBAAoBW,OAAO,CAAC,CAACC;QAC3B,IAAI,CAACH,SAAS,CAACG,IAAI,EAAE;YACnB,MAAM,IAAIC,MACR,CAAC,EAAEH,eAAe,GAAG,cAAc,EAAET,mBAAmB,CAACW,IAAI,CAAC,EAAE,CAAC;QAErE;IACF;IAEA,yEAAyE;IACzE,MAAM,EAAET,QAAQ,EAAEG,WAAW,EAAEE,UAAU,EAAEM,OAAO,EAAE,GAAGL;IACvD,IAAI;QACFM,IAAAA,gCAAoB,EAACZ,SAASa,MAAM;IACtC,EAAE,OAAOC,OAAO;QACd,MAAM,IAAIJ,MAAM,CAAC,EAAEH,eAAe,GAAG,EAAEO,MAAMC,OAAO,CAAC,CAAC;IACxD;IACA,MAAMC,oBAAoBhB;IAE1B,MAAM,EAAEiB,QAAQ,EAAE,GAAGD,kBAAkBH,MAAM,CAACK,MAAM,CAACC,QAAQ,CAACC,GAAG;IACjE,IAAIH,YAAY,CAACN,SAAS;QACxB,MAAM,IAAID,MAAM,CAAC,cAAc,EAAEO,SAAS,EAAE,CAAC;IAC/C;IAEA,IAAI;QACFI,IAAAA,iCAA0B,EAAClB,YAAYU,MAAM;IAC/C,EAAE,OAAOC,OAAO;QACd,MAAM,IAAIJ,MAAM,CAAC,EAAEH,eAAe,GAAG,EAAEO,MAAMC,OAAO,CAAC,CAAC;IACxD;IACA,MAAMO,uBAAuBnB;IAE7BoB,IAAAA,iCAAuB,EAAC;QACtBvB,UAAUgB;QACVb,aAAamB;QACbjB;QACAM;IACF;IAEA,IAAIA,SAAS;QACX,IAAI;YACFa,IAAAA,sBAAgB,EAACb;QACnB,EAAE,OAAOG,OAAO;YACd,MAAM,IAAIJ,MAAM,CAAC,EAAEH,eAAe,GAAG,EAAEO,MAAMC,OAAO,CAAC,CAAC;QACxD;IACF;IAEA,OAAO;QACLf,UAAUgB;QACVb,aAAamB;QACbjB;QACAM;IACF;AACF"}
package/dist/cjs/path.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "normalizeRelative", {
6
- enumerable: true,
7
- get: function() {
8
- return normalizeRelative;
9
- }
10
- });
11
- const _utils = require("@metamask/utils");
12
- function normalizeRelative(path) {
13
- (0, _utils.assert)(!path.startsWith('/'));
14
- (0, _utils.assert)(path.search(/:|\/\//u) === -1, `Path "${path}" potentially an URI instead of local relative`);
15
- if (path.startsWith('./')) {
16
- return path.slice(2);
17
- }
18
- return path;
19
- }
20
-
21
- //# sourceMappingURL=path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/path.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\n\n/**\n * Normalizes relative paths by optionally removing `./` prefix.\n *\n * @param path - Path to make normalize.\n * @returns The same path, with `./` prefix remove.\n */\n// TODO(ritave): Include NodeJS path polyfill and use path.normalize as well\nexport function normalizeRelative(path: string): string {\n assert(!path.startsWith('/'));\n assert(\n path.search(/:|\\/\\//u) === -1,\n `Path \"${path}\" potentially an URI instead of local relative`,\n );\n\n if (path.startsWith('./')) {\n return path.slice(2);\n }\n return path;\n}\n"],"names":["normalizeRelative","path","assert","startsWith","search","slice"],"mappings":";;;;+BASgBA;;;eAAAA;;;uBATO;AAShB,SAASA,kBAAkBC,IAAY;IAC5CC,IAAAA,aAAM,EAAC,CAACD,KAAKE,UAAU,CAAC;IACxBD,IAAAA,aAAM,EACJD,KAAKG,MAAM,CAAC,eAAe,CAAC,GAC5B,CAAC,MAAM,EAAEH,KAAK,8CAA8C,CAAC;IAG/D,IAAIA,KAAKE,UAAU,CAAC,OAAO;QACzB,OAAOF,KAAKI,KAAK,CAAC;IACpB;IACA,OAAOJ;AACT"}