ses 0.18.4 → 0.18.7
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 +20 -0
- package/README.md +105 -47
- package/dist/lockdown.cjs +7742 -7477
- package/dist/lockdown.mjs +7742 -7477
- package/dist/lockdown.umd.js +7742 -7477
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +7742 -7477
- package/dist/ses.mjs +7742 -7477
- package/dist/ses.umd.js +7742 -7477
- 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/stringify-utils.js +25 -1
- 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} +137 -11
- 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 +4 -4
- package/types.d.ts +1 -0
- package/src/environment-options.js +0 -117
package/src/module-instance.js
CHANGED
|
@@ -46,7 +46,7 @@ export const makeThirdPartyModuleInstance = (
|
|
|
46
46
|
!isArray(staticModuleRecord.exports) ||
|
|
47
47
|
arraySome(staticModuleRecord.exports, name => typeof name !== 'string')
|
|
48
48
|
) {
|
|
49
|
-
throw
|
|
49
|
+
throw TypeError(
|
|
50
50
|
`SES third-party static module record "exports" property must be an array of strings for module ${moduleSpecifier}`,
|
|
51
51
|
);
|
|
52
52
|
}
|
|
@@ -195,9 +195,7 @@ export const makeModuleInstance = (
|
|
|
195
195
|
// tdz sensitive getter
|
|
196
196
|
const get = () => {
|
|
197
197
|
if (tdz) {
|
|
198
|
-
throw
|
|
199
|
-
`binding ${q(localName)} not yet initialized`,
|
|
200
|
-
);
|
|
198
|
+
throw ReferenceError(`binding ${q(localName)} not yet initialized`);
|
|
201
199
|
}
|
|
202
200
|
return value;
|
|
203
201
|
};
|
|
@@ -207,7 +205,7 @@ export const makeModuleInstance = (
|
|
|
207
205
|
// init with initValue of a declared const binding, and return
|
|
208
206
|
// it.
|
|
209
207
|
if (!tdz) {
|
|
210
|
-
throw
|
|
208
|
+
throw TypeError(
|
|
211
209
|
`Internal: binding ${q(localName)} already initialized`,
|
|
212
210
|
);
|
|
213
211
|
}
|
|
@@ -267,7 +265,7 @@ export const makeModuleInstance = (
|
|
|
267
265
|
// tdz sensitive getter
|
|
268
266
|
const get = () => {
|
|
269
267
|
if (tdz) {
|
|
270
|
-
throw
|
|
268
|
+
throw ReferenceError(
|
|
271
269
|
`binding ${q(liveExportName)} not yet initialized`,
|
|
272
270
|
);
|
|
273
271
|
}
|
|
@@ -294,9 +292,7 @@ export const makeModuleInstance = (
|
|
|
294
292
|
// tdz sensitive setter
|
|
295
293
|
const set = newValue => {
|
|
296
294
|
if (tdz) {
|
|
297
|
-
throw
|
|
298
|
-
`binding ${q(localName)} not yet initialized`,
|
|
299
|
-
);
|
|
295
|
+
throw ReferenceError(`binding ${q(localName)} not yet initialized`);
|
|
300
296
|
}
|
|
301
297
|
value = newValue;
|
|
302
298
|
for (const updater of updaters) {
|
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%': {
|
|
@@ -831,6 +852,7 @@ export const whitelist = {
|
|
|
831
852
|
dotAll: getter,
|
|
832
853
|
flags: getter,
|
|
833
854
|
global: getter,
|
|
855
|
+
hasIndices: getter,
|
|
834
856
|
ignoreCase: getter,
|
|
835
857
|
'@@match': fn,
|
|
836
858
|
'@@matchAll': fn,
|
|
@@ -843,12 +865,10 @@ export const whitelist = {
|
|
|
843
865
|
test: fn,
|
|
844
866
|
toString: fn,
|
|
845
867
|
unicode: getter,
|
|
868
|
+
unicodeSets: getter,
|
|
846
869
|
|
|
847
870
|
// Annex B: Additional Properties of the RegExp.prototype Object
|
|
848
871
|
compile: false, // UNSAFE and suppressed.
|
|
849
|
-
// Seen on FF Nightly 88.0a1, Chrome Canary 91.0.4446.0,
|
|
850
|
-
// Safari Tech Preview Release 122 (Safari 14.2, WebKit 16612.1.6.2)
|
|
851
|
-
hasIndices: false,
|
|
852
872
|
},
|
|
853
873
|
|
|
854
874
|
'%RegExpStringIteratorPrototype%': {
|
|
@@ -872,6 +892,8 @@ export const whitelist = {
|
|
|
872
892
|
// Stage 3:
|
|
873
893
|
// https://tc39.es/proposal-relative-indexing-method/
|
|
874
894
|
at: fn,
|
|
895
|
+
// https://tc39.es/proposal-array-from-async/
|
|
896
|
+
fromAsync: fn,
|
|
875
897
|
},
|
|
876
898
|
|
|
877
899
|
'%ArrayPrototype%': {
|
|
@@ -925,14 +947,32 @@ export const whitelist = {
|
|
|
925
947
|
values: 'boolean',
|
|
926
948
|
// Failed tc39 proposal
|
|
927
949
|
// Seen on FF Nightly 88.0a1
|
|
928
|
-
at:
|
|
950
|
+
at: 'boolean',
|
|
929
951
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
930
952
|
findLast: 'boolean',
|
|
931
953
|
findLastIndex: 'boolean',
|
|
954
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
955
|
+
toReversed: 'boolean',
|
|
956
|
+
toSorted: 'boolean',
|
|
957
|
+
toSpliced: 'boolean',
|
|
958
|
+
with: 'boolean',
|
|
959
|
+
// https://github.com/tc39/proposal-array-grouping
|
|
960
|
+
group: 'boolean',
|
|
961
|
+
groupToMap: 'boolean',
|
|
962
|
+
groupBy: 'boolean',
|
|
932
963
|
},
|
|
933
964
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
934
965
|
findLast: fn,
|
|
935
966
|
findLastIndex: fn,
|
|
967
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
968
|
+
toReversed: fn,
|
|
969
|
+
toSorted: fn,
|
|
970
|
+
toSpliced: fn,
|
|
971
|
+
with: fn,
|
|
972
|
+
// https://github.com/tc39/proposal-array-grouping
|
|
973
|
+
group: fn, // Not in proposal? Where?
|
|
974
|
+
groupToMap: fn, // Not in proposal? Where?
|
|
975
|
+
groupBy: fn,
|
|
936
976
|
},
|
|
937
977
|
|
|
938
978
|
'%ArrayIteratorPrototype%': {
|
|
@@ -990,6 +1030,10 @@ export const whitelist = {
|
|
|
990
1030
|
// See https://github.com/tc39/proposal-array-find-from-last
|
|
991
1031
|
findLast: fn,
|
|
992
1032
|
findLastIndex: fn,
|
|
1033
|
+
// https://github.com/tc39/proposal-change-array-by-copy
|
|
1034
|
+
toReversed: fn,
|
|
1035
|
+
toSorted: fn,
|
|
1036
|
+
with: fn,
|
|
993
1037
|
},
|
|
994
1038
|
|
|
995
1039
|
// The TypedArray Constructors
|
|
@@ -1134,6 +1178,9 @@ export const whitelist = {
|
|
|
1134
1178
|
resize: fn,
|
|
1135
1179
|
resizable: getter,
|
|
1136
1180
|
maxByteLength: getter,
|
|
1181
|
+
// https://github.com/tc39/proposal-arraybuffer-transfer
|
|
1182
|
+
transferToFixedLength: fn,
|
|
1183
|
+
detached: getter,
|
|
1137
1184
|
},
|
|
1138
1185
|
|
|
1139
1186
|
// SharedArrayBuffer Objects
|
|
@@ -1182,18 +1229,97 @@ export const whitelist = {
|
|
|
1182
1229
|
parse: fn,
|
|
1183
1230
|
stringify: fn,
|
|
1184
1231
|
'@@toStringTag': 'string',
|
|
1232
|
+
// https://github.com/tc39/proposal-json-parse-with-source/
|
|
1233
|
+
rawJSON: fn,
|
|
1234
|
+
isRawJSON: fn,
|
|
1185
1235
|
},
|
|
1186
1236
|
|
|
1187
1237
|
// *** Control Abstraction Objects
|
|
1188
1238
|
|
|
1239
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1240
|
+
Iterator: {
|
|
1241
|
+
// Properties of the Iterator Constructor
|
|
1242
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1243
|
+
prototype: '%IteratorPrototype%',
|
|
1244
|
+
from: fn,
|
|
1245
|
+
},
|
|
1246
|
+
|
|
1189
1247
|
'%IteratorPrototype%': {
|
|
1190
1248
|
// The %IteratorPrototype% Object
|
|
1191
1249
|
'@@iterator': fn,
|
|
1250
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1251
|
+
constructor: 'Iterator',
|
|
1252
|
+
map: fn,
|
|
1253
|
+
filter: fn,
|
|
1254
|
+
take: fn,
|
|
1255
|
+
drop: fn,
|
|
1256
|
+
flatMap: fn,
|
|
1257
|
+
reduce: fn,
|
|
1258
|
+
toArray: fn,
|
|
1259
|
+
forEach: fn,
|
|
1260
|
+
some: fn,
|
|
1261
|
+
every: fn,
|
|
1262
|
+
find: fn,
|
|
1263
|
+
'@@toStringTag': 'string',
|
|
1264
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1265
|
+
toAsync: fn,
|
|
1266
|
+
},
|
|
1267
|
+
|
|
1268
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1269
|
+
'%WrapForValidIteratorPrototype%': {
|
|
1270
|
+
'[[Proto]]': '%IteratorPrototype%',
|
|
1271
|
+
next: fn,
|
|
1272
|
+
return: fn,
|
|
1273
|
+
},
|
|
1274
|
+
|
|
1275
|
+
// https://github.com/tc39/proposal-iterator-helpers
|
|
1276
|
+
'%IteratorHelperPrototype%': {
|
|
1277
|
+
'[[Proto]]': '%IteratorPrototype%',
|
|
1278
|
+
next: fn,
|
|
1279
|
+
return: fn,
|
|
1280
|
+
'@@toStringTag': 'string',
|
|
1281
|
+
},
|
|
1282
|
+
|
|
1283
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1284
|
+
AsyncIterator: {
|
|
1285
|
+
// Properties of the Iterator Constructor
|
|
1286
|
+
'[[Proto]]': '%FunctionPrototype%',
|
|
1287
|
+
prototype: '%AsyncIteratorPrototype%',
|
|
1288
|
+
from: fn,
|
|
1192
1289
|
},
|
|
1193
1290
|
|
|
1194
1291
|
'%AsyncIteratorPrototype%': {
|
|
1195
1292
|
// The %AsyncIteratorPrototype% Object
|
|
1196
1293
|
'@@asyncIterator': fn,
|
|
1294
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1295
|
+
constructor: 'AsyncIterator',
|
|
1296
|
+
map: fn,
|
|
1297
|
+
filter: fn,
|
|
1298
|
+
take: fn,
|
|
1299
|
+
drop: fn,
|
|
1300
|
+
flatMap: fn,
|
|
1301
|
+
reduce: fn,
|
|
1302
|
+
toArray: fn,
|
|
1303
|
+
forEach: fn,
|
|
1304
|
+
some: fn,
|
|
1305
|
+
every: fn,
|
|
1306
|
+
find: fn,
|
|
1307
|
+
'@@toStringTag': 'string',
|
|
1308
|
+
},
|
|
1309
|
+
|
|
1310
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1311
|
+
'%WrapForValidAsyncIteratorPrototype%': {
|
|
1312
|
+
'[[Proto]]': '%AsyncIteratorPrototype%',
|
|
1313
|
+
next: fn,
|
|
1314
|
+
return: fn,
|
|
1315
|
+
},
|
|
1316
|
+
|
|
1317
|
+
// https://github.com/tc39/proposal-async-iterator-helpers
|
|
1318
|
+
'%AsyncIteratorHelperPrototype%': {
|
|
1319
|
+
'[[Proto]]': '%AsyncIteratorPrototype%',
|
|
1320
|
+
next: fn,
|
|
1321
|
+
return: fn,
|
|
1322
|
+
'@@toStringTag': 'string',
|
|
1197
1323
|
},
|
|
1198
1324
|
|
|
1199
1325
|
'%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;
|