ses 1.13.1 → 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 +946 -695
- package/dist/lockdown.mjs +946 -695
- package/dist/lockdown.umd.js +946 -695
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses-hermes.cjs +929 -552
- package/dist/ses.cjs +946 -695
- package/dist/ses.mjs +946 -695
- package/dist/ses.umd.js +946 -695
- package/dist/ses.umd.min.js +1 -1
- package/dist/types.d.cts +5 -0
- package/package.json +9 -85
- package/src/cauterize-property.js +2 -2
- package/src/commons.js +17 -16
- package/src/compartment.js +25 -8
- 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/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 +5 -0
- package/src/make-lru-cachemap.js +0 -221
package/dist/types.d.cts
CHANGED
|
@@ -172,6 +172,11 @@ export interface CompartmentOptions {
|
|
|
172
172
|
/** @deprecated */
|
|
173
173
|
loadNowHook?: (specifier: string) => ModuleDescriptor;
|
|
174
174
|
__native__?: boolean;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* If `true`, the first error encountered during module loading will be thrown immediately
|
|
178
|
+
*/
|
|
179
|
+
noAggregateLoadErrors?: boolean;
|
|
175
180
|
}
|
|
176
181
|
|
|
177
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",
|
|
@@ -94,17 +94,18 @@
|
|
|
94
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
|
@@ -104,6 +104,7 @@ const moduleAliases = new WeakMap();
|
|
|
104
104
|
* @property {Compartment} [parentCompartment]
|
|
105
105
|
* @property {boolean} noNamespaceBox
|
|
106
106
|
* @property {(fullSpecifier: string) => Promise<ModuleExportsNamespace>} compartmentImport
|
|
107
|
+
* @property {boolean} [noAggregateLoadErrors]
|
|
107
108
|
*/
|
|
108
109
|
|
|
109
110
|
/**
|
|
@@ -173,16 +174,17 @@ export const CompartmentPrototype = {
|
|
|
173
174
|
},
|
|
174
175
|
|
|
175
176
|
async import(specifier) {
|
|
176
|
-
const { noNamespaceBox } =
|
|
177
|
-
weakmapGet(privateFields, this)
|
|
178
|
-
);
|
|
177
|
+
const { noNamespaceBox, noAggregateLoadErrors } =
|
|
178
|
+
/** @type {CompartmentFields} */ (weakmapGet(privateFields, this));
|
|
179
179
|
|
|
180
180
|
if (typeof specifier !== 'string') {
|
|
181
181
|
throw TypeError('first argument of import() must be a string');
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
return promiseThen(
|
|
185
|
-
load(privateFields, moduleAliases, this, specifier
|
|
185
|
+
load(privateFields, moduleAliases, this, specifier, {
|
|
186
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
187
|
+
}),
|
|
186
188
|
() => {
|
|
187
189
|
// The namespace box is a contentious design and likely to be a breaking
|
|
188
190
|
// change in an appropriately numbered future version.
|
|
@@ -205,16 +207,27 @@ export const CompartmentPrototype = {
|
|
|
205
207
|
throw TypeError('first argument of load() must be a string');
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
210
|
+
const { noAggregateLoadErrors } = /** @type {CompartmentFields} */ (
|
|
211
|
+
weakmapGet(privateFields, this)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return load(privateFields, moduleAliases, this, specifier, {
|
|
215
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
216
|
+
});
|
|
209
217
|
},
|
|
210
218
|
|
|
211
219
|
importNow(specifier) {
|
|
212
220
|
if (typeof specifier !== 'string') {
|
|
213
221
|
throw TypeError('first argument of importNow() must be a string');
|
|
214
222
|
}
|
|
223
|
+
const { noAggregateLoadErrors } = /** @type {CompartmentFields} */ (
|
|
224
|
+
weakmapGet(privateFields, this)
|
|
225
|
+
);
|
|
215
226
|
|
|
216
|
-
loadNow(privateFields, moduleAliases, this, specifier
|
|
217
|
-
|
|
227
|
+
loadNow(privateFields, moduleAliases, this, specifier, {
|
|
228
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
229
|
+
});
|
|
230
|
+
return compartmentImportNow(/** @type {Compartment} */ (this), specifier);
|
|
218
231
|
},
|
|
219
232
|
};
|
|
220
233
|
|
|
@@ -345,6 +358,7 @@ export const makeCompartmentConstructor = (
|
|
|
345
358
|
moduleMapHook,
|
|
346
359
|
importMetaHook,
|
|
347
360
|
__noNamespaceBox__: noNamespaceBox = false,
|
|
361
|
+
noAggregateLoadErrors = false,
|
|
348
362
|
} = compartmentOptions(...args);
|
|
349
363
|
const globalTransforms = arrayFlatMap(
|
|
350
364
|
[transforms, __shimTransforms__],
|
|
@@ -422,7 +436,9 @@ export const makeCompartmentConstructor = (
|
|
|
422
436
|
`Compartment does not support dynamic import: no configured resolveHook for compartment ${q(name)}`,
|
|
423
437
|
);
|
|
424
438
|
}
|
|
425
|
-
await load(privateFields, moduleAliases, compartment, fullSpecifier
|
|
439
|
+
await load(privateFields, moduleAliases, compartment, fullSpecifier, {
|
|
440
|
+
noAggregateErrors: noAggregateLoadErrors,
|
|
441
|
+
});
|
|
426
442
|
const { execute, exportsProxy } = link(
|
|
427
443
|
privateFields,
|
|
428
444
|
moduleAliases,
|
|
@@ -451,6 +467,7 @@ export const makeCompartmentConstructor = (
|
|
|
451
467
|
parentCompartment,
|
|
452
468
|
noNamespaceBox,
|
|
453
469
|
compartmentImport,
|
|
470
|
+
noAggregateLoadErrors,
|
|
454
471
|
});
|
|
455
472
|
}
|
|
456
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);
|
package/src/module-link.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
TypeError,
|
|
12
12
|
entries,
|
|
13
13
|
isArray,
|
|
14
|
-
|
|
14
|
+
isPrimitive,
|
|
15
15
|
mapGet,
|
|
16
16
|
mapHas,
|
|
17
17
|
mapSet,
|
|
@@ -59,11 +59,11 @@ function mayBePrecompiledModuleSource(moduleSource) {
|
|
|
59
59
|
|
|
60
60
|
function validatePrecompiledModuleSource(moduleSource, moduleSpecifier) {
|
|
61
61
|
const { __fixedExportMap__, __liveExportMap__ } = moduleSource;
|
|
62
|
-
|
|
62
|
+
!isPrimitive(__fixedExportMap__) ||
|
|
63
63
|
Fail`Property '__fixedExportMap__' of a precompiled module source must be an object, got ${q(
|
|
64
64
|
__fixedExportMap__,
|
|
65
65
|
)}, for module ${q(moduleSpecifier)}`;
|
|
66
|
-
|
|
66
|
+
!isPrimitive(__liveExportMap__) ||
|
|
67
67
|
Fail`Property '__liveExportMap__' of a precompiled module source must be an object, got ${q(
|
|
68
68
|
__liveExportMap__,
|
|
69
69
|
)}, for module ${q(moduleSpecifier)}`;
|
|
@@ -82,7 +82,7 @@ function validateVirtualModuleSource(moduleSource, moduleSpecifier) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function validateModuleSource(moduleSource, moduleSpecifier) {
|
|
85
|
-
|
|
85
|
+
!isPrimitive(moduleSource) ||
|
|
86
86
|
Fail`Invalid module source: must be of type object, got ${q(
|
|
87
87
|
moduleSource,
|
|
88
88
|
)}, for module ${q(moduleSpecifier)}`;
|