ses 0.15.13 → 0.15.16

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/dist/ses.mjs CHANGED
@@ -24,6 +24,7 @@ const universalThis= globalThis;$h‍_once.universalThis(universalThis);
24
24
  const {
25
25
  Array,
26
26
  Date,
27
+ FinalizationRegistry,
27
28
  Float32Array,
28
29
  JSON,
29
30
  Map,
@@ -38,7 +39,7 @@ const {
38
39
  String,
39
40
  WeakMap,
40
41
  WeakSet}=
41
- globalThis;$h‍_once.Array(Array);$h‍_once.Date(Date);$h‍_once.Float32Array(Float32Array);$h‍_once.JSON(JSON);$h‍_once.Map(Map);$h‍_once.Math(Math);$h‍_once.Number(Number);$h‍_once.Object(Object);$h‍_once.Promise(Promise);$h‍_once.Proxy(Proxy);$h‍_once.Reflect(Reflect);$h‍_once.FERAL_REG_EXP(FERAL_REG_EXP);$h‍_once.Set(Set);$h‍_once.String(String);$h‍_once.WeakMap(WeakMap);$h‍_once.WeakSet(WeakSet);
42
+ globalThis;$h‍_once.Array(Array);$h‍_once.Date(Date);$h‍_once.FinalizationRegistry(FinalizationRegistry);$h‍_once.Float32Array(Float32Array);$h‍_once.JSON(JSON);$h‍_once.Map(Map);$h‍_once.Math(Math);$h‍_once.Number(Number);$h‍_once.Object(Object);$h‍_once.Promise(Promise);$h‍_once.Proxy(Proxy);$h‍_once.Reflect(Reflect);$h‍_once.FERAL_REG_EXP(FERAL_REG_EXP);$h‍_once.Set(Set);$h‍_once.String(String);$h‍_once.WeakMap(WeakMap);$h‍_once.WeakSet(WeakSet);
42
43
 
43
44
  const {
44
45
  // The feral Error constructor is safe for internal use, but must not be
@@ -161,7 +162,9 @@ const typedArrayPrototype= getPrototypeOf(Uint8Array.prototype);
161
162
  * which only lives at
162
163
  * http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
163
164
  *
164
- * @param {(thisArg: Object, ...args: any[]) => any} fn
165
+ * @template {Function} F
166
+ * @param {F} fn
167
+ * returns {(thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>}
165
168
  */$h‍_once.typedArrayPrototype(typedArrayPrototype);
166
169
  const uncurryThis= (fn)=>(thisArg, ...args)=> apply(fn, thisArg, args);$h‍_once.uncurryThis(uncurryThis);
167
170
 
@@ -182,6 +185,8 @@ const iterateArray= uncurryThis(arrayPrototype[iteratorSymbol]);
182
185
  $h‍_once.iterateArray(iterateArray);const mapSet=uncurryThis(mapPrototype.set);$h‍_once.mapSet(mapSet);
183
186
  const mapGet= uncurryThis(mapPrototype.get);$h‍_once.mapGet(mapGet);
184
187
  const mapHas= uncurryThis(mapPrototype.has);$h‍_once.mapHas(mapHas);
188
+ const mapDelete= uncurryThis(mapPrototype.delete);$h‍_once.mapDelete(mapDelete);
189
+ const mapEntries= uncurryThis(mapPrototype.entries);$h‍_once.mapEntries(mapEntries);
185
190
  const iterateMap= uncurryThis(mapPrototype[iteratorSymbol]);
186
191
  //
187
192
  $h‍_once.iterateMap(iterateMap);const setAdd=uncurryThis(setPrototype.add);$h‍_once.setAdd(setAdd);
@@ -205,7 +210,8 @@ const stringSplit= uncurryThis(stringPrototype.split);$h‍_once.stringS
205
210
  const stringStartsWith= uncurryThis(stringPrototype.startsWith);$h‍_once.stringStartsWith(stringStartsWith);
206
211
  const iterateString= uncurryThis(stringPrototype[iteratorSymbol]);
207
212
  //
208
- $h‍_once.iterateString(iterateString);const weakmapDelete=uncurryThis(weakmapPrototype.delete);$h‍_once.weakmapDelete(weakmapDelete);
213
+ $h‍_once.iterateString(iterateString);const weakmapDelete=uncurryThis(weakmapPrototype.delete);
214
+ /** @type {<K, V>(thisArg: WeakMap<K, V>, ...args: Parameters<WeakMap<K,V>['get']>) => ReturnType<WeakMap<K,V>['get']>} */$h‍_once.weakmapDelete(weakmapDelete);
209
215
  const weakmapGet= uncurryThis(weakmapPrototype.get);$h‍_once.weakmapGet(weakmapGet);
210
216
  const weakmapHas= uncurryThis(weakmapPrototype.has);$h‍_once.weakmapHas(weakmapHas);
211
217
  const weakmapSet= uncurryThis(weakmapPrototype.set);
@@ -220,13 +226,19 @@ $h‍_once.functionToString(functionToString);const{all}=Promise;
220
226
  const promiseAll= (promises)=>apply(all, Promise, [promises]);$h‍_once.promiseAll(promiseAll);
221
227
  const promiseCatch= uncurryThis(promisePrototype.catch);$h‍_once.promiseCatch(promiseCatch);
222
228
  const promiseThen= uncurryThis(promisePrototype.then);
229
+ //
230
+ $h‍_once.promiseThen(promiseThen);const finalizationRegistryRegister=
231
+ FinalizationRegistry&& uncurryThis(FinalizationRegistry.prototype.register);$h‍_once.finalizationRegistryRegister(finalizationRegistryRegister);
232
+ const finalizationRegistryUnregister=
233
+ FinalizationRegistry&&
234
+ uncurryThis(FinalizationRegistry.prototype.unregister);
223
235
 
224
236
  /**
225
237
  * getConstructorOf()
226
238
  * Return the constructor from an instance.
227
239
  *
228
240
  * @param {Function} fn
229
- */$h‍_once.promiseThen(promiseThen);
241
+ */$h‍_once.finalizationRegistryUnregister(finalizationRegistryUnregister);
230
242
  const getConstructorOf= (fn)=>
231
243
  reflectGet(getPrototypeOf(fn), 'constructor');
232
244
 
@@ -3017,7 +3029,7 @@ const whitelist= {
3017
3029
  // Seen on FF Nightly 88.0a1
3018
3030
  at: false,
3019
3031
  // Seen on FF and XS
3020
- stack: false,
3032
+ stack: accessor,
3021
3033
  // Superfluously present in some versions of V8.
3022
3034
  // https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
3023
3035
  cause: false},
@@ -5438,7 +5450,7 @@ const makeCompartmentConstructor= (
5438
5450
  assign(globalObject, endowments);
5439
5451
 
5440
5452
  weakmapSet(privateFields, this, {
5441
- name,
5453
+ name: `${name}`,
5442
5454
  globalTransforms,
5443
5455
  globalObject,
5444
5456
  knownScopeProxies,
@@ -6351,16 +6363,7 @@ const ErrorInfo= {
6351
6363
 
6352
6364
  freeze(ErrorInfo);
6353
6365
 
6354
- /**
6355
- * The error annotations are sent to the baseConsole by calling some level
6356
- * method. The 'debug' level seems best, because the Chrome console classifies
6357
- * `debug` as verbose and does not show it by default. But we keep it symbolic
6358
- * so we can change our mind. (On Node, `debug`, `log`, and `info` are aliases
6359
- * for the same function and so will behave the same there.)
6360
- */
6361
- const BASE_CONSOLE_LEVEL= 'debug';
6362
-
6363
- /** @type {MakeCausalConsole} */$h‍_once.BASE_CONSOLE_LEVEL(BASE_CONSOLE_LEVEL);
6366
+ /** @type {MakeCausalConsole} */
6364
6367
  const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6365
6368
  const {
6366
6369
  getStackString,
@@ -6386,34 +6389,36 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6386
6389
  };
6387
6390
 
6388
6391
  /**
6392
+ * @param {LogSeverity} severity
6389
6393
  * @param {Error} error
6390
6394
  * @param {ErrorInfoKind} kind
6391
6395
  * @param {readonly any[]} logArgs
6392
6396
  * @param {Array<Error>} subErrorsSink
6393
6397
  */
6394
- const logErrorInfo= (error, kind, logArgs, subErrorsSink)=> {
6398
+ const logErrorInfo= (severity, error, kind, logArgs, subErrorsSink)=> {
6395
6399
  const errorTag= tagError(error);
6396
6400
  const errorName=
6397
6401
  kind=== ErrorInfo.MESSAGE? `${errorTag}:`: `${errorTag} ${kind}`;
6398
6402
  const argTags= extractErrorArgs(logArgs, subErrorsSink);
6399
6403
  // eslint-disable-next-line @endo/no-polymorphic-call
6400
- baseConsole[BASE_CONSOLE_LEVEL](errorName, ...argTags);
6404
+ baseConsole[severity](errorName, ...argTags);
6401
6405
  };
6402
6406
 
6403
6407
  /**
6404
6408
  * Logs the `subErrors` within a group name mentioning `optTag`.
6405
6409
  *
6410
+ * @param {LogSeverity} severity
6406
6411
  * @param {Error[]} subErrors
6407
6412
  * @param {string | undefined} optTag
6408
6413
  * @returns {void}
6409
6414
  */
6410
- const logSubErrors= (subErrors, optTag= undefined)=> {
6415
+ const logSubErrors= (severity, subErrors, optTag= undefined)=> {
6411
6416
  if( subErrors.length=== 0) {
6412
6417
  return;
6413
6418
  }
6414
6419
  if( subErrors.length=== 1&& optTag=== undefined) {
6415
6420
  // eslint-disable-next-line no-use-before-define
6416
- logError(subErrors[0]);
6421
+ logError(severity, subErrors[0]);
6417
6422
  return;
6418
6423
  }
6419
6424
  let label;
@@ -6430,7 +6435,7 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6430
6435
  try {
6431
6436
  for( const subError of subErrors) {
6432
6437
  // eslint-disable-next-line no-use-before-define
6433
- logError(subError);
6438
+ logError(severity, subError);
6434
6439
  }
6435
6440
  }finally {
6436
6441
  // eslint-disable-next-line @endo/no-polymorphic-call
@@ -6440,19 +6445,20 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6440
6445
 
6441
6446
  const errorsLogged= new WeakSet();
6442
6447
 
6443
- /** @type {NoteCallback} */
6444
- const noteCallback= (error, noteLogArgs)=> {
6448
+ /** @type {(severity: LogSeverity) => NoteCallback} */
6449
+ const makeNoteCallback= (severity)=>(error, noteLogArgs)=> {
6445
6450
  const subErrors= [];
6446
6451
  // Annotation arrived after the error has already been logged,
6447
6452
  // so just log the annotation immediately, rather than remembering it.
6448
- logErrorInfo(error, ErrorInfo.NOTE, noteLogArgs, subErrors);
6449
- logSubErrors(subErrors, tagError(error));
6453
+ logErrorInfo(severity, error, ErrorInfo.NOTE, noteLogArgs, subErrors);
6454
+ logSubErrors(severity, subErrors, tagError(error));
6450
6455
  };
6451
6456
 
6452
6457
  /**
6458
+ * @param {LogSeverity} severity
6453
6459
  * @param {Error} error
6454
6460
  */
6455
- const logError= (error)=>{
6461
+ const logError= (severity, error)=> {
6456
6462
  if( weaksetHas(errorsLogged, error)) {
6457
6463
  return;
6458
6464
  }
@@ -6460,17 +6466,26 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6460
6466
  weaksetAdd(errorsLogged, error);
6461
6467
  const subErrors= [];
6462
6468
  const messageLogArgs= takeMessageLogArgs(error);
6463
- const noteLogArgsArray= takeNoteLogArgsArray(error, noteCallback);
6469
+ const noteLogArgsArray= takeNoteLogArgsArray(
6470
+ error,
6471
+ makeNoteCallback(severity));
6472
+
6464
6473
  // Show the error's most informative error message
6465
6474
  if( messageLogArgs=== undefined) {
6466
6475
  // If there is no message log args, then just show the message that
6467
6476
  // the error itself carries.
6468
6477
  // eslint-disable-next-line @endo/no-polymorphic-call
6469
- baseConsole[BASE_CONSOLE_LEVEL]( `${errorTag}:`,error.message);
6478
+ baseConsole[severity]( `${errorTag}:`,error.message);
6470
6479
  }else {
6471
6480
  // If there is one, we take it to be strictly more informative than the
6472
6481
  // message string carried by the error, so show it *instead*.
6473
- logErrorInfo(error, ErrorInfo.MESSAGE, messageLogArgs, subErrors);
6482
+ logErrorInfo(
6483
+ severity,
6484
+ error,
6485
+ ErrorInfo.MESSAGE,
6486
+ messageLogArgs,
6487
+ subErrors);
6488
+
6474
6489
  }
6475
6490
  // After the message but before any other annotations, show the stack.
6476
6491
  let stackString= getStackString(error);
@@ -6482,13 +6497,13 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6482
6497
  stackString+= '\n';
6483
6498
  }
6484
6499
  // eslint-disable-next-line @endo/no-polymorphic-call
6485
- baseConsole[BASE_CONSOLE_LEVEL](stackString);
6500
+ baseConsole[severity](stackString);
6486
6501
  // Show the other annotations on error
6487
6502
  for( const noteLogArgs of noteLogArgsArray) {
6488
- logErrorInfo(error, ErrorInfo.NOTE, noteLogArgs, subErrors);
6503
+ logErrorInfo(severity, error, ErrorInfo.NOTE, noteLogArgs, subErrors);
6489
6504
  }
6490
6505
  // explain all the errors seen in the messages already emitted.
6491
- logSubErrors(subErrors, errorTag);
6506
+ logSubErrors(severity, subErrors, errorTag);
6492
6507
  };
6493
6508
 
6494
6509
  const levelMethods= arrayMap(consoleLevelMethods, ([level, _])=> {
@@ -6501,7 +6516,7 @@ const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6501
6516
  // @ts-ignore
6502
6517
  // eslint-disable-next-line @endo/no-polymorphic-call
6503
6518
  baseConsole[level](...argTags);
6504
- logSubErrors(subErrors);
6519
+ logSubErrors(level, subErrors);
6505
6520
  };
6506
6521
  defineProperty(levelMethod, 'name', { value: level});
6507
6522
  return [level, freeze(levelMethod)];
@@ -6560,7 +6575,133 @@ freeze(filterConsole);
6560
6575
  })
6561
6576
  ,
6562
6577
  // === functors[26] ===
6563
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,globalThis,defaultHandler,makeCausalConsole;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
6578
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FinalizationRegistry,Map,mapGet,mapDelete,WeakMap,mapSet,finalizationRegistryRegister,weakmapSet,weakmapGet,mapEntries,mapHas;$h‍_imports([["../commons.js", [["FinalizationRegistry", [$h‍_a => (FinalizationRegistry = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapDelete", [$h‍_a => (mapDelete = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["finalizationRegistryRegister", [$h‍_a => (finalizationRegistryRegister = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["mapEntries", [$h‍_a => (mapEntries = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]]]]]);
6579
+
6580
+
6581
+
6582
+
6583
+
6584
+
6585
+
6586
+
6587
+
6588
+
6589
+
6590
+
6591
+
6592
+
6593
+ /**
6594
+ * Create rejection-tracking machinery compatible with Node.js and browsers.
6595
+ *
6596
+ * Note that modern browsers *prevent* access to the 'unhandledrejection' and
6597
+ * 'rejectionhandled' events needed:
6598
+ * - in cross-origin mode, like when served from file://
6599
+ * - in the browser console (interactively typed-in code)
6600
+ * - in the debugger
6601
+ *
6602
+ * Then, they just look like: `Uncaught (in promise) Error: ...` and don't
6603
+ * implement the machinery.
6604
+ *
6605
+ * The solution is to serve your web page from an http:// or https:// web server
6606
+ * and execute actual code.
6607
+ *
6608
+ * @param {(reason: unknown) => void} reportReason report the reason for an
6609
+ * unhandled rejection.
6610
+ */
6611
+ const makeRejectionHandlers= (reportReason)=>{
6612
+ if( FinalizationRegistry=== undefined) {
6613
+ return undefined;
6614
+ }
6615
+
6616
+ /** @typedef {number} ReasonId */
6617
+ let lastReasonId= 0;
6618
+
6619
+ /** @type {Map<ReasonId, unknown>} */
6620
+ const idToReason= new Map();
6621
+
6622
+ /** @type {(() => void) | undefined} */
6623
+ let cancelChecking;
6624
+
6625
+ const removeReasonId= (reasonId)=>{
6626
+ mapDelete(idToReason, reasonId);
6627
+ if( cancelChecking&& idToReason.size=== 0) {
6628
+ // No more unhandled rejections to check, just cancel the check.
6629
+ cancelChecking();
6630
+ cancelChecking= undefined;
6631
+ }
6632
+ };
6633
+
6634
+ /** @type {WeakMap<Promise, ReasonId>} */
6635
+ const promiseToReasonId= new WeakMap();
6636
+
6637
+ /**
6638
+ * Clean up and report the reason for a GCed unhandled rejection.
6639
+ *
6640
+ * @param {ReasonId} heldReasonId
6641
+ */
6642
+ const finalizeDroppedPromise= (heldReasonId)=>{
6643
+ if( mapHas(idToReason)) {
6644
+ const reason= mapGet(idToReason, heldReasonId);
6645
+ removeReasonId(heldReasonId);
6646
+ reportReason(reason);
6647
+ }
6648
+ };
6649
+
6650
+ /** @type {FinalizationRegistry<ReasonId>} */
6651
+ const promiseToReason= new FinalizationRegistry(finalizeDroppedPromise);
6652
+
6653
+ /**
6654
+ * Track a rejected promise and its corresponding reason if there is no
6655
+ * rejection handler synchronously attached.
6656
+ *
6657
+ * @param {unknown} reason
6658
+ * @param {Promise} pr
6659
+ */
6660
+ const unhandledRejectionHandler= (reason, pr)=> {
6661
+ lastReasonId+= 1;
6662
+ const reasonId= lastReasonId;
6663
+
6664
+ // Update bookkeeping.
6665
+ mapSet(idToReason, reasonId, reason);
6666
+ weakmapSet(promiseToReasonId, pr, reasonId);
6667
+ finalizationRegistryRegister(promiseToReason, pr, reasonId, pr);
6668
+ };
6669
+
6670
+ /**
6671
+ * Deal with the addition of a handler to a previously rejected promise.
6672
+ *
6673
+ * Just remove it from our list. Let the FinalizationRegistry or
6674
+ * processTermination report any GCed unhandled rejected promises.
6675
+ *
6676
+ * @param {Promise} pr
6677
+ */
6678
+ const rejectionHandledHandler= (pr)=>{
6679
+ const reasonId= weakmapGet(promiseToReasonId, pr);
6680
+ removeReasonId(reasonId);
6681
+ };
6682
+
6683
+ /**
6684
+ * Report all the unhandled rejections, now that we are abruptly terminating
6685
+ * the agent cluster.
6686
+ */
6687
+ const processTerminationHandler= ()=> {
6688
+ for( const [reasonId, reason]of mapEntries(idToReason)) {
6689
+ removeReasonId(reasonId);
6690
+ reportReason(reason);
6691
+ }
6692
+ };
6693
+
6694
+ return {
6695
+ rejectionHandledHandler,
6696
+ unhandledRejectionHandler,
6697
+ processTerminationHandler};
6698
+
6699
+ };$h‍_once.makeRejectionHandlers(makeRejectionHandlers);
6700
+ })
6701
+ ,
6702
+ // === functors[27] ===
6703
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,globalThis,defaultHandler,makeCausalConsole,makeRejectionHandlers;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./unhandled-rejection.js", [["makeRejectionHandlers", [$h‍_a => (makeRejectionHandlers = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
6704
+
6564
6705
 
6565
6706
 
6566
6707
 
@@ -6579,20 +6720,19 @@ const originalConsole= console;
6579
6720
  *
6580
6721
  * @param {"safe" | "unsafe"} consoleTaming
6581
6722
  * @param {"platform" | "exit" | "abort" | "report" | "none"} [errorTrapping]
6723
+ * @param {"report" | "none"} [unhandledRejectionTrapping]
6582
6724
  * @param {GetStackString=} optGetStackString
6583
6725
  */
6584
6726
  const tameConsole= (
6585
6727
  consoleTaming= 'safe',
6586
6728
  errorTrapping= 'platform',
6729
+ unhandledRejectionTrapping= 'report',
6587
6730
  optGetStackString= undefined)=>
6588
6731
  {
6589
6732
  if( consoleTaming!== 'safe'&& consoleTaming!== 'unsafe') {
6590
6733
  throw new TypeError( `unrecognized consoleTaming ${consoleTaming}`);
6591
6734
  }
6592
6735
 
6593
- if( consoleTaming=== 'unsafe') {
6594
- return { console: originalConsole};
6595
- }
6596
6736
  let loggedErrorHandler;
6597
6737
  if( optGetStackString=== undefined) {
6598
6738
  loggedErrorHandler= defaultHandler;
@@ -6602,7 +6742,10 @@ const tameConsole= (
6602
6742
  getStackString: optGetStackString};
6603
6743
 
6604
6744
  }
6605
- const causalConsole= makeCausalConsole(originalConsole, loggedErrorHandler);
6745
+ const ourConsole=
6746
+ consoleTaming=== 'unsafe'?
6747
+ originalConsole:
6748
+ makeCausalConsole(originalConsole, loggedErrorHandler);
6606
6749
 
6607
6750
  // Attach platform-specific error traps such that any error that gets thrown
6608
6751
  // at top-of-turn (the bottom of stack) will get logged by our causal
@@ -6615,46 +6758,91 @@ const tameConsole= (
6615
6758
  // utter that. That unnecessary shim forces the whole bundle into sloppy mode,
6616
6759
  // which in turn breaks SES's strict mode invariant.
6617
6760
 
6761
+ // Disable the polymorphic check for the rest of this file. It's too noisy
6762
+ // when dealing with platform APIs.
6763
+ /* eslint-disable @endo/no-polymorphic-call */
6764
+
6618
6765
  // Node.js
6619
6766
  if( errorTrapping!== 'none'&& globalThis.process!== undefined) {
6620
- // eslint-disable-next-line @endo/no-polymorphic-call
6621
6767
  globalThis.process.on('uncaughtException', (error)=>{
6622
6768
  // causalConsole is born frozen so not vulnerable to method tampering.
6623
- // eslint-disable-next-line @endo/no-polymorphic-call
6624
- causalConsole.error(error);
6769
+ ourConsole.error(error);
6625
6770
  if( errorTrapping=== 'platform'|| errorTrapping=== 'exit') {
6626
- // eslint-disable-next-line @endo/no-polymorphic-call
6627
6771
  globalThis.process.exit(globalThis.process.exitCode|| -1);
6628
6772
  }else if( errorTrapping=== 'abort') {
6629
- // eslint-disable-next-line @endo/no-polymorphic-call
6630
6773
  globalThis.process.abort();
6631
6774
  }
6632
6775
  });
6633
6776
  }
6634
6777
 
6778
+ if(
6779
+ unhandledRejectionTrapping!== 'none'&&
6780
+ globalThis.process!== undefined)
6781
+ {
6782
+ const handleRejection= (reason)=>{
6783
+ // 'platform' and 'report' just log the reason.
6784
+ ourConsole.error('SES_UNHANDLED_REJECTION:', reason);
6785
+ };
6786
+ // Maybe track unhandled promise rejections.
6787
+ const h= makeRejectionHandlers(handleRejection);
6788
+ if( h) {
6789
+ // Rejection handlers are supported.
6790
+ globalThis.process.on('unhandledRejection', h.unhandledRejectionHandler);
6791
+ globalThis.process.on('rejectionHandled', h.rejectionHandledHandler);
6792
+ globalThis.process.on('exit', h.processTerminationHandler);
6793
+ }
6794
+ }
6795
+
6635
6796
  // Browser
6636
6797
  if(
6637
6798
  errorTrapping!== 'none'&&
6638
6799
  globalThis.window!== undefined&&
6639
6800
  globalThis.window.addEventListener!== undefined)
6640
6801
  {
6641
- // eslint-disable-next-line @endo/no-polymorphic-call
6642
6802
  globalThis.window.addEventListener('error', (event)=>{
6643
- // eslint-disable-next-line @endo/no-polymorphic-call
6644
6803
  event.preventDefault();
6645
- // eslint-disable-next-line @endo/no-polymorphic-call
6646
- causalConsole.error(event.error);
6804
+ // 'platform' and 'report' just log the reason.
6805
+ ourConsole.error(event.error);
6647
6806
  if( errorTrapping=== 'exit'|| errorTrapping=== 'abort') {
6648
6807
  globalThis.window.location.href= `about:blank`;
6649
6808
  }
6650
6809
  });
6651
6810
  }
6652
6811
 
6653
- return { console: causalConsole};
6812
+ if(
6813
+ unhandledRejectionTrapping!== 'none'&&
6814
+ globalThis.window!== undefined&&
6815
+ globalThis.window.addEventListener!== undefined)
6816
+ {
6817
+ const handleRejection= (reason)=>{
6818
+ ourConsole.error('SES_UNHANDLED_REJECTION:', reason);
6819
+ };
6820
+
6821
+ const h= makeRejectionHandlers(handleRejection);
6822
+ if( h) {
6823
+ // Rejection handlers are supported.
6824
+ globalThis.window.addEventListener('unhandledrejection', (event)=>{
6825
+ event.preventDefault();
6826
+ h.unhandledRejectionHandler(event.reason, event.promise);
6827
+ });
6828
+
6829
+ globalThis.window.addEventListener('rejectionhandled', (event)=>{
6830
+ event.preventDefault();
6831
+ h.rejectionHandledHandler(event.promise);
6832
+ });
6833
+
6834
+ globalThis.window.addEventListener('beforeunload', (_event)=>{
6835
+ h.processTerminationHandler();
6836
+ });
6837
+ }
6838
+ }
6839
+ /* eslint-enable @endo/no-polymorphic-call */
6840
+
6841
+ return { console: ourConsole};
6654
6842
  };$h‍_once.tameConsole(tameConsole);
6655
6843
  })
6656
6844
  ,
6657
- // === functors[27] ===
6845
+ // === functors[28] ===
6658
6846
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapHas,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6659
6847
 
6660
6848
 
@@ -6960,7 +7148,7 @@ const tameV8ErrorConstructor= (
6960
7148
  };$h‍_once.tameV8ErrorConstructor(tameV8ErrorConstructor);
6961
7149
  })
6962
7150
  ,
6963
- // === functors[28] ===
7151
+ // === functors[29] ===
6964
7152
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
6965
7153
 
6966
7154
 
@@ -6973,8 +7161,9 @@ const tameV8ErrorConstructor= (
6973
7161
 
6974
7162
 
6975
7163
 
6976
- // Present on at least FF. Proposed by Error-proposal. Not on SES whitelist
6977
- // so grab it before it is removed.
7164
+ // Present on at least FF and XS. Proposed by Error-proposal. The original
7165
+ // is dangerous, so tameErrorConstructor replaces it with a safe one.
7166
+ // We grab the original here before it gets replaced.
6978
7167
  const stackDesc= getOwnPropertyDescriptor(FERAL_ERROR.prototype, 'stack');
6979
7168
  const stackGetter= stackDesc&& stackDesc.get;
6980
7169
 
@@ -7036,17 +7225,7 @@ function tameErrorConstructor(
7036
7225
  const InitialError= makeErrorConstructor({ powers: 'original'});
7037
7226
  const SharedError= makeErrorConstructor({ powers: 'none'});
7038
7227
  defineProperties(ErrorPrototype, {
7039
- constructor: { value: SharedError}
7040
- /* TODO
7041
- stack: {
7042
- get() {
7043
- return '';
7044
- },
7045
- set(_) {
7046
- // ignore
7047
- },
7048
- },
7049
- */});
7228
+ constructor: { value: SharedError}});
7050
7229
 
7051
7230
 
7052
7231
  for( const NativeError of NativeErrors) {
@@ -7117,7 +7296,70 @@ function tameErrorConstructor(
7117
7296
  errorTaming,
7118
7297
  stackFiltering);
7119
7298
 
7299
+ }else if( errorTaming=== 'unsafe') {
7300
+ // v8 has too much magic around their 'stack' own property for it to
7301
+ // coexist cleanly with this accessor. So only install it on non-v8
7302
+
7303
+ // Error.prototype.stack property as proposed at
7304
+ // https://tc39.es/proposal-error-stacks/
7305
+ // with the fix proposed at
7306
+ // https://github.com/tc39/proposal-error-stacks/issues/46
7307
+ // On others, this still protects from the override mistake,
7308
+ // essentially like enable-property-overrides.js would
7309
+ // once this accessor property itself is frozen, as will happen
7310
+ // later during lockdown.
7311
+ //
7312
+ // However, there is here a change from the intent in the current
7313
+ // state of the proposal. If experience tells us whether this change
7314
+ // is a good idea, we should modify the proposal accordingly. There is
7315
+ // much code in the world that assumes `error.stack` is a string. So
7316
+ // where the proposal accommodates secure operation by making the
7317
+ // property optional, we instead accommodate secure operation by
7318
+ // having the secure form always return only the stable part, the
7319
+ // stringified error instance, and omitting all the frame information
7320
+ // rather than omitting the property.
7321
+ defineProperties(ErrorPrototype, {
7322
+ stack: {
7323
+ get() {
7324
+ return initialGetStackString(this);
7325
+ },
7326
+ set(newValue) {
7327
+ defineProperties(this, {
7328
+ stack: {
7329
+ value: newValue,
7330
+ writable: true,
7331
+ enumerable: true,
7332
+ configurable: true}});
7333
+
7334
+
7335
+ }}});
7336
+
7337
+
7338
+ }else {
7339
+ // v8 has too much magic around their 'stack' own property for it to
7340
+ // coexist cleanly with this accessor. So only install it on non-v8
7341
+ defineProperties(ErrorPrototype, {
7342
+ stack: {
7343
+ get() {
7344
+ // https://github.com/tc39/proposal-error-stacks/issues/46
7345
+ // allows this to not add an unpleasant newline. Otherwise
7346
+ // we should fix this.
7347
+ return `${this}`;
7348
+ },
7349
+ set(newValue) {
7350
+ defineProperties(this, {
7351
+ stack: {
7352
+ value: newValue,
7353
+ writable: true,
7354
+ enumerable: true,
7355
+ configurable: true}});
7356
+
7357
+
7358
+ }}});
7359
+
7360
+
7120
7361
  }
7362
+
7121
7363
  return {
7122
7364
  '%InitialGetStackString%': initialGetStackString,
7123
7365
  '%InitialError%': InitialError,
@@ -7126,7 +7368,7 @@ function tameErrorConstructor(
7126
7368
  }$h‍_once.default( tameErrorConstructor);
7127
7369
  })
7128
7370
  ,
7129
- // === functors[29] ===
7371
+ // === functors[30] ===
7130
7372
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,InertCompartment;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["Float32Array", [$h‍_a => (Float32Array = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["iterateArray", [$h‍_a => (iterateArray = $h‍_a)]],["iterateMap", [$h‍_a => (iterateMap = $h‍_a)]],["iterateSet", [$h‍_a => (iterateSet = $h‍_a)]],["iterateString", [$h‍_a => (iterateString = $h‍_a)]],["matchAllRegExp", [$h‍_a => (matchAllRegExp = $h‍_a)]],["matchAllSymbol", [$h‍_a => (matchAllSymbol = $h‍_a)]],["regexpPrototype", [$h‍_a => (regexpPrototype = $h‍_a)]]]],["./compartment-shim.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]);
7131
7373
 
7132
7374
 
@@ -7267,7 +7509,7 @@ const getAnonymousIntrinsics= ()=> {
7267
7509
  };$h‍_once.getAnonymousIntrinsics(getAnonymousIntrinsics);
7268
7510
  })
7269
7511
  ,
7270
- // === functors[30] ===
7512
+ // === functors[31] ===
7271
7513
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Set,String,TypeError,WeakMap,WeakSet,apply,arrayForEach,defineProperty,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,getPrototypeOf,isInteger,isObject,objectHasOwnProperty,ownKeys,preventExtensions,setAdd,setForEach,setHas,toStringTagSymbol,typedArrayPrototype,weakmapGet,weakmapSet,weaksetAdd,weaksetHas,assert;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isInteger", [$h‍_a => (isInteger = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["preventExtensions", [$h‍_a => (preventExtensions = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setForEach", [$h‍_a => (setForEach = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["typedArrayPrototype", [$h‍_a => (typedArrayPrototype = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
7272
7514
 
7273
7515
 
@@ -7498,7 +7740,7 @@ const makeHardener= ()=> {
7498
7740
  };$h‍_once.makeHardener(makeHardener);
7499
7741
  })
7500
7742
  ,
7501
- // === functors[31] ===
7743
+ // === functors[32] ===
7502
7744
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Date,TypeError,apply,construct,defineProperties;$h‍_imports([["./commons.js", [["Date", [$h‍_a => (Date = $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)]]]]]);
7503
7745
 
7504
7746
 
@@ -7615,7 +7857,7 @@ function tameDateConstructor(dateTaming= 'safe') {
7615
7857
  }$h‍_once.default( tameDateConstructor);
7616
7858
  })
7617
7859
  ,
7618
- // === functors[32] ===
7860
+ // === functors[33] ===
7619
7861
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,globalThis,getOwnPropertyDescriptor,defineProperty;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]]]);Object.defineProperty(tameDomains, 'name', {value: "tameDomains"});$h‍_once.tameDomains(tameDomains);
7620
7862
 
7621
7863
 
@@ -7664,7 +7906,7 @@ function tameDomains(domainTaming= 'safe') {
7664
7906
  }
7665
7907
  })
7666
7908
  ,
7667
- // === functors[33] ===
7909
+ // === functors[34] ===
7668
7910
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]]]]]);
7669
7911
 
7670
7912
 
@@ -7802,7 +8044,7 @@ function tameFunctionConstructors() {
7802
8044
  }$h‍_once.default( tameFunctionConstructors);
7803
8045
  })
