ses 0.18.4 → 0.18.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 -0
- package/README.md +105 -47
- package/dist/lockdown.cjs +7697 -7455
- package/dist/lockdown.mjs +7697 -7455
- package/dist/lockdown.umd.js +7697 -7455
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +7697 -7455
- package/dist/ses.mjs +7697 -7455
- package/dist/ses.umd.js +7697 -7455
- package/dist/ses.umd.min.js +1 -1
- package/index.js +1 -1
- package/package.json +17 -13
- package/src/commons.js +2 -3
- package/src/compartment-evaluate.js +1 -1
- package/src/compartment-shim.js +9 -9
- package/src/enable-property-overrides.js +4 -4
- package/src/error/assert.js +36 -9
- package/src/error/note-log-args.js +2 -4
- package/src/error/tame-console.js +1 -1
- package/src/error/tame-error-constructor.js +3 -3
- package/src/error/types.js +1 -0
- package/src/get-anonymous-intrinsics.js +23 -0
- package/src/global-object.js +2 -2
- package/src/intrinsics.js +10 -10
- package/src/lockdown-shim.js +13 -26
- package/src/make-hardener.js +1 -1
- package/src/module-instance.js +5 -9
- package/src/module-link.js +2 -2
- package/src/module-load.js +4 -6
- package/src/module-proxy.js +12 -12
- package/src/{whitelist-intrinsics.js → permits-intrinsics.js} +22 -21
- package/src/{whitelist.js → permits.js} +135 -8
- package/src/strict-scope-terminator.js +10 -4
- package/src/tame-date-constructor.js +1 -1
- package/src/tame-domains.js +2 -2
- package/src/tame-function-constructors.js +2 -2
- package/src/tame-harden.js +1 -1
- package/src/tame-locale-methods.js +2 -2
- package/src/tame-math-object.js +1 -1
- package/src/tame-regexp-constructor.js +2 -2
- package/src/tame-symbol-constructor.js +65 -0
- package/src/transforms.js +3 -3
- package/types.d.ts +1 -0
- package/src/environment-options.js +0 -117
package/src/module-link.js
CHANGED
|
@@ -47,7 +47,7 @@ export const link = (
|
|
|
47
47
|
|
|
48
48
|
const moduleRecord = mapGet(moduleRecords, moduleSpecifier);
|
|
49
49
|
if (moduleRecord === undefined) {
|
|
50
|
-
throw
|
|
50
|
+
throw ReferenceError(
|
|
51
51
|
`Missing link to module ${q(moduleSpecifier)} from compartment ${q(
|
|
52
52
|
compartmentName,
|
|
53
53
|
)}`,
|
|
@@ -152,7 +152,7 @@ export const instantiate = (
|
|
|
152
152
|
resolvedImports,
|
|
153
153
|
);
|
|
154
154
|
} else {
|
|
155
|
-
throw
|
|
155
|
+
throw TypeError(
|
|
156
156
|
`importHook must return a static module record, got ${q(
|
|
157
157
|
staticModuleRecord,
|
|
158
158
|
)}`,
|
package/src/module-load.js
CHANGED
|
@@ -181,7 +181,7 @@ const loadWithoutErrorAnnotation = async (
|
|
|
181
181
|
if (staticModuleRecord.record !== undefined) {
|
|
182
182
|
// ensure expected record shape
|
|
183
183
|
if (staticModuleRecord.compartment !== undefined) {
|
|
184
|
-
throw
|
|
184
|
+
throw TypeError(
|
|
185
185
|
'Cannot redirect to an explicit record with a specified compartment',
|
|
186
186
|
);
|
|
187
187
|
}
|
|
@@ -211,7 +211,7 @@ const loadWithoutErrorAnnotation = async (
|
|
|
211
211
|
if (staticModuleRecord.compartment !== undefined) {
|
|
212
212
|
// ensure expected record shape
|
|
213
213
|
if (staticModuleRecord.importMeta !== undefined) {
|
|
214
|
-
throw
|
|
214
|
+
throw TypeError(
|
|
215
215
|
'Cannot redirect to an implicit record with a specified importMeta',
|
|
216
216
|
);
|
|
217
217
|
}
|
|
@@ -230,9 +230,7 @@ const loadWithoutErrorAnnotation = async (
|
|
|
230
230
|
return aliasRecord;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
throw
|
|
234
|
-
'Unnexpected RedirectStaticModuleInterface record shape',
|
|
235
|
-
);
|
|
233
|
+
throw TypeError('Unnexpected RedirectStaticModuleInterface record shape');
|
|
236
234
|
}
|
|
237
235
|
|
|
238
236
|
return loadRecord(
|
|
@@ -351,7 +349,7 @@ export const load = async (
|
|
|
351
349
|
|
|
352
350
|
// Throw an aggregate error if there were any errors.
|
|
353
351
|
if (errors.length > 0) {
|
|
354
|
-
throw
|
|
352
|
+
throw TypeError(
|
|
355
353
|
`Failed to load module ${q(moduleSpecifier)} in package ${q(
|
|
356
354
|
compartmentName,
|
|
357
355
|
)} (${errors.length} underlying failures: ${arrayJoin(
|
package/src/module-proxy.js
CHANGED
|
@@ -60,7 +60,7 @@ export const deferExports = () => {
|
|
|
60
60
|
exportsProxy: new Proxy(proxiedExports, {
|
|
61
61
|
get(_target, name, receiver) {
|
|
62
62
|
if (!active) {
|
|
63
|
-
throw
|
|
63
|
+
throw TypeError(
|
|
64
64
|
`Cannot get property ${q(
|
|
65
65
|
name,
|
|
66
66
|
)} of module exports namespace, the module has not yet begun to execute`,
|
|
@@ -69,13 +69,13 @@ export const deferExports = () => {
|
|
|
69
69
|
return reflectGet(proxiedExports, name, receiver);
|
|
70
70
|
},
|
|
71
71
|
set(_target, name, _value) {
|
|
72
|
-
throw
|
|
72
|
+
throw TypeError(
|
|
73
73
|
`Cannot set property ${q(name)} of module exports namespace`,
|
|
74
74
|
);
|
|
75
75
|
},
|
|
76
76
|
has(_target, name) {
|
|
77
77
|
if (!active) {
|
|
78
|
-
throw
|
|
78
|
+
throw TypeError(
|
|
79
79
|
`Cannot check property ${q(
|
|
80
80
|
name,
|
|
81
81
|
)}, the module has not yet begun to execute`,
|
|
@@ -84,13 +84,13 @@ export const deferExports = () => {
|
|
|
84
84
|
return reflectHas(proxiedExports, name);
|
|
85
85
|
},
|
|
86
86
|
deleteProperty(_target, name) {
|
|
87
|
-
throw
|
|
87
|
+
throw TypeError(
|
|
88
88
|
`Cannot delete property ${q(name)}s of module exports namespace`,
|
|
89
89
|
);
|
|
90
90
|
},
|
|
91
91
|
ownKeys(_target) {
|
|
92
92
|
if (!active) {
|
|
93
|
-
throw
|
|
93
|
+
throw TypeError(
|
|
94
94
|
'Cannot enumerate keys, the module has not yet begun to execute',
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -98,7 +98,7 @@ export const deferExports = () => {
|
|
|
98
98
|
},
|
|
99
99
|
getOwnPropertyDescriptor(_target, name) {
|
|
100
100
|
if (!active) {
|
|
101
|
-
throw
|
|
101
|
+
throw TypeError(
|
|
102
102
|
`Cannot get own property descriptor ${q(
|
|
103
103
|
name,
|
|
104
104
|
)}, the module has not yet begun to execute`,
|
|
@@ -108,7 +108,7 @@ export const deferExports = () => {
|
|
|
108
108
|
},
|
|
109
109
|
preventExtensions(_target) {
|
|
110
110
|
if (!active) {
|
|
111
|
-
throw
|
|
111
|
+
throw TypeError(
|
|
112
112
|
'Cannot prevent extensions of module exports namespace, the module has not yet begun to execute',
|
|
113
113
|
);
|
|
114
114
|
}
|
|
@@ -116,7 +116,7 @@ export const deferExports = () => {
|
|
|
116
116
|
},
|
|
117
117
|
isExtensible() {
|
|
118
118
|
if (!active) {
|
|
119
|
-
throw
|
|
119
|
+
throw TypeError(
|
|
120
120
|
'Cannot check extensibility of module exports namespace, the module has not yet begun to execute',
|
|
121
121
|
);
|
|
122
122
|
}
|
|
@@ -126,20 +126,20 @@ export const deferExports = () => {
|
|
|
126
126
|
return null;
|
|
127
127
|
},
|
|
128
128
|
setPrototypeOf(_target, _proto) {
|
|
129
|
-
throw
|
|
129
|
+
throw TypeError('Cannot set prototype of module exports namespace');
|
|
130
130
|
},
|
|
131
131
|
defineProperty(_target, name, _descriptor) {
|
|
132
|
-
throw
|
|
132
|
+
throw TypeError(
|
|
133
133
|
`Cannot define property ${q(name)} of module exports namespace`,
|
|
134
134
|
);
|
|
135
135
|
},
|
|
136
136
|
apply(_target, _thisArg, _args) {
|
|
137
|
-
throw
|
|
137
|
+
throw TypeError(
|
|
138
138
|
'Cannot call module exports namespace, it is not a function',
|
|
139
139
|
);
|
|
140
140
|
},
|
|
141
141
|
construct(_target, _args) {
|
|
142
|
-
throw
|
|
142
|
+
throw TypeError(
|
|
143
143
|
'Cannot construct module exports namespace, it is not a constructor',
|
|
144
144
|
);
|
|
145
145
|
},
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
// name to the console as a useful diagnostic, possibly provoking an expansion
|
|
44
44
|
// of the whitelist.
|
|
45
45
|
|
|
46
|
-
import {
|
|
46
|
+
import { permitted, FunctionInstance, isAccessorPermit } from './permits.js';
|
|
47
47
|
import {
|
|
48
48
|
Map,
|
|
49
49
|
String,
|
|
50
|
+
Symbol,
|
|
50
51
|
TypeError,
|
|
51
52
|
arrayFilter,
|
|
52
53
|
arrayIncludes,
|
|
@@ -78,15 +79,14 @@ export default function whitelistIntrinsics(
|
|
|
78
79
|
|
|
79
80
|
// These symbols are allowed as well-known symbols
|
|
80
81
|
const wellKnownSymbolNames = new Map(
|
|
81
|
-
|
|
82
|
+
Symbol
|
|
82
83
|
? arrayMap(
|
|
83
84
|
arrayFilter(
|
|
84
|
-
entries(
|
|
85
|
+
entries(permitted['%SharedSymbol%']),
|
|
85
86
|
([name, permit]) =>
|
|
86
|
-
permit === 'symbol' &&
|
|
87
|
-
typeof intrinsics.Symbol[name] === 'symbol',
|
|
87
|
+
permit === 'symbol' && typeof Symbol[name] === 'symbol',
|
|
88
88
|
),
|
|
89
|
-
([name]) => [
|
|
89
|
+
([name]) => [Symbol[name], `@@${name}`],
|
|
90
90
|
)
|
|
91
91
|
: [],
|
|
92
92
|
);
|
|
@@ -117,7 +117,7 @@ export default function whitelistIntrinsics(
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
throw
|
|
120
|
+
throw TypeError(`Unexpected property name type ${path} ${prop}`);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/*
|
|
@@ -126,7 +126,7 @@ export default function whitelistIntrinsics(
|
|
|
126
126
|
*/
|
|
127
127
|
function visitPrototype(path, obj, protoName) {
|
|
128
128
|
if (!isObject(obj)) {
|
|
129
|
-
throw
|
|
129
|
+
throw TypeError(`Object expected: ${path}, ${obj}, ${protoName}`);
|
|
130
130
|
}
|
|
131
131
|
const proto = getPrototypeOf(obj);
|
|
132
132
|
|
|
@@ -137,7 +137,7 @@ export default function whitelistIntrinsics(
|
|
|
137
137
|
|
|
138
138
|
// Assert: protoName, if provided, is a string.
|
|
139
139
|
if (protoName !== undefined && typeof protoName !== 'string') {
|
|
140
|
-
throw
|
|
140
|
+
throw TypeError(`Malformed whitelist permit ${path}.__proto__`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// If permit not specified, default to Object.prototype.
|
|
@@ -146,9 +146,7 @@ export default function whitelistIntrinsics(
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// We can't clean [[prototype]], therefore abort.
|
|
149
|
-
throw
|
|
150
|
-
`Unexpected intrinsic ${path}.__proto__ at ${protoName}`,
|
|
151
|
-
);
|
|
149
|
+
throw TypeError(`Unexpected intrinsic ${path}.__proto__ at ${protoName}`);
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
/*
|
|
@@ -181,7 +179,7 @@ export default function whitelistIntrinsics(
|
|
|
181
179
|
|
|
182
180
|
if (objectHasOwnProperty(intrinsics, permit)) {
|
|
183
181
|
if (value !== intrinsics[permit]) {
|
|
184
|
-
throw
|
|
182
|
+
throw TypeError(`Does not match whitelist ${path}`);
|
|
185
183
|
}
|
|
186
184
|
return true;
|
|
187
185
|
}
|
|
@@ -194,7 +192,7 @@ export default function whitelistIntrinsics(
|
|
|
194
192
|
if (arrayIncludes(primitives, permit)) {
|
|
195
193
|
// eslint-disable-next-line valid-typeof
|
|
196
194
|
if (typeof value !== permit) {
|
|
197
|
-
throw
|
|
195
|
+
throw TypeError(
|
|
198
196
|
`At ${path} expected ${permit} not ${typeof value}`,
|
|
199
197
|
);
|
|
200
198
|
}
|
|
@@ -203,7 +201,7 @@ export default function whitelistIntrinsics(
|
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
203
|
|
|
206
|
-
throw
|
|
204
|
+
throw TypeError(`Unexpected whitelist permit ${permit} at ${path}`);
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
/*
|
|
@@ -213,18 +211,18 @@ export default function whitelistIntrinsics(
|
|
|
213
211
|
function isAllowedProperty(path, obj, prop, permit) {
|
|
214
212
|
const desc = getOwnPropertyDescriptor(obj, prop);
|
|
215
213
|
if (!desc) {
|
|
216
|
-
throw
|
|
214
|
+
throw TypeError(`Property ${prop} not found at ${path}`);
|
|
217
215
|
}
|
|
218
216
|
|
|
219
217
|
// Is this a value property?
|
|
220
218
|
if (objectHasOwnProperty(desc, 'value')) {
|
|
221
219
|
if (isAccessorPermit(permit)) {
|
|
222
|
-
throw
|
|
220
|
+
throw TypeError(`Accessor expected at ${path}`);
|
|
223
221
|
}
|
|
224
222
|
return isAllowedPropertyValue(path, desc.value, prop, permit);
|
|
225
223
|
}
|
|
226
224
|
if (!isAccessorPermit(permit)) {
|
|
227
|
-
throw
|
|
225
|
+
throw TypeError(`Accessor not expected at ${path}`);
|
|
228
226
|
}
|
|
229
227
|
return (
|
|
230
228
|
isAllowedPropertyValue(`${path}<get>`, desc.get, prop, permit.get) &&
|
|
@@ -242,7 +240,6 @@ export default function whitelistIntrinsics(
|
|
|
242
240
|
}
|
|
243
241
|
|
|
244
242
|
if (typeof obj === 'function') {
|
|
245
|
-
markVirtualizedNativeFunction(obj);
|
|
246
243
|
if (objectHasOwnProperty(FunctionInstance, permitProp)) {
|
|
247
244
|
return FunctionInstance[permitProp];
|
|
248
245
|
}
|
|
@@ -256,13 +253,17 @@ export default function whitelistIntrinsics(
|
|
|
256
253
|
* Visit all properties for a permit.
|
|
257
254
|
*/
|
|
258
255
|
function visitProperties(path, obj, permit) {
|
|
259
|
-
if (obj === undefined) {
|
|
256
|
+
if (obj === undefined || obj === null) {
|
|
260
257
|
return;
|
|
261
258
|
}
|
|
262
259
|
|
|
263
260
|
const protoName = permit['[[Proto]]'];
|
|
264
261
|
visitPrototype(path, obj, protoName);
|
|
265
262
|
|
|
263
|
+
if (typeof obj === 'function') {
|
|
264
|
+
markVirtualizedNativeFunction(obj);
|
|
265
|
+
}
|
|
266
|
+
|
|
266
267
|
for (const prop of ownKeys(obj)) {
|
|
267
268
|
const propString = asStringPropertyName(path, prop);
|
|
268
269
|
const subPath = `${path}.${propString}`;
|
|
@@ -311,5 +312,5 @@ export default function whitelistIntrinsics(
|
|
|
311
312
|
|
|
312
313
|
// Start path with 'intrinsics' to clarify that properties are not
|
|
313
314
|
// removed from the global object by the whitelisting operation.
|
|
314
|
-
visitProperties('intrinsics', intrinsics,
|
|
315
|
+
visitProperties('intrinsics', intrinsics, permitted);
|
|
315
316
|
}
|
|
@@ -67,7 +67,6 @@ export const universalPropertyNames = {
|
|
|
67
67
|
ReferenceError: 'ReferenceError',
|
|
68
68
|
Set: 'Set',
|
|
69
69
|
String: 'String',
|
|
70
|
-
Symbol: 'Symbol',
|
|
71
70
|
SyntaxError: 'SyntaxError',
|
|
72
71
|
TypeError: 'TypeError',
|
|
73
72
|
Uint8Array: 'Uint8Array',
|
|
@@ -77,6 +76,10 @@ export const universalPropertyNames = {
|
|
|
77
76
|
URIError: 'URIError',
|
|
78
77
|
WeakMap: 'WeakMap',
|
|
79
78
|
WeakSet: 'WeakSet',
|
|
79
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
80
|
+
Iterator: 'Iterator',
|
|
81
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
82
|
+
AsyncIterator: 'AsyncIterator',
|
|
80
83
|
|
|
81
84
|
// *** Other Properties of the Global Object
|
|
82
85
|
|
|
@@ -109,6 +112,11 @@ export const initialGlobalPropertyNames = {
|
|
|
109
112
|
Error: '%InitialError%',
|
|
110
113
|
RegExp: '%InitialRegExp%',
|
|
111
114
|
|
|
115
|
+
// Omit `Symbol`, because we want the original to appear on the
|
|
116
|
+
// start compartment without passing through the whitelist mechanism, since
|
|
117
|
+
// we want to preserve all its properties, even if we never heard of them.
|
|
118
|
+
// Symbol: '%InitialSymbol%',
|
|
119
|
+
|
|
112
120
|
// *** Other Properties of the Global Object
|
|
113
121
|
|
|
114
122
|
Math: '%InitialMath%',
|
|
@@ -137,6 +145,7 @@ export const sharedGlobalPropertyNames = {
|
|
|
137
145
|
Date: '%SharedDate%',
|
|
138
146
|
Error: '%SharedError%',
|
|
139
147
|
RegExp: '%SharedRegExp%',
|
|
148
|
+
Symbol: '%SharedSymbol%',
|
|
140
149
|
|
|
141
150
|
// *** Other Properties of the Global Object
|
|
142
151
|
|
|
@@ -241,7 +250,7 @@ export const FunctionInstance = {
|
|
|
241
250
|
};
|
|
242
251
|
|
|
243
252
|
// AsyncFunction Instances
|
|
244
|
-
const AsyncFunctionInstance = {
|
|
253
|
+
export const AsyncFunctionInstance = {
|
|
245
254
|
// This property is not mentioned in ECMA 262, but is present in V8 and
|
|
246
255
|
// necessary for lockdown to succeed.
|
|
247
256
|
'[[Proto]]': '%AsyncFunctionPrototype%',
|
|
@@ -375,7 +384,7 @@ const SharedMath = {
|
|
|
375
384
|
mod: false,
|
|
376
385
|
};
|
|
377
386
|
|
|
378
|
-
export const
|
|
387
|
+
export const permitted = {
|
|
379
388
|
// ECMA https://tc39.es/ecma262
|
|
380
389
|
|
|
381
390
|
// The intrinsics object has no prototype to avoid conflicts.
|
|
@@ -432,6 +441,8 @@ export const whitelist = {
|
|
|
432
441
|
seal: fn,
|
|
433
442
|
setPrototypeOf: fn,
|
|
434
443
|
values: fn,
|
|
444
|
+
// https://github.com/tc39/proposal-array-grouping
|
|
445
|
+
groupBy: 'boolean',
|
|
435
446
|
},
|
|
436
447
|
|
|
437
448
|
'%ObjectPrototype%': {
|
|
@@ -474,9 +485,9 @@ export const whitelist = {
|
|
|
474
485
|
constructor: '%InertFunction%',
|
|
475
486
|
toString: fn,
|
|
476
487
|
'@@hasInstance': fn,
|
|
477
|
-
// proposed but not yet std
|
|
488
|
+
// proposed but not yet std. To be removed if there
|
|
478
489
|
caller: false,
|
|
479
|
-
// proposed but not yet std
|
|
490
|
+
// proposed but not yet std. To be removed if there
|
|
480
491
|
arguments: false,
|
|
481
492
|
},
|
|
482
493
|
|
|
@@ -492,10 +503,12 @@ export const whitelist = {
|
|
|
492
503
|
valueOf: fn,
|
|
493
504
|
},
|
|
494
505
|
|
|
495
|
-
|
|
506
|
+
'%SharedSymbol%': {
|
|
496
507
|
// Properties of the Symbol Constructor
|
|
497
508
|
'[[Proto]]': '%FunctionPrototype%',
|
|
509
|
+
asyncDispose: 'symbol',
|
|
498
510
|
asyncIterator: 'symbol',
|
|
511
|
+
dispose: 'symbol',
|
|
499
512
|
for: fn,
|
|
500
513
|
hasInstance: 'symbol',
|
|
501
514
|
isConcatSpreadable: 'symbol',
|
|
@@ -511,11 +524,15 @@ export const whitelist = {
|
|
|
511
524
|
toPrimitive: 'symbol',
|
|
512
525
|
toStringTag: 'symbol',
|
|
513
526
|
unscopables: 'symbol',
|
|
527
|
+
// Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
|
|
528
|
+
useSimple: false,
|
|
529
|
+
// Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
|
|
530
|
+
useSetter: false,
|
|
514
531
|
},
|
|
515
532
|
|
|
516
533
|
'%SymbolPrototype%': {
|
|
517
534
|
// Properties of the Symbol Prototype Object
|
|
518
|
-
constructor: '
|
|
535
|
+
constructor: '%SharedSymbol%',
|
|
519
536
|
description: getter,
|
|
520
537
|
toString: fn,
|
|
521
538
|
valueOf: fn,
|
|
@@ -780,6 +797,10 @@ export const whitelist = {
|
|
|
780
797
|
trimRight: fn,
|
|
781
798
|
// See https://github.com/Moddable-OpenSource/moddable/issues/523
|
|
782
799
|
compare: false,
|
|
800
|
+
// https://github.com/tc39/proposal-is-usv-string
|
|
801
|
+
isWellFormed: fn,
|
|
802
|
+
toWellFormed: fn,
|
|
803
|
+
unicodeSets: fn,
|
|
783
804
|
},
|
|
784
805
|
|
|
785
806
|
'%StringIteratorPrototype%': {
|
|
@@ -872,6 +893,8 @@ export const whitelist = {
|
|
|
872
893
|
// Stage 3:
|
|
873
894
|
// https://tc39.es/proposal-relative-indexing-method/
|
|
874
895
|
at: fn,
|
|
896
|
+
// https://tc39.es/proposal-array-from-async/
|
|
897
|
+
fromAsync: fn,
|
|
875
898
|
},
|
|
876
899
|
|
|
877
900
|
'%ArrayPrototype%': {
|
|
@@ -925,14 +948,32 @@ export const whitelist = {
|
|
|
925
948
|
values: 'boolean',
|
|
926
949
|
// Failed tc39 proposal
|
|
927
950
|
// Seen on FF Nightly 88.0a1
|
|
928
|
-
at:
|
|
951
|
+
at: 'boolean',
|
|
929
952
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
930
953
|
findLast: 'boolean',
|
|
931
954
|
findLastIndex: 'boolean',
|
|
955
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
956
|
+
toReversed: 'boolean',
|
|
957
|
+
toSorted: 'boolean',
|
|
958
|
+
toSpliced: 'boolean',
|
|
959
|
+
with: 'boolean',
|
|
960
|
+
// https://github.com/tc39/proposal-array-grouping
|
|
961
|
+
group: 'boolean',
|
|
962
|
+
groupToMap: 'boolean',
|
|
963
|
+
groupBy: 'boolean',
|
|
932
964
|
},
|
|
933
965
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
934
966
|
findLast: fn,
|
|
935
967
|
findLastIndex: fn,
|
|
968
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
969
|
+
toReversed: fn,
|
|
970
|
+
toSorted: fn,
|
|
971
|
+
toSpliced: fn,
|
|
972
|
+
with: fn,
|
|
973
|
+
// https://github.com/tc39/proposal-array-grouping
|
|
974
|
+
group: fn, // Not in proposal? Where?
|
|
975
|
+
groupToMap: fn, // Not in proposal? Where?
|
|
976
|
+
groupBy: fn,
|
|
936
977
|
},
|
|
937
978
|
|
|
938
979
|
'%ArrayIteratorPrototype%': {
|
|
@@ -990,6 +1031,10 @@ export const whitelist = {
|
|
|
990
1031
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
991
1032
|
findLast: fn,
|
|
992
1033
|
findLastIndex: fn,
|
|
1034
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
1035
|
+
toReversed: fn,
|
|
1036
|
+
toSorted: fn,
|
|
1037
|
+
with: fn,
|
|
993
1038
|
},
|
|
994
1039
|
|
|
995
1040
|
// The TypedArray Constructors
|
|
@@ -1134,6 +1179,9 @@ export const whitelist = {
|
|
|
1134
1179
|
resize: fn,
|
|
1135
1180
|
resizable: getter,
|
|
1136
1181
|
maxByteLength: getter,
|
|
1182
|
+
// https://github.com/tc39/proposal-arraybuffer-transfer
|
|
1183
|
+
transferToFixedLength: fn,
|
|
1184
|
+
detached: getter,
|
|
1137
1185
|
},
|
|
1138
1186
|
|
|
1139
1187
|
// SharedArrayBuffer Objects
|
|
@@ -1182,18 +1230,97 @@ export const whitelist = {
|
|
|
1182
1230
|
parse: fn,
|
|
1183
1231
|
stringify: fn,
|
|
1184
1232
|
'@@toStringTag': 'string',
|
|
1233
|
+
// https://github.com/tc39/proposal-json-parse-with-source/
|
|
1234
|
+
rawJSON: fn,
|
|
1235
|
+
isRawJSON: fn,
|
|
1185
1236
|
},
|
|
1186
1237
|
|
|
1187
1238
|
// *** Control Abstraction Objects
|
|
1188
1239
|
|
|
1240
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1241
|
+
Iterator: {
|
|
1242
|
+
// Properties of the Iterator Constructor
|
|
1243
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1244
|
+
prototype: '%IteratorPrototype%',
|
|
1245
|
+
from: fn,
|
|
1246
|
+
},
|
|
1247
|
+
|
|
1189
1248
|
'%IteratorPrototype%': {
|
|
1190
1249
|
// The %IteratorPrototype% Object
|
|
1191
1250
|
'@@iterator': fn,
|
|
1251
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1252
|
+
constructor: 'Iterator',
|
|
1253
|
+
map: fn,
|
|
1254
|
+
filter: fn,
|
|
1255
|
+
take: fn,
|
|
1256
|
+
drop: fn,
|
|
1257
|
+
flatMap: fn,
|
|
1258
|
+
reduce: fn,
|
|
1259
|
+
toArray: fn,
|
|
1260
|
+
forEach: fn,
|
|
1261
|
+
some: fn,
|
|
1262
|
+
every: fn,
|
|
1263
|
+
find: fn,
|
|
1264
|
+
'@@toStringTag': 'string',
|
|
1265
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1266
|
+
toAsync: fn,
|
|
1267
|
+
},
|
|
1268
|
+
|
|
1269
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1270
|
+
'%WrapForValidIteratorPrototype%': {
|
|
1271
|
+
'[[Proto]]': '%IteratorPrototype%',
|
|
1272
|
+
next: fn,
|
|
1273
|
+
return: fn,
|
|
1274
|
+
},
|
|
1275
|
+
|
|
1276
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1277
|
+
'%IteratorHelperPrototype%': {
|
|
1278
|
+
'[[Proto]]': '%IteratorPrototype%',
|
|
1279
|
+
next: fn,
|
|
1280
|
+
return: fn,
|
|
1281
|
+
'@@toStringTag': 'string',
|
|
1282
|
+
},
|
|
1283
|
+
|
|
1284
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1285
|
+
AsyncIterator: {
|
|
1286
|
+
// Properties of the Iterator Constructor
|
|
1287
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1288
|
+
prototype: '%AsyncIteratorPrototype%',
|
|
1289
|
+
from: fn,
|
|
1192
1290
|
},
|
|
1193
1291
|
|
|
1194
1292
|
'%AsyncIteratorPrototype%': {
|
|
1195
1293
|
// The %AsyncIteratorPrototype% Object
|
|
1196
1294
|
'@@asyncIterator': fn,
|
|
1295
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1296
|
+
constructor: 'AsyncIterator',
|
|
1297
|
+
map: fn,
|
|
1298
|
+
filter: fn,
|
|
1299
|
+
take: fn,
|
|
1300
|
+
drop: fn,
|
|
1301
|
+
flatMap: fn,
|
|
1302
|
+
reduce: fn,
|
|
1303
|
+
toArray: fn,
|
|
1304
|
+
forEach: fn,
|
|
1305
|
+
some: fn,
|
|
1306
|
+
every: fn,
|
|
1307
|
+
find: fn,
|
|
1308
|
+
'@@toStringTag': 'string',
|
|
1309
|
+
},
|
|
1310
|
+
|
|
1311
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1312
|
+
'%WrapForValidAsyncIteratorPrototype%': {
|
|
1313
|
+
'[[Proto]]': '%AsyncIteratorPrototype%',
|
|
1314
|
+
next: fn,
|
|
1315
|
+
return: fn,
|
|
1316
|
+
},
|
|
1317
|
+
|
|
1318
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1319
|
+
'%AsyncIteratorHelperPrototype%': {
|
|
1320
|
+
'[[Proto]]': '%AsyncIteratorPrototype%',
|
|
1321
|
+
next: fn,
|
|
1322
|
+
return: fn,
|
|
1323
|
+
'@@toStringTag': 'string',
|
|
1197
1324
|
},
|
|
1198
1325
|
|
|
1199
1326
|
'%InertGeneratorFunction%': {
|
|
@@ -43,7 +43,7 @@ const scopeProxyHandlerProperties = {
|
|
|
43
43
|
set(_shadow, prop, _value) {
|
|
44
44
|
// We should only hit this if the has() hook returned true matches the v8
|
|
45
45
|
// ReferenceError message "Uncaught ReferenceError: xyz is not defined"
|
|
46
|
-
throw
|
|
46
|
+
throw ReferenceError(`${String(prop)} is not defined`);
|
|
47
47
|
},
|
|
48
48
|
|
|
49
49
|
has(_shadow, prop) {
|
|
@@ -53,22 +53,28 @@ const scopeProxyHandlerProperties = {
|
|
|
53
53
|
|
|
54
54
|
// note: this is likely a bug of safari
|
|
55
55
|
// https://bugs.webkit.org/show_bug.cgi?id=195534
|
|
56
|
-
getPrototypeOf() {
|
|
56
|
+
getPrototypeOf(_shadow) {
|
|
57
57
|
return null;
|
|
58
58
|
},
|
|
59
59
|
|
|
60
60
|
// See https://github.com/endojs/endo/issues/1510
|
|
61
61
|
// TODO: report as bug to v8 or Chrome, and record issue link here.
|
|
62
|
-
getOwnPropertyDescriptor(
|
|
62
|
+
getOwnPropertyDescriptor(_shadow, prop) {
|
|
63
63
|
// Coerce with `String` in case prop is a symbol.
|
|
64
64
|
const quotedProp = q(String(prop));
|
|
65
65
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
66
66
|
console.warn(
|
|
67
67
|
`getOwnPropertyDescriptor trap on scopeTerminatorHandler for ${quotedProp}`,
|
|
68
|
-
|
|
68
|
+
TypeError().stack,
|
|
69
69
|
);
|
|
70
70
|
return undefined;
|
|
71
71
|
},
|
|
72
|
+
|
|
73
|
+
// See https://github.com/endojs/endo/issues/1490
|
|
74
|
+
// TODO Report bug to JSC or Safari
|
|
75
|
+
ownKeys(_shadow) {
|
|
76
|
+
return [];
|
|
77
|
+
},
|
|
72
78
|
};
|
|
73
79
|
|
|
74
80
|
// The scope handler's prototype is a proxy that throws if any trap other
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
export default function tameDateConstructor(dateTaming = 'safe') {
|
|
12
12
|
if (dateTaming !== 'safe' && dateTaming !== 'unsafe') {
|
|
13
|
-
throw
|
|
13
|
+
throw TypeError(`unrecognized dateTaming ${dateTaming}`);
|
|
14
14
|
}
|
|
15
15
|
const OriginalDate = Date;
|
|
16
16
|
const DatePrototype = OriginalDate.prototype;
|
package/src/tame-domains.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export function tameDomains(domainTaming = 'safe') {
|
|
11
11
|
if (domainTaming !== 'safe' && domainTaming !== 'unsafe') {
|
|
12
|
-
throw
|
|
12
|
+
throw TypeError(`unrecognized domainTaming ${domainTaming}`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (domainTaming === 'unsafe') {
|
|
@@ -27,7 +27,7 @@ export function tameDomains(domainTaming = 'safe') {
|
|
|
27
27
|
// The domain descriptor on Node.js initially has value: null, which
|
|
28
28
|
// becomes a get, set pair after domains initialize.
|
|
29
29
|
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_DOMAINS.md
|
|
30
|
-
throw
|
|
30
|
+
throw TypeError(
|
|
31
31
|
`SES failed to lockdown, Node.js domains have been initialized (SES_NO_DOMAINS)`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
// list must be updated to match.
|
|
31
31
|
//
|
|
32
32
|
// In addition, the standard needs to define four new intrinsics for the safe
|
|
33
|
-
// replacement functions. See [./
|
|
33
|
+
// replacement functions. See [./permits-intrinsics.js].
|
|
34
34
|
//
|
|
35
35
|
// Adapted from SES/Caja
|
|
36
36
|
// Copyright (C) 2011 Google Inc.
|
|
@@ -84,7 +84,7 @@ export default function tameFunctionConstructors() {
|
|
|
84
84
|
// prototype of functions.
|
|
85
85
|
// eslint-disable-next-line func-names
|
|
86
86
|
const InertConstructor = function () {
|
|
87
|
-
throw
|
|
87
|
+
throw TypeError(
|
|
88
88
|
'Function.prototype.constructor is not a valid constructor.',
|
|
89
89
|
);
|
|
90
90
|
};
|
package/src/tame-harden.js
CHANGED
|
@@ -3,7 +3,7 @@ import { TypeError, freeze } from './commons.js';
|
|
|
3
3
|
|
|
4
4
|
export const tameHarden = (safeHarden, hardenTaming) => {
|
|
5
5
|
if (hardenTaming !== 'safe' && hardenTaming !== 'unsafe') {
|
|
6
|
-
throw
|
|
6
|
+
throw TypeError(`unrecognized fakeHardenOption ${hardenTaming}`);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
if (hardenTaming === 'safe') {
|