ses 0.15.22 → 0.15.23
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/CHANGELOG.md +16 -0
- package/NEWS.md +26 -20
- package/dist/lockdown.cjs +65 -23
- package/dist/lockdown.mjs +65 -23
- package/dist/lockdown.umd.js +65 -23
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +65 -23
- package/dist/ses.mjs +65 -23
- package/dist/ses.umd.js +65 -23
- package/dist/ses.umd.min.js +1 -1
- package/package.json +4 -4
- 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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.15.23](https://github.com/endojs/endo/compare/ses@0.15.22...ses@0.15.23) (2022-09-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ses:** improve performance of uncurryThis ([b1ad60a](https://github.com/endojs/endo/commit/b1ad60ae89545499d6cbcaa3812118ac4229d83c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* add a do-nothing SharedError.prepareStackTrace ([#1290](https://github.com/endojs/endo/issues/1290)) ([705aef2](https://github.com/endojs/endo/commit/705aef24f34bb9794f0aa807d567b3efbf0c23af))
|
|
17
|
+
* **ses:** report unhandled promise rejection when collected ([dae7235](https://github.com/endojs/endo/commit/dae7235011da907823c27ca5dfb9ed72519a4062))
|
|
18
|
+
* **ses:** uncurryThis type fixes ([feb062c](https://github.com/endojs/endo/commit/feb062c56ee05b12657596defce68107894bafd4))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
### [0.15.22](https://github.com/endojs/endo/compare/ses@0.15.21...ses@0.15.22) (2022-09-14)
|
|
7
23
|
|
|
8
24
|
|
package/NEWS.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
User-visible changes in SES:
|
|
2
2
|
|
|
3
|
+
# v0.15.23 (2022-09-26)
|
|
4
|
+
|
|
5
|
+
- Fixes the unhandled promise rejection logic to report unhandled rejections
|
|
6
|
+
when the promise is collected. Because of a bug it previously only reported
|
|
7
|
+
at process exit.
|
|
8
|
+
- Improves the fidelity of emulation for V8 `Error.prepareStackTrace`,
|
|
9
|
+
allowing more legacy code to work by default in isolation.
|
|
10
|
+
|
|
3
11
|
# v0.15.18 (2022-08-23)
|
|
4
12
|
|
|
5
13
|
- Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
|
|
@@ -45,7 +53,7 @@ User-visible changes in SES:
|
|
|
45
53
|
|
|
46
54
|
# 0.15.0 (2021-11-02)
|
|
47
55
|
|
|
48
|
-
-
|
|
56
|
+
- _BREAKING CHANGE_: The lockdown option `domainTaming` is now `safe` by
|
|
49
57
|
default, which will break any application that depends transtively on the
|
|
50
58
|
Node.js `domain` module.
|
|
51
59
|
Notably, [standard-things/esm](https://github.com/standard-things/esm)
|
|
@@ -53,10 +61,11 @@ User-visible changes in SES:
|
|
|
53
61
|
|
|
54
62
|
This protects against the unhardened `domain` property appearing on shared
|
|
55
63
|
objects like callbacks and promises.
|
|
56
|
-
This overcomes the last
|
|
64
|
+
This overcomes the last _known_ obstacle toward object capability containment.
|
|
65
|
+
|
|
57
66
|
- Lockdown will now read options from the environment as defined by the Node.js
|
|
58
67
|
`process.env` parameter space.
|
|
59
|
-
-
|
|
68
|
+
- _BREAKING CHANGE_: Lockdown may no longer be called more than once.
|
|
60
69
|
Lockdown no longer returns a boolean to indicate whether it was effective
|
|
61
70
|
(true) or redundant (false). Instead, Lockdown will return undefined for
|
|
62
71
|
its first invocation or throw an error otherwise.
|
|
@@ -102,7 +111,7 @@ User-visible changes in SES:
|
|
|
102
111
|
|
|
103
112
|
# 0.14.0 (2021-07-22)
|
|
104
113
|
|
|
105
|
-
-
|
|
114
|
+
- _BREAKING_: Any precompiled static module records from prior versions
|
|
106
115
|
will not load in this version of SES or beyond. The format of the preamble
|
|
107
116
|
has been changed to admit the possibility of a variable named `Map` declared
|
|
108
117
|
in the scope of a module.
|
|
@@ -119,8 +128,7 @@ User-visible changes in SES:
|
|
|
119
128
|
|
|
120
129
|
# 0.13.4 (2021-06-19)
|
|
121
130
|
|
|
122
|
-
- Adds more TypeScript definitions, importable with `/// <reference
|
|
123
|
-
types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
|
|
131
|
+
- Adds more TypeScript definitions, importable with `/// <reference types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
|
|
124
132
|
and many types importable with `import('ses')` notation.
|
|
125
133
|
- Adds descriptive detail to module system link error messages and fixes the
|
|
126
134
|
reported exports for one.
|
|
@@ -132,25 +140,25 @@ User-visible changes in SES:
|
|
|
132
140
|
|
|
133
141
|
# 0.13.0 (2021-06-01)
|
|
134
142
|
|
|
135
|
-
-
|
|
143
|
+
- _BREAKING CHANGE_ The `ses/lockdown` module is again just `ses`.
|
|
136
144
|
Instead of having a light 43KB `ses/lockdown` and a heavy 3.1MB `ses`, there
|
|
137
145
|
is just a 52KB `ses` that has everything except `StaticModuleRecord`.
|
|
138
146
|
For this release, there remains a `ses/lockdown` alias to `ses`.
|
|
139
|
-
-
|
|
147
|
+
- _BREAKING CHANGE_ Third-party static module interface implementations _must_
|
|
140
148
|
now explicitly list their exported names.
|
|
141
149
|
For CommonJS, this implies using a heuristic static analysis of `exports`
|
|
142
150
|
changes.
|
|
143
151
|
Consequently, third-party modules can now participate in linkage with ESM
|
|
144
152
|
including support for `export * from './spec.cjs'` and also named imports
|
|
145
153
|
like `import * from './spec.cjs'`.
|
|
146
|
-
-
|
|
154
|
+
- _BREAKING CHANGE_ The `StaticModuleRecord` constructor has been removed in
|
|
147
155
|
favor of a duck-type for compiled static module records that is intrinsic to
|
|
148
156
|
the shim and may be emulated by a third-party `StaticModuleRecord`
|
|
149
157
|
constructor.
|
|
150
158
|
The constructor must perform the module analysis and transform the source,
|
|
151
159
|
and present this duck-type to the Compartment `importHook`.
|
|
152
160
|
This relieves SES of a dependency on Babel and simplifies its API.
|
|
153
|
-
-
|
|
161
|
+
- _BREAKING CHANGE_ The UMD distribution of SES must have the UTF-8 charset.
|
|
154
162
|
The prior versions were accidentally ASCII, so SES would have worked
|
|
155
163
|
in any web page, regardless of the charset.
|
|
156
164
|
To remedy this, be sure to include `<head><meta charset="utf-8"></head>` in
|
|
@@ -163,8 +171,7 @@ User-visible changes in SES:
|
|
|
163
171
|
- Fix: `new Compartment(null, null, options)` no longer throws.
|
|
164
172
|
- New lockdown option: `overrideDebug: [...props]` to detect where a property
|
|
165
173
|
assignment needs to be turned into a `defineProperty` to avoid the override
|
|
166
|
-
mistake.
|
|
167
|
-
['constructor']`.
|
|
174
|
+
mistake. Most useful as `overrideTaming: 'severe', overrideDebug: ['constructor']`.
|
|
168
175
|
- We reopened Safari bug
|
|
169
176
|
[Object.defineProperties triggering a setter](https://bugs.webkit.org/show_bug.cgi?id=222538#c17)
|
|
170
177
|
when we found that it was causing an infinite recursion initializing SES
|
|
@@ -237,18 +244,17 @@ User-visible changes in SES:
|
|
|
237
244
|
|
|
238
245
|
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
246
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
247
|
+
```js
|
|
248
|
+
assert(false, X`literal part ${secretData} with ${q(publicData)}.`);
|
|
249
|
+
```
|
|
243
250
|
|
|
244
251
|
acts like
|
|
245
252
|
|
|
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`.
|
|
253
|
+
```js
|
|
254
|
+
assert(false, X`literal part ${q(secretData)} with ${q(publicData)}.`);
|
|
255
|
+
```
|
|
251
256
|
|
|
257
|
+
Note that the information rendered by the SES shim `console` object always includes all the unredacted data independent of the setting of `errorTaming`.
|
|
252
258
|
|
|
253
259
|
# 0.12.3 (2021-03-01)
|
|
254
260
|
|
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)=> {
|
|
@@ -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)=> {
|
|
@@ -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(
|