7804
8046
  ,
7805
- // === functors[34] ===
8047
+ // === functors[35] ===
7806
8048
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let WeakSet,defineProperty,freeze,functionPrototype,functionToString,stringEndsWith,weaksetAdd,weaksetHas;$h‍_imports([["./commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["functionPrototype", [$h‍_a => (functionPrototype = $h‍_a)]],["functionToString", [$h‍_a => (functionToString = $h‍_a)]],["stringEndsWith", [$h‍_a => (stringEndsWith = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
7807
8049
 
7808
8050
 
@@ -7855,7 +8097,7 @@ const tameFunctionToString= ()=> {
7855
8097
  };$h‍_once.tameFunctionToString(tameFunctionToString);
7856
8098
  })
7857
8099
  ,
7858
- // === functors[35] ===
8100
+ // === functors[36] ===
7859
8101
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Number,String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h‍_imports([["./commons.js", [["Number", [$h‍_a => (Number = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
7860
8102
 
7861
8103
 
@@ -7943,7 +8185,7 @@ function tameLocaleMethods(intrinsics, localeTaming= 'safe') {
7943
8185
  }$h‍_once.default( tameLocaleMethods);
7944
8186
  })
7945
8187
  ,
7946
- // === functors[36] ===
8188
+ // === functors[37] ===
7947
8189
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Math,TypeError,create,getOwnPropertyDescriptors,objectPrototype;$h‍_imports([["./commons.js", [["Math", [$h‍_a => (Math = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]]]]]);
7948
8190
 
7949
8191
 
@@ -7972,7 +8214,7 @@ function tameMathObject(mathTaming= 'safe') {
7972
8214
  }$h‍_once.default( tameMathObject);
7973
8215
  })
7974
8216
  ,
7975
- // === functors[37] ===
8217
+ // === functors[38] ===
7976
8218
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_REG_EXP,TypeError,construct,defineProperties,getOwnPropertyDescriptor,speciesSymbol;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["speciesSymbol", [$h‍_a => (speciesSymbol = $h‍_a)]]]]]);
7977
8219
 
7978
8220
 
@@ -8027,7 +8269,7 @@ function tameRegExpConstructor(regExpTaming= 'safe') {
8027
8269
  }$h‍_once.default( tameRegExpConstructor);
8028
8270
  })
