@metamask/snaps-utils 0.35.1-flask.1 → 1.0.0-prerelease.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.
- package/CHANGELOG.md +5 -46
- package/dist/{esm/array.js → array.js} +7 -3
- package/dist/array.js.map +1 -0
- package/dist/{types/caveats.d.ts → caveats.d.ts} +4 -0
- package/dist/caveats.js +35 -0
- package/dist/caveats.js.map +1 -0
- package/dist/checksum.js +42 -0
- package/dist/checksum.js.map +1 -0
- package/dist/cronjob.js +71 -0
- package/dist/cronjob.js.map +1 -0
- package/dist/deep-clone.js +9 -0
- package/dist/deep-clone.js.map +1 -0
- package/dist/{esm/default-endowments.js → default-endowments.js} +6 -3
- package/dist/default-endowments.js.map +1 -0
- package/dist/entropy.js +8 -0
- package/dist/entropy.js.map +1 -0
- package/dist/{cjs/eval-worker.js → eval-worker.js} +21 -22
- package/dist/eval-worker.js.map +1 -0
- package/dist/eval.js +27 -0
- package/dist/eval.js.map +1 -0
- package/dist/{esm/fs.js → fs.js} +56 -33
- package/dist/fs.js.map +1 -0
- package/dist/{types/handlers.d.ts → handlers.d.ts} +42 -5
- package/dist/handlers.js +3 -0
- package/dist/handlers.js.map +1 -0
- package/dist/{types/iframe.d.ts → iframe.d.ts} +2 -3
- package/dist/{esm/iframe.js → iframe.js} +18 -16
- package/dist/iframe.js.map +1 -0
- package/dist/iframe.test.browser.js +15 -0
- package/dist/iframe.test.browser.js.map +1 -0
- package/dist/{types/index.browser.d.ts → index.browser.d.ts} +1 -2
- package/dist/index.browser.js +37 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/{types/index.d.ts → index.d.ts} +1 -2
- package/dist/index.executionenv.js +22 -0
- package/dist/index.executionenv.js.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/json-rpc.js +46 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/json.d.ts +9 -0
- package/dist/json.js +18 -0
- package/dist/json.js.map +1 -0
- package/dist/{esm/logging.js → logging.js} +14 -6
- package/dist/logging.js.map +1 -0
- package/dist/manifest/index.browser.js +18 -0
- package/dist/manifest/index.browser.js.map +1 -0
- package/dist/manifest/index.js +19 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/{esm/manifest → manifest}/manifest.js +113 -98
- package/dist/manifest/manifest.js.map +1 -0
- package/dist/{types/manifest → manifest}/validation.d.ts +73 -31
- package/dist/manifest/validation.js +141 -0
- package/dist/manifest/validation.js.map +1 -0
- package/dist/{esm/mock.js → mock.js} +40 -42
- package/dist/mock.js.map +1 -0
- package/dist/namespace.d.ts +275 -0
- package/dist/namespace.js +225 -0
- package/dist/namespace.js.map +1 -0
- package/dist/notification.d.ts +66 -0
- package/dist/notification.js +58 -0
- package/dist/notification.js.map +1 -0
- package/dist/{types/npm.d.ts → npm.d.ts} +2 -0
- package/dist/npm.js +74 -0
- package/dist/npm.js.map +1 -0
- package/dist/path.js +21 -0
- package/dist/path.js.map +1 -0
- package/dist/{esm/post-process.js → post-process.js} +99 -110
- package/dist/post-process.js.map +1 -0
- package/dist/{types/snaps.d.ts → snaps.d.ts} +2 -9
- package/dist/snaps.js +202 -0
- package/dist/snaps.js.map +1 -0
- package/dist/{types/types.d.ts → types.d.ts} +5 -2
- package/dist/types.js +103 -0
- package/dist/types.js.map +1 -0
- package/dist/{esm/versions.js → versions.js} +18 -15
- package/dist/versions.js.map +1 -0
- package/dist/{esm/virtual-file → virtual-file}/VirtualFile.js +33 -47
- package/dist/virtual-file/VirtualFile.js.map +1 -0
- package/dist/virtual-file/index.browser.js +18 -0
- package/dist/virtual-file/index.browser.js.map +1 -0
- package/dist/virtual-file/index.js +19 -0
- package/dist/virtual-file/index.js.map +1 -0
- package/dist/virtual-file/toVirtualFile.js +30 -0
- package/dist/virtual-file/toVirtualFile.js.map +1 -0
- package/package.json +32 -61
- package/dist/cjs/array.js +0 -23
- package/dist/cjs/array.js.map +0 -1
- package/dist/cjs/caveats.js +0 -33
- package/dist/cjs/caveats.js.map +0 -1
- package/dist/cjs/checksum.js +0 -38
- package/dist/cjs/checksum.js.map +0 -1
- package/dist/cjs/cronjob.js +0 -84
- package/dist/cjs/cronjob.js.map +0 -1
- package/dist/cjs/deep-clone.js +0 -22
- package/dist/cjs/deep-clone.js.map +0 -1
- package/dist/cjs/default-endowments.js +0 -49
- package/dist/cjs/default-endowments.js.map +0 -1
- package/dist/cjs/entropy.js +0 -23
- package/dist/cjs/entropy.js.map +0 -1
- package/dist/cjs/enum.js +0 -16
- package/dist/cjs/enum.js.map +0 -1
- package/dist/cjs/eval-worker.js.map +0 -1
- package/dist/cjs/eval.js +0 -29
- package/dist/cjs/eval.js.map +0 -1
- package/dist/cjs/fs.js +0 -126
- package/dist/cjs/fs.js.map +0 -1
- package/dist/cjs/handlers.js +0 -6
- package/dist/cjs/handlers.js.map +0 -1
- package/dist/cjs/icon.js +0 -37
- package/dist/cjs/icon.js.map +0 -1
- package/dist/cjs/iframe.js +0 -59
- package/dist/cjs/iframe.js.map +0 -1
- package/dist/cjs/index.browser.js +0 -40
- package/dist/cjs/index.browser.js.map +0 -1
- package/dist/cjs/index.executionenv.js +0 -24
- package/dist/cjs/index.executionenv.js.map +0 -1
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json-rpc.js +0 -46
- package/dist/cjs/json-rpc.js.map +0 -1
- package/dist/cjs/json.js +0 -16
- package/dist/cjs/json.js.map +0 -1
- package/dist/cjs/logging.js +0 -40
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/manifest/index.browser.js +0 -20
- package/dist/cjs/manifest/index.browser.js.map +0 -1
- package/dist/cjs/manifest/index.js +0 -21
- package/dist/cjs/manifest/index.js.map +0 -1
- package/dist/cjs/manifest/manifest.js +0 -239
- package/dist/cjs/manifest/manifest.js.map +0 -1
- package/dist/cjs/manifest/validation.js +0 -183
- package/dist/cjs/manifest/validation.js.map +0 -1
- package/dist/cjs/mock.js +0 -128
- package/dist/cjs/mock.js.map +0 -1
- package/dist/cjs/namespace.js +0 -124
- package/dist/cjs/namespace.js.map +0 -1
- package/dist/cjs/npm.js +0 -81
- package/dist/cjs/npm.js.map +0 -1
- package/dist/cjs/path.js +0 -21
- package/dist/cjs/path.js.map +0 -1
- package/dist/cjs/post-process.js +0 -328
- package/dist/cjs/post-process.js.map +0 -1
- package/dist/cjs/snaps.js +0 -230
- package/dist/cjs/snaps.js.map +0 -1
- package/dist/cjs/types.js +0 -117
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/validation.js +0 -22
- package/dist/cjs/validation.js.map +0 -1
- package/dist/cjs/versions.js +0 -47
- package/dist/cjs/versions.js.map +0 -1
- package/dist/cjs/virtual-file/VirtualFile.js +0 -85
- package/dist/cjs/virtual-file/VirtualFile.js.map +0 -1
- package/dist/cjs/virtual-file/index.browser.js +0 -20
- package/dist/cjs/virtual-file/index.browser.js.map +0 -1
- package/dist/cjs/virtual-file/index.js +0 -21
- package/dist/cjs/virtual-file/index.js.map +0 -1
- package/dist/cjs/virtual-file/toVirtualFile.js +0 -33
- package/dist/cjs/virtual-file/toVirtualFile.js.map +0 -1
- package/dist/esm/array.js.map +0 -1
- package/dist/esm/caveats.js +0 -23
- package/dist/esm/caveats.js.map +0 -1
- package/dist/esm/checksum.js +0 -36
- package/dist/esm/checksum.js.map +0 -1
- package/dist/esm/cronjob.js +0 -66
- package/dist/esm/cronjob.js.map +0 -1
- package/dist/esm/deep-clone.js +0 -7
- package/dist/esm/deep-clone.js.map +0 -1
- package/dist/esm/default-endowments.js.map +0 -1
- package/dist/esm/entropy.js +0 -6
- package/dist/esm/entropy.js.map +0 -1
- package/dist/esm/enum.js +0 -12
- package/dist/esm/enum.js.map +0 -1
- package/dist/esm/eval-worker.js +0 -47
- package/dist/esm/eval-worker.js.map +0 -1
- package/dist/esm/eval.js +0 -25
- package/dist/esm/eval.js.map +0 -1
- package/dist/esm/fs.js.map +0 -1
- package/dist/esm/handlers.js +0 -3
- package/dist/esm/handlers.js.map +0 -1
- package/dist/esm/icon.js +0 -11
- package/dist/esm/icon.js.map +0 -1
- package/dist/esm/iframe.js.map +0 -1
- package/dist/esm/index.browser.js +0 -23
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.executionenv.js +0 -7
- package/dist/esm/index.executionenv.js.map +0 -1
- package/dist/esm/index.js +0 -28
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json-rpc.js +0 -39
- package/dist/esm/json-rpc.js.map +0 -1
- package/dist/esm/json.js +0 -17
- package/dist/esm/json.js.map +0 -1
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/manifest/index.browser.js +0 -3
- package/dist/esm/manifest/index.browser.js.map +0 -1
- package/dist/esm/manifest/index.js +0 -4
- package/dist/esm/manifest/index.js.map +0 -1
- package/dist/esm/manifest/manifest.js.map +0 -1
- package/dist/esm/manifest/validation.js +0 -152
- package/dist/esm/manifest/validation.js.map +0 -1
- package/dist/esm/mock.js.map +0 -1
- package/dist/esm/namespace.js +0 -110
- package/dist/esm/namespace.js.map +0 -1
- package/dist/esm/npm.js +0 -70
- package/dist/esm/npm.js.map +0 -1
- package/dist/esm/path.js +0 -17
- package/dist/esm/path.js.map +0 -1
- package/dist/esm/post-process.js.map +0 -1
- package/dist/esm/snaps.js +0 -215
- package/dist/esm/snaps.js.map +0 -1
- package/dist/esm/types.js +0 -85
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/validation.js +0 -17
- package/dist/esm/validation.js.map +0 -1
- package/dist/esm/versions.js.map +0 -1
- package/dist/esm/virtual-file/VirtualFile.js.map +0 -1
- package/dist/esm/virtual-file/index.browser.js +0 -3
- package/dist/esm/virtual-file/index.browser.js.map +0 -1
- package/dist/esm/virtual-file/index.js +0 -4
- package/dist/esm/virtual-file/index.js.map +0 -1
- package/dist/esm/virtual-file/toVirtualFile.js +0 -26
- package/dist/esm/virtual-file/toVirtualFile.js.map +0 -1
- package/dist/types/enum.d.ts +0 -30
- package/dist/types/icon.d.ts +0 -4
- package/dist/types/json.d.ts +0 -13
- package/dist/types/namespace.d.ts +0 -124
- package/dist/types/validation.d.ts +0 -8
- /package/dist/{types/array.d.ts → array.d.ts} +0 -0
- /package/dist/{types/checksum.d.ts → checksum.d.ts} +0 -0
- /package/dist/{types/cronjob.d.ts → cronjob.d.ts} +0 -0
- /package/dist/{types/deep-clone.d.ts → deep-clone.d.ts} +0 -0
- /package/dist/{types/default-endowments.d.ts → default-endowments.d.ts} +0 -0
- /package/dist/{types/entropy.d.ts → entropy.d.ts} +0 -0
- /package/dist/{types/eval-worker.d.ts → eval-worker.d.ts} +0 -0
- /package/dist/{types/eval.d.ts → eval.d.ts} +0 -0
- /package/dist/{types/fs.d.ts → fs.d.ts} +0 -0
- /package/dist/{types/iframe.test.browser.d.ts → iframe.test.browser.d.ts} +0 -0
- /package/dist/{types/index.executionenv.d.ts → index.executionenv.d.ts} +0 -0
- /package/dist/{types/json-rpc.d.ts → json-rpc.d.ts} +0 -0
- /package/dist/{types/logging.d.ts → logging.d.ts} +0 -0
- /package/dist/{types/manifest → manifest}/index.browser.d.ts +0 -0
- /package/dist/{types/manifest → manifest}/index.d.ts +0 -0
- /package/dist/{types/manifest → manifest}/manifest.d.ts +0 -0
- /package/dist/{types/mock.d.ts → mock.d.ts} +0 -0
- /package/dist/{types/path.d.ts → path.d.ts} +0 -0
- /package/dist/{types/post-process.d.ts → post-process.d.ts} +0 -0
- /package/dist/{types/versions.d.ts → versions.d.ts} +0 -0
- /package/dist/{types/virtual-file → virtual-file}/VirtualFile.d.ts +0 -0
- /package/dist/{types/virtual-file → virtual-file}/index.browser.d.ts +0 -0
- /package/dist/{types/virtual-file → virtual-file}/index.d.ts +0 -0
- /package/dist/{types/virtual-file → virtual-file}/toVirtualFile.d.ts +0 -0
package/dist/cjs/fs.js
DELETED
|
@@ -1,126 +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
|
-
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
|
package/dist/cjs/fs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fs.ts"],"sourcesContent":["import { Json } from '@metamask/utils';\nimport { promises as fs } from 'fs';\nimport os from 'os';\nimport pathUtils from 'path';\n\nimport { parseJson } from './json';\nimport { readVirtualFile, VirtualFile } 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":";;;;;;;;;;;IAgBsBA,WAAW;eAAXA;;IA2BAC,MAAM;eAANA;;IAeAC,YAAY;eAAZA;;IA+BNC,cAAc;eAAdA;;IAYAC,mBAAmB;eAAnBA;;IAkBMC,gBAAgB;eAAhBA;;IAkBAC,eAAe;eAAfA;;IAqBAC,gBAAgB;eAAhBA;;;oBA7JS;2DAChB;6DACO;sBAEI;6BACmB;;;;;;AAUtC,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"}
|
package/dist/cjs/handlers.js
DELETED
package/dist/cjs/handlers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handlers.ts"],"names":[],"mappings":""}
|
package/dist/cjs/icon.js
DELETED
|
@@ -1,37 +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
|
-
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
|
package/dist/cjs/icon.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/icon.ts"],"sourcesContent":["import { assert } from '@metamask/utils';\nimport isSvg from 'is-svg';\n\nimport { 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"}
|
package/dist/cjs/iframe.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
package/dist/cjs/iframe.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,40 +0,0 @@
|
|
|
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("./handlers"), exports);
|
|
14
|
-
_export_star(require("./iframe"), exports);
|
|
15
|
-
_export_star(require("./json"), exports);
|
|
16
|
-
_export_star(require("./json-rpc"), exports);
|
|
17
|
-
_export_star(require("./logging"), exports);
|
|
18
|
-
_export_star(require("./manifest/index.browser"), exports);
|
|
19
|
-
_export_star(require("./namespace"), exports);
|
|
20
|
-
_export_star(require("./path"), exports);
|
|
21
|
-
_export_star(require("./snaps"), exports);
|
|
22
|
-
_export_star(require("./types"), exports);
|
|
23
|
-
_export_star(require("./validation"), exports);
|
|
24
|
-
_export_star(require("./versions"), exports);
|
|
25
|
-
_export_star(require("./virtual-file/index.browser"), exports);
|
|
26
|
-
function _export_star(from, to) {
|
|
27
|
-
Object.keys(from).forEach(function(k) {
|
|
28
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
29
|
-
Object.defineProperty(to, k, {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function() {
|
|
32
|
-
return from[k];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return from;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 './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 './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"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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("./cronjob"), exports);
|
|
8
|
-
_export_star(require("./checksum"), 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("./eval"), exports);
|
|
14
|
-
_export_star(require("./fs"), exports);
|
|
15
|
-
_export_star(require("./handlers"), exports);
|
|
16
|
-
_export_star(require("./iframe"), exports);
|
|
17
|
-
_export_star(require("./json"), exports);
|
|
18
|
-
_export_star(require("./json-rpc"), exports);
|
|
19
|
-
_export_star(require("./logging"), exports);
|
|
20
|
-
_export_star(require("./manifest"), exports);
|
|
21
|
-
_export_star(require("./mock"), exports);
|
|
22
|
-
_export_star(require("./namespace"), exports);
|
|
23
|
-
_export_star(require("./npm"), exports);
|
|
24
|
-
_export_star(require("./path"), exports);
|
|
25
|
-
_export_star(require("./post-process"), exports);
|
|
26
|
-
_export_star(require("./snaps"), exports);
|
|
27
|
-
_export_star(require("./types"), exports);
|
|
28
|
-
_export_star(require("./validation"), exports);
|
|
29
|
-
_export_star(require("./versions"), exports);
|
|
30
|
-
_export_star(require("./virtual-file"), exports);
|
|
31
|
-
function _export_star(from, to) {
|
|
32
|
-
Object.keys(from).forEach(function(k) {
|
|
33
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
34
|
-
Object.defineProperty(to, k, {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function() {
|
|
37
|
-
return from[k];
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return from;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './eval';\nexport * from './fs';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\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;qBACA;qBACA"}
|
package/dist/cjs/json-rpc.js
DELETED
|
@@ -1,46 +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
|
-
RpcOriginsStruct: function() {
|
|
13
|
-
return RpcOriginsStruct;
|
|
14
|
-
},
|
|
15
|
-
assertIsRpcOrigins: function() {
|
|
16
|
-
return assertIsRpcOrigins;
|
|
17
|
-
},
|
|
18
|
-
assertIsJsonRpcSuccess: function() {
|
|
19
|
-
return assertIsJsonRpcSuccess;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _utils = require("@metamask/utils");
|
|
23
|
-
const _superstruct = require("superstruct");
|
|
24
|
-
const RpcOriginsStruct = (0, _superstruct.refine)((0, _superstruct.object)({
|
|
25
|
-
dapps: (0, _superstruct.optional)((0, _superstruct.boolean)()),
|
|
26
|
-
snaps: (0, _superstruct.optional)((0, _superstruct.boolean)())
|
|
27
|
-
}), 'RPC origins', (value)=>{
|
|
28
|
-
if (!Object.values(value).some(Boolean)) {
|
|
29
|
-
throw new Error('Must specify at least one JSON-RPC origin');
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
});
|
|
33
|
-
function assertIsRpcOrigins(value, // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
34
|
-
ErrorWrapper) {
|
|
35
|
-
(0, _utils.assertStruct)(value, RpcOriginsStruct, 'Invalid JSON-RPC origins', ErrorWrapper);
|
|
36
|
-
}
|
|
37
|
-
function assertIsJsonRpcSuccess(value) {
|
|
38
|
-
if (!(0, _utils.isJsonRpcSuccess)(value)) {
|
|
39
|
-
if ((0, _utils.isJsonRpcFailure)(value)) {
|
|
40
|
-
throw new Error(`JSON-RPC request failed: ${value.error.message}`);
|
|
41
|
-
}
|
|
42
|
-
throw new Error('Invalid JSON-RPC response.');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=json-rpc.js.map
|
package/dist/cjs/json-rpc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/json-rpc.ts"],"sourcesContent":["import {\n isJsonRpcFailure,\n isJsonRpcSuccess,\n Json,\n JsonRpcSuccess,\n AssertionErrorConstructor,\n assertStruct,\n} from '@metamask/utils';\nimport { boolean, Infer, object, optional, refine } from 'superstruct';\n\nexport const RpcOriginsStruct = refine(\n object({\n dapps: optional(boolean()),\n snaps: optional(boolean()),\n }),\n 'RPC origins',\n (value) => {\n if (!Object.values(value).some(Boolean)) {\n throw new Error('Must specify at least one JSON-RPC origin');\n }\n\n return true;\n },\n);\n\nexport type RpcOrigins = Infer<typeof RpcOriginsStruct>;\n\n/**\n * Asserts that the given value is a valid {@link RpcOrigins} object.\n *\n * @param value - The value to assert.\n * @param ErrorWrapper - An optional error wrapper to use. Defaults to\n * {@link AssertionError}.\n * @throws If the value is not a valid {@link RpcOrigins} object.\n */\nexport function assertIsRpcOrigins(\n value: unknown,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is RpcOrigins {\n assertStruct(\n value,\n RpcOriginsStruct,\n 'Invalid JSON-RPC origins',\n ErrorWrapper,\n );\n}\n\n/**\n * Assert that the given value is a successful JSON-RPC response. If the value\n * is not a success response, an error is thrown. If the value is an JSON-RPC\n * error, the error message is included in the thrown error.\n *\n * @param value - The value to check.\n * @throws If the value is not a JSON-RPC success response.\n */\nexport function assertIsJsonRpcSuccess(\n value: unknown,\n): asserts value is JsonRpcSuccess<Json> {\n if (!isJsonRpcSuccess(value)) {\n if (isJsonRpcFailure(value)) {\n throw new Error(`JSON-RPC request failed: ${value.error.message}`);\n }\n\n throw new Error('Invalid JSON-RPC response.');\n }\n}\n"],"names":["RpcOriginsStruct","assertIsRpcOrigins","assertIsJsonRpcSuccess","refine","object","dapps","optional","boolean","snaps","value","Object","values","some","Boolean","Error","ErrorWrapper","assertStruct","isJsonRpcSuccess","isJsonRpcFailure","error","message"],"mappings":";;;;;;;;;;;IAUaA,gBAAgB;eAAhBA;;IAyBGC,kBAAkB;eAAlBA;;IAqBAC,sBAAsB;eAAtBA;;;uBAjDT;6BACkD;AAElD,MAAMF,mBAAmBG,IAAAA,mBAAM,EACpCC,IAAAA,mBAAM,EAAC;IACLC,OAAOC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;IACvBC,OAAOF,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;AACzB,IACA,eACA,CAACE;IACC,IAAI,CAACC,OAAOC,MAAM,CAACF,OAAOG,IAAI,CAACC,UAAU;QACvC,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAO;AACT;AAaK,SAASb,mBACdQ,KAAc,EACd,gEAAgE;AAChEM,YAAwC;IAExCC,IAAAA,mBAAY,EACVP,OACAT,kBACA,4BACAe;AAEJ;AAUO,SAASb,uBACdO,KAAc;IAEd,IAAI,CAACQ,IAAAA,uBAAgB,EAACR,QAAQ;QAC5B,IAAIS,IAAAA,uBAAgB,EAACT,QAAQ;YAC3B,MAAM,IAAIK,MAAM,CAAC,yBAAyB,EAAEL,MAAMU,KAAK,CAACC,OAAO,CAAC,CAAC;QACnE;QAEA,MAAM,IAAIN,MAAM;IAClB;AACF"}
|
package/dist/cjs/json.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "parseJson", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return parseJson;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _utils = require("@metamask/utils");
|
|
12
|
-
function parseJson(json) {
|
|
13
|
-
return (0, _utils.getSafeJson)(JSON.parse(json));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=json.js.map
|
package/dist/cjs/json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/json.ts"],"sourcesContent":["import { getSafeJson, Json } from '@metamask/utils';\n\n// TODO: Upstream this to @metamask/utils\n\n/**\n * Parse JSON safely.\n *\n * Does multiple kinds of validation and strips unwanted properties like\n * `__proto__` and `constructor`.\n *\n * @param json - A JSON string to be parsed.\n * @returns The parsed JSON object.\n * @template Type - The type of the JSON object. The type is not actually\n * checked, but it is used to infer the return type.\n */\nexport function parseJson<Type extends Json = Json>(json: string) {\n return getSafeJson<Type>(JSON.parse(json));\n}\n"],"names":["parseJson","json","getSafeJson","JSON","parse"],"mappings":";;;;+BAegBA;;;eAAAA;;;uBAfkB;AAe3B,SAASA,UAAoCC,IAAY;IAC9D,OAAOC,IAAAA,kBAAW,EAAOC,KAAKC,KAAK,CAACH;AACtC"}
|
package/dist/cjs/logging.js
DELETED
|
@@ -1,40 +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
|
-
snapsLogger: function() {
|
|
13
|
-
return snapsLogger;
|
|
14
|
-
},
|
|
15
|
-
logInfo: function() {
|
|
16
|
-
return logInfo;
|
|
17
|
-
},
|
|
18
|
-
logError: function() {
|
|
19
|
-
return logError;
|
|
20
|
-
},
|
|
21
|
-
logWarning: function() {
|
|
22
|
-
return logWarning;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _utils = require("@metamask/utils");
|
|
26
|
-
const snapsLogger = (0, _utils.createProjectLogger)('snaps');
|
|
27
|
-
function logInfo(message, ...optionalParams) {
|
|
28
|
-
// eslint-disable-next-line no-console
|
|
29
|
-
console.log(message, ...optionalParams);
|
|
30
|
-
}
|
|
31
|
-
function logError(error, ...optionalParams) {
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
|
-
console.error(error, ...optionalParams);
|
|
34
|
-
}
|
|
35
|
-
function logWarning(message, ...optionalParams) {
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
console.warn(message, ...optionalParams);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=logging.js.map
|
package/dist/cjs/logging.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/logging.ts"],"sourcesContent":["import { createProjectLogger } from '@metamask/utils';\n\n// The global logger used across the monorepo. Other projects should use this\n// to create a module logger.\nexport const snapsLogger = createProjectLogger('snaps');\n\n/**\n * Log a message. Currently, this is just a wrapper around `console.log`, but\n * the implementation may change in the future. These logs will be included in\n * production builds, so they should be used sparingly, and not contain any\n * sensitive information.\n *\n * This function makes it easy to swap out the logging implementation in all\n * files at once.\n *\n * @param message - The message to log.\n * @param optionalParams - Additional parameters to pass to the logging.\n */\nexport function logInfo(message: string, ...optionalParams: unknown[]): void {\n // eslint-disable-next-line no-console\n console.log(message, ...optionalParams);\n}\n\n/**\n * Log an error. Currently, this is just a wrapper around `console.error`, but\n * the implementation may change in the future. These logs will be included in\n * production builds, so they should be used sparingly, and not contain any\n * sensitive information.\n *\n * These logs should always be visible, without requiring the user to enable\n * verbose logging (like setting a `DEBUG` environment variable), as they are\n * important for debugging snaps.\n *\n * This function makes it easy to swap out the logging implementation in all\n * files at once.\n *\n * @param error - The error to log.\n * @param optionalParams - Additional parameters to pass to the logging.\n */\nexport function logError(error: unknown, ...optionalParams: unknown[]): void {\n // eslint-disable-next-line no-console\n console.error(error, ...optionalParams);\n}\n\n/**\n * Log a warning. Currently, this is just a wrapper around `console.warn`, but\n * the implementation may change in the future. These logs will be included in\n * production builds, so they should be used sparingly, and not contain any\n * sensitive information.\n *\n * These logs should always be visible, without requiring the user to enable\n * verbose logging (like setting a `DEBUG` environment variable), as they are\n * important for debugging snaps.\n *\n * This function makes it easy to swap out the logging implementation in all\n * files at once.\n *\n * @param message - The message to log.\n * @param optionalParams - Additional parameters to pass to the logging.\n */\nexport function logWarning(\n message: string,\n ...optionalParams: unknown[]\n): void {\n // eslint-disable-next-line no-console\n console.warn(message, ...optionalParams);\n}\n"],"names":["snapsLogger","logInfo","logError","logWarning","createProjectLogger","message","optionalParams","console","log","error","warn"],"mappings":";;;;;;;;;;;IAIaA,WAAW;eAAXA;;IAcGC,OAAO;eAAPA;;IAqBAC,QAAQ;eAARA;;IAqBAC,UAAU;eAAVA;;;uBA5DoB;AAI7B,MAAMH,cAAcI,IAAAA,0BAAmB,EAAC;AAcxC,SAASH,QAAQI,OAAe,EAAE,GAAGC,cAAyB;IACnE,sCAAsC;IACtCC,QAAQC,GAAG,CAACH,YAAYC;AAC1B;AAkBO,SAASJ,SAASO,KAAc,EAAE,GAAGH,cAAyB;IACnE,sCAAsC;IACtCC,QAAQE,KAAK,CAACA,UAAUH;AAC1B;AAkBO,SAASH,WACdE,OAAe,EACf,GAAGC,cAAyB;IAE5B,sCAAsC;IACtCC,QAAQG,IAAI,CAACL,YAAYC;AAC3B"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./validation"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=index.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifest/index.browser.ts"],"sourcesContent":["export * from './validation';\n"],"names":[],"mappings":";;;;qBAAc"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./manifest"), exports);
|
|
6
|
-
_export_star(require("./validation"), exports);
|
|
7
|
-
function _export_star(from, to) {
|
|
8
|
-
Object.keys(from).forEach(function(k) {
|
|
9
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
-
Object.defineProperty(to, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return from[k];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return from;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifest/index.ts"],"sourcesContent":["export * from './manifest';\nexport * from './validation';\n"],"names":[],"mappings":";;;;qBAAc;qBACA"}
|