ses 0.15.22 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,49 @@
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.16.0](https://github.com/endojs/endo/compare/ses@0.15.23...ses@0.16.0) (2022-10-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add links to resources and community portals ([b0fef82](https://github.com/endojs/endo/commit/b0fef82192d476c43e9e10d5ad696cdad5bcb0b5))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **ses:** Fail safe when getOwnPropertyDescriptor reports absence of a known property ([5fa3b50](https://github.com/endojs/endo/commit/5fa3b506dc3d8826d0d213a9514e554986823a1d))
17
+ * **ses:** Harden all non-integer typed array properties, even if canonical ([88cab0b](https://github.com/endojs/endo/commit/88cab0be4cf816dc578f2ff441fd9bcda0aa5cf5))
18
+ * **ses:** Lock down all typed array expando properties ([dc82f5d](https://github.com/endojs/endo/commit/dc82f5d2908b3507965562c7c1b3bf12d852af8f))
19
+ * minor improvements to some override comments ([#1327](https://github.com/endojs/endo/issues/1327)) ([678285a](https://github.com/endojs/endo/commit/678285a3345adec894f265ba56c2fa6636f846b8))
20
+ * **marshal:** Return a special error message from passStyleOf(typedArray) ([dbd498e](https://github.com/endojs/endo/commit/dbd498e30a5c3b0d2713d863bc7479ceef39cd79)), closes [#1326](https://github.com/endojs/endo/issues/1326)
21
+ * delete broken objectFromEntries ([#1306](https://github.com/endojs/endo/issues/1306)) ([d83be67](https://github.com/endojs/endo/commit/d83be675d23a928f287d6d9118f7258f0abd855a))
22
+ * **ses:** expand the scope this-value test ([3d50c1a](https://github.com/endojs/endo/commit/3d50c1ac073250406a8b38735610ca6d86fdd680))
23
+ * **ses:** Fix incompatible spelling ([c32fdf1](https://github.com/endojs/endo/commit/c32fdf10bdc1a21096ba190c384fa9f08f85f1f3))
24
+ * **ses:** scope tests - expand Symbol.unscopables fidelity test ([bb542f7](https://github.com/endojs/endo/commit/bb542f78a1520a8e54e981d224dee28b171518d6))
25
+ * **ses:** scope tests - expand Symbolunscopables fidelity test ([c603c5a](https://github.com/endojs/endo/commit/c603c5aa4a1ba271cf17d754df789a52aa7debfb))
26
+ * **ses:** scope tests - move teardown into ava teardown call ([e59f682](https://github.com/endojs/endo/commit/e59f6829e3061adcd8fbf78cde84cf3f9abc5bf8))
27
+ * **ses:** scope tests - rename variables to match purpose ([18d64c3](https://github.com/endojs/endo/commit/18d64c31315e47c798443f78a3bcfb77f4698366))
28
+ * **ses:** this-value scope test includes optimizable props ([9c3fea3](https://github.com/endojs/endo/commit/9c3fea3dfd2d72f0fc13455bc1e54de455ead83e))
29
+ * **ses:** this-value scope test includes unscopables fidelity test ([0be95ac](https://github.com/endojs/endo/commit/0be95acdb9a5251d1c37061bb5ae59180e298f65))
30
+
31
+
32
+
33
+ ### [0.15.23](https://github.com/endojs/endo/compare/ses@0.15.22...ses@0.15.23) (2022-09-27)
34
+
35
+
36
+ ### Features
37
+
38
+ * **ses:** improve performance of uncurryThis ([b1ad60a](https://github.com/endojs/endo/commit/b1ad60ae89545499d6cbcaa3812118ac4229d83c))
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * add a do-nothing SharedError.prepareStackTrace ([#1290](https://github.com/endojs/endo/issues/1290)) ([705aef2](https://github.com/endojs/endo/commit/705aef24f34bb9794f0aa807d567b3efbf0c23af))
44
+ * **ses:** report unhandled promise rejection when collected ([dae7235](https://github.com/endojs/endo/commit/dae7235011da907823c27ca5dfb9ed72519a4062))
45
+ * **ses:** uncurryThis type fixes ([feb062c](https://github.com/endojs/endo/commit/feb062c56ee05b12657596defce68107894bafd4))
46
+
47
+
48
+
6
49
  ### [0.15.22](https://github.com/endojs/endo/compare/ses@0.15.21...ses@0.15.22) (2022-09-14)
7
50
 
8
51
 
package/NEWS.md CHANGED
@@ -1,5 +1,18 @@
1
1
  User-visible changes in SES:
2
2
 
3
+ # v0.16.0 (2022-10-19)
4
+
5
+ - When hardening a typed array, detects and locks down properties named as
6
+ number-coercible strings that are not index properties.
7
+
8
+ # v0.15.23 (2022-09-27)
9
+
10
+ - Fixes the unhandled promise rejection logic to report unhandled rejections
11
+ when the promise is collected. Because of a bug it previously only reported
12
+ at process exit.
13
+ - Improves the fidelity of emulation for V8 `Error.prepareStackTrace`,
14
+ allowing more legacy code to work by default in isolation.
15
+
3
16
  # v0.15.18 (2022-08-23)
4
17
 
5
18
  - Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
@@ -45,7 +58,7 @@ User-visible changes in SES:
45
58
 
46
59
  # 0.15.0 (2021-11-02)
47
60
 
48
- - *BREAKING CHANGE*: The lockdown option `domainTaming` is now `safe` by
61
+ - _BREAKING CHANGE_: The lockdown option `domainTaming` is now `safe` by
49
62
  default, which will break any application that depends transtively on the
50
63
  Node.js `domain` module.
51
64
  Notably, [standard-things/esm](https://github.com/standard-things/esm)
@@ -53,10 +66,11 @@ User-visible changes in SES:
53
66
 
54
67
  This protects against the unhardened `domain` property appearing on shared
55
68
  objects like callbacks and promises.
56
- This overcomes the last *known* obstacle toward object capability containment.
69
+ This overcomes the last _known_ obstacle toward object capability containment.
70
+
57
71
  - Lockdown will now read options from the environment as defined by the Node.js
58
72
  `process.env` parameter space.
59
- - *BREAKING CHANGE*: Lockdown may no longer be called more than once.
73
+ - _BREAKING CHANGE_: Lockdown may no longer be called more than once.
60
74
  Lockdown no longer returns a boolean to indicate whether it was effective
61
75
  (true) or redundant (false). Instead, Lockdown will return undefined for
62
76
  its first invocation or throw an error otherwise.
@@ -102,7 +116,7 @@ User-visible changes in SES:
102
116
 
103
117
  # 0.14.0 (2021-07-22)
104
118
 
105
- - *BREAKING*: Any precompiled static module records from prior versions
119
+ - _BREAKING_: Any precompiled static module records from prior versions
106
120
  will not load in this version of SES or beyond. The format of the preamble
107
121
  has been changed to admit the possibility of a variable named `Map` declared
108
122
  in the scope of a module.
@@ -119,8 +133,7 @@ User-visible changes in SES:
119
133
 
120
134
  # 0.13.4 (2021-06-19)
121
135
 
122
- - Adds more TypeScript definitions, importable with `/// <reference
123
- types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
136
+ - Adds more TypeScript definitions, importable with `/// <reference types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
124
137
  and many types importable with `import('ses')` notation.
125
138
  - Adds descriptive detail to module system link error messages and fixes the
126
139
  reported exports for one.
@@ -132,25 +145,25 @@ User-visible changes in SES:
132
145
 
133
146
  # 0.13.0 (2021-06-01)
134
147
 
135
- - *BREAKING CHANGE* The `ses/lockdown` module is again just `ses`.
148
+ - _BREAKING CHANGE_ The `ses/lockdown` module is again just `ses`.
136
149
  Instead of having a light 43KB `ses/lockdown` and a heavy 3.1MB `ses`, there
137
150
  is just a 52KB `ses` that has everything except `StaticModuleRecord`.
138
151
  For this release, there remains a `ses/lockdown` alias to `ses`.
139
- - *BREAKING CHANGE* Third-party static module interface implementations *must*
152
+ - _BREAKING CHANGE_ Third-party static module interface implementations _must_
140
153
  now explicitly list their exported names.
141
154
  For CommonJS, this implies using a heuristic static analysis of `exports`
142
155
  changes.
143
156
  Consequently, third-party modules can now participate in linkage with ESM
144
157
  including support for `export * from './spec.cjs'` and also named imports
145
158
  like `import * from './spec.cjs'`.
146
- - *BREAKING CHANGE* The `StaticModuleRecord` constructor has been removed in
159
+ - _BREAKING CHANGE_ The `StaticModuleRecord` constructor has been removed in
147
160
  favor of a duck-type for compiled static module records that is intrinsic to
148
161
  the shim and may be emulated by a third-party `StaticModuleRecord`
149
162
  constructor.
150
163
  The constructor must perform the module analysis and transform the source,
151
164
  and present this duck-type to the Compartment `importHook`.
152
165
  This relieves SES of a dependency on Babel and simplifies its API.
153
- - *BREAKING CHANGE* The UMD distribution of SES must have the UTF-8 charset.
166
+ - _BREAKING CHANGE_ The UMD distribution of SES must have the UTF-8 charset.
154
167
  The prior versions were accidentally ASCII, so SES would have worked
155
168
  in any web page, regardless of the charset.
156
169
  To remedy this, be sure to include `<head><meta charset="utf-8"></head>` in
@@ -163,8 +176,7 @@ User-visible changes in SES:
163
176
  - Fix: `new Compartment(null, null, options)` no longer throws.
164
177
  - New lockdown option: `overrideDebug: [...props]` to detect where a property
165
178
  assignment needs to be turned into a `defineProperty` to avoid the override
166
- mistake. Most useful as `overrideTaming: 'severe', overrideDebug:
167
- ['constructor']`.
179
+ mistake. Most useful as `overrideTaming: 'severe', overrideDebug: ['constructor']`.
168
180
  - We reopened Safari bug
169
181
  [Object.defineProperties triggering a setter](https://bugs.webkit.org/show_bug.cgi?id=222538#c17)
170
182
  when we found that it was causing an infinite recursion initializing SES
@@ -237,18 +249,17 @@ User-visible changes in SES:
237
249
 
238
250
  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
251
 
240
- ```js
241
- assert(false, X`literal part ${secretData} with ${q(publicData)}.`);
242
- ```
252
+ ```js
253
+ assert(false, X`literal part ${secretData} with ${q(publicData)}.`);
254
+ ```
243
255
 
244
256
  acts like
245
257
 
246
- ```js
247
- assert(false, X`literal part ${q(secretData)} with ${q(publicData)}.`);
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`.
258
+ ```js
259
+ assert(false, X`literal part ${q(secretData)} with ${q(publicData)}.`);
260
+ ```
251
261
 
262
+ Note that the information rendered by the SES shim `console` object always includes all the unredacted data independent of the setting of `errorTaming`.
252
263
 
253
264
  # 0.12.3 (2021-03-01)
254
265
 
package/README.md CHANGED
@@ -32,6 +32,19 @@ SES starts where the Caja project left off
32
32
  https://github.com/google/caja/wiki/SES, and goes on to introduce compartments
33
33
  and modernize the permitted JavaScript features.
34
34
 
35
+ Please join the conversation on our [Mailing List][SES Strategy Group] and
36
+ [Matrix][Endo Matrix].
37
+ We record a [weekly conference call][SES Strategy Recordings] with the Hardened
38
+ JavaScript engineering community.
39
+
40
+ _Hardened JavaScript_, Kris Kowal:
41
+
42
+ [![Primer on Hardened JavaScript](https://img.youtube.com/vi/RoodZSIL-DE/0.jpg)](https://www.youtube.com/watch?v=RoodZSIL-DE)
43
+
44
+ _Don't add Security, Remove Insecurity_, Mark Miller:
45
+
46
+ [![Don't add Security, Remove Insecurity](https://img.youtube.com/vi/u-XETUbxNUU/0.jpg)](https://www.youtube.com/watch?v=u-XETUbxNUU)
47
+
35
48
  ## Install
36
49
 
37
50
  ```sh
@@ -689,7 +702,11 @@ report available on the
689
702
  [Agoric blog](https://agoric.com/blog/technology/metamask-agoric-hardened-js-security-review/)
690
703
  that includes links to recordings of code walk-throughs and technical
691
704
  discussion, and issues are tagged
692
- [audit-SEStival](https://github.com/endojs/endo/labels/audit-sestival).
705
+ [audit-SEStival](https://github.com/endojs/endo/issues?q=label%3Aaudit-sestival).
706
+ The [video recordings of the MetaMask and Agoric collaborative
707
+ review](https://www.youtube.com/playlist?list=PLzDw4TTug5O2d1XOdB7VNCZbIxRZu3gov).
708
+ provide useful background for future audits, reviews, and for learning more
709
+ about how the `ses` shim constructs a Hardened JavaScript environment.
693
710
 
694
711
  In addition to vulnerability assessments, active efforts to [formally verify
695
712
  the Agoric kernel](https://agoric.com/blog/technology/the-path-to-verified-blds-how-informal-systems-and-agoric-are-using-formal-methods-analysis-to-improve-software-integrity/)
@@ -711,3 +728,7 @@ For non-security bugs, please use the [regular Issues page][SES Issues].
711
728
  [SES proposal]: https://github.com/tc39/proposal-ses
712
729
  [SECURITY.md]: https://github.com/endojs/endo/blob/master/packages/ses/SECURITY.md
713
730
  [SES Issues]: https://github.com/endojs/endo/issues
731
+ [SES Strategy Group]: https://groups.google.com/g/ses-strategy
732
+ [SES Strategy Recordings]: https://www.youtube.com/playlist?list=PLzDw4TTug5O1jzKodRDp3qec8zl88oxGd
733
+ [Endo Matrix]: https://matrix.to/#/#endojs:matrix.org
734
+
package/dist/lockdown.cjs CHANGED
@@ -69,8 +69,9 @@ const {
69
69
  seal,
70
70
  preventExtensions,
71
71
  setPrototypeOf,
72
- values}=
73
- Object;$h‍_once.assign(assign);$h‍_once.create(create);$h‍_once.defineProperties(defineProperties);$h‍_once.entries(entries);$h‍_once.freeze(freeze);$h‍_once.getOwnPropertyDescriptor(getOwnPropertyDescriptor);$h‍_once.getOwnPropertyDescriptors(getOwnPropertyDescriptors);$h‍_once.getOwnPropertyNames(getOwnPropertyNames);$h‍_once.getPrototypeOf(getPrototypeOf);$h‍_once.is(is);$h‍_once.isExtensible(isExtensible);$h‍_once.keys(keys);$h‍_once.objectPrototype(objectPrototype);$h‍_once.seal(seal);$h‍_once.preventExtensions(preventExtensions);$h‍_once.setPrototypeOf(setPrototypeOf);$h‍_once.values(values);
72
+ values,
73
+ fromEntries}=
74
+ Object;$h‍_once.assign(assign);$h‍_once.create(create);$h‍_once.defineProperties(defineProperties);$h‍_once.entries(entries);$h‍_once.freeze(freeze);$h‍_once.getOwnPropertyDescriptor(getOwnPropertyDescriptor);$h‍_once.getOwnPropertyDescriptors(getOwnPropertyDescriptors);$h‍_once.getOwnPropertyNames(getOwnPropertyNames);$h‍_once.getPrototypeOf(getPrototypeOf);$h‍_once.is(is);$h‍_once.isExtensible(isExtensible);$h‍_once.keys(keys);$h‍_once.objectPrototype(objectPrototype);$h‍_once.seal(seal);$h‍_once.preventExtensions(preventExtensions);$h‍_once.setPrototypeOf(setPrototypeOf);$h‍_once.values(values);$h‍_once.fromEntries(fromEntries);
74
75
 
75
76
  const {
76
77
  species: speciesSymbol,
@@ -85,24 +86,8 @@ const { isInteger}= Number;$h‍_once.isInteger(isInteger);
85
86
 
86
87
  const { stringify: stringifyJson}= JSON;
87
88
 
88
- // At time of this writing, we still support Node 10 which doesn't have
89
- // `Object.fromEntries`. If it is absent, this should be an adequate
90
- // replacement.
91
- // By the terminology of https://ponyfoo.com/articles/polyfills-or-ponyfills
92
- // it is a ponyfill rather than a polyfill or shim because we do not
93
- // install it on `Object`.
94
- $h‍_once.stringifyJson(stringifyJson);const objectFromEntries=(entryPairs)=>{
95
- const result= {};
96
- for( const [prop, val]of entryPairs) {
97
- result[prop]= val;
98
- }
99
- return result;
100
- };
101
-
102
- const fromEntries= Object.fromEntries|| objectFromEntries;
103
-
104
89
  // Needed only for the Safari bug workaround below
105
- $h‍_once.fromEntries(fromEntries);const{defineProperty:originalDefineProperty}=Object;
90
+ $h‍_once.stringifyJson(stringifyJson);const{defineProperty:originalDefineProperty}=Object;
106
91
 
107
92
  const defineProperty= (object, prop, descriptor)=> {
108
93
  // We used to do the following, until we had to reopen Safari bug
@@ -147,35 +132,32 @@ const { prototype: weaksetPrototype}= WeakSet;$h‍_once.weaksetPrototy
147
132
  const { prototype: functionPrototype}= Function;$h‍_once.functionPrototype(functionPrototype);
148
133
  const { prototype: promisePrototype}= Promise;$h‍_once.promisePrototype(promisePrototype);
149
134
 
150
- const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);
135
+ const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);$h‍_once.typedArrayPrototype(typedArrayPrototype);
151
136
 
137
+ const { bind}= functionPrototype;
152
138
  /**
153
139
  * uncurryThis()
154
- * This form of uncurry uses Reflect.apply()
155
- *
156
- * The original uncurry uses:
157
- * const bind = Function.prototype.bind;
158
- * const uncurryThis = bind.bind(bind.call);
140
+ * Equivalent of: fn => (thisArg, ...args) => apply(fn, thisArg, args)
159
141
  *
160
142
  * See those reference for a complete explanation:
161
143
  * http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
162
144
  * which only lives at
163
145
  * http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
164
146
  *
165
- * @template {Function} F
166
- * @param {F} fn
167
- * returns {(thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>}
168
- */$h‍_once.typedArrayPrototype(typedArrayPrototype);
169
- const uncurryThis= (fn)=>(thisArg, ...args)=> apply(fn, thisArg, args);$h‍_once.uncurryThis(uncurryThis);
170
-
147
+ * @type {<F extends (this: any, ...args: any[]) => any>(fn: F) => ((thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>)}
148
+ */
149
+ const uncurryThis= bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
150
+ $h‍_once.uncurryThis(uncurryThis);
171
151
  const objectHasOwnProperty= uncurryThis(objectPrototype.hasOwnProperty);
172
152
  //
173
153
  $h‍_once.objectHasOwnProperty(objectHasOwnProperty);const arrayFilter=uncurryThis(arrayPrototype.filter);$h‍_once.arrayFilter(arrayFilter);
174
154
  const arrayForEach= uncurryThis(arrayPrototype.forEach);$h‍_once.arrayForEach(arrayForEach);
175
155
  const arrayIncludes= uncurryThis(arrayPrototype.includes);$h‍_once.arrayIncludes(arrayIncludes);
176
- const arrayJoin= uncurryThis(arrayPrototype.join);$h‍_once.arrayJoin(arrayJoin);
156
+ const arrayJoin= uncurryThis(arrayPrototype.join);
157
+ /** @type {<T, U>(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]} */$h‍_once.arrayJoin(arrayJoin);
177
158
  const arrayMap= uncurryThis(arrayPrototype.map);$h‍_once.arrayMap(arrayMap);
178
- const arrayPop= uncurryThis(arrayPrototype.pop);$h‍_once.arrayPop(arrayPop);
159
+ const arrayPop= uncurryThis(arrayPrototype.pop);
160
+ /** @type {<T>(thisArg: T[], ...items: T[]) => number} */$h‍_once.arrayPop(arrayPop);
179
161
  const arrayPush= uncurryThis(arrayPrototype.push);$h‍_once.arrayPush(arrayPush);
180
162
  const arraySlice= uncurryThis(arrayPrototype.slice);$h‍_once.arraySlice(arraySlice);
181
163
  const arraySome= uncurryThis(arrayPrototype.some);$h‍_once.arraySome(arraySome);
@@ -202,10 +184,17 @@ const matchAllRegExp= uncurryThis(regexpPrototype[matchAllSymbol]);
202
184
  $h‍_once.matchAllRegExp(matchAllRegExp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h‍_once.stringEndsWith(stringEndsWith);
203
185
  const stringIncludes= uncurryThis(stringPrototype.includes);$h‍_once.stringIncludes(stringIncludes);
204
186
  const stringIndexOf= uncurryThis(stringPrototype.indexOf);$h‍_once.stringIndexOf(stringIndexOf);
205
- const stringMatch= uncurryThis(stringPrototype.match);$h‍_once.stringMatch(stringMatch);
187
+ const stringMatch= uncurryThis(stringPrototype.match);
188
+ /**
189
+ * @type {
190
+ * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) |
191
+ * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string)
192
+ * }
193
+ */$h‍_once.stringMatch(stringMatch);
206
194
  const stringReplace= uncurryThis(stringPrototype.replace);$h‍_once.stringReplace(stringReplace);
207
195
  const stringSearch= uncurryThis(stringPrototype.search);$h‍_once.stringSearch(stringSearch);
208
- const stringSlice= uncurryThis(stringPrototype.slice);$h‍_once.stringSlice(stringSlice);
196
+ const stringSlice= uncurryThis(stringPrototype.slice);
197
+ /** @type {(thisArg: string, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[]} */$h‍_once.stringSlice(stringSlice);
209
198
  const stringSplit= uncurryThis(stringPrototype.split);$h‍_once.stringSplit(stringSplit);
210
199
  const stringStartsWith= uncurryThis(stringPrototype.startsWith);$h‍_once.stringStartsWith(stringStartsWith);
211
200
  const iterateString= uncurryThis(stringPrototype[iteratorSymbol]);
@@ -224,7 +213,8 @@ $h‍_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPro
224
213
  //
225
214
  $h‍_once.functionToString(functionToString);const{all}=Promise;
226
215
  const promiseAll= (promises)=>apply(all, Promise, [promises]);$h‍_once.promiseAll(promiseAll);
227
- const promiseCatch= uncurryThis(promisePrototype.catch);$h‍_once.promiseCatch(promiseCatch);
216
+ const promiseCatch= uncurryThis(promisePrototype.catch);
217
+ /** @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
218
  const promiseThen= uncurryThis(promisePrototype.then);
229
219
  //
230
220
  $h‍_once.promiseThen(promiseThen);const finalizationRegistryRegister=
@@ -412,7 +402,7 @@ const noEvalEvaluate= ()=> {
412
402
  /**
413
403
  * Joins English terms with commas and an optional conjunction.
414
404
  *
415
- * @param {string[]} terms
405
+ * @param {(string | StringablePayload)[]} terms
416
406
  * @param {"and" | "or"} conjunction
417
407
  */
418
408
  const enJoin= (terms, conjunction)=> {
@@ -5318,7 +5308,10 @@ const CompartmentPrototype= {
5318
5308
  ()=> {
5319
5309
  // The namespace box is a contentious design and likely to be a breaking
5320
5310
  // change in an appropriately numbered future version.
5321
- const namespace= compartmentImportNow(this, specifier);
5311
+ const namespace= compartmentImportNow(
5312
+ /** @type {Compartment} */ this,
5313
+ specifier);
5314
+
5322
5315
  return { namespace};
5323
5316
  });
5324
5317
 
@@ -5341,7 +5334,7 @@ const CompartmentPrototype= {
5341
5334
 
5342
5335
  assertModuleHooks(this);
5343
5336
 
5344
- return compartmentImportNow(this, specifier);
5337
+ return compartmentImportNow(/** @type {Compartment} */ this, specifier);
5345
5338
  }};$h‍_once.CompartmentPrototype(CompartmentPrototype);
5346
5339
 
5347
5340
 
@@ -5837,22 +5830,27 @@ const severeEnablements= {
5837
5830
  ...moderateEnablements,
5838
5831
 
5839
5832
  /**
5840
- * Rollup(as used at least by vega) and webpack
5833
+ * Rollup (as used at least by vega) and webpack
5841
5834
  * (as used at least by regenerator) both turn exports into assignments
5842
5835
  * to a big `exports` object that inherits directly from
5843
- * `Object.prototype`.Some of the exported names we've seen include
5836
+ * `Object.prototype`. Some of the exported names we've seen include
5844
5837
  * `hasOwnProperty`, `constructor`, and `toString`. But the strategy used
5845
- * by rollup and webpack means potentionally turns any exported name
5846
- * into an assignment rejected by the override mistake.That's why
5847
- * we take the extreme step of enabling everything on`Object.prototype`.
5838
+ * by rollup and webpack potentionally turns any exported name
5839
+ * into an assignment rejected by the override mistake. That's why
5840
+ * the `severe` enablements takes the extreme step of enabling
5841
+ * everything on `Object.prototype`.
5848
5842
  *
5849
5843
  * In addition, code doing inheritance manually will often override
5850
5844
  * the `constructor` property on the new prototype by assignment. We've
5851
5845
  * seen this several times.
5852
5846
  *
5853
5847
  * The cost of enabling all these is that they create a miserable debugging
5854
- * experience. https://github.com/Agoric/agoric-sdk/issues/2324 explains
5855
- * how it confused the Node console.
5848
+ * experience specifically on Node.
5849
+ * https://github.com/Agoric/agoric-sdk/issues/2324
5850
+ * explains how it confused the Node console.
5851
+ *
5852
+ * (TODO Reexamine the vscode situation. I think it may have improved
5853
+ * since the following paragraph was written.)
5856
5854
  *
5857
5855
  * The vscode debugger's object inspector shows the own data properties of
5858
5856
  * an object, which is typically what you want, but also shows both getter
@@ -5869,8 +5867,8 @@ const severeEnablements= {
5869
5867
  * The widely used Buffer defined at https://github.com/feross/buffer
5870
5868
  * on initialization, manually creates the equivalent of a subclass of
5871
5869
  * `TypedArray`, which it then initializes by assignment. These assignments
5872
- * include enough of the `TypeArray` methods that here, we just enable
5873
- * them all.
5870
+ * include enough of the `TypeArray` methods that here, the `severe`
5871
+ * enablements just enable them all.
5874
5872
  */
5875
5873
  '%TypedArrayPrototype%': '*'};$h‍_once.severeEnablements(severeEnablements);
5876
5874
  })
@@ -6539,9 +6537,9 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6539
6537
  const levelMethod= (...logArgs)=> {
6540
6538
  const subErrors= [];
6541
6539
  const argTags= extractErrorArgs(logArgs, subErrors);
6542
- // @ts-ignore
6543
6540
  // eslint-disable-next-line @endo/no-polymorphic-call
6544
6541
  baseConsole[level](...argTags);
6542
+ // @ts-expect-error ConsoleProp vs LogSeverity mismatch
6545
6543
  logSubErrors(level, subErrors);
6546
6544
  };
6547
6545
  defineProperty(levelMethod, 'name', { value: level});
@@ -6666,7 +6664,7 @@ const makeRejectionHandlers= (reportReason)=>{
6666
6664
  * @param {ReasonId} heldReasonId
6667
6665
  */
6668
6666
  const finalizeDroppedPromise= (heldReasonId)=>{
6669
- if( mapHas(idToReason)) {
6667
+ if( mapHas(idToReason, heldReasonId)) {
6670
6668
  const reason= mapGet(idToReason, heldReasonId);
6671
6669
  removeReasonId(heldReasonId);
6672
6670
  reportReason(reason);
@@ -7209,7 +7207,8 @@ const tameV8ErrorConstructor= (
7209
7207
  })
7210
7208
  ,
7211
7209
  // === 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)]]]]]);
7210
+ (({ 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)]]]]]);
7211
+
7213
7212
 
7214
7213
 
7215
7214
 
@@ -7348,6 +7347,39 @@ function tameErrorConstructor(
7348
7347
 
7349
7348
 
7350
7349
 
7350
+ if( platform=== 'v8') {
7351
+ // `SharedError.prepareStackTrace`, if it exists, must also be
7352
+ // powerless. However, from what we've heard, depd expects to be able to
7353
+ // assign to it without the assignment throwing. It is normally a function
7354
+ // that returns a stack string to be magically added to error objects.
7355
+ // However, as long as we're adding a lenient standin, we may as well
7356
+ // accommodate any who expect to get a function they can call and get
7357
+ // a string back. This prepareStackTrace is a do-nothing function that
7358
+ // always returns the empty string.
7359
+ defineProperties(SharedError, {
7360
+ prepareStackTrace: {
7361
+ get() {
7362
+ return ()=> '';
7363
+ },
7364
+ set(_prepareFn) {
7365
+ // do nothing
7366
+ },
7367
+ enumerable: false,
7368
+ configurable: true},
7369
+
7370
+ captureStackTrace: {
7371
+ value: (errorish, _constructorOpt)=> {
7372
+ defineProperty(errorish, 'stack', {
7373
+ value: ''});
7374
+
7375
+ },
7376
+ writable: false,
7377
+ enumerable: false,
7378
+ configurable: true}});
7379
+
7380
+
7381
+ }
7382
+
7351
7383
  let initialGetStackString= tamedMethods.getStackString;
7352
7384
  if( platform=== 'v8') {
7353
7385
  initialGetStackString= tameV8ErrorConstructor(
@@ -7638,40 +7670,52 @@ const getTypedArrayToStringTag= typedArrayToStringTag.get;
7638
7670
  assert(getTypedArrayToStringTag);
7639
7671
 
7640
7672
  // Exported for tests.
7641
- /** @param {unknown} object */
7673
+ /**
7674
+ * Duplicates packages/marshal/src/helpers/passStyle-helpers.js to avoid a dependency.
7675
+ *
7676
+ * @param {unknown} object
7677
+ */
7642
7678
  const isTypedArray= (object)=>{
7643
7679
  // The object must pass a brand check or toStringTag will return undefined.
7644
7680
  const tag= apply(getTypedArrayToStringTag, object, []);
7645
7681
  return tag!== undefined;
7646
7682
  };
7647
7683
 
7684
+ /**
7685
+ * Tests if a property key is an integer-valued canonical numeric index.
7686
+ * https://tc39.es/ecma262/#sec-canonicalnumericindexstring
7687
+ *
7688
+ * @param {string | symbol} propertyKey
7689
+ */$h‍_once.isTypedArray(isTypedArray);
7690
+ const isCanonicalIntegerIndexString= (propertyKey)=>{
7691
+ const n= +String(propertyKey);
7692
+ return isInteger(n)&& String(n)=== propertyKey;
7693
+ };
7694
+
7648
7695
  /**
7649
7696
  * @template T
7650
7697
  * @param {ArrayLike<T>} array
7651
- */$h‍_once.isTypedArray(isTypedArray);
7698
+ */
7652
7699
  const freezeTypedArray= (array)=>{
7653
- const descs= getOwnPropertyDescriptors(array);
7654
-
7655
7700
  preventExtensions(array);
7656
7701
 
7657
7702
  // Downgrade writable expandos to readonly, even if non-configurable.
7658
- arrayForEach(ownKeys(descs), (/** @type {string | symbol} */ name)=> {
7659
- const desc= descs[/** @type {string} */ name];
7660
- // The numbered properties are writable and non-configurable,
7661
- // and cannot be made non-writable by defineProperty.
7662
- // This is a strange behavior intrinsic to TypedArrays, but no more harmful
7663
- // than the mutability of properties of a hardened Map or Set,
7664
- // so we carve out this exceptional behavior.
7665
- //
7666
- // TypedArrays are integer-indexed exotic objects, so indexed properties
7667
- // outside the range of 0 to the typed array's length are disallowed.
7668
- // Assignment to these indexes silently fails and defining an indexed
7669
- // property throws an error.
7670
- // So, we only need to make non-index properties non-writable and
7671
- // non-configurable.
7703
+ // We get each descriptor individually rather than using
7704
+ // getOwnPropertyDescriptors in order to fail safe when encountering
7705
+ // an obscure GraalJS issue where getOwnPropertyDescriptor returns
7706
+ // undefined for a property that does exist.
7707
+ arrayForEach(ownKeys(array), (/** @type {string | symbol} */ name)=> {
7708
+ const desc= getOwnPropertyDescriptor(array, name);
7709
+ assert(desc);
7710
+ // TypedArrays are integer-indexed exotic objects, which define special
7711
+ // treatment for property names in canonical numeric form:
7712
+ // integers in range are permanently writable and non-configurable.
7672
7713
  // https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects
7673
- const number= +String(name);
7674
- if( !isInteger(number)) {
7714
+ //
7715
+ // This is analogous to the data of a hardened Map or Set,
7716
+ // so we carve out this exceptional behavior but make all other
7717
+ // properties non-configurable.
7718
+ if( !isCanonicalIntegerIndexString(name)) {
7675
7719
  defineProperty(array, name, {
7676
7720
  ...desc,
7677
7721
  writable: false,
@@ -9167,6 +9211,7 @@ assign(globalThis, {
9167
9211
  preventExtensions: cell("preventExtensions"),
9168
9212
  setPrototypeOf: cell("setPrototypeOf"),
9169
9213
  values: cell("values"),
9214
+ fromEntries: cell("fromEntries"),
9170
9215
  speciesSymbol: cell("speciesSymbol"),
9171
9216
  toStringTagSymbol: cell("toStringTagSymbol"),
9172
9217
  iteratorSymbol: cell("iteratorSymbol"),
@@ -9175,7 +9220,6 @@ assign(globalThis, {
9175
9220
  symbolFor: cell("symbolFor"),
9176
9221
  isInteger: cell("isInteger"),
9177
9222
  stringifyJson: cell("stringifyJson"),
9178
- fromEntries: cell("fromEntries"),
9179
9223
  defineProperty: cell("defineProperty"),
9180
9224
  apply: cell("apply"),
9181
9225
  construct: cell("construct"),
@@ -9483,6 +9527,7 @@ assign(globalThis, {
9483
9527
  preventExtensions: cells[0].preventExtensions.set,
9484
9528
  setPrototypeOf: cells[0].setPrototypeOf.set,
9485
9529
  values: cells[0].values.set,
9530
+ fromEntries: cells[0].fromEntries.set,
9486
9531
  speciesSymbol: cells[0].speciesSymbol.set,
9487
9532
  toStringTagSymbol: cells[0].toStringTagSymbol.set,
9488
9533
  iteratorSymbol: cells[0].iteratorSymbol.set,
@@ -9491,7 +9536,6 @@ assign(globalThis, {
9491
9536
  symbolFor: cells[0].symbolFor.set,
9492
9537
  isInteger: cells[0].isInteger.set,
9493
9538
  stringifyJson: cells[0].stringifyJson.set,
9494
- fromEntries: cells[0].fromEntries.set,
9495
9539
  defineProperty: cells[0].defineProperty.set,
9496
9540
  apply: cells[0].apply.set,
9497
9541
  construct: cells[0].construct.set,