ses 0.13.3 → 0.13.5
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/NEWS.md +12 -1
- package/dist/lockdown.cjs +35 -63
- package/dist/lockdown.mjs +35 -63
- package/dist/lockdown.umd.js +35 -63
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +35 -63
- package/dist/ses.mjs +35 -63
- package/dist/ses.umd.js +35 -63
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +146 -47
- package/package.json +6 -7
- package/src/compartment-shim.js +4 -18
- package/src/error/types.js +2 -2
- package/src/lockdown-shim.js +6 -20
- package/src/make-hardener.js +2 -2
- package/src/transforms.js +4 -1
- package/CHANGELOG.md +0 -147
package/NEWS.md
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
User-visible changes in SES:
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# 0.13.5 (2021-08-07)
|
|
4
4
|
|
|
5
|
+
- Censors the pattern `{...import(specifier)`}.
|
|
6
|
+
We previously censored `import(specifier)` and expressly allowed
|
|
7
|
+
`object.import(specifier)`.
|
|
8
|
+
The relaxation for the latter form in version 0.13.0 inadvertently allowed
|
|
9
|
+
import with the spread operator.
|
|
10
|
+
|
|
11
|
+
# 0.13.4 (2021-06-19)
|
|
12
|
+
|
|
13
|
+
- Adds more TypeScript definitions, importable with `/// <reference
|
|
14
|
+
types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
|
|
15
|
+
and many types importable with `import('ses')` notation.
|
|
5
16
|
- Adds descriptive detail to module system link error messages and fixes the
|
|
6
17
|
reported exports for one.
|
|
7
18
|
|
package/dist/lockdown.cjs
CHANGED
|
@@ -2058,8 +2058,8 @@ freeze(bestEffortStringify);
|
|
|
2058
2058
|
*/
|
|
2059
2059
|
|
|
2060
2060
|
// Type all the overloads of the assertTypeof function.
|
|
2061
|
-
// There may eventually be a better way to do this, but
|
|
2062
|
-
//
|
|
2061
|
+
// There may eventually be a better way to do this, but they break with
|
|
2062
|
+
// Typescript 4.0.
|
|
2063
2063
|
/**
|
|
2064
2064
|
* @callback AssertTypeofBigint
|
|
2065
2065
|
* @param {any} specimen
|
|
@@ -3394,7 +3394,7 @@ const htmlCommentPattern = new RegExp(`(?:${'<'}!--|--${'>'})`, 'g');
|
|
|
3394
3394
|
* @returns { string }
|
|
3395
3395
|
*/const evadeHtmlCommentTest = (src) => {const replaceFn = (match) => match[0] === '<' ? '< ! --' : '-- >';return src.replace(htmlCommentPattern, replaceFn);}; // /////////////////////////////////////////////////////////////////////////////
|
|
3396
3396
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest); // /////////////////////////////////////////////////////////////////////////////
|
|
3397
|
-
const importPattern = new RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3397
|
+
const importPattern = new RegExp('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3398
3398
|
* Conservatively reject the source text if it may contain a dynamic
|
|
3399
3399
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
3400
3400
|
* also reject some other text as well.
|
|
@@ -6196,6 +6196,7 @@ moduleRecord) =>
|
|
|
6196
6196
|
|
|
6197
6197
|
|
|
6198
6198
|
|
|
6199
|
+
|
|
6199
6200
|
|
|
6200
6201
|
|
|
6201
6202
|
const { quote: q } = assert;
|
|
@@ -6388,49 +6389,34 @@ defineProperties(InertCompartment, {
|
|
|
6388
6389
|
prototype: { value: CompartmentPrototype } });
|
|
6389
6390
|
|
|
6390
6391
|
|
|
6391
|
-
/**
|
|
6392
|
-
* @callback CompartmentConstructor
|
|
6393
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6394
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6395
|
-
*
|
|
6396
|
-
* @param {Object} endowments
|
|
6397
|
-
* @param {Object} _moduleMap
|
|
6398
|
-
* @param {Object} [options]
|
|
6399
|
-
* @param {string} [options.name]
|
|
6400
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6401
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6402
|
-
* @param {Object} [options.globalLexicals]
|
|
6403
|
-
*/
|
|
6404
|
-
|
|
6405
6392
|
/**
|
|
6406
6393
|
* @callback MakeCompartmentConstructor
|
|
6407
6394
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6408
|
-
* @param {
|
|
6395
|
+
* @param {Record<string, any>} intrinsics
|
|
6409
6396
|
* @param {(object: Object) => void} nativeBrander
|
|
6410
|
-
* @returns {
|
|
6397
|
+
* @returns {Compartment['constructor']}
|
|
6411
6398
|
*/
|
|
6412
6399
|
|
|
6413
6400
|
/** @type {MakeCompartmentConstructor} */ /**
|
|
6414
|
-
* @callback CompartmentConstructor
|
|
6415
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6416
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6417
|
-
*
|
|
6418
|
-
* @param {Object} endowments
|
|
6419
|
-
* @param {Object} _moduleMap
|
|
6420
|
-
* @param {Object} [options]
|
|
6421
|
-
* @param {string} [options.name]
|
|
6422
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6423
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6424
|
-
* @param {Object} [options.globalLexicals]
|
|
6425
|
-
*/ /**
|
|
6426
6401
|
* @callback MakeCompartmentConstructor
|
|
6427
6402
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6428
|
-
* @param {
|
|
6403
|
+
* @param {Record<string, any>} intrinsics
|
|
6429
6404
|
* @param {(object: Object) => void} nativeBrander
|
|
6430
|
-
* @returns {
|
|
6431
|
-
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {
|
|
6405
|
+
* @returns {Compartment['constructor']}
|
|
6406
|
+
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {function Compartment(endowments = {}, moduleMap = {}, options = {}) {
|
|
6407
|
+
if (new.target === undefined) {
|
|
6408
|
+
throw new TypeError(
|
|
6409
|
+
"Class constructor Compartment cannot be invoked without 'new'");
|
|
6410
|
+
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6432
6413
|
// Extract options, and shallow-clone transforms.
|
|
6433
|
-
|
|
6414
|
+
// Extract options, and shallow-clone transforms.
|
|
6415
|
+
const { name = '<unknown>',
|
|
6416
|
+
transforms = [],
|
|
6417
|
+
__shimTransforms__ = [],
|
|
6418
|
+
globalLexicals = {},
|
|
6419
|
+
resolveHook,
|
|
6434
6420
|
importHook,
|
|
6435
6421
|
moduleMapHook } =
|
|
6436
6422
|
options;
|
|
@@ -8095,19 +8081,19 @@ const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object;
|
|
|
8095
8081
|
const { ownKeys } = Reflect;
|
|
8096
8082
|
|
|
8097
8083
|
/**
|
|
8098
|
-
* @typedef {
|
|
8084
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8099
8085
|
*/
|
|
8100
8086
|
|
|
8101
8087
|
/**
|
|
8102
8088
|
* Create a `harden` function.
|
|
8103
8089
|
*
|
|
8104
|
-
* @returns {
|
|
8090
|
+
* @returns {Harden}
|
|
8105
8091
|
*/ /**
|
|
8106
|
-
* @typedef {
|
|
8092
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8107
8093
|
*/ /**
|
|
8108
8094
|
* Create a `harden` function.
|
|
8109
8095
|
*
|
|
8110
|
-
* @returns {
|
|
8096
|
+
* @returns {Harden}
|
|
8111
8097
|
*/const makeHardener = () => {const hardened = new WeakSet();const { harden } = { /**
|
|
8112
8098
|
* @template T
|
|
8113
8099
|
* @param {T} root
|
|
@@ -8930,20 +8916,7 @@ const hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
|
|
|
8930
8916
|
|
|
8931
8917
|
|
|
8932
8918
|
|
|
8933
|
-
/**
|
|
8934
|
-
* @typedef {{
|
|
8935
|
-
* dateTaming?: 'safe' | 'unsafe',
|
|
8936
|
-
* errorTaming?: 'safe' | 'unsafe',
|
|
8937
|
-
* mathTaming?: 'safe' | 'unsafe',
|
|
8938
|
-
* regExpTaming?: 'safe' | 'unsafe',
|
|
8939
|
-
* localeTaming?: 'safe' | 'unsafe',
|
|
8940
|
-
* consoleTaming?: 'safe' | 'unsafe',
|
|
8941
|
-
* overrideTaming?: 'min' | 'moderate' | 'severe',
|
|
8942
|
-
* overrideDebug?: Array<string>,
|
|
8943
|
-
* stackFiltering?: 'concise' | 'verbose',
|
|
8944
|
-
* __allowUnsafeMonkeyPatching__?: 'safe' | 'unsafe',
|
|
8945
|
-
* }} LockdownOptions
|
|
8946
|
-
*/
|
|
8919
|
+
/** @typedef {import('../index.js').LockdownOptions} LockdownOptions */
|
|
8947
8920
|
|
|
8948
8921
|
const { details: d, quote: q } = assert;
|
|
8949
8922
|
|
|
@@ -9047,13 +9020,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9047
9020
|
// is useful. See
|
|
9048
9021
|
// [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
|
|
9049
9022
|
// for an explanation.
|
|
9050
|
-
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe',
|
|
9023
|
+
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe', // deprecated
|
|
9024
|
+
errorTaming = 'safe', mathTaming = 'safe', // deprecated
|
|
9025
|
+
regExpTaming = 'safe', localeTaming = 'safe', consoleTaming = 'safe', overrideTaming = 'moderate', overrideDebug = [], stackFiltering = 'concise', __allowUnsafeMonkeyPatching__ = 'safe', ...extraOptions } = options; // Assert that only supported options were passed.
|
|
9051
9026
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9052
9027
|
// Assert that only supported options were passed.
|
|
9053
9028
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9054
9029
|
const extraOptionsNames = Reflect.ownKeys(extraOptions);assert(extraOptionsNames.length === 0, d`lockdown(): non supported option ${q(extraOptionsNames)}`);
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
9030
|
// Asserts for multiple invocation of lockdown().
|
|
9058
9031
|
// Asserts for multiple invocation of lockdown().
|
|
9059
9032
|
if (firstOptions) {for (const name of keys(firstOptions)) {
|
|
@@ -9066,9 +9039,9 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9066
9039
|
}
|
|
9067
9040
|
|
|
9068
9041
|
firstOptions = {
|
|
9069
|
-
dateTaming,
|
|
9042
|
+
dateTaming, // deprecated
|
|
9070
9043
|
errorTaming,
|
|
9071
|
-
mathTaming,
|
|
9044
|
+
mathTaming, // deprecated
|
|
9072
9045
|
regExpTaming,
|
|
9073
9046
|
localeTaming,
|
|
9074
9047
|
consoleTaming,
|
|
@@ -9221,12 +9194,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9221
9194
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9222
9195
|
* @param {Object} compartmentPrototype
|
|
9223
9196
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9197
|
+
* @returns {import('../index.js').Lockdown}
|
|
9224
9198
|
*/$h_once.repairIntrinsics(repairIntrinsics); /**
|
|
9225
9199
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9226
9200
|
* @param {Object} compartmentPrototype
|
|
9227
9201
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9228
|
-
|
|
9229
|
-
{
|
|
9202
|
+
* @returns {import('../index.js').Lockdown}
|
|
9203
|
+
*/const makeLockdown = (makeCompartmentConstructor, compartmentPrototype, getAnonymousIntrinsics) => {
|
|
9230
9204
|
/**
|
|
9231
9205
|
* @param {LockdownOptions} [options]
|
|
9232
9206
|
*/
|
|
@@ -9240,9 +9214,7 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9240
9214
|
return maybeHardenIntrinsics();
|
|
9241
9215
|
};
|
|
9242
9216
|
return lockdown;
|
|
9243
|
-
};
|
|
9244
|
-
|
|
9245
|
-
/** @typedef {ReturnType<typeof makeLockdown>} Lockdown */$h_once.makeLockdown(makeLockdown);
|
|
9217
|
+
};$h_once.makeLockdown(makeLockdown);
|
|
9246
9218
|
})
|
|
9247
9219
|
|
|
9248
9220
|
,
|
package/dist/lockdown.mjs
CHANGED
|
@@ -2058,8 +2058,8 @@ freeze(bestEffortStringify);
|
|
|
2058
2058
|
*/
|
|
2059
2059
|
|
|
2060
2060
|
// Type all the overloads of the assertTypeof function.
|
|
2061
|
-
// There may eventually be a better way to do this, but
|
|
2062
|
-
//
|
|
2061
|
+
// There may eventually be a better way to do this, but they break with
|
|
2062
|
+
// Typescript 4.0.
|
|
2063
2063
|
/**
|
|
2064
2064
|
* @callback AssertTypeofBigint
|
|
2065
2065
|
* @param {any} specimen
|
|
@@ -3394,7 +3394,7 @@ const htmlCommentPattern = new RegExp(`(?:${'<'}!--|--${'>'})`, 'g');
|
|
|
3394
3394
|
* @returns { string }
|
|
3395
3395
|
*/const evadeHtmlCommentTest = (src) => {const replaceFn = (match) => match[0] === '<' ? '< ! --' : '-- >';return src.replace(htmlCommentPattern, replaceFn);}; // /////////////////////////////////////////////////////////////////////////////
|
|
3396
3396
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest); // /////////////////////////////////////////////////////////////////////////////
|
|
3397
|
-
const importPattern = new RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3397
|
+
const importPattern = new RegExp('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3398
3398
|
* Conservatively reject the source text if it may contain a dynamic
|
|
3399
3399
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
3400
3400
|
* also reject some other text as well.
|
|
@@ -6196,6 +6196,7 @@ moduleRecord) =>
|
|
|
6196
6196
|
|
|
6197
6197
|
|
|
6198
6198
|
|
|
6199
|
+
|
|
6199
6200
|
|
|
6200
6201
|
|
|
6201
6202
|
const { quote: q } = assert;
|
|
@@ -6388,49 +6389,34 @@ defineProperties(InertCompartment, {
|
|
|
6388
6389
|
prototype: { value: CompartmentPrototype } });
|
|
6389
6390
|
|
|
6390
6391
|
|
|
6391
|
-
/**
|
|
6392
|
-
* @callback CompartmentConstructor
|
|
6393
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6394
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6395
|
-
*
|
|
6396
|
-
* @param {Object} endowments
|
|
6397
|
-
* @param {Object} _moduleMap
|
|
6398
|
-
* @param {Object} [options]
|
|
6399
|
-
* @param {string} [options.name]
|
|
6400
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6401
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6402
|
-
* @param {Object} [options.globalLexicals]
|
|
6403
|
-
*/
|
|
6404
|
-
|
|
6405
6392
|
/**
|
|
6406
6393
|
* @callback MakeCompartmentConstructor
|
|
6407
6394
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6408
|
-
* @param {
|
|
6395
|
+
* @param {Record<string, any>} intrinsics
|
|
6409
6396
|
* @param {(object: Object) => void} nativeBrander
|
|
6410
|
-
* @returns {
|
|
6397
|
+
* @returns {Compartment['constructor']}
|
|
6411
6398
|
*/
|
|
6412
6399
|
|
|
6413
6400
|
/** @type {MakeCompartmentConstructor} */ /**
|
|
6414
|
-
* @callback CompartmentConstructor
|
|
6415
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6416
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6417
|
-
*
|
|
6418
|
-
* @param {Object} endowments
|
|
6419
|
-
* @param {Object} _moduleMap
|
|
6420
|
-
* @param {Object} [options]
|
|
6421
|
-
* @param {string} [options.name]
|
|
6422
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6423
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6424
|
-
* @param {Object} [options.globalLexicals]
|
|
6425
|
-
*/ /**
|
|
6426
6401
|
* @callback MakeCompartmentConstructor
|
|
6427
6402
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6428
|
-
* @param {
|
|
6403
|
+
* @param {Record<string, any>} intrinsics
|
|
6429
6404
|
* @param {(object: Object) => void} nativeBrander
|
|
6430
|
-
* @returns {
|
|
6431
|
-
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {
|
|
6405
|
+
* @returns {Compartment['constructor']}
|
|
6406
|
+
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {function Compartment(endowments = {}, moduleMap = {}, options = {}) {
|
|
6407
|
+
if (new.target === undefined) {
|
|
6408
|
+
throw new TypeError(
|
|
6409
|
+
"Class constructor Compartment cannot be invoked without 'new'");
|
|
6410
|
+
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6432
6413
|
// Extract options, and shallow-clone transforms.
|
|
6433
|
-
|
|
6414
|
+
// Extract options, and shallow-clone transforms.
|
|
6415
|
+
const { name = '<unknown>',
|
|
6416
|
+
transforms = [],
|
|
6417
|
+
__shimTransforms__ = [],
|
|
6418
|
+
globalLexicals = {},
|
|
6419
|
+
resolveHook,
|
|
6434
6420
|
importHook,
|
|
6435
6421
|
moduleMapHook } =
|
|
6436
6422
|
options;
|
|
@@ -8095,19 +8081,19 @@ const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object;
|
|
|
8095
8081
|
const { ownKeys } = Reflect;
|
|
8096
8082
|
|
|
8097
8083
|
/**
|
|
8098
|
-
* @typedef {
|
|
8084
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8099
8085
|
*/
|
|
8100
8086
|
|
|
8101
8087
|
/**
|
|
8102
8088
|
* Create a `harden` function.
|
|
8103
8089
|
*
|
|
8104
|
-
* @returns {
|
|
8090
|
+
* @returns {Harden}
|
|
8105
8091
|
*/ /**
|
|
8106
|
-
* @typedef {
|
|
8092
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8107
8093
|
*/ /**
|
|
8108
8094
|
* Create a `harden` function.
|
|
8109
8095
|
*
|
|
8110
|
-
* @returns {
|
|
8096
|
+
* @returns {Harden}
|
|
8111
8097
|
*/const makeHardener = () => {const hardened = new WeakSet();const { harden } = { /**
|
|
8112
8098
|
* @template T
|
|
8113
8099
|
* @param {T} root
|
|
@@ -8930,20 +8916,7 @@ const hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
|
|
|
8930
8916
|
|
|
8931
8917
|
|
|
8932
8918
|
|
|
8933
|
-
/**
|
|
8934
|
-
* @typedef {{
|
|
8935
|
-
* dateTaming?: 'safe' | 'unsafe',
|
|
8936
|
-
* errorTaming?: 'safe' | 'unsafe',
|
|
8937
|
-
* mathTaming?: 'safe' | 'unsafe',
|
|
8938
|
-
* regExpTaming?: 'safe' | 'unsafe',
|
|
8939
|
-
* localeTaming?: 'safe' | 'unsafe',
|
|
8940
|
-
* consoleTaming?: 'safe' | 'unsafe',
|
|
8941
|
-
* overrideTaming?: 'min' | 'moderate' | 'severe',
|
|
8942
|
-
* overrideDebug?: Array<string>,
|
|
8943
|
-
* stackFiltering?: 'concise' | 'verbose',
|
|
8944
|
-
* __allowUnsafeMonkeyPatching__?: 'safe' | 'unsafe',
|
|
8945
|
-
* }} LockdownOptions
|
|
8946
|
-
*/
|
|
8919
|
+
/** @typedef {import('../index.js').LockdownOptions} LockdownOptions */
|
|
8947
8920
|
|
|
8948
8921
|
const { details: d, quote: q } = assert;
|
|
8949
8922
|
|
|
@@ -9047,13 +9020,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9047
9020
|
// is useful. See
|
|
9048
9021
|
// [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
|
|
9049
9022
|
// for an explanation.
|
|
9050
|
-
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe',
|
|
9023
|
+
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe', // deprecated
|
|
9024
|
+
errorTaming = 'safe', mathTaming = 'safe', // deprecated
|
|
9025
|
+
regExpTaming = 'safe', localeTaming = 'safe', consoleTaming = 'safe', overrideTaming = 'moderate', overrideDebug = [], stackFiltering = 'concise', __allowUnsafeMonkeyPatching__ = 'safe', ...extraOptions } = options; // Assert that only supported options were passed.
|
|
9051
9026
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9052
9027
|
// Assert that only supported options were passed.
|
|
9053
9028
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9054
9029
|
const extraOptionsNames = Reflect.ownKeys(extraOptions);assert(extraOptionsNames.length === 0, d`lockdown(): non supported option ${q(extraOptionsNames)}`);
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
9030
|
// Asserts for multiple invocation of lockdown().
|
|
9058
9031
|
// Asserts for multiple invocation of lockdown().
|
|
9059
9032
|
if (firstOptions) {for (const name of keys(firstOptions)) {
|
|
@@ -9066,9 +9039,9 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9066
9039
|
}
|
|
9067
9040
|
|
|
9068
9041
|
firstOptions = {
|
|
9069
|
-
dateTaming,
|
|
9042
|
+
dateTaming, // deprecated
|
|
9070
9043
|
errorTaming,
|
|
9071
|
-
mathTaming,
|
|
9044
|
+
mathTaming, // deprecated
|
|
9072
9045
|
regExpTaming,
|
|
9073
9046
|
localeTaming,
|
|
9074
9047
|
consoleTaming,
|
|
@@ -9221,12 +9194,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9221
9194
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9222
9195
|
* @param {Object} compartmentPrototype
|
|
9223
9196
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9197
|
+
* @returns {import('../index.js').Lockdown}
|
|
9224
9198
|
*/$h_once.repairIntrinsics(repairIntrinsics); /**
|
|
9225
9199
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9226
9200
|
* @param {Object} compartmentPrototype
|
|
9227
9201
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9228
|
-
|
|
9229
|
-
{
|
|
9202
|
+
* @returns {import('../index.js').Lockdown}
|
|
9203
|
+
*/const makeLockdown = (makeCompartmentConstructor, compartmentPrototype, getAnonymousIntrinsics) => {
|
|
9230
9204
|
/**
|
|
9231
9205
|
* @param {LockdownOptions} [options]
|
|
9232
9206
|
*/
|
|
@@ -9240,9 +9214,7 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9240
9214
|
return maybeHardenIntrinsics();
|
|
9241
9215
|
};
|
|
9242
9216
|
return lockdown;
|
|
9243
|
-
};
|
|
9244
|
-
|
|
9245
|
-
/** @typedef {ReturnType<typeof makeLockdown>} Lockdown */$h_once.makeLockdown(makeLockdown);
|
|
9217
|
+
};$h_once.makeLockdown(makeLockdown);
|
|
9246
9218
|
})
|
|
9247
9219
|
|
|
9248
9220
|
,
|
package/dist/lockdown.umd.js
CHANGED
|
@@ -2058,8 +2058,8 @@ freeze(bestEffortStringify);
|
|
|
2058
2058
|
*/
|
|
2059
2059
|
|
|
2060
2060
|
// Type all the overloads of the assertTypeof function.
|
|
2061
|
-
// There may eventually be a better way to do this, but
|
|
2062
|
-
//
|
|
2061
|
+
// There may eventually be a better way to do this, but they break with
|
|
2062
|
+
// Typescript 4.0.
|
|
2063
2063
|
/**
|
|
2064
2064
|
* @callback AssertTypeofBigint
|
|
2065
2065
|
* @param {any} specimen
|
|
@@ -3394,7 +3394,7 @@ const htmlCommentPattern = new RegExp(`(?:${'<'}!--|--${'>'})`, 'g');
|
|
|
3394
3394
|
* @returns { string }
|
|
3395
3395
|
*/const evadeHtmlCommentTest = (src) => {const replaceFn = (match) => match[0] === '<' ? '< ! --' : '-- >';return src.replace(htmlCommentPattern, replaceFn);}; // /////////////////////////////////////////////////////////////////////////////
|
|
3396
3396
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest); // /////////////////////////////////////////////////////////////////////////////
|
|
3397
|
-
const importPattern = new RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3397
|
+
const importPattern = new RegExp('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))', 'g'); /**
|
|
3398
3398
|
* Conservatively reject the source text if it may contain a dynamic
|
|
3399
3399
|
* import expression. To reject without parsing, `rejectImportExpressions` will
|
|
3400
3400
|
* also reject some other text as well.
|
|
@@ -6196,6 +6196,7 @@ moduleRecord) =>
|
|
|
6196
6196
|
|
|
6197
6197
|
|
|
6198
6198
|
|
|
6199
|
+
|
|
6199
6200
|
|
|
6200
6201
|
|
|
6201
6202
|
const { quote: q } = assert;
|
|
@@ -6388,49 +6389,34 @@ defineProperties(InertCompartment, {
|
|
|
6388
6389
|
prototype: { value: CompartmentPrototype } });
|
|
6389
6390
|
|
|
6390
6391
|
|
|
6391
|
-
/**
|
|
6392
|
-
* @callback CompartmentConstructor
|
|
6393
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6394
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6395
|
-
*
|
|
6396
|
-
* @param {Object} endowments
|
|
6397
|
-
* @param {Object} _moduleMap
|
|
6398
|
-
* @param {Object} [options]
|
|
6399
|
-
* @param {string} [options.name]
|
|
6400
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6401
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6402
|
-
* @param {Object} [options.globalLexicals]
|
|
6403
|
-
*/
|
|
6404
|
-
|
|
6405
6392
|
/**
|
|
6406
6393
|
* @callback MakeCompartmentConstructor
|
|
6407
6394
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6408
|
-
* @param {
|
|
6395
|
+
* @param {Record<string, any>} intrinsics
|
|
6409
6396
|
* @param {(object: Object) => void} nativeBrander
|
|
6410
|
-
* @returns {
|
|
6397
|
+
* @returns {Compartment['constructor']}
|
|
6411
6398
|
*/
|
|
6412
6399
|
|
|
6413
6400
|
/** @type {MakeCompartmentConstructor} */ /**
|
|
6414
|
-
* @callback CompartmentConstructor
|
|
6415
|
-
* Each Compartment constructor is a global. A host that wants to execute
|
|
6416
|
-
* code in a context bound to a new global creates a new compartment.
|
|
6417
|
-
*
|
|
6418
|
-
* @param {Object} endowments
|
|
6419
|
-
* @param {Object} _moduleMap
|
|
6420
|
-
* @param {Object} [options]
|
|
6421
|
-
* @param {string} [options.name]
|
|
6422
|
-
* @param {Array<Transform>} [options.transforms]
|
|
6423
|
-
* @param {Array<Transform>} [options.__shimTransforms__]
|
|
6424
|
-
* @param {Object} [options.globalLexicals]
|
|
6425
|
-
*/ /**
|
|
6426
6401
|
* @callback MakeCompartmentConstructor
|
|
6427
6402
|
* @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
|
|
6428
|
-
* @param {
|
|
6403
|
+
* @param {Record<string, any>} intrinsics
|
|
6429
6404
|
* @param {(object: Object) => void} nativeBrander
|
|
6430
|
-
* @returns {
|
|
6431
|
-
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {
|
|
6405
|
+
* @returns {Compartment['constructor']}
|
|
6406
|
+
*/ /** @type {MakeCompartmentConstructor} */const makeCompartmentConstructor = (targetMakeCompartmentConstructor, intrinsics, nativeBrander) => {function Compartment(endowments = {}, moduleMap = {}, options = {}) {
|
|
6407
|
+
if (new.target === undefined) {
|
|
6408
|
+
throw new TypeError(
|
|
6409
|
+
"Class constructor Compartment cannot be invoked without 'new'");
|
|
6410
|
+
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6432
6413
|
// Extract options, and shallow-clone transforms.
|
|
6433
|
-
|
|
6414
|
+
// Extract options, and shallow-clone transforms.
|
|
6415
|
+
const { name = '<unknown>',
|
|
6416
|
+
transforms = [],
|
|
6417
|
+
__shimTransforms__ = [],
|
|
6418
|
+
globalLexicals = {},
|
|
6419
|
+
resolveHook,
|
|
6434
6420
|
importHook,
|
|
6435
6421
|
moduleMapHook } =
|
|
6436
6422
|
options;
|
|
@@ -8095,19 +8081,19 @@ const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object;
|
|
|
8095
8081
|
const { ownKeys } = Reflect;
|
|
8096
8082
|
|
|
8097
8083
|
/**
|
|
8098
|
-
* @typedef {
|
|
8084
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8099
8085
|
*/
|
|
8100
8086
|
|
|
8101
8087
|
/**
|
|
8102
8088
|
* Create a `harden` function.
|
|
8103
8089
|
*
|
|
8104
|
-
* @returns {
|
|
8090
|
+
* @returns {Harden}
|
|
8105
8091
|
*/ /**
|
|
8106
|
-
* @typedef {
|
|
8092
|
+
* @typedef {import('../index.js').Harden} Harden
|
|
8107
8093
|
*/ /**
|
|
8108
8094
|
* Create a `harden` function.
|
|
8109
8095
|
*
|
|
8110
|
-
* @returns {
|
|
8096
|
+
* @returns {Harden}
|
|
8111
8097
|
*/const makeHardener = () => {const hardened = new WeakSet();const { harden } = { /**
|
|
8112
8098
|
* @template T
|
|
8113
8099
|
* @param {T} root
|
|
@@ -8930,20 +8916,7 @@ const hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
|
|
|
8930
8916
|
|
|
8931
8917
|
|
|
8932
8918
|
|
|
8933
|
-
/**
|
|
8934
|
-
* @typedef {{
|
|
8935
|
-
* dateTaming?: 'safe' | 'unsafe',
|
|
8936
|
-
* errorTaming?: 'safe' | 'unsafe',
|
|
8937
|
-
* mathTaming?: 'safe' | 'unsafe',
|
|
8938
|
-
* regExpTaming?: 'safe' | 'unsafe',
|
|
8939
|
-
* localeTaming?: 'safe' | 'unsafe',
|
|
8940
|
-
* consoleTaming?: 'safe' | 'unsafe',
|
|
8941
|
-
* overrideTaming?: 'min' | 'moderate' | 'severe',
|
|
8942
|
-
* overrideDebug?: Array<string>,
|
|
8943
|
-
* stackFiltering?: 'concise' | 'verbose',
|
|
8944
|
-
* __allowUnsafeMonkeyPatching__?: 'safe' | 'unsafe',
|
|
8945
|
-
* }} LockdownOptions
|
|
8946
|
-
*/
|
|
8919
|
+
/** @typedef {import('../index.js').LockdownOptions} LockdownOptions */
|
|
8947
8920
|
|
|
8948
8921
|
const { details: d, quote: q } = assert;
|
|
8949
8922
|
|
|
@@ -9047,13 +9020,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9047
9020
|
// is useful. See
|
|
9048
9021
|
// [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
|
|
9049
9022
|
// for an explanation.
|
|
9050
|
-
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe',
|
|
9023
|
+
options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };const { dateTaming = 'safe', // deprecated
|
|
9024
|
+
errorTaming = 'safe', mathTaming = 'safe', // deprecated
|
|
9025
|
+
regExpTaming = 'safe', localeTaming = 'safe', consoleTaming = 'safe', overrideTaming = 'moderate', overrideDebug = [], stackFiltering = 'concise', __allowUnsafeMonkeyPatching__ = 'safe', ...extraOptions } = options; // Assert that only supported options were passed.
|
|
9051
9026
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9052
9027
|
// Assert that only supported options were passed.
|
|
9053
9028
|
// Use Reflect.ownKeys to reject symbol-named properties as well.
|
|
9054
9029
|
const extraOptionsNames = Reflect.ownKeys(extraOptions);assert(extraOptionsNames.length === 0, d`lockdown(): non supported option ${q(extraOptionsNames)}`);
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
9030
|
// Asserts for multiple invocation of lockdown().
|
|
9058
9031
|
// Asserts for multiple invocation of lockdown().
|
|
9059
9032
|
if (firstOptions) {for (const name of keys(firstOptions)) {
|
|
@@ -9066,9 +9039,9 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9066
9039
|
}
|
|
9067
9040
|
|
|
9068
9041
|
firstOptions = {
|
|
9069
|
-
dateTaming,
|
|
9042
|
+
dateTaming, // deprecated
|
|
9070
9043
|
errorTaming,
|
|
9071
|
-
mathTaming,
|
|
9044
|
+
mathTaming, // deprecated
|
|
9072
9045
|
regExpTaming,
|
|
9073
9046
|
localeTaming,
|
|
9074
9047
|
consoleTaming,
|
|
@@ -9221,12 +9194,13 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9221
9194
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9222
9195
|
* @param {Object} compartmentPrototype
|
|
9223
9196
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9197
|
+
* @returns {import('../index.js').Lockdown}
|
|
9224
9198
|
*/$h_once.repairIntrinsics(repairIntrinsics); /**
|
|
9225
9199
|
* @param {CompartmentConstructorMaker} makeCompartmentConstructor
|
|
9226
9200
|
* @param {Object} compartmentPrototype
|
|
9227
9201
|
* @param {() => Object} getAnonymousIntrinsics
|
|
9228
|
-
|
|
9229
|
-
{
|
|
9202
|
+
* @returns {import('../index.js').Lockdown}
|
|
9203
|
+
*/const makeLockdown = (makeCompartmentConstructor, compartmentPrototype, getAnonymousIntrinsics) => {
|
|
9230
9204
|
/**
|
|
9231
9205
|
* @param {LockdownOptions} [options]
|
|
9232
9206
|
*/
|
|
@@ -9240,9 +9214,7 @@ const alreadyHardenedIntrinsics = () => false;
|
|
|
9240
9214
|
return maybeHardenIntrinsics();
|
|
9241
9215
|
};
|
|
9242
9216
|
return lockdown;
|
|
9243
|
-
};
|
|
9244
|
-
|
|
9245
|
-
/** @typedef {ReturnType<typeof makeLockdown>} Lockdown */$h_once.makeLockdown(makeLockdown);
|
|
9217
|
+
};$h_once.makeLockdown(makeLockdown);
|
|
9246
9218
|
})
|
|
9247
9219
|
|
|
9248
9220
|
,
|