8029
8271
  ,
8030
- // === functors[38] ===
8272
+ // === functors[39] ===
8031
8273
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let whitelist,FunctionInstance,isAccessorPermit,Map,String,TypeError,arrayFilter,arrayIncludes,arrayMap,entries,getOwnPropertyDescriptor,getPrototypeOf,isObject,mapGet,objectHasOwnProperty,ownKeys,symbolKeyFor;$h‍_imports([["./whitelist.js", [["whitelist", [$h‍_a => (whitelist = $h‍_a)]],["FunctionInstance", [$h‍_a => (FunctionInstance = $h‍_a)]],["isAccessorPermit", [$h‍_a => (isAccessorPermit = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["symbolKeyFor", [$h‍_a => (symbolKeyFor = $h‍_a)]]]]]);
8032
8274
 
8033
8275
 
@@ -8333,7 +8575,7 @@ function whitelistIntrinsics(
8333
8575
  }$h‍_once.default( whitelistIntrinsics);
8334
8576
  })
8335
8577
  ,
8336
- // === functors[39] ===
8578
+ // === functors[40] ===
8337
8579
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["noEvalEvaluate", [$h‍_a => (noEvalEvaluate = $h‍_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h‍_a => (enJoin = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./whitelist-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h‍_a => (makeEnvironmentCaptor = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]]]);
8338
8580
 
8339
8581
 
@@ -8496,6 +8738,10 @@ const repairIntrinsics= (options= {})=> {
8496
8738
  const {
8497
8739
  errorTaming= getenv('LOCKDOWN_ERROR_TAMING', 'safe'),
8498
8740
  errorTrapping= getenv('LOCKDOWN_ERROR_TRAPPING', 'platform'),
8741
+ unhandledRejectionTrapping= getenv(
8742
+ 'LOCKDOWN_UNHANDLED_REJECTION_TRAPPING',
8743
+ 'report'),
8744
+
8499
8745
  regExpTaming= getenv('LOCKDOWN_REGEXP_TAMING', 'safe'),
8500
8746
  localeTaming= getenv('LOCKDOWN_LOCALE_TAMING', 'safe'),
8501
8747
  consoleTaming= getenv('LOCKDOWN_CONSOLE_TAMING', 'safe'),
@@ -8622,18 +8868,23 @@ const repairIntrinsics= (options= {})=> {
8622
8868
 
8623
8869
  const intrinsics= finalIntrinsics();
8624
8870
 
8625
- // Wrap console unless suppressed.
8626
- // At the moment, the console is considered a host power in the start
8627
- // compartment, and not a primordial. Hence it is absent from the whilelist
8628
- // and bypasses the intrinsicsCollector.
8871
+ /**
8872
+ * Wrap console unless suppressed.
8873
+ * At the moment, the console is considered a host power in the start
8874
+ * compartment, and not a primordial. Hence it is absent from the whilelist
8875
+ * and bypasses the intrinsicsCollector.
8876
+ *
8877
+ * @type {((error: any) => string | undefined) | undefined}
8878
+ */
8629
8879
  let optGetStackString;
8630
8880
  if( errorTaming!== 'unsafe') {
8631
8881
  optGetStackString= intrinsics['%InitialGetStackString%'];
8632
8882
  }
8633
8883
  const consoleRecord= tameConsole(
8634
- // @ts-ignore tameConsole does its own input validation
8884
+ // @ts-expect-error tameConsole does its own input validation
8635
8885
  consoleTaming,
8636
8886
  errorTrapping,
8887
+ unhandledRejectionTrapping,
8637
8888
  optGetStackString);
8638
8889
 
8639
8890
  globalThis.console= /** @type {Console} */ consoleRecord.console;
@@ -8745,7 +8996,7 @@ const lockdown= (options= {})=> {
8745
8996
  };$h‍_once.lockdown(lockdown);
8746
8997
  })
8747
8998
  ,
8748
- // === functors[40] ===
8999
+ // === functors[41] ===
8749
9000
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let globalThis,TypeError,assign,tameFunctionToString,getGlobalIntrinsics,lockdown,makeCompartmentConstructor,assert;$h‍_imports([["./src/commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./src/tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./src/intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]],["./src/lockdown-shim.js", [["lockdown", [$h‍_a => (lockdown = $h‍_a)]]]],["./src/compartment-shim.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./src/error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
8750
9001
 
8751
9002
 
@@ -8816,6 +9067,7 @@ assign(globalThis, {
8816
9067
  globalThis: cell("globalThis"),
8817
9068
  Array: cell("Array"),
8818
9069
  Date: cell("Date"),
9070
+ FinalizationRegistry: cell("FinalizationRegistry"),
8819
9071
  Float32Array: cell("Float32Array"),
8820
9072
  JSON: cell("JSON"),
8821
9073
  Map: cell("Map"),
@@ -8899,6 +9151,8 @@ assign(globalThis, {
8899
9151
  mapSet: cell("mapSet"),
8900
9152
  mapGet: cell("mapGet"),
8901
9153
  mapHas: cell("mapHas"),
9154
+ mapDelete: cell("mapDelete"),
9155
+ mapEntries: cell("mapEntries"),
8902
9156
  iterateMap: cell("iterateMap"),
8903
9157
  setAdd: cell("setAdd"),
8904
9158
  setDelete: cell("setDelete"),
@@ -8929,6 +9183,8 @@ assign(globalThis, {
8929
9183
  promiseAll: cell("promiseAll"),
8930
9184
  promiseCatch: cell("promiseCatch"),
8931
9185
  promiseThen: cell("promiseThen"),
9186
+ finalizationRegistryRegister: cell("finalizationRegistryRegister"),
9187
+ finalizationRegistryUnregister: cell("finalizationRegistryUnregister"),
8932
9188
  getConstructorOf: cell("getConstructorOf"),
8933
9189
  immutableObject: cell("immutableObject"),
8934
9190
  isObject: cell("isObject"),
@@ -9044,7 +9300,9 @@ assign(globalThis, {
9044
9300
  makeCausalConsole: cell("makeCausalConsole"),
9045
9301
  filterConsole: cell("filterConsole"),
9046
9302
  consoleWhitelist: cell("consoleWhitelist"),
9047
- BASE_CONSOLE_LEVEL: cell("BASE_CONSOLE_LEVEL"),
9303
+ },
9304
+ {
9305
+ makeRejectionHandlers: cell("makeRejectionHandlers"),
9048
9306
  },
9049
9307
  {
9050
9308
  tameConsole: cell("tameConsole"),
@@ -9125,6 +9383,7 @@ assign(globalThis, {
9125
9383
  universalThis: cells[0].globalThis.set,
9126
9384
  Array: cells[0].Array.set,
9127
9385
  Date: cells[0].Date.set,
9386
+ FinalizationRegistry: cells[0].FinalizationRegistry.set,
9128
9387
  Float32Array: cells[0].Float32Array.set,
9129
9388
  JSON: cells[0].JSON.set,
9130
9389
  Map: cells[0].Map.set,
@@ -9208,6 +9467,8 @@ assign(globalThis, {
9208
9467
  mapSet: cells[0].mapSet.set,
9209
9468
  mapGet: cells[0].mapGet.set,
9210
9469
  mapHas: cells[0].mapHas.set,
9470
+ mapDelete: cells[0].mapDelete.set,
9471
+ mapEntries: cells[0].mapEntries.set,
9211
9472
  iterateMap: cells[0].iterateMap.set,
9212
9473
  setAdd: cells[0].setAdd.set,
9213
9474
  setDelete: cells[0].setDelete.set,
@@ -9238,6 +9499,8 @@ assign(globalThis, {
9238
9499
  promiseAll: cells[0].promiseAll.set,
9239
9500
  promiseCatch: cells[0].promiseCatch.set,
9240
9501
  promiseThen: cells[0].promiseThen.set,
9502
+ finalizationRegistryRegister: cells[0].finalizationRegistryRegister.set,
9503
+ finalizationRegistryUnregister: cells[0].finalizationRegistryUnregister.set,
9241
9504
  getConstructorOf: cells[0].getConstructorOf.set,
9242
9505
  immutableObject: cells[0].immutableObject.set,
9243
9506
  isObject: cells[0].isObject.set,
@@ -9586,84 +9849,84 @@ assign(globalThis, {
9586
9849
  makeCausalConsole: cells[25].makeCausalConsole.set,
9587
9850
  filterConsole: cells[25].filterConsole.set,
9588
9851
  consoleWhitelist: cells[25].consoleWhitelist.set,
9589
- BASE_CONSOLE_LEVEL: cells[25].BASE_CONSOLE_LEVEL.set,
9590
9852
  },
9591
9853
  });
9592
9854
  functors[26]({
9593
9855
  imports(entries) {
9594
9856
  const map = new Map(entries);
9595
9857
  observeImports(map, "../commons.js", 0);
9596
- observeImports(map, "./assert.js", 4);
9597
- observeImports(map, "./console.js", 25);
9598
- observeImports(map, "./internal-types.js", 1);
9599
- observeImports(map, "./types.js", 3);
9600
9858
  },
9601
9859
  liveVar: {
9602
9860
  },
9603
9861
  onceVar: {
9604
- tameConsole: cells[26].tameConsole.set,
9862
+ makeRejectionHandlers: cells[26].makeRejectionHandlers.set,
9605
9863
  },
9606
9864
  });
9607
9865
  functors[27]({
9608
9866
  imports(entries) {
9609
9867
  const map = new Map(entries);
9610
9868
  observeImports(map, "../commons.js", 0);
9869
+ observeImports(map, "./assert.js", 4);
9870
+ observeImports(map, "./console.js", 25);
9871
+ observeImports(map, "./internal-types.js", 1);
9872
+ observeImports(map, "./types.js", 3);
9873
+ observeImports(map, "./unhandled-rejection.js", 26);
9611
9874
  },
9612
9875
  liveVar: {
9613
9876
  },
9614
9877
  onceVar: {
9615
- filterFileName: cells[27].filterFileName.set,
9616
- shortenCallSiteString: cells[27].shortenCallSiteString.set,
9617
- tameV8ErrorConstructor: cells[27].tameV8ErrorConstructor.set,
9878
+ tameConsole: cells[27].tameConsole.set,
9618
9879
  },
9619
9880
  });
9620
9881
  functors[28]({
9621
9882
  imports(entries) {
9622
9883
  const map = new Map(entries);
9623
9884
  observeImports(map, "../commons.js", 0);
9624
- observeImports(map, "../whitelist.js", 14);
9625
- observeImports(map, "./tame-v8-error-constructor.js", 27);
9626
9885
  },
9627
9886
  liveVar: {
9628
9887
  },
9629
9888
  onceVar: {
9630
- default: cells[28].default.set,
9889
+ filterFileName: cells[28].filterFileName.set,
9890
+ shortenCallSiteString: cells[28].shortenCallSiteString.set,
9891
+ tameV8ErrorConstructor: cells[28].tameV8ErrorConstructor.set,
9631
9892
  },
9632
9893
  });
9633
9894
  functors[29]({
9634
9895
  imports(entries) {
9635
9896
  const map = new Map(entries);
9636
- observeImports(map, "./commons.js", 0);
9637
- observeImports(map, "./compartment-shim.js", 20);
9897
+ observeImports(map, "../commons.js", 0);
9898
+ observeImports(map, "../whitelist.js", 14);
9899
+ observeImports(map, "./tame-v8-error-constructor.js", 28);
9638
9900
  },
9639
9901
  liveVar: {
9640
9902
  },
9641
9903
  onceVar: {
9642
- getAnonymousIntrinsics: cells[29].getAnonymousIntrinsics.set,
9904
+ default: cells[29].default.set,
9643
9905
  },
9644
9906
  });
9645
9907
  functors[30]({
9646
9908
  imports(entries) {
9647
9909
  const map = new Map(entries);
9648
9910
  observeImports(map, "./commons.js", 0);
9649
- observeImports(map, "./error/assert.js", 4);
9911
+ observeImports(map, "./compartment-shim.js", 20);
9650
9912
  },
9651
9913
  liveVar: {
9652
9914
  },
9653
9915
  onceVar: {
9654
- isTypedArray: cells[30].isTypedArray.set,
9655
- makeHardener: cells[30].makeHardener.set,
9916
+ getAnonymousIntrinsics: cells[30].getAnonymousIntrinsics.set,
9656
9917
  },
9657
9918
  });
9658
9919
  functors[31]({
9659
9920
  imports(entries) {
9660
9921
  const map = new Map(entries);
9661
9922
  observeImports(map, "./commons.js", 0);
9923
+ observeImports(map, "./error/assert.js", 4);
9662
9924
  },
9663
9925
  liveVar: {
9664
9926
  },
9665
9927
  onceVar: {
9666
- default: cells[31].default.set,
9928
+ isTypedArray: cells[31].isTypedArray.set,
9929
+ makeHardener: cells[31].makeHardener.set,
9667
9930
  },
9668
9931
  });
9669
9932
  functors[32]({
@@ -9674,7 +9937,7 @@ assign(globalThis, {
9674
9937
  liveVar: {
9675
9938
  },
9676
9939
  onceVar: {
9677
- tameDomains: cells[32].tameDomains.set,
9940
+ default: cells[32].default.set,
9678
9941
  },
9679
9942
  });
9680
9943
  functors[33]({
@@ -9685,7 +9948,7 @@ assign(globalThis, {
9685
9948
  liveVar: {
9686
9949
  },
9687
9950
  onceVar: {
9688
- default: cells[33].default.set,
9951
+ tameDomains: cells[33].tameDomains.set,
9689
9952
  },
9690
9953
  });
9691
9954
  functors[34]({
@@ -9696,25 +9959,25 @@ assign(globalThis, {
9696
9959
  liveVar: {
9697
9960
  },
9698
9961
  onceVar: {
9699
- tameFunctionToString: cells[34].tameFunctionToString.set,
9962
+ default: cells[34].default.set,
9700
9963
  },
9701
9964
  });
9702
9965
  functors[35]({
9703
9966
  imports(entries) {
9704
9967
  const map = new Map(entries);
9705
9968
  observeImports(map, "./commons.js", 0);
9706
- observeImports(map, "./error/assert.js", 4);
9707
9969
  },
9708
9970
  liveVar: {
9709
9971
  },
9710
9972
  onceVar: {
9711
- default: cells[35].default.set,
9973
+ tameFunctionToString: cells[35].tameFunctionToString.set,
9712
9974
  },
9713
9975
  });
9714
9976
  functors[36]({
9715
9977
  imports(entries) {
9716
9978
  const map = new Map(entries);
9717
9979
  observeImports(map, "./commons.js", 0);
9980
+ observeImports(map, "./error/assert.js", 4);
9718
9981
  },
9719
9982
  liveVar: {
9720
9983
  },
@@ -9737,7 +10000,6 @@ assign(globalThis, {
9737
10000
  imports(entries) {
9738
10001
  const map = new Map(entries);
9739
10002
  observeImports(map, "./commons.js", 0);
9740
- observeImports(map, "./whitelist.js", 14);
9741
10003
  },
9742
10004
  liveVar: {
9743
10005
  },
@@ -9746,6 +10008,18 @@ assign(globalThis, {
9746
10008
  },
9747
10009
  });
9748
10010
  functors[39]({
10011
+ imports(entries) {
10012
+ const map = new Map(entries);
10013
+ observeImports(map, "./commons.js", 0);
10014
+ observeImports(map, "./whitelist.js", 14);
10015
+ },
10016
+ liveVar: {
10017
+ },
10018
+ onceVar: {
10019
+ default: cells[39].default.set,
10020
+ },
10021
+ });
10022
+ functors[40]({
9749
10023
  imports(entries) {
9750
10024
  const map = new Map(entries);
9751
10025
  observeImports(map, "./commons.js", 0);
@@ -9754,39 +10028,39 @@ assign(globalThis, {
9754
10028
  observeImports(map, "./environment-options.js", 24);
9755
10029
  observeImports(map, "./error/assert.js", 4);
9756
10030
  observeImports(map, "./error/stringify-utils.js", 2);
9757
- observeImports(map, "./error/tame-console.js", 26);
9758
- observeImports(map, "./error/tame-error-constructor.js", 28);
9759
- observeImports(map, "./get-anonymous-intrinsics.js", 29);
10031
+ observeImports(map, "./error/tame-console.js", 27);
10032
+ observeImports(map, "./error/tame-error-constructor.js", 29);
10033
+ observeImports(map, "./get-anonymous-intrinsics.js", 30);
9760
10034
  observeImports(map, "./global-object.js", 15);
9761
10035
  observeImports(map, "./intrinsics.js", 21);
9762
- observeImports(map, "./make-hardener.js", 30);
10036
+ observeImports(map, "./make-hardener.js", 31);
9763
10037
  observeImports(map, "./make-safe-evaluator.js", 10);
9764
- observeImports(map, "./tame-date-constructor.js", 31);
9765
- observeImports(map, "./tame-domains.js", 32);
9766
- observeImports(map, "./tame-function-constructors.js", 33);
9767
- observeImports(map, "./tame-function-tostring.js", 34);
9768
- observeImports(map, "./tame-locale-methods.js", 35);
9769
- observeImports(map, "./tame-math-object.js", 36);
9770
- observeImports(map, "./tame-regexp-constructor.js", 37);
9771
- observeImports(map, "./whitelist-intrinsics.js", 38);
10038
+ observeImports(map, "./tame-date-constructor.js", 32);
10039
+ observeImports(map, "./tame-domains.js", 33);
10040
+ observeImports(map, "./tame-function-constructors.js", 34);
10041
+ observeImports(map, "./tame-function-tostring.js", 35);
10042
+ observeImports(map, "./tame-locale-methods.js", 36);
10043
+ observeImports(map, "./tame-math-object.js", 37);
10044
+ observeImports(map, "./tame-regexp-constructor.js", 38);
10045
+ observeImports(map, "./whitelist-intrinsics.js", 39);
9772
10046
  observeImports(map, "./whitelist.js", 14);
9773
10047
  },
9774
10048
  liveVar: {
9775
10049
  },
9776
10050
  onceVar: {
9777
- repairIntrinsics: cells[39].repairIntrinsics.set,
9778
- lockdown: cells[39].lockdown.set,
10051
+ repairIntrinsics: cells[40].repairIntrinsics.set,
10052
+ lockdown: cells[40].lockdown.set,
9779
10053
  },
9780
10054
  });
9781
- functors[40]({
10055
+ functors[41]({
9782
10056
  imports(entries) {
9783
10057
  const map = new Map(entries);
9784
10058
  observeImports(map, "./src/commons.js", 0);
9785
10059
  observeImports(map, "./src/compartment-shim.js", 20);
9786
10060
  observeImports(map, "./src/error/assert.js", 4);
9787
10061
  observeImports(map, "./src/intrinsics.js", 21);
9788
- observeImports(map, "./src/lockdown-shim.js", 39);
9789
- observeImports(map, "./src/tame-function-tostring.js", 34);
10062
+ observeImports(map, "./src/lockdown-shim.js", 40);
10063
+ observeImports(map, "./src/tame-function-tostring.js", 35);
9790
10064
  },
9791
10065
  liveVar: {
9792
10066
  },