@metamask/snaps-utils 5.1.1 → 5.1.2
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 +6 -1
- package/dist/cjs/eval-worker.js +8 -17
- package/dist/cjs/eval-worker.js.map +1 -1
- package/dist/esm/eval-worker.js +8 -17
- package/dist/esm/eval-worker.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [5.1.2]
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fix missing `global` during snap evaluation ([#2072](https://github.com/MetaMask/snaps/pull/2072))
|
|
12
|
+
|
|
9
13
|
## [5.1.1]
|
|
10
14
|
### Changed
|
|
11
15
|
- Fix missing export ([#2045](https://github.com/MetaMask/snaps/pull/2045))
|
|
@@ -138,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
138
142
|
- The version of the package no longer needs to match the version of all other
|
|
139
143
|
MetaMask Snaps packages.
|
|
140
144
|
|
|
141
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.
|
|
145
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.2...HEAD
|
|
146
|
+
[5.1.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.1...@metamask/snaps-utils@5.1.2
|
|
142
147
|
[5.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.0...@metamask/snaps-utils@5.1.1
|
|
143
148
|
[5.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.1...@metamask/snaps-utils@5.1.0
|
|
144
149
|
[5.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.0...@metamask/snaps-utils@5.0.1
|
package/dist/cjs/eval-worker.js
CHANGED
|
@@ -18,29 +18,20 @@ lockdown({
|
|
|
18
18
|
// Node.js domains are deprecated.
|
|
19
19
|
domainTaming: 'unsafe'
|
|
20
20
|
});
|
|
21
|
-
/**
|
|
22
|
-
* Get mock endowments that don't do anything. This is useful for running the
|
|
23
|
-
* eval, for snaps that try to communicate with the extension on initialisation,
|
|
24
|
-
* for example.
|
|
25
|
-
*
|
|
26
|
-
* @returns The mock endowments.
|
|
27
|
-
*/ function getMockEndowments() {
|
|
28
|
-
const endowments = (0, _mock.generateMockEndowments)();
|
|
29
|
-
return {
|
|
30
|
-
...endowments,
|
|
31
|
-
window: endowments,
|
|
32
|
-
self: endowments
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
21
|
const snapFilePath = process.argv[2];
|
|
36
22
|
const snapModule = {
|
|
37
23
|
exports: {}
|
|
38
24
|
};
|
|
39
|
-
new Compartment({
|
|
40
|
-
...
|
|
25
|
+
const compartment = new Compartment({
|
|
26
|
+
...(0, _mock.generateMockEndowments)(),
|
|
41
27
|
module: snapModule,
|
|
42
28
|
exports: snapModule.exports
|
|
43
|
-
})
|
|
29
|
+
});
|
|
30
|
+
// Mirror BaseSnapExecutor
|
|
31
|
+
compartment.globalThis.self = compartment.globalThis;
|
|
32
|
+
compartment.globalThis.global = compartment.globalThis;
|
|
33
|
+
compartment.globalThis.window = compartment.globalThis;
|
|
34
|
+
compartment.evaluate((0, _fs.readFileSync)(snapFilePath, 'utf8'));
|
|
44
35
|
const invalidExports = Object.keys(snapModule.exports).filter((snapExport)=>!_handlertypes.SNAP_EXPORT_NAMES.includes(snapExport));
|
|
45
36
|
if (invalidExports.length > 0) {
|
|
46
37
|
// eslint-disable-next-line no-console
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\
|
|
1
|
+
{"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\nsetTimeout(() => process.exit(0), 1000); // Hack to ensure worker exits\n"],"names":["lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","domainTaming","snapFilePath","process","argv","snapModule","exports","compartment","Compartment","generateMockEndowments","module","globalThis","self","global","window","evaluate","readFileSync","invalidExports","Object","keys","filter","snapExport","SNAP_EXPORT_NAMES","includes","length","console","warn","join","setTimeout","exit"],"mappings":"AAAA,uDAAuD;;;;;QAChD;oBAEsB;8BAGK;sBACK;AAIvCA,SAAS;IACPC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAEhB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClCC,cAAc;AAChB;AAEA,MAAMC,eAAeC,QAAQC,IAAI,CAAC,EAAE;AAEpC,MAAMC,aAAgC;IAAEC,SAAS,CAAC;AAAE;AAEpD,MAAMC,cAAc,IAAIC,YAAY;IAClC,GAAGC,IAAAA,4BAAsB,GAAE;IAC3BC,QAAQL;IACRC,SAASD,WAAWC,OAAO;AAC7B;AAEA,0BAA0B;AAC1BC,YAAYI,UAAU,CAACC,IAAI,GAAGL,YAAYI,UAAU;AACpDJ,YAAYI,UAAU,CAACE,MAAM,GAAGN,YAAYI,UAAU;AACtDJ,YAAYI,UAAU,CAACG,MAAM,GAAGP,YAAYI,UAAU;AAEtDJ,YAAYQ,QAAQ,CAACC,IAAAA,gBAAY,EAACd,cAAc;AAEhD,MAAMe,iBAAiBC,OAAOC,IAAI,CAACd,WAAWC,OAAO,EAAEc,MAAM,CAC3D,CAACC,aAAe,CAACC,+BAAiB,CAACC,QAAQ,CAACF;AAG9C,IAAIJ,eAAeO,MAAM,GAAG,GAAG;IAC7B,sCAAsC;IACtCC,QAAQC,IAAI,CAAC,CAAC,gCAAgC,EAAET,eAAeU,IAAI,CAAC,MAAM,CAAC;AAC7E;AAEAC,WAAW,IAAMzB,QAAQ0B,IAAI,CAAC,IAAI,OAAO,8BAA8B"}
|
package/dist/esm/eval-worker.js
CHANGED
|
@@ -14,29 +14,20 @@ lockdown({
|
|
|
14
14
|
// Node.js domains are deprecated.
|
|
15
15
|
domainTaming: 'unsafe'
|
|
16
16
|
});
|
|
17
|
-
/**
|
|
18
|
-
* Get mock endowments that don't do anything. This is useful for running the
|
|
19
|
-
* eval, for snaps that try to communicate with the extension on initialisation,
|
|
20
|
-
* for example.
|
|
21
|
-
*
|
|
22
|
-
* @returns The mock endowments.
|
|
23
|
-
*/ function getMockEndowments() {
|
|
24
|
-
const endowments = generateMockEndowments();
|
|
25
|
-
return {
|
|
26
|
-
...endowments,
|
|
27
|
-
window: endowments,
|
|
28
|
-
self: endowments
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
17
|
const snapFilePath = process.argv[2];
|
|
32
18
|
const snapModule = {
|
|
33
19
|
exports: {}
|
|
34
20
|
};
|
|
35
|
-
new Compartment({
|
|
36
|
-
...
|
|
21
|
+
const compartment = new Compartment({
|
|
22
|
+
...generateMockEndowments(),
|
|
37
23
|
module: snapModule,
|
|
38
24
|
exports: snapModule.exports
|
|
39
|
-
})
|
|
25
|
+
});
|
|
26
|
+
// Mirror BaseSnapExecutor
|
|
27
|
+
compartment.globalThis.self = compartment.globalThis;
|
|
28
|
+
compartment.globalThis.global = compartment.globalThis;
|
|
29
|
+
compartment.globalThis.window = compartment.globalThis;
|
|
30
|
+
compartment.evaluate(readFileSync(snapFilePath, 'utf8'));
|
|
40
31
|
const invalidExports = Object.keys(snapModule.exports).filter((snapExport)=>!SNAP_EXPORT_NAMES.includes(snapExport));
|
|
41
32
|
if (invalidExports.length > 0) {
|
|
42
33
|
// eslint-disable-next-line no-console
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\
|
|
1
|
+
{"version":3,"sources":["../../src/eval-worker.ts"],"sourcesContent":["// eslint-disable-next-line import/no-unassigned-import\nimport 'ses/lockdown';\n\nimport { readFileSync } from 'fs';\n\nimport type { HandlerType } from './handler-types';\nimport { SNAP_EXPORT_NAMES } from './handler-types';\nimport { generateMockEndowments } from './mock';\n\ndeclare let lockdown: any, Compartment: any;\n\nlockdown({\n consoleTaming: 'unsafe',\n errorTaming: 'unsafe',\n mathTaming: 'unsafe',\n dateTaming: 'unsafe',\n overrideTaming: 'severe',\n\n // We disable domain taming, because it does not work in certain cases when\n // running tests. This is unlikely to be a problem in production, because\n // Node.js domains are deprecated.\n domainTaming: 'unsafe',\n});\n\nconst snapFilePath = process.argv[2];\n\nconst snapModule: { exports?: any } = { exports: {} };\n\nconst compartment = new Compartment({\n ...generateMockEndowments(),\n module: snapModule,\n exports: snapModule.exports,\n});\n\n// Mirror BaseSnapExecutor\ncompartment.globalThis.self = compartment.globalThis;\ncompartment.globalThis.global = compartment.globalThis;\ncompartment.globalThis.window = compartment.globalThis;\n\ncompartment.evaluate(readFileSync(snapFilePath, 'utf8'));\n\nconst invalidExports = Object.keys(snapModule.exports).filter(\n (snapExport) => !SNAP_EXPORT_NAMES.includes(snapExport as HandlerType),\n);\n\nif (invalidExports.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid snap exports detected:\\n${invalidExports.join('\\n')}`);\n}\n\nsetTimeout(() => process.exit(0), 1000); // Hack to ensure worker exits\n"],"names":["readFileSync","SNAP_EXPORT_NAMES","generateMockEndowments","lockdown","consoleTaming","errorTaming","mathTaming","dateTaming","overrideTaming","domainTaming","snapFilePath","process","argv","snapModule","exports","compartment","Compartment","module","globalThis","self","global","window","evaluate","invalidExports","Object","keys","filter","snapExport","includes","length","console","warn","join","setTimeout","exit"],"mappings":"AAAA,uDAAuD;AACvD,OAAO,eAAe;AAEtB,SAASA,YAAY,QAAQ,KAAK;AAGlC,SAASC,iBAAiB,QAAQ,kBAAkB;AACpD,SAASC,sBAAsB,QAAQ,SAAS;AAIhDC,SAAS;IACPC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC,YAAY;IACZC,gBAAgB;IAEhB,2EAA2E;IAC3E,yEAAyE;IACzE,kCAAkC;IAClCC,cAAc;AAChB;AAEA,MAAMC,eAAeC,QAAQC,IAAI,CAAC,EAAE;AAEpC,MAAMC,aAAgC;IAAEC,SAAS,CAAC;AAAE;AAEpD,MAAMC,cAAc,IAAIC,YAAY;IAClC,GAAGd,wBAAwB;IAC3Be,QAAQJ;IACRC,SAASD,WAAWC,OAAO;AAC7B;AAEA,0BAA0B;AAC1BC,YAAYG,UAAU,CAACC,IAAI,GAAGJ,YAAYG,UAAU;AACpDH,YAAYG,UAAU,CAACE,MAAM,GAAGL,YAAYG,UAAU;AACtDH,YAAYG,UAAU,CAACG,MAAM,GAAGN,YAAYG,UAAU;AAEtDH,YAAYO,QAAQ,CAACtB,aAAaU,cAAc;AAEhD,MAAMa,iBAAiBC,OAAOC,IAAI,CAACZ,WAAWC,OAAO,EAAEY,MAAM,CAC3D,CAACC,aAAe,CAAC1B,kBAAkB2B,QAAQ,CAACD;AAG9C,IAAIJ,eAAeM,MAAM,GAAG,GAAG;IAC7B,sCAAsC;IACtCC,QAAQC,IAAI,CAAC,CAAC,gCAAgC,EAAER,eAAeS,IAAI,CAAC,MAAM,CAAC;AAC7E;AAEAC,WAAW,IAAMtB,QAAQuB,IAAI,CAAC,IAAI,OAAO,8BAA8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"@babel/types": "^7.23.0",
|
|
70
70
|
"@metamask/base-controller": "^4.0.0",
|
|
71
71
|
"@metamask/key-tree": "^9.0.0",
|
|
72
|
-
"@metamask/permission-controller": "^7.
|
|
72
|
+
"@metamask/permission-controller": "^7.1.0",
|
|
73
73
|
"@metamask/rpc-errors": "^6.1.0",
|
|
74
74
|
"@metamask/slip44": "^3.1.0",
|
|
75
75
|
"@metamask/snaps-registry": "^3.0.0",
|
|
76
|
-
"@metamask/snaps-sdk": "^1.3.
|
|
76
|
+
"@metamask/snaps-sdk": "^1.3.2",
|
|
77
77
|
"@metamask/utils": "^8.2.1",
|
|
78
78
|
"@noble/hashes": "^1.3.1",
|
|
79
79
|
"@scure/base": "^1.1.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
93
93
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
94
94
|
"@lavamoat/allow-scripts": "^2.5.1",
|
|
95
|
-
"@metamask/auto-changelog": "^3.4.
|
|
95
|
+
"@metamask/auto-changelog": "^3.4.4",
|
|
96
96
|
"@metamask/eslint-config": "^12.1.0",
|
|
97
97
|
"@metamask/eslint-config-jest": "^12.1.0",
|
|
98
98
|
"@metamask/eslint-config-nodejs": "^12.1.0",
|