@metamask/snaps-execution-environments 0.38.0-flask.1 → 0.38.1-flask.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 +13 -1
- package/dist/browserify/iframe/index.html +45 -23
- package/dist/browserify/node-process/bundle.js +44 -22
- package/dist/browserify/node-thread/bundle.js +44 -22
- package/dist/browserify/offscreen/index.html +45 -23
- package/dist/browserify/worker-executor/bundle.js +45 -23
- package/dist/browserify/worker-pool/index.html +45 -23
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.38.1-flask.1]
|
|
10
|
+
### Changed
|
|
11
|
+
- Update LavaMoat packages to latest versions ([#1657](https://github.com/MetaMask/snaps/pull/1657))
|
|
12
|
+
|
|
13
|
+
### Removed
|
|
14
|
+
- Remove direct dependency on SES ([#1660](https://github.com/MetaMask/snaps/pull/1660))
|
|
15
|
+
- It's now a dev dependency, as it's only used in development.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Pass correct scuttle args ([#1654](https://github.com/MetaMask/snaps/pull/1654))
|
|
19
|
+
|
|
9
20
|
## [0.38.0-flask.1]
|
|
10
21
|
### Added
|
|
11
22
|
- Add `onInstall` and `onUpdate` lifecycle hooks ([#1643](https://github.com/MetaMask/snaps/pull/1643))
|
|
@@ -21,7 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
21
32
|
- The version of the package no longer needs to match the version of all other
|
|
22
33
|
MetaMask Snaps packages.
|
|
23
34
|
|
|
24
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@0.38.
|
|
35
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@0.38.1-flask.1...HEAD
|
|
36
|
+
[0.38.1-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@0.38.0-flask.1...@metamask/snaps-execution-environments@0.38.1-flask.1
|
|
25
37
|
[0.38.0-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@0.37.3-flask.1...@metamask/snaps-execution-environments@0.38.0-flask.1
|
|
26
38
|
[0.37.3-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-execution-environments@0.37.2-flask.1...@metamask/snaps-execution-environments@0.37.3-flask.1
|
|
27
39
|
[0.37.2-flask.1]: https://github.com/MetaMask/snaps/releases/tag/@metamask/snaps-execution-environments@0.37.2-flask.1
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
// security options are hard-coded at build time
|
|
96
96
|
const {
|
|
97
97
|
scuttleGlobalThis,
|
|
98
|
-
|
|
99
|
-
} = {"scuttleGlobalThis":true,"scuttleGlobalThisExceptions":["postMessage","removeEventListener","isSecureContext"]}
|
|
98
|
+
} = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext"]}}
|
|
100
99
|
|
|
101
100
|
function getGlobalRef () {
|
|
102
101
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -2525,7 +2524,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2525
2524
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2526
2525
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2527
2526
|
const importPattern= new FERAL_REG_EXP(
|
|
2528
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2527
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2529
2528
|
'g');
|
|
2530
2529
|
|
|
2531
2530
|
|
|
@@ -10963,7 +10962,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10963
10962
|
globalThisRefs,
|
|
10964
10963
|
// security options
|
|
10965
10964
|
scuttleGlobalThis,
|
|
10966
|
-
scuttleGlobalThisExceptions,
|
|
10967
10965
|
debugMode,
|
|
10968
10966
|
runWithPrecompiledModules,
|
|
10969
10967
|
reportStatsHook,
|
|
@@ -10991,7 +10989,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10991
10989
|
getExternalCompartment,
|
|
10992
10990
|
globalThisRefs,
|
|
10993
10991
|
scuttleGlobalThis,
|
|
10994
|
-
scuttleGlobalThisExceptions,
|
|
10995
10992
|
debugMode,
|
|
10996
10993
|
runWithPrecompiledModules,
|
|
10997
10994
|
reportStatsHook,
|
|
@@ -11010,8 +11007,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11010
11007
|
prepareModuleInitializerArgs,
|
|
11011
11008
|
getExternalCompartment,
|
|
11012
11009
|
globalThisRefs = ['globalThis'],
|
|
11013
|
-
scuttleGlobalThis =
|
|
11014
|
-
scuttleGlobalThisExceptions = [],
|
|
11010
|
+
scuttleGlobalThis = {},
|
|
11015
11011
|
debugMode = false,
|
|
11016
11012
|
runWithPrecompiledModules = false,
|
|
11017
11013
|
reportStatsHook = () => {},
|
|
@@ -11557,6 +11553,7 @@ module.exports = {
|
|
|
11557
11553
|
return module.exports
|
|
11558
11554
|
})()
|
|
11559
11555
|
|
|
11556
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11560
11557
|
const moduleCache = new Map()
|
|
11561
11558
|
const packageCompartmentCache = new Map()
|
|
11562
11559
|
const globalStore = new Map()
|
|
@@ -11565,22 +11562,11 @@ module.exports = {
|
|
|
11565
11562
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11566
11563
|
|
|
11567
11564
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11568
|
-
if (
|
|
11569
|
-
if (!Array.isArray(
|
|
11570
|
-
throw new Error(`LavaMoat -
|
|
11565
|
+
if (scuttleOpts.enabled) {
|
|
11566
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11567
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11571
11568
|
}
|
|
11572
|
-
|
|
11573
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11574
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11575
|
-
if (!prop.startsWith('/')) {
|
|
11576
|
-
continue
|
|
11577
|
-
}
|
|
11578
|
-
const parts = prop.split('/')
|
|
11579
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11580
|
-
const flags = parts[parts.length - 1]
|
|
11581
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11582
|
-
}
|
|
11583
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11569
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11584
11570
|
}
|
|
11585
11571
|
|
|
11586
11572
|
const kernel = {
|
|
@@ -11593,6 +11579,43 @@ module.exports = {
|
|
|
11593
11579
|
Object.freeze(kernel)
|
|
11594
11580
|
return kernel
|
|
11595
11581
|
|
|
11582
|
+
// generate final scuttling options (1) by taking default
|
|
11583
|
+
// options into consideration, (2) turning RE strings into
|
|
11584
|
+
// actual REs and (3) without mutating original opts object
|
|
11585
|
+
function generateScuttleOpts(originalOpts) {
|
|
11586
|
+
const defaultOpts = {
|
|
11587
|
+
enabled: true,
|
|
11588
|
+
exceptions: [],
|
|
11589
|
+
scuttlerName: '',
|
|
11590
|
+
}
|
|
11591
|
+
const opts = Object.assign({},
|
|
11592
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11593
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11594
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11595
|
+
)
|
|
11596
|
+
if (opts.scuttlerName) {
|
|
11597
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11598
|
+
throw new Error(
|
|
11599
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11600
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11601
|
+
)
|
|
11602
|
+
}
|
|
11603
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11604
|
+
}
|
|
11605
|
+
return opts
|
|
11606
|
+
|
|
11607
|
+
function toRE(except) {
|
|
11608
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11609
|
+
if (!except.startsWith('/')) {
|
|
11610
|
+
return except
|
|
11611
|
+
}
|
|
11612
|
+
const parts = except.split('/')
|
|
11613
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11614
|
+
const flags = parts[parts.length - 1]
|
|
11615
|
+
return new RegExp(pattern, flags)
|
|
11616
|
+
}
|
|
11617
|
+
}
|
|
11618
|
+
|
|
11596
11619
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11597
11620
|
const props = new Array()
|
|
11598
11621
|
getPrototypeChain(globalRef)
|
|
@@ -11995,7 +12018,6 @@ module.exports = {
|
|
|
11995
12018
|
globalRef,
|
|
11996
12019
|
globalThisRefs,
|
|
11997
12020
|
scuttleGlobalThis,
|
|
11998
|
-
scuttleGlobalThisExceptions,
|
|
11999
12021
|
debugMode,
|
|
12000
12022
|
runWithPrecompiledModules,
|
|
12001
12023
|
reportStatsHook,
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
// security options are hard-coded at build time
|
|
90
90
|
const {
|
|
91
91
|
scuttleGlobalThis,
|
|
92
|
-
scuttleGlobalThisExceptions,
|
|
93
92
|
} = {}
|
|
94
93
|
|
|
95
94
|
function getGlobalRef () {
|
|
@@ -2519,7 +2518,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2519
2518
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2520
2519
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2521
2520
|
const importPattern= new FERAL_REG_EXP(
|
|
2522
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2521
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2523
2522
|
'g');
|
|
2524
2523
|
|
|
2525
2524
|
|
|
@@ -10957,7 +10956,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10957
10956
|
globalThisRefs,
|
|
10958
10957
|
// security options
|
|
10959
10958
|
scuttleGlobalThis,
|
|
10960
|
-
scuttleGlobalThisExceptions,
|
|
10961
10959
|
debugMode,
|
|
10962
10960
|
runWithPrecompiledModules,
|
|
10963
10961
|
reportStatsHook,
|
|
@@ -10985,7 +10983,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10985
10983
|
getExternalCompartment,
|
|
10986
10984
|
globalThisRefs,
|
|
10987
10985
|
scuttleGlobalThis,
|
|
10988
|
-
scuttleGlobalThisExceptions,
|
|
10989
10986
|
debugMode,
|
|
10990
10987
|
runWithPrecompiledModules,
|
|
10991
10988
|
reportStatsHook,
|
|
@@ -11004,8 +11001,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11004
11001
|
prepareModuleInitializerArgs,
|
|
11005
11002
|
getExternalCompartment,
|
|
11006
11003
|
globalThisRefs = ['globalThis'],
|
|
11007
|
-
scuttleGlobalThis =
|
|
11008
|
-
scuttleGlobalThisExceptions = [],
|
|
11004
|
+
scuttleGlobalThis = {},
|
|
11009
11005
|
debugMode = false,
|
|
11010
11006
|
runWithPrecompiledModules = false,
|
|
11011
11007
|
reportStatsHook = () => {},
|
|
@@ -11551,6 +11547,7 @@ module.exports = {
|
|
|
11551
11547
|
return module.exports
|
|
11552
11548
|
})()
|
|
11553
11549
|
|
|
11550
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11554
11551
|
const moduleCache = new Map()
|
|
11555
11552
|
const packageCompartmentCache = new Map()
|
|
11556
11553
|
const globalStore = new Map()
|
|
@@ -11559,22 +11556,11 @@ module.exports = {
|
|
|
11559
11556
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11560
11557
|
|
|
11561
11558
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11562
|
-
if (
|
|
11563
|
-
if (!Array.isArray(
|
|
11564
|
-
throw new Error(`LavaMoat -
|
|
11559
|
+
if (scuttleOpts.enabled) {
|
|
11560
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11561
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11565
11562
|
}
|
|
11566
|
-
|
|
11567
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11568
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11569
|
-
if (!prop.startsWith('/')) {
|
|
11570
|
-
continue
|
|
11571
|
-
}
|
|
11572
|
-
const parts = prop.split('/')
|
|
11573
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11574
|
-
const flags = parts[parts.length - 1]
|
|
11575
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11576
|
-
}
|
|
11577
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11563
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11578
11564
|
}
|
|
11579
11565
|
|
|
11580
11566
|
const kernel = {
|
|
@@ -11587,6 +11573,43 @@ module.exports = {
|
|
|
11587
11573
|
Object.freeze(kernel)
|
|
11588
11574
|
return kernel
|
|
11589
11575
|
|
|
11576
|
+
// generate final scuttling options (1) by taking default
|
|
11577
|
+
// options into consideration, (2) turning RE strings into
|
|
11578
|
+
// actual REs and (3) without mutating original opts object
|
|
11579
|
+
function generateScuttleOpts(originalOpts) {
|
|
11580
|
+
const defaultOpts = {
|
|
11581
|
+
enabled: true,
|
|
11582
|
+
exceptions: [],
|
|
11583
|
+
scuttlerName: '',
|
|
11584
|
+
}
|
|
11585
|
+
const opts = Object.assign({},
|
|
11586
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11587
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11588
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11589
|
+
)
|
|
11590
|
+
if (opts.scuttlerName) {
|
|
11591
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11592
|
+
throw new Error(
|
|
11593
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11594
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11595
|
+
)
|
|
11596
|
+
}
|
|
11597
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11598
|
+
}
|
|
11599
|
+
return opts
|
|
11600
|
+
|
|
11601
|
+
function toRE(except) {
|
|
11602
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11603
|
+
if (!except.startsWith('/')) {
|
|
11604
|
+
return except
|
|
11605
|
+
}
|
|
11606
|
+
const parts = except.split('/')
|
|
11607
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11608
|
+
const flags = parts[parts.length - 1]
|
|
11609
|
+
return new RegExp(pattern, flags)
|
|
11610
|
+
}
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11590
11613
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11591
11614
|
const props = new Array()
|
|
11592
11615
|
getPrototypeChain(globalRef)
|
|
@@ -11989,7 +12012,6 @@ module.exports = {
|
|
|
11989
12012
|
globalRef,
|
|
11990
12013
|
globalThisRefs,
|
|
11991
12014
|
scuttleGlobalThis,
|
|
11992
|
-
scuttleGlobalThisExceptions,
|
|
11993
12015
|
debugMode,
|
|
11994
12016
|
runWithPrecompiledModules,
|
|
11995
12017
|
reportStatsHook,
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
// security options are hard-coded at build time
|
|
90
90
|
const {
|
|
91
91
|
scuttleGlobalThis,
|
|
92
|
-
scuttleGlobalThisExceptions,
|
|
93
92
|
} = {}
|
|
94
93
|
|
|
95
94
|
function getGlobalRef () {
|
|
@@ -2519,7 +2518,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2519
2518
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2520
2519
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2521
2520
|
const importPattern= new FERAL_REG_EXP(
|
|
2522
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2521
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2523
2522
|
'g');
|
|
2524
2523
|
|
|
2525
2524
|
|
|
@@ -10957,7 +10956,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10957
10956
|
globalThisRefs,
|
|
10958
10957
|
// security options
|
|
10959
10958
|
scuttleGlobalThis,
|
|
10960
|
-
scuttleGlobalThisExceptions,
|
|
10961
10959
|
debugMode,
|
|
10962
10960
|
runWithPrecompiledModules,
|
|
10963
10961
|
reportStatsHook,
|
|
@@ -10985,7 +10983,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10985
10983
|
getExternalCompartment,
|
|
10986
10984
|
globalThisRefs,
|
|
10987
10985
|
scuttleGlobalThis,
|
|
10988
|
-
scuttleGlobalThisExceptions,
|
|
10989
10986
|
debugMode,
|
|
10990
10987
|
runWithPrecompiledModules,
|
|
10991
10988
|
reportStatsHook,
|
|
@@ -11004,8 +11001,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11004
11001
|
prepareModuleInitializerArgs,
|
|
11005
11002
|
getExternalCompartment,
|
|
11006
11003
|
globalThisRefs = ['globalThis'],
|
|
11007
|
-
scuttleGlobalThis =
|
|
11008
|
-
scuttleGlobalThisExceptions = [],
|
|
11004
|
+
scuttleGlobalThis = {},
|
|
11009
11005
|
debugMode = false,
|
|
11010
11006
|
runWithPrecompiledModules = false,
|
|
11011
11007
|
reportStatsHook = () => {},
|
|
@@ -11551,6 +11547,7 @@ module.exports = {
|
|
|
11551
11547
|
return module.exports
|
|
11552
11548
|
})()
|
|
11553
11549
|
|
|
11550
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11554
11551
|
const moduleCache = new Map()
|
|
11555
11552
|
const packageCompartmentCache = new Map()
|
|
11556
11553
|
const globalStore = new Map()
|
|
@@ -11559,22 +11556,11 @@ module.exports = {
|
|
|
11559
11556
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11560
11557
|
|
|
11561
11558
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11562
|
-
if (
|
|
11563
|
-
if (!Array.isArray(
|
|
11564
|
-
throw new Error(`LavaMoat -
|
|
11559
|
+
if (scuttleOpts.enabled) {
|
|
11560
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11561
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11565
11562
|
}
|
|
11566
|
-
|
|
11567
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11568
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11569
|
-
if (!prop.startsWith('/')) {
|
|
11570
|
-
continue
|
|
11571
|
-
}
|
|
11572
|
-
const parts = prop.split('/')
|
|
11573
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11574
|
-
const flags = parts[parts.length - 1]
|
|
11575
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11576
|
-
}
|
|
11577
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11563
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11578
11564
|
}
|
|
11579
11565
|
|
|
11580
11566
|
const kernel = {
|
|
@@ -11587,6 +11573,43 @@ module.exports = {
|
|
|
11587
11573
|
Object.freeze(kernel)
|
|
11588
11574
|
return kernel
|
|
11589
11575
|
|
|
11576
|
+
// generate final scuttling options (1) by taking default
|
|
11577
|
+
// options into consideration, (2) turning RE strings into
|
|
11578
|
+
// actual REs and (3) without mutating original opts object
|
|
11579
|
+
function generateScuttleOpts(originalOpts) {
|
|
11580
|
+
const defaultOpts = {
|
|
11581
|
+
enabled: true,
|
|
11582
|
+
exceptions: [],
|
|
11583
|
+
scuttlerName: '',
|
|
11584
|
+
}
|
|
11585
|
+
const opts = Object.assign({},
|
|
11586
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11587
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11588
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11589
|
+
)
|
|
11590
|
+
if (opts.scuttlerName) {
|
|
11591
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11592
|
+
throw new Error(
|
|
11593
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11594
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11595
|
+
)
|
|
11596
|
+
}
|
|
11597
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11598
|
+
}
|
|
11599
|
+
return opts
|
|
11600
|
+
|
|
11601
|
+
function toRE(except) {
|
|
11602
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11603
|
+
if (!except.startsWith('/')) {
|
|
11604
|
+
return except
|
|
11605
|
+
}
|
|
11606
|
+
const parts = except.split('/')
|
|
11607
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11608
|
+
const flags = parts[parts.length - 1]
|
|
11609
|
+
return new RegExp(pattern, flags)
|
|
11610
|
+
}
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11590
11613
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11591
11614
|
const props = new Array()
|
|
11592
11615
|
getPrototypeChain(globalRef)
|
|
@@ -11989,7 +12012,6 @@ module.exports = {
|
|
|
11989
12012
|
globalRef,
|
|
11990
12013
|
globalThisRefs,
|
|
11991
12014
|
scuttleGlobalThis,
|
|
11992
|
-
scuttleGlobalThisExceptions,
|
|
11993
12015
|
debugMode,
|
|
11994
12016
|
runWithPrecompiledModules,
|
|
11995
12017
|
reportStatsHook,
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
// security options are hard-coded at build time
|
|
96
96
|
const {
|
|
97
97
|
scuttleGlobalThis,
|
|
98
|
-
|
|
99
|
-
} = {"scuttleGlobalThis":true,"scuttleGlobalThisExceptions":["postMessage","removeEventListener","isSecureContext"]}
|
|
98
|
+
} = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext"]}}
|
|
100
99
|
|
|
101
100
|
function getGlobalRef () {
|
|
102
101
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -2525,7 +2524,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2525
2524
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2526
2525
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2527
2526
|
const importPattern= new FERAL_REG_EXP(
|
|
2528
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2527
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2529
2528
|
'g');
|
|
2530
2529
|
|
|
2531
2530
|
|
|
@@ -10963,7 +10962,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10963
10962
|
globalThisRefs,
|
|
10964
10963
|
// security options
|
|
10965
10964
|
scuttleGlobalThis,
|
|
10966
|
-
scuttleGlobalThisExceptions,
|
|
10967
10965
|
debugMode,
|
|
10968
10966
|
runWithPrecompiledModules,
|
|
10969
10967
|
reportStatsHook,
|
|
@@ -10991,7 +10989,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10991
10989
|
getExternalCompartment,
|
|
10992
10990
|
globalThisRefs,
|
|
10993
10991
|
scuttleGlobalThis,
|
|
10994
|
-
scuttleGlobalThisExceptions,
|
|
10995
10992
|
debugMode,
|
|
10996
10993
|
runWithPrecompiledModules,
|
|
10997
10994
|
reportStatsHook,
|
|
@@ -11010,8 +11007,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11010
11007
|
prepareModuleInitializerArgs,
|
|
11011
11008
|
getExternalCompartment,
|
|
11012
11009
|
globalThisRefs = ['globalThis'],
|
|
11013
|
-
scuttleGlobalThis =
|
|
11014
|
-
scuttleGlobalThisExceptions = [],
|
|
11010
|
+
scuttleGlobalThis = {},
|
|
11015
11011
|
debugMode = false,
|
|
11016
11012
|
runWithPrecompiledModules = false,
|
|
11017
11013
|
reportStatsHook = () => {},
|
|
@@ -11557,6 +11553,7 @@ module.exports = {
|
|
|
11557
11553
|
return module.exports
|
|
11558
11554
|
})()
|
|
11559
11555
|
|
|
11556
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11560
11557
|
const moduleCache = new Map()
|
|
11561
11558
|
const packageCompartmentCache = new Map()
|
|
11562
11559
|
const globalStore = new Map()
|
|
@@ -11565,22 +11562,11 @@ module.exports = {
|
|
|
11565
11562
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11566
11563
|
|
|
11567
11564
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11568
|
-
if (
|
|
11569
|
-
if (!Array.isArray(
|
|
11570
|
-
throw new Error(`LavaMoat -
|
|
11565
|
+
if (scuttleOpts.enabled) {
|
|
11566
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11567
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11571
11568
|
}
|
|
11572
|
-
|
|
11573
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11574
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11575
|
-
if (!prop.startsWith('/')) {
|
|
11576
|
-
continue
|
|
11577
|
-
}
|
|
11578
|
-
const parts = prop.split('/')
|
|
11579
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11580
|
-
const flags = parts[parts.length - 1]
|
|
11581
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11582
|
-
}
|
|
11583
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11569
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11584
11570
|
}
|
|
11585
11571
|
|
|
11586
11572
|
const kernel = {
|
|
@@ -11593,6 +11579,43 @@ module.exports = {
|
|
|
11593
11579
|
Object.freeze(kernel)
|
|
11594
11580
|
return kernel
|
|
11595
11581
|
|
|
11582
|
+
// generate final scuttling options (1) by taking default
|
|
11583
|
+
// options into consideration, (2) turning RE strings into
|
|
11584
|
+
// actual REs and (3) without mutating original opts object
|
|
11585
|
+
function generateScuttleOpts(originalOpts) {
|
|
11586
|
+
const defaultOpts = {
|
|
11587
|
+
enabled: true,
|
|
11588
|
+
exceptions: [],
|
|
11589
|
+
scuttlerName: '',
|
|
11590
|
+
}
|
|
11591
|
+
const opts = Object.assign({},
|
|
11592
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11593
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11594
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11595
|
+
)
|
|
11596
|
+
if (opts.scuttlerName) {
|
|
11597
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11598
|
+
throw new Error(
|
|
11599
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11600
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11601
|
+
)
|
|
11602
|
+
}
|
|
11603
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11604
|
+
}
|
|
11605
|
+
return opts
|
|
11606
|
+
|
|
11607
|
+
function toRE(except) {
|
|
11608
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11609
|
+
if (!except.startsWith('/')) {
|
|
11610
|
+
return except
|
|
11611
|
+
}
|
|
11612
|
+
const parts = except.split('/')
|
|
11613
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11614
|
+
const flags = parts[parts.length - 1]
|
|
11615
|
+
return new RegExp(pattern, flags)
|
|
11616
|
+
}
|
|
11617
|
+
}
|
|
11618
|
+
|
|
11596
11619
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11597
11620
|
const props = new Array()
|
|
11598
11621
|
getPrototypeChain(globalRef)
|
|
@@ -11995,7 +12018,6 @@ module.exports = {
|
|
|
11995
12018
|
globalRef,
|
|
11996
12019
|
globalThisRefs,
|
|
11997
12020
|
scuttleGlobalThis,
|
|
11998
|
-
scuttleGlobalThisExceptions,
|
|
11999
12021
|
debugMode,
|
|
12000
12022
|
runWithPrecompiledModules,
|
|
12001
12023
|
reportStatsHook,
|
|
@@ -89,8 +89,7 @@
|
|
|
89
89
|
// security options are hard-coded at build time
|
|
90
90
|
const {
|
|
91
91
|
scuttleGlobalThis,
|
|
92
|
-
|
|
93
|
-
} = {"scuttleGlobalThis":true,"scuttleGlobalThisExceptions":["postMessage","removeEventListener","isSecureContext"]}
|
|
92
|
+
} = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext"]}}
|
|
94
93
|
|
|
95
94
|
function getGlobalRef () {
|
|
96
95
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -2519,7 +2518,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2519
2518
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2520
2519
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2521
2520
|
const importPattern= new FERAL_REG_EXP(
|
|
2522
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2521
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2523
2522
|
'g');
|
|
2524
2523
|
|
|
2525
2524
|
|
|
@@ -10957,7 +10956,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10957
10956
|
globalThisRefs,
|
|
10958
10957
|
// security options
|
|
10959
10958
|
scuttleGlobalThis,
|
|
10960
|
-
scuttleGlobalThisExceptions,
|
|
10961
10959
|
debugMode,
|
|
10962
10960
|
runWithPrecompiledModules,
|
|
10963
10961
|
reportStatsHook,
|
|
@@ -10985,7 +10983,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10985
10983
|
getExternalCompartment,
|
|
10986
10984
|
globalThisRefs,
|
|
10987
10985
|
scuttleGlobalThis,
|
|
10988
|
-
scuttleGlobalThisExceptions,
|
|
10989
10986
|
debugMode,
|
|
10990
10987
|
runWithPrecompiledModules,
|
|
10991
10988
|
reportStatsHook,
|
|
@@ -11004,8 +11001,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11004
11001
|
prepareModuleInitializerArgs,
|
|
11005
11002
|
getExternalCompartment,
|
|
11006
11003
|
globalThisRefs = ['globalThis'],
|
|
11007
|
-
scuttleGlobalThis =
|
|
11008
|
-
scuttleGlobalThisExceptions = [],
|
|
11004
|
+
scuttleGlobalThis = {},
|
|
11009
11005
|
debugMode = false,
|
|
11010
11006
|
runWithPrecompiledModules = false,
|
|
11011
11007
|
reportStatsHook = () => {},
|
|
@@ -11551,6 +11547,7 @@ module.exports = {
|
|
|
11551
11547
|
return module.exports
|
|
11552
11548
|
})()
|
|
11553
11549
|
|
|
11550
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11554
11551
|
const moduleCache = new Map()
|
|
11555
11552
|
const packageCompartmentCache = new Map()
|
|
11556
11553
|
const globalStore = new Map()
|
|
@@ -11559,22 +11556,11 @@ module.exports = {
|
|
|
11559
11556
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11560
11557
|
|
|
11561
11558
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11562
|
-
if (
|
|
11563
|
-
if (!Array.isArray(
|
|
11564
|
-
throw new Error(`LavaMoat -
|
|
11559
|
+
if (scuttleOpts.enabled) {
|
|
11560
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11561
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11565
11562
|
}
|
|
11566
|
-
|
|
11567
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11568
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11569
|
-
if (!prop.startsWith('/')) {
|
|
11570
|
-
continue
|
|
11571
|
-
}
|
|
11572
|
-
const parts = prop.split('/')
|
|
11573
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11574
|
-
const flags = parts[parts.length - 1]
|
|
11575
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11576
|
-
}
|
|
11577
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11563
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11578
11564
|
}
|
|
11579
11565
|
|
|
11580
11566
|
const kernel = {
|
|
@@ -11587,6 +11573,43 @@ module.exports = {
|
|
|
11587
11573
|
Object.freeze(kernel)
|
|
11588
11574
|
return kernel
|
|
11589
11575
|
|
|
11576
|
+
// generate final scuttling options (1) by taking default
|
|
11577
|
+
// options into consideration, (2) turning RE strings into
|
|
11578
|
+
// actual REs and (3) without mutating original opts object
|
|
11579
|
+
function generateScuttleOpts(originalOpts) {
|
|
11580
|
+
const defaultOpts = {
|
|
11581
|
+
enabled: true,
|
|
11582
|
+
exceptions: [],
|
|
11583
|
+
scuttlerName: '',
|
|
11584
|
+
}
|
|
11585
|
+
const opts = Object.assign({},
|
|
11586
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11587
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11588
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11589
|
+
)
|
|
11590
|
+
if (opts.scuttlerName) {
|
|
11591
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11592
|
+
throw new Error(
|
|
11593
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11594
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11595
|
+
)
|
|
11596
|
+
}
|
|
11597
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11598
|
+
}
|
|
11599
|
+
return opts
|
|
11600
|
+
|
|
11601
|
+
function toRE(except) {
|
|
11602
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11603
|
+
if (!except.startsWith('/')) {
|
|
11604
|
+
return except
|
|
11605
|
+
}
|
|
11606
|
+
const parts = except.split('/')
|
|
11607
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11608
|
+
const flags = parts[parts.length - 1]
|
|
11609
|
+
return new RegExp(pattern, flags)
|
|
11610
|
+
}
|
|
11611
|
+
}
|
|
11612
|
+
|
|
11590
11613
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11591
11614
|
const props = new Array()
|
|
11592
11615
|
getPrototypeChain(globalRef)
|
|
@@ -11989,7 +12012,6 @@ module.exports = {
|
|
|
11989
12012
|
globalRef,
|
|
11990
12013
|
globalThisRefs,
|
|
11991
12014
|
scuttleGlobalThis,
|
|
11992
|
-
scuttleGlobalThisExceptions,
|
|
11993
12015
|
debugMode,
|
|
11994
12016
|
runWithPrecompiledModules,
|
|
11995
12017
|
reportStatsHook,
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
// security options are hard-coded at build time
|
|
96
96
|
const {
|
|
97
97
|
scuttleGlobalThis,
|
|
98
|
-
|
|
99
|
-
} = {"scuttleGlobalThis":true,"scuttleGlobalThisExceptions":["postMessage","removeEventListener","isSecureContext"]}
|
|
98
|
+
} = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext"]}}
|
|
100
99
|
|
|
101
100
|
function getGlobalRef () {
|
|
102
101
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -2525,7 +2524,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
2525
2524
|
// /////////////////////////////////////////////////////////////////////////////
|
|
2526
2525
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
2527
2526
|
const importPattern= new FERAL_REG_EXP(
|
|
2528
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2527
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
2529
2528
|
'g');
|
|
2530
2529
|
|
|
2531
2530
|
|
|
@@ -10963,7 +10962,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10963
10962
|
globalThisRefs,
|
|
10964
10963
|
// security options
|
|
10965
10964
|
scuttleGlobalThis,
|
|
10966
|
-
scuttleGlobalThisExceptions,
|
|
10967
10965
|
debugMode,
|
|
10968
10966
|
runWithPrecompiledModules,
|
|
10969
10967
|
reportStatsHook,
|
|
@@ -10991,7 +10989,6 @@ function observeImports(map, importName, importIndex) {
|
|
|
10991
10989
|
getExternalCompartment,
|
|
10992
10990
|
globalThisRefs,
|
|
10993
10991
|
scuttleGlobalThis,
|
|
10994
|
-
scuttleGlobalThisExceptions,
|
|
10995
10992
|
debugMode,
|
|
10996
10993
|
runWithPrecompiledModules,
|
|
10997
10994
|
reportStatsHook,
|
|
@@ -11010,8 +11007,7 @@ function observeImports(map, importName, importIndex) {
|
|
|
11010
11007
|
prepareModuleInitializerArgs,
|
|
11011
11008
|
getExternalCompartment,
|
|
11012
11009
|
globalThisRefs = ['globalThis'],
|
|
11013
|
-
scuttleGlobalThis =
|
|
11014
|
-
scuttleGlobalThisExceptions = [],
|
|
11010
|
+
scuttleGlobalThis = {},
|
|
11015
11011
|
debugMode = false,
|
|
11016
11012
|
runWithPrecompiledModules = false,
|
|
11017
11013
|
reportStatsHook = () => {},
|
|
@@ -11557,6 +11553,7 @@ module.exports = {
|
|
|
11557
11553
|
return module.exports
|
|
11558
11554
|
})()
|
|
11559
11555
|
|
|
11556
|
+
const scuttleOpts = generateScuttleOpts(scuttleGlobalThis)
|
|
11560
11557
|
const moduleCache = new Map()
|
|
11561
11558
|
const packageCompartmentCache = new Map()
|
|
11562
11559
|
const globalStore = new Map()
|
|
@@ -11565,22 +11562,11 @@ module.exports = {
|
|
|
11565
11562
|
const rootPackageCompartment = createRootPackageCompartment(globalRef)
|
|
11566
11563
|
|
|
11567
11564
|
// scuttle globalThis right after we used it to create the root package compartment
|
|
11568
|
-
if (
|
|
11569
|
-
if (!Array.isArray(
|
|
11570
|
-
throw new Error(`LavaMoat -
|
|
11565
|
+
if (scuttleOpts.enabled) {
|
|
11566
|
+
if (!Array.isArray(scuttleOpts.exceptions)) {
|
|
11567
|
+
throw new Error(`LavaMoat - scuttleGlobalThis.exceptions must be an array, got "${typeof scuttleOpts.exceptions}"`)
|
|
11571
11568
|
}
|
|
11572
|
-
|
|
11573
|
-
for (let i = 0; i < scuttleGlobalThisExceptions.length; i++) {
|
|
11574
|
-
const prop = scuttleGlobalThisExceptions[i]
|
|
11575
|
-
if (!prop.startsWith('/')) {
|
|
11576
|
-
continue
|
|
11577
|
-
}
|
|
11578
|
-
const parts = prop.split('/')
|
|
11579
|
-
const pattern = parts.slice(1, -1).join('/')
|
|
11580
|
-
const flags = parts[parts.length - 1]
|
|
11581
|
-
scuttleGlobalThisExceptions[i] = new RegExp(pattern, flags)
|
|
11582
|
-
}
|
|
11583
|
-
performScuttleGlobalThis(globalRef, scuttleGlobalThisExceptions)
|
|
11569
|
+
scuttleOpts.scuttlerFunc(globalRef, realm => performScuttleGlobalThis(realm, scuttleOpts.exceptions))
|
|
11584
11570
|
}
|
|
11585
11571
|
|
|
11586
11572
|
const kernel = {
|
|
@@ -11593,6 +11579,43 @@ module.exports = {
|
|
|
11593
11579
|
Object.freeze(kernel)
|
|
11594
11580
|
return kernel
|
|
11595
11581
|
|
|
11582
|
+
// generate final scuttling options (1) by taking default
|
|
11583
|
+
// options into consideration, (2) turning RE strings into
|
|
11584
|
+
// actual REs and (3) without mutating original opts object
|
|
11585
|
+
function generateScuttleOpts(originalOpts) {
|
|
11586
|
+
const defaultOpts = {
|
|
11587
|
+
enabled: true,
|
|
11588
|
+
exceptions: [],
|
|
11589
|
+
scuttlerName: '',
|
|
11590
|
+
}
|
|
11591
|
+
const opts = Object.assign({},
|
|
11592
|
+
originalOpts === true ? { ... defaultOpts } : { ...originalOpts },
|
|
11593
|
+
{ scuttlerFunc: (globalRef, scuttle) => scuttle(globalRef) },
|
|
11594
|
+
{ exceptions: (originalOpts.exceptions || defaultOpts.exceptions).map(e => toRE(e)) },
|
|
11595
|
+
)
|
|
11596
|
+
if (opts.scuttlerName) {
|
|
11597
|
+
if (!globalRef[opts.scuttlerName]) {
|
|
11598
|
+
throw new Error(
|
|
11599
|
+
`LavaMoat - 'scuttlerName' function "${opts.scuttlerName}" expected on globalRef.` +
|
|
11600
|
+
'To learn more visit https://github.com/LavaMoat/LavaMoat/pull/462.',
|
|
11601
|
+
)
|
|
11602
|
+
}
|
|
11603
|
+
opts.scuttlerFunc = globalRef[opts.scuttlerName]
|
|
11604
|
+
}
|
|
11605
|
+
return opts
|
|
11606
|
+
|
|
11607
|
+
function toRE(except) {
|
|
11608
|
+
// turn scuttleGlobalThis.exceptions regexes strings to actual regexes
|
|
11609
|
+
if (!except.startsWith('/')) {
|
|
11610
|
+
return except
|
|
11611
|
+
}
|
|
11612
|
+
const parts = except.split('/')
|
|
11613
|
+
const pattern = parts.slice(1, -1).join('/')
|
|
11614
|
+
const flags = parts[parts.length - 1]
|
|
11615
|
+
return new RegExp(pattern, flags)
|
|
11616
|
+
}
|
|
11617
|
+
}
|
|
11618
|
+
|
|
11596
11619
|
function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
|
|
11597
11620
|
const props = new Array()
|
|
11598
11621
|
getPrototypeChain(globalRef)
|
|
@@ -11995,7 +12018,6 @@ module.exports = {
|
|
|
11995
12018
|
globalRef,
|
|
11996
12019
|
globalThisRefs,
|
|
11997
12020
|
scuttleGlobalThis,
|
|
11998
|
-
scuttleGlobalThisExceptions,
|
|
11999
12021
|
debugMode,
|
|
12000
12022
|
runWithPrecompiledModules,
|
|
12001
12023
|
reportStatsHook,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-execution-environments",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1-flask.1",
|
|
4
4
|
"description": "Snap sandbox environments for executing SES javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"json-rpc-engine": "^6.1.0",
|
|
55
55
|
"nanoid": "^3.1.31",
|
|
56
56
|
"pump": "^3.0.0",
|
|
57
|
-
"ses": "^0.18.1",
|
|
58
57
|
"stream-browserify": "^3.0.0",
|
|
59
58
|
"superstruct": "^1.0.3"
|
|
60
59
|
},
|
|
@@ -65,8 +64,8 @@
|
|
|
65
64
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
66
65
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
67
66
|
"@lavamoat/allow-scripts": "^2.3.1",
|
|
68
|
-
"@lavamoat/lavapack": "^5.1
|
|
69
|
-
"@lavamoat/lavatube": "^0.
|
|
67
|
+
"@lavamoat/lavapack": "^5.2.1",
|
|
68
|
+
"@lavamoat/lavatube": "^0.2.3",
|
|
70
69
|
"@metamask/auto-changelog": "^3.1.0",
|
|
71
70
|
"@metamask/eslint-config": "^12.1.0",
|
|
72
71
|
"@metamask/eslint-config-jest": "^12.1.0",
|
|
@@ -107,13 +106,14 @@
|
|
|
107
106
|
"jest": "^29.0.2",
|
|
108
107
|
"jest-fetch-mock": "^3.0.3",
|
|
109
108
|
"lavamoat": "^7.0.0",
|
|
110
|
-
"lavamoat-browserify": "^15.
|
|
109
|
+
"lavamoat-browserify": "^15.7.1",
|
|
111
110
|
"memfs": "^3.4.13",
|
|
112
111
|
"prettier": "^2.7.1",
|
|
113
112
|
"prettier-plugin-packagejson": "^2.2.11",
|
|
114
113
|
"process": "^0.11.10",
|
|
115
114
|
"rimraf": "^4.1.2",
|
|
116
115
|
"serve-handler": "^6.1.5",
|
|
116
|
+
"ses": "^0.18.1",
|
|
117
117
|
"terser": "^5.17.7",
|
|
118
118
|
"ts-node": "^10.9.1",
|
|
119
119
|
"tsconfig-paths": "^4.2.0",
|