ses 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -50
- package/dist/lockdown.cjs +1032 -714
- package/dist/lockdown.mjs +1032 -714
- package/dist/lockdown.umd.js +1032 -714
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses-hermes.cjs +1010 -580
- package/dist/ses.cjs +1032 -714
- package/dist/ses.mjs +1032 -714
- package/dist/ses.umd.js +1032 -714
- package/dist/ses.umd.min.js +1 -1
- package/dist/types.d.cts +10 -0
- package/package.json +10 -86
- package/src/cauterize-property.js +2 -2
- package/src/commons.js +17 -16
- package/src/compartment.js +104 -36
- package/src/enable-property-overrides.js +4 -4
- package/src/error/assert.js +2 -2
- package/src/error/note-log-args.js +5 -4
- package/src/global-object.js +3 -3
- package/src/intrinsics.js +8 -8
- package/src/make-hardener.js +4 -4
- package/src/module-link.js +4 -4
- package/src/module-load.js +48 -13
- package/src/permits-intrinsics.js +8 -8
- package/src/permits.js +2 -0
- package/src/scope-constants.js +2 -2
- package/src/tame-locale-methods.js +2 -2
- package/src/tame-regenerator-runtime.js +2 -2
- package/types.d.ts +10 -0
- package/src/make-lru-cachemap.js +0 -221
package/dist/types.d.cts
CHANGED
|
@@ -167,6 +167,16 @@ export interface CompartmentOptions {
|
|
|
167
167
|
modules?: Map<string, ModuleDescriptor>;
|
|
168
168
|
__shimTransforms__?: Array<Transform>;
|
|
169
169
|
__noNamespaceBox__?: boolean;
|
|
170
|
+
/** @deprecated */
|
|
171
|
+
loadHook?: (specifier: string) => Promise<ModuleDescriptor>;
|
|
172
|
+
/** @deprecated */
|
|
173
|
+
loadNowHook?: (specifier: string) => ModuleDescriptor;
|
|
174
|
+
__native__?: boolean;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* If `true`, the first error encountered during module loading will be thrown immediately
|
|
178
|
+
*/
|
|
179
|
+
noAggregateLoadErrors?: boolean;
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
export interface EvaluateOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -91,20 +91,21 @@
|
|
|
91
91
|
"test": "tsd && ava",
|
|
92
92
|
"test:hermes": "./scripts/hermes-test.sh",
|
|
93
93
|
"test:xs": "xst dist/ses.umd.js test/_lockdown-safe.js && node scripts/generate-test-xs.js && xst tmp/test-xs.js && rm -rf tmp",
|
|
94
|
-
"postpack": "git clean -
|
|
94
|
+
"postpack": "git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\""
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@endo/
|
|
98
|
-
"@endo/
|
|
97
|
+
"@endo/cache-map": "^1.1.0",
|
|
98
|
+
"@endo/env-options": "^1.1.11",
|
|
99
|
+
"@endo/immutable-arraybuffer": "^1.1.2"
|
|
99
100
|
},
|
|
100
101
|
"devDependencies": {
|
|
101
102
|
"@babel/generator": "^7.26.3",
|
|
102
103
|
"@babel/parser": "~7.26.2",
|
|
103
104
|
"@babel/traverse": "~7.25.9",
|
|
104
105
|
"@babel/types": "~7.26.0",
|
|
105
|
-
"@endo/compartment-mapper": "^1.6.
|
|
106
|
-
"@endo/module-source": "^1.3.
|
|
107
|
-
"@endo/test262-runner": "^0.1.
|
|
106
|
+
"@endo/compartment-mapper": "^1.6.3",
|
|
107
|
+
"@endo/module-source": "^1.3.3",
|
|
108
|
+
"@endo/test262-runner": "^0.1.48",
|
|
108
109
|
"@types/babel__traverse": "^7.20.5",
|
|
109
110
|
"ava": "^6.1.3",
|
|
110
111
|
"babel-eslint": "^10.1.0",
|
|
@@ -137,84 +138,7 @@
|
|
|
137
138
|
},
|
|
138
139
|
"eslintConfig": {
|
|
139
140
|
"extends": [
|
|
140
|
-
"plugin:@endo/
|
|
141
|
-
],
|
|
142
|
-
"rules": {
|
|
143
|
-
"no-restricted-globals": [
|
|
144
|
-
"error",
|
|
145
|
-
"AggregateError",
|
|
146
|
-
"Array",
|
|
147
|
-
"ArrayBuffer",
|
|
148
|
-
"Atomics",
|
|
149
|
-
"BigInt",
|
|
150
|
-
"BigInt64Array",
|
|
151
|
-
"BigUint64Array",
|
|
152
|
-
"Boolean",
|
|
153
|
-
"Compartment",
|
|
154
|
-
"DataView",
|
|
155
|
-
"Date",
|
|
156
|
-
"Error",
|
|
157
|
-
"EvalError",
|
|
158
|
-
"Float32Array",
|
|
159
|
-
"Float64Array",
|
|
160
|
-
"Function",
|
|
161
|
-
"HandledPromise",
|
|
162
|
-
"Int16Array",
|
|
163
|
-
"Int32Array",
|
|
164
|
-
"Int8Array",
|
|
165
|
-
"JSON",
|
|
166
|
-
"Map",
|
|
167
|
-
"Math",
|
|
168
|
-
"Number",
|
|
169
|
-
"Object",
|
|
170
|
-
"Promise",
|
|
171
|
-
"Proxy",
|
|
172
|
-
"RangeError",
|
|
173
|
-
"ReferenceError",
|
|
174
|
-
"Reflect",
|
|
175
|
-
"RegExp",
|
|
176
|
-
"Set",
|
|
177
|
-
"SharedArrayBuffer",
|
|
178
|
-
"String",
|
|
179
|
-
"Symbol",
|
|
180
|
-
"SyntaxError",
|
|
181
|
-
"TypeError",
|
|
182
|
-
"URIError",
|
|
183
|
-
"Uint16Array",
|
|
184
|
-
"Uint32Array",
|
|
185
|
-
"Uint8Array",
|
|
186
|
-
"Uint8ClampedArray",
|
|
187
|
-
"WeakMap",
|
|
188
|
-
"WeakSet",
|
|
189
|
-
"assert",
|
|
190
|
-
"decodeURI",
|
|
191
|
-
"decodeURIComponent",
|
|
192
|
-
"encodeURI",
|
|
193
|
-
"encodeURIComponent",
|
|
194
|
-
"escape",
|
|
195
|
-
"eval",
|
|
196
|
-
"globalThis",
|
|
197
|
-
"isFinite",
|
|
198
|
-
"isNaN",
|
|
199
|
-
"lockdown",
|
|
200
|
-
"parseFloat",
|
|
201
|
-
"parseInt",
|
|
202
|
-
"unescape"
|
|
203
|
-
],
|
|
204
|
-
"@endo/no-polymorphic-call": "error"
|
|
205
|
-
},
|
|
206
|
-
"overrides": [
|
|
207
|
-
{
|
|
208
|
-
"files": [
|
|
209
|
-
"test/**/*.js",
|
|
210
|
-
"demos/**/*.js",
|
|
211
|
-
"scripts/**/*.js"
|
|
212
|
-
],
|
|
213
|
-
"rules": {
|
|
214
|
-
"no-restricted-globals": "off",
|
|
215
|
-
"@endo/no-polymorphic-call": "off"
|
|
216
|
-
}
|
|
217
|
-
}
|
|
141
|
+
"plugin:@endo/ses"
|
|
218
142
|
]
|
|
219
143
|
},
|
|
220
144
|
"ava": {
|
|
@@ -226,5 +150,5 @@
|
|
|
226
150
|
"typeCoverage": {
|
|
227
151
|
"atLeast": 81.17
|
|
228
152
|
},
|
|
229
|
-
"gitHead": "
|
|
153
|
+
"gitHead": "9815aea9541f241389d2135c6097a7442bdffa17"
|
|
230
154
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasOwn } from './commons.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @import {Reporter} from './reporting-types.js'
|
|
@@ -52,7 +52,7 @@ export const cauterizeProperty = (
|
|
|
52
52
|
try {
|
|
53
53
|
delete obj[prop];
|
|
54
54
|
} catch (err) {
|
|
55
|
-
if (
|
|
55
|
+
if (hasOwn(obj, prop)) {
|
|
56
56
|
if (typeof obj === 'function' && prop === 'prototype') {
|
|
57
57
|
obj.prototype = undefined;
|
|
58
58
|
if (obj.prototype === undefined) {
|
package/src/commons.js
CHANGED
|
@@ -77,6 +77,7 @@ export const {
|
|
|
77
77
|
setPrototypeOf,
|
|
78
78
|
values,
|
|
79
79
|
fromEntries,
|
|
80
|
+
hasOwn,
|
|
80
81
|
} = Object;
|
|
81
82
|
|
|
82
83
|
export const {
|
|
@@ -166,7 +167,10 @@ const { bind } = functionPrototype;
|
|
|
166
167
|
*/
|
|
167
168
|
export const uncurryThis = bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use `hasOwn` instead
|
|
172
|
+
*/
|
|
173
|
+
export const objectHasOwnProperty = hasOwn;
|
|
170
174
|
//
|
|
171
175
|
export const arrayFilter = uncurryThis(arrayPrototype.filter);
|
|
172
176
|
export const arrayForEach = uncurryThis(arrayPrototype.forEach);
|
|
@@ -272,23 +276,20 @@ export const getConstructorOf = fn =>
|
|
|
272
276
|
reflectGet(getPrototypeOf(fn), 'constructor');
|
|
273
277
|
|
|
274
278
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* const isObject = value => {
|
|
279
|
-
* if (value === null) return false;
|
|
280
|
-
* const type = typeof value;
|
|
281
|
-
* return type === 'object' || type === 'function';
|
|
282
|
-
* };
|
|
279
|
+
* TODO Consolidate with `isPrimitive` that's currently in `@endo/pass-style`.
|
|
280
|
+
* Layering constraints make this tricky, which is why we haven't yet figured
|
|
281
|
+
* out how to do this.
|
|
283
282
|
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
283
|
+
* @type {(val: unknown) => val is (undefined
|
|
284
|
+
* | null
|
|
285
|
+
* | boolean
|
|
286
|
+
* | number
|
|
287
|
+
* | bigint
|
|
288
|
+
* | string
|
|
289
|
+
* | symbol)}
|
|
290
290
|
*/
|
|
291
|
-
export const
|
|
291
|
+
export const isPrimitive = val =>
|
|
292
|
+
!val || (typeof val !== 'object' && typeof val !== 'function');
|
|
292
293
|
|
|
293
294
|
/**
|
|
294
295
|
* isError tests whether an object inherits from the intrinsic
|
package/src/compartment.js
CHANGED
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
|
|
40
40
|
// @ts-check
|
|
41
41
|
/* eslint-disable no-underscore-dangle */
|
|
42
|
-
/// <reference types="ses">
|
|
43
42
|
|
|
44
43
|
import {
|
|
45
44
|
Map,
|
|
@@ -68,17 +67,50 @@ import { getDeferredExports } from './module-proxy.js';
|
|
|
68
67
|
import { compartmentEvaluate } from './compartment-evaluate.js';
|
|
69
68
|
import { makeSafeEvaluator } from './make-safe-evaluator.js';
|
|
70
69
|
|
|
71
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* @import {ImportHook, ImportMetaHook, ImportNowHook, ModuleDescriptor, ModuleExportsNamespace, ModuleMap, ModuleMapHook, ResolveHook, ModuleSource, CompartmentOptions} from '../types.js'
|
|
72
|
+
* @import {Transform} from './lockdown.js'
|
|
73
|
+
* @import {DeferredExports} from './module-proxy.js'
|
|
74
|
+
*/
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Associates every public module exports namespace with its corresponding
|
|
78
|
+
* compartment and specifier so they can be used to link modules across
|
|
79
|
+
* compartments. The mechanism to thread an alias is to use the
|
|
80
|
+
* {@link Compartment.module} function to obtain the exports namespace of a foreign
|
|
81
|
+
* module and pass it into another compartment's `moduleMap` constructor option
|
|
82
|
+
* @type {WeakMap<ModuleExportsNamespace, Compartment>}
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
79
85
|
const moduleAliases = new WeakMap();
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Private fields for `Compartment` instances
|
|
89
|
+
* @typedef {object} CompartmentFields
|
|
90
|
+
* @property {string} name
|
|
91
|
+
* @property {object} globalObject
|
|
92
|
+
* @property {Array<Transform>} globalTransforms
|
|
93
|
+
* @property {(source: string, options?: {localTransforms?: Array<Transform>}) => void} safeEvaluate
|
|
94
|
+
* @property {ResolveHook} resolveHook
|
|
95
|
+
* @property {ImportHook} importHook
|
|
96
|
+
* @property {ImportNowHook} importNowHook
|
|
97
|
+
* @property {ModuleMap} moduleMap
|
|
98
|
+
* @property {ModuleMapHook} moduleMapHook
|
|
99
|
+
* @property {ImportMetaHook} importMetaHook
|
|
100
|
+
* @property {Map<string, ModuleSource>} moduleRecords
|
|
101
|
+
* @property {Array<Transform>} __shimTransforms__
|
|
102
|
+
* @property {DeferredExports} deferredExports
|
|
103
|
+
* @property {Map<string, ModuleDescriptor>} instances
|
|
104
|
+
* @property {Compartment} [parentCompartment]
|
|
105
|
+
* @property {boolean} noNamespaceBox
|
|
106
|
+
* @property {(fullSpecifier: string) => Promise<ModuleExportsNamespace>} compartmentImport
|
|
107
|
+
* @property {boolean} [noAggregateLoadErrors]
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Captures the private state for each {@link Compartment}
|
|
112
|
+
* @type {WeakMap<Compartment, CompartmentFields>}
|
|
113
|
+
*/
|
|
82
114
|
const privateFields = new WeakMap();
|
|
83
115
|
|
|
84
116
|
export const InertCompartment = function Compartment(
|
|
@@ -94,6 +126,7 @@ export const InertCompartment = function Compartment(
|
|
|
94
126
|
/**
|
|
95
127
|
* @param {Compartment} compartment
|
|
96
128
|
* @param {string} specifier
|
|
129
|
+
* @returns {{namespace: ModuleExportsNamespace}}
|
|
97
130
|
*/
|
|
98
131
|
const compartmentImportNow = (compartment, specifier) => {
|
|
99
132
|
const { execute, exportsProxy } = link(
|
|
@@ -106,27 +139,20 @@ const compartmentImportNow = (compartment, specifier) => {
|
|
|
106
139
|
return exportsProxy;
|
|
107
140
|
};
|
|
108
141
|
|
|
142
|
+
/** @type {Compartment & {constructor: typeof InertCompartment}} */
|
|
109
143
|
export const CompartmentPrototype = {
|
|
110
144
|
constructor: InertCompartment,
|
|
111
145
|
|
|
112
146
|
get globalThis() {
|
|
113
|
-
return weakmapGet(privateFields, this)
|
|
147
|
+
return /** @type {CompartmentFields} */ (weakmapGet(privateFields, this))
|
|
148
|
+
.globalObject;
|
|
114
149
|
},
|
|
115
150
|
|
|
116
151
|
get name() {
|
|
117
|
-
return weakmapGet(privateFields, this)
|
|
152
|
+
return /** @type {CompartmentFields} */ (weakmapGet(privateFields, this))
|
|
153
|
+
.name;
|
|
118
154
|
},
|
|
119
155
|
|
|
120
|
-
/**
|
|
121
|
-
* @param {string} source is a JavaScript program grammar construction.
|
|
122
|
-
* @param {object} [options]
|
|
123
|
-
* @param {Array<import('./lockdown-shim').Transform>} [options.transforms]
|
|
124
|
-
* @param {boolean} [options.sloppyGlobalsMode]
|
|
125
|
-
* @param {object} [options.__moduleShimLexicals__]
|
|
126
|
-
* @param {boolean} [options.__evadeHtmlCommentTest__]
|
|
127
|
-
* @param {boolean} [options.__evadeImportExpressionTest__]
|
|
128
|
-
* @param {boolean} [options.__rejectSomeDirectEvalExpressions__]
|
|
129
|
-
*/
|
|
130
156
|
evaluate(source, options = {}) {
|
|
131
157
|
const compartmentFields = weakmapGet(privateFields, this);
|
|
132
158
|
return compartmentEvaluate(compartmentFields, source, options);
|
|
@@ -148,14 +174,17 @@ export const CompartmentPrototype = {
|
|
|
148
174
|
},
|
|
149
175
|
|
|
150
176
|
async import(specifier) {
|
|
151
|
-
const { noNamespaceBox } =
|
|
177
|
+
const { noNamespaceBox, noAggregateLoadErrors } =
|
|
178
|
+
/** @type {CompartmentFields} */ (weakmapGet(privateFields, this));
|
|
152
179
|
|
|
153
180
|
if (typeof specifier !== 'string') {
|
|
154
181
|
throw TypeError('first argument of import() must be a string');
|
|
155
182
|
}
|
|
156
183
|
|
|
157
184
|
return promiseThen(
|
|
158
|
-
load(privateFields, moduleAliases, this, specifier
|
|
185
|
+
load(privateFields, moduleAliases, this, specifier, {
|
|
186
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
187
|
+
}),
|
|
159
188
|
() => {
|
|
160
189
|
// The namespace box is a contentious design and likely to be a breaking
|
|
161
190
|
// change in an appropriately numbered future version.
|
|
@@ -178,15 +207,26 @@ export const CompartmentPrototype = {
|
|
|
178
207
|
throw TypeError('first argument of load() must be a string');
|
|
179
208
|
}
|
|
180
209
|
|
|
181
|
-
|
|
210
|
+
const { noAggregateLoadErrors } = /** @type {CompartmentFields} */ (
|
|
211
|
+
weakmapGet(privateFields, this)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return load(privateFields, moduleAliases, this, specifier, {
|
|
215
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
216
|
+
});
|
|
182
217
|
},
|
|
183
218
|
|
|
184
219
|
importNow(specifier) {
|
|
185
220
|
if (typeof specifier !== 'string') {
|
|
186
221
|
throw TypeError('first argument of importNow() must be a string');
|
|
187
222
|
}
|
|
223
|
+
const { noAggregateLoadErrors } = /** @type {CompartmentFields} */ (
|
|
224
|
+
weakmapGet(privateFields, this)
|
|
225
|
+
);
|
|
188
226
|
|
|
189
|
-
loadNow(privateFields, moduleAliases, this, specifier
|
|
227
|
+
loadNow(privateFields, moduleAliases, this, specifier, {
|
|
228
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
229
|
+
});
|
|
190
230
|
return compartmentImportNow(/** @type {Compartment} */ (this), specifier);
|
|
191
231
|
},
|
|
192
232
|
};
|
|
@@ -218,15 +258,35 @@ defineProperties(InertCompartment, {
|
|
|
218
258
|
* @returns {Compartment['constructor']}
|
|
219
259
|
*/
|
|
220
260
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
/**
|
|
262
|
+
* "Options bag"-style `Compartment` constructor arguments.
|
|
263
|
+
* @typedef {[options?: CompartmentOptions & { __options__: true }]} CompartmentOptionsArgs
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Legacy `Compartment` constructor arguments.
|
|
268
|
+
*
|
|
269
|
+
* @deprecated
|
|
270
|
+
* @typedef {[globals?: Map<string, any>, modules?: Map<string, ModuleDescriptor>, options?: CompartmentOptions]} LegacyCompartmentOptionsArgs
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* In order to facilitate migration from the deprecated signature of the
|
|
275
|
+
* compartment constructor,
|
|
276
|
+
*
|
|
277
|
+
* `new Compartent(globals?, modules?, options?)`
|
|
278
|
+
*
|
|
279
|
+
* to the new signature:
|
|
280
|
+
*
|
|
281
|
+
* `new Compartment(options?)`
|
|
282
|
+
*
|
|
283
|
+
* ...where globals and modules are expressed in the options bag instead of
|
|
284
|
+
* positional arguments, this function detects the temporary sigil __options__
|
|
285
|
+
* on the first argument and coerces compartments arguments into a single
|
|
286
|
+
* compartments object.
|
|
287
|
+
* @param {CompartmentOptionsArgs|LegacyCompartmentOptionsArgs} args
|
|
288
|
+
* @returns {CompartmentOptions}
|
|
289
|
+
*/
|
|
230
290
|
export const compartmentOptions = (...args) => {
|
|
231
291
|
if (args.length === 0) {
|
|
232
292
|
return {};
|
|
@@ -248,7 +308,7 @@ export const compartmentOptions = (...args) => {
|
|
|
248
308
|
globals = /** @type {Map<string, any>} */ ({}),
|
|
249
309
|
modules = /** @type {Map<string, ModuleDescriptor>} */ ({}),
|
|
250
310
|
options = {},
|
|
251
|
-
] = args;
|
|
311
|
+
] = /** @type {LegacyCompartmentOptionsArgs} */ (args);
|
|
252
312
|
assertEqual(
|
|
253
313
|
options.modules,
|
|
254
314
|
undefined,
|
|
@@ -274,6 +334,10 @@ export const makeCompartmentConstructor = (
|
|
|
274
334
|
markVirtualizedNativeFunction,
|
|
275
335
|
{ parentCompartment = undefined, enforceNew = false } = {},
|
|
276
336
|
) => {
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @param {CompartmentOptionsArgs|LegacyCompartmentOptionsArgs} args
|
|
340
|
+
*/
|
|
277
341
|
function Compartment(...args) {
|
|
278
342
|
if (enforceNew && new.target === undefined) {
|
|
279
343
|
throw TypeError(
|
|
@@ -294,6 +358,7 @@ export const makeCompartmentConstructor = (
|
|
|
294
358
|
moduleMapHook,
|
|
295
359
|
importMetaHook,
|
|
296
360
|
__noNamespaceBox__: noNamespaceBox = false,
|
|
361
|
+
noAggregateLoadErrors = false,
|
|
297
362
|
} = compartmentOptions(...args);
|
|
298
363
|
const globalTransforms = arrayFlatMap(
|
|
299
364
|
[transforms, __shimTransforms__],
|
|
@@ -371,7 +436,9 @@ export const makeCompartmentConstructor = (
|
|
|
371
436
|
`Compartment does not support dynamic import: no configured resolveHook for compartment ${q(name)}`,
|
|
372
437
|
);
|
|
373
438
|
}
|
|
374
|
-
await load(privateFields, moduleAliases, compartment, fullSpecifier
|
|
439
|
+
await load(privateFields, moduleAliases, compartment, fullSpecifier, {
|
|
440
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
441
|
+
});
|
|
375
442
|
const { execute, exportsProxy } = link(
|
|
376
443
|
privateFields,
|
|
377
444
|
moduleAliases,
|
|
@@ -400,6 +467,7 @@ export const makeCompartmentConstructor = (
|
|
|
400
467
|
parentCompartment,
|
|
401
468
|
noNamespaceBox,
|
|
402
469
|
compartmentImport,
|
|
470
|
+
noAggregateLoadErrors,
|
|
403
471
|
});
|
|
404
472
|
}
|
|
405
473
|
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
defineProperty,
|
|
12
12
|
getOwnPropertyDescriptor,
|
|
13
13
|
getOwnPropertyDescriptors,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isPrimitive,
|
|
15
|
+
hasOwn,
|
|
16
16
|
ownKeys,
|
|
17
17
|
setHas,
|
|
18
18
|
} from './commons.js';
|
|
@@ -109,7 +109,7 @@ export default function enablePropertyOverrides(
|
|
|
109
109
|
)}' of '${path}'`,
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
112
|
+
if (hasOwn(this, prop)) {
|
|
113
113
|
this[prop] = newValue;
|
|
114
114
|
} else {
|
|
115
115
|
if (isDebug) {
|
|
@@ -179,7 +179,7 @@ export default function enablePropertyOverrides(
|
|
|
179
179
|
enableProperty(subPath, obj, prop);
|
|
180
180
|
} else if (subPlan === '*') {
|
|
181
181
|
enableAllProperties(subPath, desc.value);
|
|
182
|
-
} else if (
|
|
182
|
+
} else if (!isPrimitive(subPlan)) {
|
|
183
183
|
enableProperties(subPath, desc.value, subPlan);
|
|
184
184
|
} else {
|
|
185
185
|
throw TypeError(`Unexpected override enablement plan ${subPath}`);
|
package/src/error/assert.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
ownKeys,
|
|
40
40
|
create,
|
|
41
41
|
objectPrototype,
|
|
42
|
-
|
|
42
|
+
hasOwn,
|
|
43
43
|
} from '../commons.js';
|
|
44
44
|
import { an, bestEffortStringify } from './stringify-utils.js';
|
|
45
45
|
import './types.js';
|
|
@@ -307,7 +307,7 @@ export const sanitizeError = error => {
|
|
|
307
307
|
for (const name of ownKeys(error)) {
|
|
308
308
|
// @ts-expect-error TS still confused by symbols as property names
|
|
309
309
|
const desc = descs[name];
|
|
310
|
-
if (desc &&
|
|
310
|
+
if (desc && hasOwn(desc, 'get')) {
|
|
311
311
|
defineProperty(error, name, {
|
|
312
312
|
value: error[name], // invoke the getter to convert to data property
|
|
313
313
|
});
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
/* eslint-disable @endo/no-polymorphic-call */
|
|
3
3
|
/* eslint-disable no-restricted-globals */
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { makeCacheMapKit } from '@endo/cache-map';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* @import {CacheMapKit} from '@endo/cache-map';
|
|
8
9
|
* @import {LogArgs} from './internal-types.js';
|
|
9
10
|
*/
|
|
10
11
|
|
|
@@ -29,16 +30,16 @@ export const makeNoteLogArgsArrayKit = (
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* @type {WeakMap<Error, LogArgs[]>}
|
|
33
|
-
*
|
|
34
33
|
* Maps from an error to an array of log args, where each log args is
|
|
35
34
|
* remembered as an annotation on that error. This can be used, for example,
|
|
36
35
|
* to keep track of additional causes of the error. The elements of any
|
|
37
36
|
* log args may include errors which are associated with further annotations.
|
|
38
37
|
* An augmented console, like the causal console of `console.js`, could
|
|
39
38
|
* then retrieve the graph of such annotations.
|
|
39
|
+
*
|
|
40
|
+
* @type {CacheMapKit<WeakMapConstructor, Error, LogArgs[]>}
|
|
40
41
|
*/
|
|
41
|
-
const noteLogArgsArrayMap =
|
|
42
|
+
const { cache: noteLogArgsArrayMap } = makeCacheMapKit(errorsBudget);
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* @param {Error} error
|
package/src/global-object.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
defineProperty,
|
|
6
6
|
entries,
|
|
7
7
|
freeze,
|
|
8
|
-
|
|
8
|
+
hasOwn,
|
|
9
9
|
unscopablesSymbol,
|
|
10
10
|
} from './commons.js';
|
|
11
11
|
import { makeEvalFunction } from './make-eval-function.js';
|
|
@@ -87,7 +87,7 @@ export const setGlobalObjectMutableProperties = (
|
|
|
87
87
|
},
|
|
88
88
|
) => {
|
|
89
89
|
for (const [name, intrinsicName] of entries(universalPropertyNames)) {
|
|
90
|
-
if (
|
|
90
|
+
if (hasOwn(intrinsics, intrinsicName)) {
|
|
91
91
|
defineProperty(globalObject, name, {
|
|
92
92
|
value: intrinsics[intrinsicName],
|
|
93
93
|
writable: true,
|
|
@@ -98,7 +98,7 @@ export const setGlobalObjectMutableProperties = (
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
for (const [name, intrinsicName] of entries(newGlobalPropertyNames)) {
|
|
101
|
-
if (
|
|
101
|
+
if (hasOwn(intrinsics, intrinsicName)) {
|
|
102
102
|
defineProperty(globalObject, name, {
|
|
103
103
|
value: intrinsics[intrinsicName],
|
|
104
104
|
writable: true,
|
package/src/intrinsics.js
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
getOwnPropertyDescriptors,
|
|
12
12
|
globalThis,
|
|
13
13
|
is,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isPrimitive,
|
|
15
|
+
hasOwn,
|
|
16
16
|
values,
|
|
17
17
|
weaksetHas,
|
|
18
18
|
} from './commons.js';
|
|
@@ -37,7 +37,7 @@ const isFunction = obj => typeof obj === 'function';
|
|
|
37
37
|
// get masked as one overwrites the other. Accordingly, the thrown error
|
|
38
38
|
// complains of a "Conflicting definition".
|
|
39
39
|
function initProperty(obj, name, desc) {
|
|
40
|
-
if (
|
|
40
|
+
if (hasOwn(obj, name)) {
|
|
41
41
|
const preDesc = getOwnPropertyDescriptor(obj, name);
|
|
42
42
|
if (
|
|
43
43
|
!preDesc ||
|
|
@@ -69,7 +69,7 @@ function initProperties(obj, descs) {
|
|
|
69
69
|
function sampleGlobals(globalObject, newPropertyNames) {
|
|
70
70
|
const newIntrinsics = { __proto__: null };
|
|
71
71
|
for (const [globalName, intrinsicName] of entries(newPropertyNames)) {
|
|
72
|
-
if (
|
|
72
|
+
if (hasOwn(globalObject, globalName)) {
|
|
73
73
|
newIntrinsics[intrinsicName] = globalObject[globalName];
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -94,11 +94,11 @@ export const makeIntrinsicsCollector = reporter => {
|
|
|
94
94
|
// to the intrinsics.
|
|
95
95
|
const completePrototypes = () => {
|
|
96
96
|
for (const [name, intrinsic] of entries(intrinsics)) {
|
|
97
|
-
if (
|
|
97
|
+
if (isPrimitive(intrinsic)) {
|
|
98
98
|
// eslint-disable-next-line no-continue
|
|
99
99
|
continue;
|
|
100
100
|
}
|
|
101
|
-
if (!
|
|
101
|
+
if (!hasOwn(intrinsic, 'prototype')) {
|
|
102
102
|
// eslint-disable-next-line no-continue
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
@@ -120,12 +120,12 @@ export const makeIntrinsicsCollector = reporter => {
|
|
|
120
120
|
}
|
|
121
121
|
if (
|
|
122
122
|
typeof namePrototype !== 'string' ||
|
|
123
|
-
!
|
|
123
|
+
!hasOwn(permitted, namePrototype)
|
|
124
124
|
) {
|
|
125
125
|
throw TypeError(`Unrecognized ${name}.prototype permits entry`);
|
|
126
126
|
}
|
|
127
127
|
const intrinsicPrototype = intrinsic.prototype;
|
|
128
|
-
if (
|
|
128
|
+
if (hasOwn(intrinsics, namePrototype)) {
|
|
129
129
|
if (intrinsics[namePrototype] !== intrinsicPrototype) {
|
|
130
130
|
throw TypeError(`Conflicting bindings of ${namePrototype}`);
|
|
131
131
|
}
|
package/src/make-hardener.js
CHANGED
|
@@ -35,8 +35,8 @@ import {
|
|
|
35
35
|
getOwnPropertyDescriptors,
|
|
36
36
|
getPrototypeOf,
|
|
37
37
|
isInteger,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
isPrimitive,
|
|
39
|
+
hasOwn,
|
|
40
40
|
ownKeys,
|
|
41
41
|
preventExtensions,
|
|
42
42
|
setAdd,
|
|
@@ -151,7 +151,7 @@ export const makeHardener = () => {
|
|
|
151
151
|
* @param {any} val
|
|
152
152
|
*/
|
|
153
153
|
function enqueue(val) {
|
|
154
|
-
if (
|
|
154
|
+
if (isPrimitive(val)) {
|
|
155
155
|
// ignore primitives
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
@@ -206,7 +206,7 @@ export const makeHardener = () => {
|
|
|
206
206
|
// test could be confused. We use hasOwnProperty to be sure about
|
|
207
207
|
// whether 'value' is present or not, which tells us for sure that
|
|
208
208
|
// this is a data property.
|
|
209
|
-
if (
|
|
209
|
+
if (hasOwn(desc, 'value')) {
|
|
210
210
|
enqueue(desc.value);
|
|
211
211
|
} else {
|
|
212
212
|
enqueue(desc.get);
|