ses 0.15.22 → 0.15.24
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 +34 -20
- package/dist/lockdown.cjs +66 -24
- package/dist/lockdown.mjs +66 -24
- package/dist/lockdown.umd.js +66 -24
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +66 -24
- package/dist/ses.mjs +66 -24
- package/dist/ses.umd.js +66 -24
- package/dist/ses.umd.min.js +1 -1
- package/package.json +4 -5
- package/src/commons.js +14 -9
- package/src/compartment-shim.js +5 -2
- package/src/error/console.js +1 -1
- package/src/error/stringify-utils.js +1 -1
- package/src/error/tame-error-constructor.js +34 -0
- package/src/error/unhandled-rejection.js +1 -1
- package/src/transforms.js +1 -1
- package/CHANGELOG.md +0 -507
package/NEWS.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
User-visible changes in SES:
|
|
2
2
|
|
|
3
|
+
# v0.15.24 (2023-08-07)
|
|
4
|
+
|
|
5
|
+
- Censors the pattern `{...import(specifier)`}.
|
|
6
|
+
We previously censored `import(specifier)` and expressly allowed
|
|
7
|
+
`object.import(specifier)`.
|
|
8
|
+
The relaxation for the latter form in version 0.13.0 inadvertently allowed
|
|
9
|
+
import with the spread operator.
|
|
10
|
+
|
|
11
|
+
# v0.15.23 (2022-09-27)
|
|
12
|
+
|
|
13
|
+
- Fixes the unhandled promise rejection logic to report unhandled rejections
|
|
14
|
+
when the promise is collected. Because of a bug it previously only reported
|
|
15
|
+
at process exit.
|
|
16
|
+
- Improves the fidelity of emulation for V8 `Error.prepareStackTrace`,
|
|
17
|
+
allowing more legacy code to work by default in isolation.
|
|
18
|
+
|
|
3
19
|
# v0.15.18 (2022-08-23)
|
|
4
20
|
|
|
5
21
|
- Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
|
|
@@ -45,7 +61,7 @@ User-visible changes in SES:
|
|
|
45
61
|
|
|
46
62
|
# 0.15.0 (2021-11-02)
|
|
47
63
|
|
|
48
|
-
-
|
|
64
|
+
- _BREAKING CHANGE_: The lockdown option `domainTaming` is now `safe` by
|
|
49
65
|
default, which will break any application that depends transtively on the
|
|
50
66
|
Node.js `domain` module.
|
|
51
67
|
Notably, [standard-things/esm](https://github.com/standard-things/esm)
|
|
@@ -53,10 +69,11 @@ User-visible changes in SES:
|
|
|
53
69
|
|
|
54
70
|
This protects against the unhardened `domain` property appearing on shared
|
|
55
71
|
objects like callbacks and promises.
|
|
56
|
-
This overcomes the last
|
|
72
|
+
This overcomes the last _known_ obstacle toward object capability containment.
|
|
73
|
+
|
|
57
74
|
- Lockdown will now read options from the environment as defined by the Node.js
|
|
58
75
|
`process.env` parameter space.
|
|
59
|
-
-
|
|
76
|
+
- _BREAKING CHANGE_: Lockdown may no longer be called more than once.
|
|
60
77
|
Lockdown no longer returns a boolean to indicate whether it was effective
|
|
61
78
|
(true) or redundant (false). Instead, Lockdown will return undefined for
|
|
62
79
|
its first invocation or throw an error otherwise.
|
|
@@ -102,7 +119,7 @@ User-visible changes in SES:
|
|
|
102
119
|
|
|
103
120
|
# 0.14.0 (2021-07-22)
|
|
104
121
|
|
|
105
|
-
-
|
|
122
|
+
- _BREAKING_: Any precompiled static module records from prior versions
|
|
106
123
|
will not load in this version of SES or beyond. The format of the preamble
|
|
107
124
|
has been changed to admit the possibility of a variable named `Map` declared
|
|
108
125
|
in the scope of a module.
|
|
@@ -119,8 +136,7 @@ User-visible changes in SES:
|
|
|
119
136
|
|
|
120
137
|
# 0.13.4 (2021-06-19)
|
|
121
138
|
|
|
122
|
-
- Adds more TypeScript definitions, importable with `/// <reference
|
|
123
|
-
types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
|
|
139
|
+
- Adds more TypeScript definitions, importable with `/// <reference types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
|
|
124
140
|
and many types importable with `import('ses')` notation.
|
|
125
141
|
- Adds descriptive detail to module system link error messages and fixes the
|
|
126
142
|
reported exports for one.
|
|
@@ -132,25 +148,25 @@ User-visible changes in SES:
|
|
|
132
148
|
|
|
133
149
|
# 0.13.0 (2021-06-01)
|
|
134
150
|
|
|
135
|
-
-
|
|
151
|
+
- _BREAKING CHANGE_ The `ses/lockdown` module is again just `ses`.
|
|
136
152
|
Instead of having a light 43KB `ses/lockdown` and a heavy 3.1MB `ses`, there
|
|
137
153
|
is just a 52KB `ses` that has everything except `StaticModuleRecord`.
|
|
138
154
|
For this release, there remains a `ses/lockdown` alias to `ses`.
|
|
139
|
-
-
|
|
155
|
+
- _BREAKING CHANGE_ Third-party static module interface implementations _must_
|
|
140
156
|
now explicitly list their exported names.
|
|
141
157
|
For CommonJS, this implies using a heuristic static analysis of `exports`
|
|
142
158
|
changes.
|
|
143
159
|
Consequently, third-party modules can now participate in linkage with ESM
|
|
144
160
|
including support for `export * from './spec.cjs'` and also named imports
|
|
145
161
|
like `import * from './spec.cjs'`.
|
|
146
|
-
-
|
|
162
|
+
- _BREAKING CHANGE_ The `StaticModuleRecord` constructor has been removed in
|
|
147
163
|
favor of a duck-type for compiled static module records that is intrinsic to
|
|
148
164
|
the shim and may be emulated by a third-party `StaticModuleRecord`
|
|
149
165
|
constructor.
|
|
150
166
|
The constructor must perform the module analysis and transform the source,
|
|
151
167
|
and present this duck-type to the Compartment `importHook`.
|
|
152
168
|
This relieves SES of a dependency on Babel and simplifies its API.
|
|
153
|
-
-
|
|
169
|
+
- _BREAKING CHANGE_ The UMD distribution of SES must have the UTF-8 charset.
|
|
154
170
|
The prior versions were accidentally ASCII, so SES would have worked
|
|
155
171
|
in any web page, regardless of the charset.
|
|
156
172
|
To remedy this, be sure to include `<head><meta charset="utf-8"></head>` in
|
|
@@ -163,8 +179,7 @@ User-visible changes in SES:
|
|
|
163
179
|
- Fix: `new Compartment(null, null, options)` no longer throws.
|
|
164
180
|
- New lockdown option: `overrideDebug: [...props]` to detect where a property
|
|
165
181
|
assignment needs to be turned into a `defineProperty` to avoid the override
|
|
166
|
-
mistake.
|
|
167
|
-
['constructor']`.
|
|
182
|
+
mistake. Most useful as `overrideTaming: 'severe', overrideDebug: ['constructor']`.
|
|
168
183
|
- We reopened Safari bug
|
|
169
184
|
[Object.defineProperties triggering a setter](https://bugs.webkit.org/show_bug.cgi?id=222538#c17)
|
|
170
185
|
when we found that it was causing an infinite recursion initializing SES
|
|
@@ -237,18 +252,17 @@ User-visible changes in SES:
|
|
|
237
252
|
|
|
238
253
|
The purpose of the `details` template literal tag (often spelled `X` or `d`) together with the `quote` function (often spelled `q`) is to redact data from the error messages carried by error instances. With this release, the same `{errorTaming: 'unsafe'}` would suppress that redaction as well, so that all substitution values would act like they've been quoted. IOW, with this setting
|
|
239
254
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
255
|
+
```js
|
|
256
|
+
assert(false, X`literal part ${secretData} with ${q(publicData)}.`);
|
|
257
|
+
```
|
|
243
258
|
|
|
244
259
|
acts like
|
|
245
260
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Note that the information rendered by the SES shim `console` object always includes all the unredacted data independent of the setting of `errorTaming`.
|
|
261
|
+
```js
|
|
262
|
+
assert(false, X`literal part ${q(secretData)} with ${q(publicData)}.`);
|
|
263
|
+
```
|
|
251
264
|
|
|
265
|
+
Note that the information rendered by the SES shim `console` object always includes all the unredacted data independent of the setting of `errorTaming`.
|
|
252
266
|
|
|
253
267
|
# 0.12.3 (2021-03-01)
|
|
254
268
|
|
package/dist/lockdown.cjs
CHANGED
|
@@ -147,35 +147,32 @@ const { prototype: weaksetPrototype}= WeakSet;$h_once.weaksetPrototy
|
|
|
147
147
|
const { prototype: functionPrototype}= Function;$h_once.functionPrototype(functionPrototype);
|
|
148
148
|
const { prototype: promisePrototype}= Promise;$h_once.promisePrototype(promisePrototype);
|
|
149
149
|
|
|
150
|
-
const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);
|
|
150
|
+
const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);$h_once.typedArrayPrototype(typedArrayPrototype);
|
|
151
151
|
|
|
152
|
+
const { bind}= functionPrototype;
|
|
152
153
|
/**
|
|
153
154
|
* uncurryThis()
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* The original uncurry uses:
|
|
157
|
-
* const bind = Function.prototype.bind;
|
|
158
|
-
* const uncurryThis = bind.bind(bind.call);
|
|
155
|
+
* Equivalent of: fn => (thisArg, ...args) => apply(fn, thisArg, args)
|
|
159
156
|
*
|
|
160
157
|
* See those reference for a complete explanation:
|
|
161
158
|
* http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
162
159
|
* which only lives at
|
|
163
160
|
* http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
164
161
|
*
|
|
165
|
-
* @
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const uncurryThis= (fn)=>(thisArg, ...args)=> apply(fn, thisArg, args);$h_once.uncurryThis(uncurryThis);
|
|
170
|
-
|
|
162
|
+
* @type {<F extends (this: any, ...args: any[]) => any>(fn: F) => ((thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>)}
|
|
163
|
+
*/
|
|
164
|
+
const uncurryThis= bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
|
|
165
|
+
$h_once.uncurryThis(uncurryThis);
|
|
171
166
|
const objectHasOwnProperty= uncurryThis(objectPrototype.hasOwnProperty);
|
|
172
167
|
//
|
|
173
168
|
$h_once.objectHasOwnProperty(objectHasOwnProperty);const arrayFilter=uncurryThis(arrayPrototype.filter);$h_once.arrayFilter(arrayFilter);
|
|
174
169
|
const arrayForEach= uncurryThis(arrayPrototype.forEach);$h_once.arrayForEach(arrayForEach);
|
|
175
170
|
const arrayIncludes= uncurryThis(arrayPrototype.includes);$h_once.arrayIncludes(arrayIncludes);
|
|
176
|
-
const arrayJoin= uncurryThis(arrayPrototype.join)
|
|
171
|
+
const arrayJoin= uncurryThis(arrayPrototype.join);
|
|
172
|
+
/** @type {<T, U>(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]} */$h_once.arrayJoin(arrayJoin);
|
|
177
173
|
const arrayMap= uncurryThis(arrayPrototype.map);$h_once.arrayMap(arrayMap);
|
|
178
|
-
const arrayPop= uncurryThis(arrayPrototype.pop)
|
|
174
|
+
const arrayPop= uncurryThis(arrayPrototype.pop);
|
|
175
|
+
/** @type {<T>(thisArg: T[], ...items: T[]) => number} */$h_once.arrayPop(arrayPop);
|
|
179
176
|
const arrayPush= uncurryThis(arrayPrototype.push);$h_once.arrayPush(arrayPush);
|
|
180
177
|
const arraySlice= uncurryThis(arrayPrototype.slice);$h_once.arraySlice(arraySlice);
|
|
181
178
|
const arraySome= uncurryThis(arrayPrototype.some);$h_once.arraySome(arraySome);
|
|
@@ -202,10 +199,17 @@ const matchAllRegExp= uncurryThis(regexpPrototype[matchAllSymbol]);
|
|
|
202
199
|
$h_once.matchAllRegExp(matchAllRegExp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h_once.stringEndsWith(stringEndsWith);
|
|
203
200
|
const stringIncludes= uncurryThis(stringPrototype.includes);$h_once.stringIncludes(stringIncludes);
|
|
204
201
|
const stringIndexOf= uncurryThis(stringPrototype.indexOf);$h_once.stringIndexOf(stringIndexOf);
|
|
205
|
-
const stringMatch= uncurryThis(stringPrototype.match)
|
|
202
|
+
const stringMatch= uncurryThis(stringPrototype.match);
|
|
203
|
+
/**
|
|
204
|
+
* @type {
|
|
205
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) |
|
|
206
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string)
|
|
207
|
+
* }
|
|
208
|
+
*/$h_once.stringMatch(stringMatch);
|
|
206
209
|
const stringReplace= uncurryThis(stringPrototype.replace);$h_once.stringReplace(stringReplace);
|
|
207
210
|
const stringSearch= uncurryThis(stringPrototype.search);$h_once.stringSearch(stringSearch);
|
|
208
|
-
const stringSlice= uncurryThis(stringPrototype.slice)
|
|
211
|
+
const stringSlice= uncurryThis(stringPrototype.slice);
|
|
212
|
+
/** @type {(thisArg: string, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[]} */$h_once.stringSlice(stringSlice);
|
|
209
213
|
const stringSplit= uncurryThis(stringPrototype.split);$h_once.stringSplit(stringSplit);
|
|
210
214
|
const stringStartsWith= uncurryThis(stringPrototype.startsWith);$h_once.stringStartsWith(stringStartsWith);
|
|
211
215
|
const iterateString= uncurryThis(stringPrototype[iteratorSymbol]);
|
|
@@ -224,7 +228,8 @@ $h_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPro
|
|
|
224
228
|
//
|
|
225
229
|
$h_once.functionToString(functionToString);const{all}=Promise;
|
|
226
230
|
const promiseAll= (promises)=>apply(all, Promise, [promises]);$h_once.promiseAll(promiseAll);
|
|
227
|
-
const promiseCatch= uncurryThis(promisePrototype.catch)
|
|
231
|
+
const promiseCatch= uncurryThis(promisePrototype.catch);
|
|
232
|
+
/** @type {<T, TResult1 = T, TResult2 = never>(thisArg: T, onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null) => Promise<TResult1 | TResult2>} */$h_once.promiseCatch(promiseCatch);
|
|
228
233
|
const promiseThen= uncurryThis(promisePrototype.then);
|
|
229
234
|
//
|
|
230
235
|
$h_once.promiseThen(promiseThen);const finalizationRegistryRegister=
|
|
@@ -412,7 +417,7 @@ const noEvalEvaluate= ()=> {
|
|
|
412
417
|
/**
|
|
413
418
|
* Joins English terms with commas and an optional conjunction.
|
|
414
419
|
*
|
|
415
|
-
* @param {string[]} terms
|
|
420
|
+
* @param {(string | StringablePayload)[]} terms
|
|
416
421
|
* @param {"and" | "or"} conjunction
|
|
417
422
|
*/
|
|
418
423
|
const enJoin= (terms, conjunction)=> {
|
|
@@ -1985,7 +1990,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
1985
1990
|
// /////////////////////////////////////////////////////////////////////////////
|
|
1986
1991
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
1987
1992
|
const importPattern= new FERAL_REG_EXP(
|
|
1988
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
1993
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
1989
1994
|
'g');
|
|
1990
1995
|
|
|
1991
1996
|
|
|
@@ -5318,7 +5323,10 @@ const CompartmentPrototype= {
|
|
|
5318
5323
|
()=> {
|
|
5319
5324
|
// The namespace box is a contentious design and likely to be a breaking
|
|
5320
5325
|
// change in an appropriately numbered future version.
|
|
5321
|
-
const namespace= compartmentImportNow(
|
|
5326
|
+
const namespace= compartmentImportNow(
|
|
5327
|
+
/** @type {Compartment} */ this,
|
|
5328
|
+
specifier);
|
|
5329
|
+
|
|
5322
5330
|
return { namespace};
|
|
5323
5331
|
});
|
|
5324
5332
|
|
|
@@ -5341,7 +5349,7 @@ const CompartmentPrototype= {
|
|
|
5341
5349
|
|
|
5342
5350
|
assertModuleHooks(this);
|
|
5343
5351
|
|
|
5344
|
-
return compartmentImportNow(this,
|
|
5352
|
+
return compartmentImportNow(/** @type {Compartment} */ this, specifier);
|
|
5345
5353
|
}};$h_once.CompartmentPrototype(CompartmentPrototype);
|
|
5346
5354
|
|
|
5347
5355
|
|
|
@@ -6539,9 +6547,9 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
|
|
|
6539
6547
|
const levelMethod= (...logArgs)=> {
|
|
6540
6548
|
const subErrors= [];
|
|
6541
6549
|
const argTags= extractErrorArgs(logArgs, subErrors);
|
|
6542
|
-
// @ts-ignore
|
|
6543
6550
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
6544
6551
|
baseConsole[level](...argTags);
|
|
6552
|
+
// @ts-expect-error ConsoleProp vs LogSeverity mismatch
|
|
6545
6553
|
logSubErrors(level, subErrors);
|
|
6546
6554
|
};
|
|
6547
6555
|
defineProperty(levelMethod, 'name', { value: level});
|
|
@@ -6666,7 +6674,7 @@ const makeRejectionHandlers= (reportReason)=>{
|
|
|
6666
6674
|
* @param {ReasonId} heldReasonId
|
|
6667
6675
|
*/
|
|
6668
6676
|
const finalizeDroppedPromise= (heldReasonId)=>{
|
|
6669
|
-
if( mapHas(idToReason)) {
|
|
6677
|
+
if( mapHas(idToReason, heldReasonId)) {
|
|
6670
6678
|
const reason= mapGet(idToReason, heldReasonId);
|
|
6671
6679
|
removeReasonId(heldReasonId);
|
|
6672
6680
|
reportReason(reason);
|
|
@@ -7209,7 +7217,8 @@ const tameV8ErrorConstructor= (
|
|
|
7209
7217
|
})
|
|
7210
7218
|
,
|
|
7211
7219
|
// === functors[29] ===
|
|
7212
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,NativeErrors,tameV8ErrorConstructor;$h_imports([["../commons.js", [["FERAL_ERROR", [$h_a => (FERAL_ERROR = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["apply", [$h_a => (apply = $h_a)]],["construct", [$h_a => (construct = $h_a)]],["defineProperties", [$h_a => (defineProperties = $h_a)]],["setPrototypeOf", [$h_a => (setPrototypeOf = $h_a)]],["getOwnPropertyDescriptor", [$h_a => (getOwnPropertyDescriptor = $h_a)]]]],["../whitelist.js", [["NativeErrors", [$h_a => (NativeErrors = $h_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h_a => (tameV8ErrorConstructor = $h_a)]]]]]);
|
|
7220
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,defineProperty,NativeErrors,tameV8ErrorConstructor;$h_imports([["../commons.js", [["FERAL_ERROR", [$h_a => (FERAL_ERROR = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["apply", [$h_a => (apply = $h_a)]],["construct", [$h_a => (construct = $h_a)]],["defineProperties", [$h_a => (defineProperties = $h_a)]],["setPrototypeOf", [$h_a => (setPrototypeOf = $h_a)]],["getOwnPropertyDescriptor", [$h_a => (getOwnPropertyDescriptor = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]]]],["../whitelist.js", [["NativeErrors", [$h_a => (NativeErrors = $h_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h_a => (tameV8ErrorConstructor = $h_a)]]]]]);
|
|
7221
|
+
|
|
7213
7222
|
|
|
7214
7223
|
|
|
7215
7224
|
|
|
@@ -7348,6 +7357,39 @@ function tameErrorConstructor(
|
|
|
7348
7357
|
|
|
7349
7358
|
|
|
7350
7359
|
|
|
7360
|
+
if( platform=== 'v8') {
|
|
7361
|
+
// `SharedError.prepareStackTrace`, if it exists, must also be
|
|
7362
|
+
// powerless. However, from what we've heard, depd expects to be able to
|
|
7363
|
+
// assign to it without the assignment throwing. It is normally a function
|
|
7364
|
+
// that returns a stack string to be magically added to error objects.
|
|
7365
|
+
// However, as long as we're adding a lenient standin, we may as well
|
|
7366
|
+
// accommodate any who expect to get a function they can call and get
|
|
7367
|
+
// a string back. This prepareStackTrace is a do-nothing function that
|
|
7368
|
+
// always returns the empty string.
|
|
7369
|
+
defineProperties(SharedError, {
|
|
7370
|
+
prepareStackTrace: {
|
|
7371
|
+
get() {
|
|
7372
|
+
return ()=> '';
|
|
7373
|
+
},
|
|
7374
|
+
set(_prepareFn) {
|
|
7375
|
+
// do nothing
|
|
7376
|
+
},
|
|
7377
|
+
enumerable: false,
|
|
7378
|
+
configurable: true},
|
|
7379
|
+
|
|
7380
|
+
captureStackTrace: {
|
|
7381
|
+
value: (errorish, _constructorOpt)=> {
|
|
7382
|
+
defineProperty(errorish, 'stack', {
|
|
7383
|
+
value: ''});
|
|
7384
|
+
|
|
7385
|
+
},
|
|
7386
|
+
writable: false,
|
|
7387
|
+
enumerable: false,
|
|
7388
|
+
configurable: true}});
|
|
7389
|
+
|
|
7390
|
+
|
|
7391
|
+
}
|
|
7392
|
+
|
|
7351
7393
|
let initialGetStackString= tamedMethods.getStackString;
|
|
7352
7394
|
if( platform=== 'v8') {
|
|
7353
7395
|
initialGetStackString= tameV8ErrorConstructor(
|
package/dist/lockdown.mjs
CHANGED
|
@@ -147,35 +147,32 @@ const { prototype: weaksetPrototype}= WeakSet;$h_once.weaksetPrototy
|
|
|
147
147
|
const { prototype: functionPrototype}= Function;$h_once.functionPrototype(functionPrototype);
|
|
148
148
|
const { prototype: promisePrototype}= Promise;$h_once.promisePrototype(promisePrototype);
|
|
149
149
|
|
|
150
|
-
const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);
|
|
150
|
+
const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);$h_once.typedArrayPrototype(typedArrayPrototype);
|
|
151
151
|
|
|
152
|
+
const { bind}= functionPrototype;
|
|
152
153
|
/**
|
|
153
154
|
* uncurryThis()
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* The original uncurry uses:
|
|
157
|
-
* const bind = Function.prototype.bind;
|
|
158
|
-
* const uncurryThis = bind.bind(bind.call);
|
|
155
|
+
* Equivalent of: fn => (thisArg, ...args) => apply(fn, thisArg, args)
|
|
159
156
|
*
|
|
160
157
|
* See those reference for a complete explanation:
|
|
161
158
|
* http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
162
159
|
* which only lives at
|
|
163
160
|
* http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
164
161
|
*
|
|
165
|
-
* @
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const uncurryThis= (fn)=>(thisArg, ...args)=> apply(fn, thisArg, args);$h_once.uncurryThis(uncurryThis);
|
|
170
|
-
|
|
162
|
+
* @type {<F extends (this: any, ...args: any[]) => any>(fn: F) => ((thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>)}
|
|
163
|
+
*/
|
|
164
|
+
const uncurryThis= bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
|
|
165
|
+
$h_once.uncurryThis(uncurryThis);
|
|
171
166
|
const objectHasOwnProperty= uncurryThis(objectPrototype.hasOwnProperty);
|
|
172
167
|
//
|
|
173
168
|
$h_once.objectHasOwnProperty(objectHasOwnProperty);const arrayFilter=uncurryThis(arrayPrototype.filter);$h_once.arrayFilter(arrayFilter);
|
|
174
169
|
const arrayForEach= uncurryThis(arrayPrototype.forEach);$h_once.arrayForEach(arrayForEach);
|
|
175
170
|
const arrayIncludes= uncurryThis(arrayPrototype.includes);$h_once.arrayIncludes(arrayIncludes);
|
|
176
|
-
const arrayJoin= uncurryThis(arrayPrototype.join)
|
|
171
|
+
const arrayJoin= uncurryThis(arrayPrototype.join);
|
|
172
|
+
/** @type {<T, U>(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]} */$h_once.arrayJoin(arrayJoin);
|
|
177
173
|
const arrayMap= uncurryThis(arrayPrototype.map);$h_once.arrayMap(arrayMap);
|
|
178
|
-
const arrayPop= uncurryThis(arrayPrototype.pop)
|
|
174
|
+
const arrayPop= uncurryThis(arrayPrototype.pop);
|
|
175
|
+
/** @type {<T>(thisArg: T[], ...items: T[]) => number} */$h_once.arrayPop(arrayPop);
|
|
179
176
|
const arrayPush= uncurryThis(arrayPrototype.push);$h_once.arrayPush(arrayPush);
|
|
180
177
|
const arraySlice= uncurryThis(arrayPrototype.slice);$h_once.arraySlice(arraySlice);
|
|
181
178
|
const arraySome= uncurryThis(arrayPrototype.some);$h_once.arraySome(arraySome);
|
|
@@ -202,10 +199,17 @@ const matchAllRegExp= uncurryThis(regexpPrototype[matchAllSymbol]);
|
|
|
202
199
|
$h_once.matchAllRegExp(matchAllRegExp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h_once.stringEndsWith(stringEndsWith);
|
|
203
200
|
const stringIncludes= uncurryThis(stringPrototype.includes);$h_once.stringIncludes(stringIncludes);
|
|
204
201
|
const stringIndexOf= uncurryThis(stringPrototype.indexOf);$h_once.stringIndexOf(stringIndexOf);
|
|
205
|
-
const stringMatch= uncurryThis(stringPrototype.match)
|
|
202
|
+
const stringMatch= uncurryThis(stringPrototype.match);
|
|
203
|
+
/**
|
|
204
|
+
* @type {
|
|
205
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) |
|
|
206
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string)
|
|
207
|
+
* }
|
|
208
|
+
*/$h_once.stringMatch(stringMatch);
|
|
206
209
|
const stringReplace= uncurryThis(stringPrototype.replace);$h_once.stringReplace(stringReplace);
|
|
207
210
|
const stringSearch= uncurryThis(stringPrototype.search);$h_once.stringSearch(stringSearch);
|
|
208
|
-
const stringSlice= uncurryThis(stringPrototype.slice)
|
|
211
|
+
const stringSlice= uncurryThis(stringPrototype.slice);
|
|
212
|
+
/** @type {(thisArg: string, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[]} */$h_once.stringSlice(stringSlice);
|
|
209
213
|
const stringSplit= uncurryThis(stringPrototype.split);$h_once.stringSplit(stringSplit);
|
|
210
214
|
const stringStartsWith= uncurryThis(stringPrototype.startsWith);$h_once.stringStartsWith(stringStartsWith);
|
|
211
215
|
const iterateString= uncurryThis(stringPrototype[iteratorSymbol]);
|
|
@@ -224,7 +228,8 @@ $h_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPro
|
|
|
224
228
|
//
|
|
225
229
|
$h_once.functionToString(functionToString);const{all}=Promise;
|
|
226
230
|
const promiseAll= (promises)=>apply(all, Promise, [promises]);$h_once.promiseAll(promiseAll);
|
|
227
|
-
const promiseCatch= uncurryThis(promisePrototype.catch)
|
|
231
|
+
const promiseCatch= uncurryThis(promisePrototype.catch);
|
|
232
|
+
/** @type {<T, TResult1 = T, TResult2 = never>(thisArg: T, onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null) => Promise<TResult1 | TResult2>} */$h_once.promiseCatch(promiseCatch);
|
|
228
233
|
const promiseThen= uncurryThis(promisePrototype.then);
|
|
229
234
|
//
|
|
230
235
|
$h_once.promiseThen(promiseThen);const finalizationRegistryRegister=
|
|
@@ -412,7 +417,7 @@ const noEvalEvaluate= ()=> {
|
|
|
412
417
|
/**
|
|
413
418
|
* Joins English terms with commas and an optional conjunction.
|
|
414
419
|
*
|
|
415
|
-
* @param {string[]} terms
|
|
420
|
+
* @param {(string | StringablePayload)[]} terms
|
|
416
421
|
* @param {"and" | "or"} conjunction
|
|
417
422
|
*/
|
|
418
423
|
const enJoin= (terms, conjunction)=> {
|
|
@@ -1985,7 +1990,7 @@ const evadeHtmlCommentTest= (src)=>{
|
|
|
1985
1990
|
// /////////////////////////////////////////////////////////////////////////////
|
|
1986
1991
|
$h_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
|
|
1987
1992
|
const importPattern= new FERAL_REG_EXP(
|
|
1988
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
1993
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
1989
1994
|
'g');
|
|
1990
1995
|
|
|
1991
1996
|
|
|
@@ -5318,7 +5323,10 @@ const CompartmentPrototype= {
|
|
|
5318
5323
|
()=> {
|
|
5319
5324
|
// The namespace box is a contentious design and likely to be a breaking
|
|
5320
5325
|
// change in an appropriately numbered future version.
|
|
5321
|
-
const namespace= compartmentImportNow(
|
|
5326
|
+
const namespace= compartmentImportNow(
|
|
5327
|
+
/** @type {Compartment} */ this,
|
|
5328
|
+
specifier);
|
|
5329
|
+
|
|
5322
5330
|
return { namespace};
|
|
5323
5331
|
});
|
|
5324
5332
|
|
|
@@ -5341,7 +5349,7 @@ const CompartmentPrototype= {
|
|
|
5341
5349
|
|
|
5342
5350
|
assertModuleHooks(this);
|
|
5343
5351
|
|
|
5344
|
-
return compartmentImportNow(this,
|
|
5352
|
+
return compartmentImportNow(/** @type {Compartment} */ this, specifier);
|
|
5345
5353
|
}};$h_once.CompartmentPrototype(CompartmentPrototype);
|
|
5346
5354
|
|
|
5347
5355
|
|
|
@@ -6539,9 +6547,9 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
|
|
|
6539
6547
|
const levelMethod= (...logArgs)=> {
|
|
6540
6548
|
const subErrors= [];
|
|
6541
6549
|
const argTags= extractErrorArgs(logArgs, subErrors);
|
|
6542
|
-
// @ts-ignore
|
|
6543
6550
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
6544
6551
|
baseConsole[level](...argTags);
|
|
6552
|
+
// @ts-expect-error ConsoleProp vs LogSeverity mismatch
|
|
6545
6553
|
logSubErrors(level, subErrors);
|
|
6546
6554
|
};
|
|
6547
6555
|
defineProperty(levelMethod, 'name', { value: level});
|
|
@@ -6666,7 +6674,7 @@ const makeRejectionHandlers= (reportReason)=>{
|
|
|
6666
6674
|
* @param {ReasonId} heldReasonId
|
|
6667
6675
|
*/
|
|
6668
6676
|
const finalizeDroppedPromise= (heldReasonId)=>{
|
|
6669
|
-
if( mapHas(idToReason)) {
|
|
6677
|
+
if( mapHas(idToReason, heldReasonId)) {
|
|
6670
6678
|
const reason= mapGet(idToReason, heldReasonId);
|
|
6671
6679
|
removeReasonId(heldReasonId);
|
|
6672
6680
|
reportReason(reason);
|
|
@@ -7209,7 +7217,8 @@ const tameV8ErrorConstructor= (
|
|
|
7209
7217
|
})
|
|
7210
7218
|
,
|
|
7211
7219
|
// === functors[29] ===
|
|
7212
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,NativeErrors,tameV8ErrorConstructor;$h_imports([["../commons.js", [["FERAL_ERROR", [$h_a => (FERAL_ERROR = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["apply", [$h_a => (apply = $h_a)]],["construct", [$h_a => (construct = $h_a)]],["defineProperties", [$h_a => (defineProperties = $h_a)]],["setPrototypeOf", [$h_a => (setPrototypeOf = $h_a)]],["getOwnPropertyDescriptor", [$h_a => (getOwnPropertyDescriptor = $h_a)]]]],["../whitelist.js", [["NativeErrors", [$h_a => (NativeErrors = $h_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h_a => (tameV8ErrorConstructor = $h_a)]]]]]);
|
|
7220
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,defineProperty,NativeErrors,tameV8ErrorConstructor;$h_imports([["../commons.js", [["FERAL_ERROR", [$h_a => (FERAL_ERROR = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["apply", [$h_a => (apply = $h_a)]],["construct", [$h_a => (construct = $h_a)]],["defineProperties", [$h_a => (defineProperties = $h_a)]],["setPrototypeOf", [$h_a => (setPrototypeOf = $h_a)]],["getOwnPropertyDescriptor", [$h_a => (getOwnPropertyDescriptor = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]]]],["../whitelist.js", [["NativeErrors", [$h_a => (NativeErrors = $h_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h_a => (tameV8ErrorConstructor = $h_a)]]]]]);
|
|
7221
|
+
|
|
7213
7222
|
|
|
7214
7223
|
|
|
7215
7224
|
|
|
@@ -7348,6 +7357,39 @@ function tameErrorConstructor(
|
|
|
7348
7357
|
|
|
7349
7358
|
|
|
7350
7359
|
|
|
7360
|
+
if( platform=== 'v8') {
|
|
7361
|
+
// `SharedError.prepareStackTrace`, if it exists, must also be
|
|
7362
|
+
// powerless. However, from what we've heard, depd expects to be able to
|
|
7363
|
+
// assign to it without the assignment throwing. It is normally a function
|
|
7364
|
+
// that returns a stack string to be magically added to error objects.
|
|
7365
|
+
// However, as long as we're adding a lenient standin, we may as well
|
|
7366
|
+
// accommodate any who expect to get a function they can call and get
|
|
7367
|
+
// a string back. This prepareStackTrace is a do-nothing function that
|
|
7368
|
+
// always returns the empty string.
|
|
7369
|
+
defineProperties(SharedError, {
|
|
7370
|
+
prepareStackTrace: {
|
|
7371
|
+
get() {
|
|
7372
|
+
return ()=> '';
|
|
7373
|
+
},
|
|
7374
|
+
set(_prepareFn) {
|
|
7375
|
+
// do nothing
|
|
7376
|
+
},
|
|
7377
|
+
enumerable: false,
|
|
7378
|
+
configurable: true},
|
|
7379
|
+
|
|
7380
|
+
captureStackTrace: {
|
|
7381
|
+
value: (errorish, _constructorOpt)=> {
|
|
7382
|
+
defineProperty(errorish, 'stack', {
|
|
7383
|
+
value: ''});
|
|
7384
|
+
|
|
7385
|
+
},
|
|
7386
|
+
writable: false,
|
|
7387
|
+
enumerable: false,
|
|
7388
|
+
configurable: true}});
|
|
7389
|
+
|
|
7390
|
+
|
|
7391
|
+
}
|
|
7392
|
+
|
|
7351
7393
|
let initialGetStackString= tamedMethods.getStackString;
|
|
7352
7394
|
if( platform=== 'v8') {
|
|
7353
7395
|
initialGetStackString= tameV8ErrorConstructor(
|