@metamask/snaps-execution-environments 3.4.3 → 4.0.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/browserify/iframe/bundle.js +5 -5
  3. package/dist/browserify/iframe/index.html +1132 -389
  4. package/dist/browserify/node-process/bundle.js +1135 -392
  5. package/dist/browserify/node-thread/bundle.js +1135 -392
  6. package/dist/browserify/webview/bundle.js +9 -0
  7. package/dist/browserify/{offscreen → webview}/index.html +1132 -389
  8. package/dist/browserify/worker-executor/bundle.js +1137 -394
  9. package/dist/browserify/worker-pool/bundle.js +5 -5
  10. package/dist/browserify/worker-pool/index.html +1132 -389
  11. package/dist/cjs/common/BaseSnapExecutor.js +2 -2
  12. package/dist/cjs/common/BaseSnapExecutor.js.map +1 -1
  13. package/dist/cjs/common/commands.js +18 -0
  14. package/dist/cjs/common/commands.js.map +1 -1
  15. package/dist/cjs/common/validation.js +27 -0
  16. package/dist/cjs/common/validation.js.map +1 -1
  17. package/dist/cjs/index.js +20 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/{offscreen/OffscreenSnapExecutor.js → proxy/ProxySnapExecutor.js} +26 -16
  20. package/dist/cjs/proxy/ProxySnapExecutor.js.map +1 -0
  21. package/dist/cjs/proxy/index.js +20 -0
  22. package/dist/cjs/proxy/index.js.map +1 -0
  23. package/dist/cjs/webview/WebViewExecutorStream.js +121 -0
  24. package/dist/cjs/webview/WebViewExecutorStream.js.map +1 -0
  25. package/dist/cjs/webview/index.js +19 -0
  26. package/dist/cjs/webview/index.js.map +1 -0
  27. package/dist/esm/common/BaseSnapExecutor.js +1 -1
  28. package/dist/esm/common/BaseSnapExecutor.js.map +1 -1
  29. package/dist/esm/common/commands.js +19 -1
  30. package/dist/esm/common/commands.js.map +1 -1
  31. package/dist/esm/common/validation.js +29 -0
  32. package/dist/esm/common/validation.js.map +1 -1
  33. package/dist/esm/index.js +3 -0
  34. package/dist/esm/index.js.map +1 -0
  35. package/dist/esm/{offscreen/OffscreenSnapExecutor.js → proxy/ProxySnapExecutor.js} +25 -20
  36. package/dist/esm/proxy/ProxySnapExecutor.js.map +1 -0
  37. package/dist/esm/proxy/index.js +3 -0
  38. package/dist/esm/proxy/index.js.map +1 -0
  39. package/dist/esm/webview/WebViewExecutorStream.js +111 -0
  40. package/dist/esm/webview/WebViewExecutorStream.js.map +1 -0
  41. package/dist/esm/webview/index.js +15 -0
  42. package/dist/esm/webview/index.js.map +1 -0
  43. package/dist/types/common/validation.d.ts +48 -0
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/{offscreen/OffscreenSnapExecutor.d.ts → proxy/ProxySnapExecutor.d.ts} +9 -9
  46. package/dist/types/proxy/index.d.ts +1 -0
  47. package/dist/types/webview/WebViewExecutorStream.d.ts +32 -0
  48. package/package.json +13 -13
  49. package/dist/browserify/offscreen/bundle.js +0 -9
  50. package/dist/cjs/offscreen/OffscreenSnapExecutor.js.map +0 -1
  51. package/dist/cjs/offscreen/index.js +0 -19
  52. package/dist/cjs/offscreen/index.js.map +0 -1
  53. package/dist/esm/offscreen/OffscreenSnapExecutor.js.map +0 -1
  54. package/dist/esm/offscreen/index.js +0 -15
  55. package/dist/esm/offscreen/index.js.map +0 -1
  56. /package/dist/types/{offscreen → webview}/index.d.ts +0 -0
@@ -31,21 +31,21 @@
31
31
  const statsMode = false
32
32
 
33
33
  // initialize the kernel
34
- const reportStatsHook = statsMode ? (function makeInitStatsHook ({ onStatsReady }) {
34
+ const reportStatsHook = statsMode ? (function makeInitStatsHook({ onStatsReady }) {
35
35
  let statModuleStack = []
36
36
  return reportStatsHook
37
37
 
38
- function reportStatsHook (event, moduleId) {
38
+ function reportStatsHook(event, moduleId) {
39
39
  if (event === 'start') {
40
40
  // record start
41
41
  const startTime = Date.now()
42
42
  // console.log(`loaded module ${moduleId}`)
43
43
  const statRecord = {
44
- 'name': moduleId,
45
- 'value': null,
46
- 'children': [],
47
- 'startTime': startTime,
48
- 'endTime': null,
44
+ name: moduleId,
45
+ value: null,
46
+ children: [],
47
+ startTime: startTime,
48
+ endTime: null,
49
49
  }
50
50
  // add as child to current
51
51
  if (statModuleStack.length > 0) {
@@ -59,7 +59,11 @@
59
59
  const currentStat = statModuleStack[statModuleStack.length - 1]
60
60
  // sanity check, should only get an end for the current top of stack
61
61
  if (currentStat.name !== moduleId) {
62
- console.error(`stats hook misaligned "${currentStat.name}", "${moduleId}" ${statModuleStack.map(e => e.name).join()}`)
62
+ console.error(
63
+ `stats hook misaligned "${
64
+ currentStat.name
65
+ }", "${moduleId}" ${statModuleStack.map((e) => e.name).join()}`
66
+ )
63
67
  }
64
68
  currentStat.endTime = endTime
65
69
  const startTime = currentStat.startTime
@@ -74,7 +78,6 @@
74
78
  statModuleStack.pop()
75
79
  }
76
80
  }
77
-
78
81
  })({ onStatsReady }) : () => {}
79
82
  const createKernel = // LavaMoat Prelude
80
83
  (function () {
@@ -97,7 +100,7 @@
97
100
  // security options are hard-coded at build time
98
101
  const {
99
102
  scuttleGlobalThis,
100
- } = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext"]}}
103
+ } = {"scuttleGlobalThis":{"enabled":true,"exceptions":["postMessage","removeEventListener","isSecureContext","ReactNativeWebView","JSON","String"]}}
101
104
 
102
105
  function getGlobalRef () {
103
106
  if (typeof globalThis !== 'undefined') {
@@ -134,11 +137,12 @@
134
137
  const module = { exports }
135
138
  ;(function(){
136
139
  // START of injected code from ses
140
+ // ses@1.1.0
137
141
  'use strict';
138
142
  (() => {
139
143
  const functors = [
140
144
  // === functors[0] ===
141
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); /* global globalThis */
145
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* global globalThis */
142
146
  /* eslint-disable no-restricted-globals */
143
147
 
144
148
  /**
@@ -430,10 +434,10 @@ const noEvalEvaluate= ()=> {
430
434
  // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_EVAL.md
431
435
  throw TypeError('Cannot eval with evalTaming set to "noEval" (SES_NO_EVAL)');
432
436
  };$h‍_once.noEvalEvaluate(noEvalEvaluate);
433
- })
437
+ })()
434
438
  ,
435
439
  // === functors[1] ===
436
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let TypeError;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]]]]]);
440
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]]]]]);
437
441
 
438
442
  /** getThis returns globalThis in sloppy mode or undefined in strict mode. */
439
443
  function getThis() {
@@ -444,10 +448,11 @@ if( getThis()) {
444
448
  // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_SLOPPY.md
445
449
  throw TypeError( `SES failed to initialize, sloppy mode (SES_NO_SLOPPY)`);
446
450
  }
447
- })
451
+ })()
448
452
  ,
449
453
  // === functors[2] ===
450
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); // @ts-check
454
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* global globalThis */
455
+ // @ts-check
451
456
 
452
457
  // `@endo/env-options` needs to be imported quite early, and so should
453
458
  // avoid importing from ses or anything that depends on ses.
@@ -466,6 +471,8 @@ const uncurryThis=
466
471
  (receiver, ...args)=>
467
472
  apply(fn, receiver, args);
468
473
  const arrayPush= uncurryThis(Array.prototype.push);
474
+ const arrayIncludes= uncurryThis(Array.prototype.includes);
475
+ const stringSplit= uncurryThis(String.prototype.split);
469
476
 
470
477
  const q= JSON.stringify;
471
478
 
@@ -486,8 +493,10 @@ const Fail= (literals, ...args)=> {
486
493
  * the environment variables that were captured.
487
494
  *
488
495
  * @param {object} aGlobal
496
+ * @param {boolean} [dropNames] Defaults to false. If true, don't track
497
+ * names used.
489
498
  */
490
- const makeEnvironmentCaptor= (aGlobal)=>{
499
+ const makeEnvironmentCaptor= (aGlobal, dropNames= false)=> {
491
500
  const capturedEnvironmentOptionNames= [];
492
501
 
493
502
  /**
@@ -496,13 +505,17 @@ const makeEnvironmentCaptor= (aGlobal)=>{
496
505
  *
497
506
  * @param {string} optionName
498
507
  * @param {string} defaultSetting
508
+ * @param {string[]} [optOtherValues]
509
+ * If provided, the option value must be included or match `defaultSetting`.
499
510
  * @returns {string}
500
511
  */
501
- const getEnvironmentOption= (optionName, defaultSetting)=> {
502
- // eslint-disable-next-line @endo/no-polymorphic-call
512
+ const getEnvironmentOption= (
513
+ optionName,
514
+ defaultSetting,
515
+ optOtherValues= undefined)=>
516
+ {
503
517
  typeof optionName=== 'string'||
504
518
  Fail `Environment option name ${q(optionName)} must be a string.`;
505
- // eslint-disable-next-line @endo/no-polymorphic-call
506
519
  typeof defaultSetting=== 'string'||
507
520
  Fail `Environment option default setting ${q(
508
521
  defaultSetting)
@@ -510,44 +523,79 @@ const makeEnvironmentCaptor= (aGlobal)=>{
510
523
 
511
524
  /** @type {string} */
512
525
  let setting= defaultSetting;
513
- const globalProcess= aGlobal.process;
514
- if( globalProcess&& typeof globalProcess=== 'object') {
515
- const globalEnv= globalProcess.env;
516
- if( globalEnv&& typeof globalEnv=== 'object') {
517
- if( optionName in globalEnv) {
526
+ const globalProcess= aGlobal.process|| undefined;
527
+ const globalEnv=
528
+ typeof globalProcess=== 'object'&& globalProcess.env|| undefined;
529
+ if( typeof globalEnv=== 'object') {
530
+ if( optionName in globalEnv) {
531
+ if( !dropNames) {
518
532
  arrayPush(capturedEnvironmentOptionNames, optionName);
519
- const optionValue= globalEnv[optionName];
520
- // eslint-disable-next-line @endo/no-polymorphic-call
521
- typeof optionValue=== 'string'||
522
- Fail `Environment option named ${q(
523
- optionName)
524
- }, if present, must have a corresponding string value, got ${q(
525
- optionValue)
526
- }`;
527
- setting= optionValue;
528
533
  }
534
+ const optionValue= globalEnv[optionName];
535
+ // eslint-disable-next-line @endo/no-polymorphic-call
536
+ typeof optionValue=== 'string'||
537
+ Fail `Environment option named ${q(
538
+ optionName)
539
+ }, if present, must have a corresponding string value, got ${q(
540
+ optionValue)
541
+ }`;
542
+ setting= optionValue;
529
543
  }
530
544
  }
545
+ optOtherValues=== undefined||
546
+ setting=== defaultSetting||
547
+ arrayIncludes(optOtherValues, setting)||
548
+ Fail `Unrecognized ${q(optionName)} value ${q(
549
+ setting)
550
+ }. Expected one of ${q([defaultSetting,...optOtherValues]) }`;
531
551
  return setting;
532
552
  };
533
553
  freeze(getEnvironmentOption);
534
554
 
555
+ /**
556
+ * @param {string} optionName
557
+ * @returns {string[]}
558
+ */
559
+ const getEnvironmentOptionsList= (optionName)=>{
560
+ const option= getEnvironmentOption(optionName, '');
561
+ return freeze(option=== ''? []: stringSplit(option, ','));
562
+ };
563
+ freeze(getEnvironmentOptionsList);
564
+
565
+ const environmentOptionsListHas= (optionName, element)=>
566
+ arrayIncludes(getEnvironmentOptionsList(optionName), element);
567
+
535
568
  const getCapturedEnvironmentOptionNames= ()=> {
536
569
  return freeze([...capturedEnvironmentOptionNames]);
537
570
  };
538
571
  freeze(getCapturedEnvironmentOptionNames);
539
572
 
540
- return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames});
573
+ return freeze({
574
+ getEnvironmentOption,
575
+ getEnvironmentOptionsList,
576
+ environmentOptionsListHas,
577
+ getCapturedEnvironmentOptionNames});
578
+
541
579
  };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
542
580
  freeze(makeEnvironmentCaptor);
543
- })
581
+
582
+ /**
583
+ * For the simple case, where the global in question is `globalThis` and no
584
+ * reporting of option names is desired.
585
+ */
586
+ const {
587
+ getEnvironmentOption,
588
+ getEnvironmentOptionsList,
589
+ environmentOptionsListHas}=
590
+ makeEnvironmentCaptor(globalThis, true);$h‍_once.getEnvironmentOption(getEnvironmentOption);$h‍_once.getEnvironmentOptionsList(getEnvironmentOptionsList);$h‍_once.environmentOptionsListHas(environmentOptionsListHas);
591
+ })()
544
592
  ,
545
593
  // === functors[3] ===
546
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([["./src/env-options.js", []]]);
547
- })
594
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./src/env-options.js", []]]);
595
+ })()
548
596
  ,
549
597
  // === functors[4] ===
550
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Set,String,isArray,arrayJoin,arraySlice,arraySort,arrayMap,keys,fromEntries,freeze,is,isError,setAdd,setHas,stringIncludes,stringStartsWith,stringifyJson,toStringTagSymbol;$h‍_imports([["../commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["stringIncludes", [$h‍_a => (stringIncludes = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["stringifyJson", [$h‍_a => (stringifyJson = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
598
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,isArray,arrayJoin,arraySlice,arraySort,arrayMap,keys,fromEntries,freeze,is,isError,setAdd,setHas,stringIncludes,stringStartsWith,stringifyJson,toStringTagSymbol;$h‍_imports([["../commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["stringIncludes", [$h‍_a => (stringIncludes = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["stringifyJson", [$h‍_a => (stringifyJson = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
551
599
 
552
600
 
553
601
 
@@ -739,16 +787,16 @@ const bestEffortStringify= (payload, spaces= undefined)=> {
739
787
  }
740
788
  };$h‍_once.bestEffortStringify(bestEffortStringify);
741
789
  freeze(bestEffortStringify);
742
- })
790
+ })()
743
791
  ,
744
792
  // === functors[5] ===
745
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); // @ts-check
793
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); // @ts-check
746
794
 
747
795
  /**
748
796
  * @callback BaseAssert
749
797
  * The `assert` function itself.
750
798
  *
751
- * @param {*} flag The truthy/falsy value
799
+ * @param {any} flag The truthy/falsy value
752
800
  * @param {Details=} optDetails The details to throw
753
801
  * @param {ErrorConstructor=} ErrorConstructor An optional alternate error
754
802
  * constructor to use.
@@ -795,8 +843,8 @@ freeze(bestEffortStringify);
795
843
  * The `assert.equal` method
796
844
  *
797
845
  * Assert that two values must be `Object.is`.
798
- * @param {*} actual The value we received
799
- * @param {*} expected What we wanted
846
+ * @param {any} actual The value we received
847
+ * @param {any} expected What we wanted
800
848
  * @param {Details=} optDetails The details to throw
801
849
  * @param {ErrorConstructor=} ErrorConstructor An optional alternate error
802
850
  * constructor to use.
@@ -945,7 +993,7 @@ freeze(bestEffortStringify);
945
993
  * ```
946
994
  *
947
995
  * @callback AssertQuote
948
- * @param {*} payload What to declassify
996
+ * @param {any} payload What to declassify
949
997
  * @param {(string|number)=} spaces
950
998
  * @returns {StringablePayload} The declassified payload
951
999
  */
@@ -1147,10 +1195,10 @@ freeze(bestEffortStringify);
1147
1195
  * @param {string=} topic
1148
1196
  * @returns {VirtualConsole}
1149
1197
  */
1150
- })
1198
+ })()
1151
1199
  ,
1152
1200
  // === functors[6] ===
1153
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); // @ts-check
1201
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); // @ts-check
1154
1202
 
1155
1203
  /**
1156
1204
  * @typedef {readonly any[]} LogArgs
@@ -1235,14 +1283,14 @@ freeze(bestEffortStringify);
1235
1283
  * calls methods of the `loggedErrorHandler` to customize how it handles logged
1236
1284
  * errors.
1237
1285
  *
1238
- * @param {VirtualConsole} baseConsole
1286
+ * @param {VirtualConsole | undefined} baseConsole
1239
1287
  * @param {LoggedErrorHandler} loggedErrorHandler
1240
- * @returns {VirtualConsole}
1288
+ * @returns {VirtualConsole | undefined}
1241
1289
  */
1242
- })
1290
+ })()
1243
1291
  ,
1244
1292
  // === functors[7] ===
1245
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([["./internal-types.js", []]]);
1293
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./internal-types.js", []]]);
1246
1294
 
1247
1295
 
1248
1296
 
@@ -1519,10 +1567,10 @@ const makeNoteLogArgsArrayKit= (
1519
1567
 
1520
1568
  };$h‍_once.makeNoteLogArgsArrayKit(makeNoteLogArgsArrayKit);
1521
1569
  freeze(makeNoteLogArgsArrayKit);
1522
- })
1570
+ })()
1523
1571
  ,
1524
1572
  // === functors[8] ===
1525
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,globalThis,is,isError,regexpTest,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h‍_imports([["../commons.js", [["RangeError", [$h‍_a => (RangeError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["stringIndexOf", [$h‍_a => (stringIndexOf = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["weakmapDelete", [$h‍_a => (weakmapDelete = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./stringify-utils.js", [["an", [$h‍_a => (an = $h‍_a)]],["bestEffortStringify", [$h‍_a => (bestEffortStringify = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit", [$h‍_a => (makeNoteLogArgsArrayKit = $h‍_a)]]]]]);
1573
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,globalThis,is,isError,regexpTest,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h‍_imports([["../commons.js", [["RangeError", [$h‍_a => (RangeError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["stringIndexOf", [$h‍_a => (stringIndexOf = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["weakmapDelete", [$h‍_a => (weakmapDelete = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./stringify-utils.js", [["an", [$h‍_a => (an = $h‍_a)]],["bestEffortStringify", [$h‍_a => (bestEffortStringify = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit", [$h‍_a => (makeNoteLogArgsArrayKit = $h‍_a)]]]]]);
1526
1574
 
1527
1575
 
1528
1576
 
@@ -1991,10 +2039,10 @@ freeze(makeAssert);
1991
2039
 
1992
2040
  /** @type {Assert} */
1993
2041
  const assert= makeAssert();$h‍_once.assert(assert);
1994
- })
2042
+ })()
1995
2043
  ,
1996
2044
  // === functors[9] ===
1997
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Set,String,TypeError,WeakMap,WeakSet,globalThis,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)]],["globalThis", [$h‍_a => (globalThis = $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)]]]]]);
2045
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,TypeError,WeakMap,WeakSet,globalThis,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)]],["globalThis", [$h‍_a => (globalThis = $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)]]]]]);
1998
2046
 
1999
2047
 
2000
2048
 
@@ -2241,10 +2289,10 @@ const makeHardener= ()=> {
2241
2289
 
2242
2290
  return harden;
2243
2291
  };$h‍_once.makeHardener(makeHardener);
2244
- })
2292
+ })()
2245
2293
  ,
2246
2294
  // === functors[10] ===
2247
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); /* eslint-disable no-restricted-globals */
2295
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* eslint-disable no-restricted-globals */
2248
2296
  /**
2249
2297
  * @file Exports {@code whitelist}, a recursively defined
2250
2298
  * JSON record enumerating all intrinsics and their properties
@@ -3366,7 +3414,21 @@ const permitted= {
3366
3414
  size: getter,
3367
3415
  values: fn,
3368
3416
  '@@iterator': fn,
3369
- '@@toStringTag': 'string'},
3417
+ '@@toStringTag': 'string',
3418
+ // See https://github.com/tc39/proposal-set-methods
3419
+ intersection: fn,
3420
+ // See https://github.com/tc39/proposal-set-methods
3421
+ union: fn,
3422
+ // See https://github.com/tc39/proposal-set-methods
3423
+ difference: fn,
3424
+ // See https://github.com/tc39/proposal-set-methods
3425
+ symmetricDifference: fn,
3426
+ // See https://github.com/tc39/proposal-set-methods
3427
+ isSubsetOf: fn,
3428
+ // See https://github.com/tc39/proposal-set-methods
3429
+ isSupersetOf: fn,
3430
+ // See https://github.com/tc39/proposal-set-methods
3431
+ isDisjointFrom: fn},
3370
3432
 
3371
3433
 
3372
3434
  '%SetIteratorPrototype%': {
@@ -3660,6 +3722,8 @@ const permitted= {
3660
3722
  race: fn,
3661
3723
  reject: fn,
3662
3724
  resolve: fn,
3725
+ // https://github.com/tc39/proposal-promise-with-resolvers
3726
+ withResolvers: fn,
3663
3727
  '@@species': getter},
3664
3728
 
3665
3729
 
@@ -3758,10 +3822,10 @@ const permitted= {
3758
3822
  harden: { ...fn, isFake: 'boolean'},
3759
3823
 
3760
3824
  '%InitialGetStackString%': fn};$h‍_once.permitted(permitted);
3761
- })
3825
+ })()
3762
3826
  ,
3763
3827
  // === functors[11] ===
3764
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let TypeError,WeakSet,arrayFilter,create,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,isObject,objectHasOwnProperty,values,weaksetHas,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,permitted;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["permitted", [$h‍_a => (permitted = $h‍_a)]]]]]);
3828
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,WeakSet,arrayFilter,create,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,isObject,objectHasOwnProperty,values,weaksetHas,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,permitted;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["permitted", [$h‍_a => (permitted = $h‍_a)]]]]]);
3765
3829
 
3766
3830
 
3767
3831
 
@@ -3935,10 +3999,10 @@ const getGlobalIntrinsics= (globalObject)=>{
3935
3999
 
3936
4000
  return finalIntrinsics();
3937
4001
  };$h‍_once.getGlobalIntrinsics(getGlobalIntrinsics);
3938
- })
4002
+ })()
3939
4003
  ,
3940
4004
  // === functors[12] ===
3941
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let permitted,FunctionInstance,isAccessorPermit,Map,String,Symbol,TypeError,arrayFilter,arrayIncludes,arrayMap,entries,getOwnPropertyDescriptor,getPrototypeOf,isObject,mapGet,objectHasOwnProperty,ownKeys,symbolKeyFor;$h‍_imports([["./permits.js", [["permitted", [$h‍_a => (permitted = $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)]],["Symbol", [$h‍_a => (Symbol = $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)]]]]]);
4005
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let permitted,FunctionInstance,isAccessorPermit,Map,String,Symbol,TypeError,arrayFilter,arrayIncludes,arrayMap,entries,getOwnPropertyDescriptor,getPrototypeOf,isObject,mapGet,objectHasOwnProperty,ownKeys,symbolKeyFor;$h‍_imports([["./permits.js", [["permitted", [$h‍_a => (permitted = $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)]],["Symbol", [$h‍_a => (Symbol = $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)]]]]]);
3942
4006
 
3943
4007
 
3944
4008
 
@@ -4014,7 +4078,18 @@ function whitelistIntrinsics(
4014
4078
  intrinsics,
4015
4079
  markVirtualizedNativeFunction)
4016
4080
  {
4017
- // These primitives are allowed allowed for permits.
4081
+ let groupStarted= false;
4082
+ const inConsoleGroup= (level, ...args)=> {
4083
+ if( !groupStarted) {
4084
+ // eslint-disable-next-line @endo/no-polymorphic-call
4085
+ console.groupCollapsed('Removing unpermitted intrinsics');
4086
+ groupStarted= true;
4087
+ }
4088
+ // eslint-disable-next-line @endo/no-polymorphic-call
4089
+ return console[level](...args);
4090
+ };
4091
+
4092
+ // These primitives are allowed for permits.
4018
4093
  const primitives= ['undefined', 'boolean', 'number', 'string', 'symbol'];
4019
4094
 
4020
4095
  // These symbols are allowed as well-known symbols
@@ -4219,11 +4294,7 @@ function whitelistIntrinsics(
4219
4294
  // that we are removing it so we know to look into it, as happens when
4220
4295
  // the language evolves new features to existing intrinsics.
4221
4296
  if( subPermit!== false) {
4222
- // This call to `console.warn` is intentional. It is not a vestige of
4223
- // a debugging attempt. See the comment at top of file for an
4224
- // explanation.
4225
- // eslint-disable-next-line @endo/no-polymorphic-call
4226
- console.warn( `Removing ${subPath}`);
4297
+ inConsoleGroup('warn', `Removing ${subPath}`);
4227
4298
  }
4228
4299
  try {
4229
4300
  delete obj[prop];
@@ -4232,17 +4303,17 @@ function whitelistIntrinsics(
4232
4303
  if( typeof obj=== 'function'&& prop=== 'prototype') {
4233
4304
  obj.prototype= undefined;
4234
4305
  if( obj.prototype=== undefined) {
4235
- // eslint-disable-next-line @endo/no-polymorphic-call
4236
- console.warn( `Tolerating undeletable ${subPath} === undefined`);
4306
+ inConsoleGroup(
4307
+ 'warn',
4308
+ `Tolerating undeletable ${subPath} === undefined`);
4309
+
4237
4310
  // eslint-disable-next-line no-continue
4238
4311
  continue;
4239
4312
  }
4240
4313
  }
4241
- // eslint-disable-next-line @endo/no-polymorphic-call
4242
- console.error( `failed to delete ${subPath}`,err);
4314
+ inConsoleGroup('error', `failed to delete ${subPath}`,err);
4243
4315
  }else {
4244
- // eslint-disable-next-line @endo/no-polymorphic-call
4245
- console.error( `deleting ${subPath} threw`,err);
4316
+ inConsoleGroup('error', `deleting ${subPath} threw`,err);
4246
4317
  }
4247
4318
  throw err;
4248
4319
  }
@@ -4250,14 +4321,21 @@ function whitelistIntrinsics(
4250
4321
  }
4251
4322
  }
4252
4323
 
4253
- // Start path with 'intrinsics' to clarify that properties are not
4254
- // removed from the global object by the whitelisting operation.
4255
- visitProperties('intrinsics', intrinsics, permitted);
4324
+ try {
4325
+ // Start path with 'intrinsics' to clarify that properties are not
4326
+ // removed from the global object by the whitelisting operation.
4327
+ visitProperties('intrinsics', intrinsics, permitted);
4328
+ }finally {
4329
+ if( groupStarted) {
4330
+ // eslint-disable-next-line @endo/no-polymorphic-call
4331
+ console.groupEnd();
4332
+ }
4333
+ }
4256
4334
  }$h‍_once.default( whitelistIntrinsics);
4257
- })
4335
+ })()
4258
4336
  ,
4259
4337
  // === functors[13] ===
4260
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf,freeze;$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)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]);
4338
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf,freeze;$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)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]);
4261
4339
 
4262
4340
 
4263
4341
 
@@ -4393,10 +4471,10 @@ function tameFunctionConstructors() {
4393
4471
 
4394
4472
  return newIntrinsics;
4395
4473
  }$h‍_once.default( tameFunctionConstructors);
4396
- })
4474
+ })()
4397
4475
  ,
4398
4476
  // === functors[14] ===
4399
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
4477
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
4400
4478
 
4401
4479
 
4402
4480
 
@@ -4526,10 +4604,10 @@ function tameDateConstructor(dateTaming= 'safe') {
4526
4604
  '%SharedDate%': SharedDate};
4527
4605
 
4528
4606
  }$h‍_once.default( tameDateConstructor);
4529
- })
4607
+ })()
4530
4608
  ,
4531
4609
  // === functors[15] ===
4532
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
4610
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
4533
4611
 
4534
4612
 
4535
4613
 
@@ -4573,10 +4651,10 @@ function tameMathObject(mathTaming= 'safe') {
4573
4651
  '%SharedMath%': sharedMath};
4574
4652
 
4575
4653
  }$h‍_once.default( tameMathObject);
4576
- })
4654
+ })()
4577
4655
  ,
4578
4656
  // === functors[16] ===
4579
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
4657
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
4580
4658
 
4581
4659
 
4582
4660
 
@@ -4637,10 +4715,12 @@ function tameRegExpConstructor(regExpTaming= 'safe') {
4637
4715
  '%SharedRegExp%': SharedRegExp};
4638
4716
 
4639
4717
  }$h‍_once.default( tameRegExpConstructor);
4640
- })
4718
+ })()
4641
4719
  ,
4642
4720
  // === functors[17] ===
4643
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); /**
4721
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let toStringTagSymbol;$h‍_imports([["./commons.js", [["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
4722
+
4723
+ /**
4644
4724
  * @file Exports {@code enablements}, a recursively defined
4645
4725
  * JSON record defining the optimum set of intrinsics properties
4646
4726
  * that need to be "repaired" before hardening is applied on
@@ -4715,7 +4795,14 @@ const minEnablements= {
4715
4795
 
4716
4796
  '%ErrorPrototype%': {
4717
4797
  name: true // set by "precond", "ava", "node-fetch"
4718
- }};
4798
+ },
4799
+ '%IteratorPrototype%': {
4800
+ toString: true,
4801
+ // https://github.com/tc39/proposal-iterator-helpers
4802
+ constructor: true,
4803
+ // https://github.com/tc39/proposal-iterator-helpers
4804
+ [toStringTagSymbol]: true}};
4805
+
4719
4806
 
4720
4807
 
4721
4808
  /**
@@ -4793,7 +4880,11 @@ const moderateEnablements= {
4793
4880
 
4794
4881
 
4795
4882
  '%IteratorPrototype%': {
4796
- toString: true}};
4883
+ toString: true,
4884
+ // https://github.com/tc39/proposal-iterator-helpers
4885
+ constructor: true,
4886
+ // https://github.com/tc39/proposal-iterator-helpers
4887
+ [toStringTagSymbol]: true}};
4797
4888
 
4798
4889
 
4799
4890
 
@@ -4835,7 +4926,7 @@ const severeEnablements= {
4835
4926
  * With the `'*'` setting here, all the properties inherited from
4836
4927
  * `Object.prototype` are accessors, creating an unusable display as seen
4837
4928
  * at As explained at
4838
- * https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md#overridetaming-options
4929
+ * https://github.com/endojs/endo/blob/master/packages/ses/docs/lockdown.md#overridetaming-options
4839
4930
  * Open the triangles at the bottom of that section.
4840
4931
  */
4841
4932
  '%ObjectPrototype%': '*',
@@ -4860,11 +4951,10 @@ const severeEnablements= {
4860
4951
  * is accepted.
4861
4952
  */
4862
4953
  '%SetPrototype%': '*'};$h‍_once.severeEnablements(severeEnablements);
4863
- })
4954
+ })()
4864
4955
  ,
4865
4956
  // === functors[18] ===
4866
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Set,String,TypeError,arrayForEach,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,getOwnPropertyNames,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]]]],["./enablements.js", [["minEnablements", [$h‍_a => (minEnablements = $h‍_a)]],["moderateEnablements", [$h‍_a => (moderateEnablements = $h‍_a)]],["severeEnablements", [$h‍_a => (severeEnablements = $h‍_a)]]]]]);
4867
-
4957
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,TypeError,arrayForEach,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]]]],["./enablements.js", [["minEnablements", [$h‍_a => (minEnablements = $h‍_a)]],["moderateEnablements", [$h‍_a => (moderateEnablements = $h‍_a)]],["severeEnablements", [$h‍_a => (severeEnablements = $h‍_a)]]]]]);
4868
4958
 
4869
4959
 
4870
4960
 
@@ -4953,9 +5043,43 @@ function enablePropertyOverrides(
4953
5043
  if( 'value'in desc&& desc.configurable) {
4954
5044
  const { value}= desc;
4955
5045
 
4956
- function getter() {
4957
- return value;
4958
- }
5046
+ const isDebug= setHas(debugProperties, prop);
5047
+
5048
+ // We use concise method syntax to be `this` sensitive, but still
5049
+ // omit a prototype property or [[Construct]] behavior.
5050
+ // @ts-expect-error We know there is an accessor descriptor there
5051
+ const { get: getter, set: setter}= getOwnPropertyDescriptor(
5052
+ {
5053
+ get[ prop]() {
5054
+ return value;
5055
+ },
5056
+ set[ prop](newValue) {
5057
+ if( obj=== this) {
5058
+ throw TypeError(
5059
+ `Cannot assign to read only property '${String(
5060
+ prop)
5061
+ }' of '${path}'`);
5062
+
5063
+ }
5064
+ if( objectHasOwnProperty(this, prop)) {
5065
+ this[prop]= newValue;
5066
+ }else {
5067
+ if( isDebug) {
5068
+ // eslint-disable-next-line @endo/no-polymorphic-call
5069
+ console.error(TypeError( `Override property ${prop}`));
5070
+ }
5071
+ defineProperty(this, prop, {
5072
+ value: newValue,
5073
+ writable: true,
5074
+ enumerable: true,
5075
+ configurable: true});
5076
+
5077
+ }
5078
+ }},
5079
+
5080
+ prop);
5081
+
5082
+
4959
5083
  defineProperty(getter, 'originalValue', {
4960
5084
  value,
4961
5085
  writable: false,
@@ -4963,32 +5087,6 @@ function enablePropertyOverrides(
4963
5087
  configurable: false});
4964
5088
 
4965
5089
 
4966
- const isDebug= setHas(debugProperties, prop);
4967
-
4968
- function setter(newValue) {
4969
- if( obj=== this) {
4970
- throw TypeError(
4971
- `Cannot assign to read only property '${String(
4972
- prop)
4973
- }' of '${path}'`);
4974
-
4975
- }
4976
- if( objectHasOwnProperty(this, prop)) {
4977
- this[prop]= newValue;
4978
- }else {
4979
- if( isDebug) {
4980
- // eslint-disable-next-line @endo/no-polymorphic-call
4981
- console.error(TypeError( `Override property ${prop}`));
4982
- }
4983
- defineProperty(this, prop, {
4984
- value: newValue,
4985
- writable: true,
4986
- enumerable: true,
4987
- configurable: true});
4988
-
4989
- }
4990
- }
4991
-
4992
5090
  defineProperty(obj, prop, {
4993
5091
  get: getter,
4994
5092
  set: setter,
@@ -5013,12 +5111,11 @@ function enablePropertyOverrides(
5013
5111
  }
5014
5112
  // TypeScript does not allow symbols to be used as indexes because it
5015
5113
  // cannot recokon types of symbolized properties.
5016
- // @ts-ignore
5017
5114
  arrayForEach(ownKeys(descs), (prop)=>enable(path, obj, prop, descs[prop]));
5018
5115
  }
5019
5116
 
5020
5117
  function enableProperties(path, obj, plan) {
5021
- for( const prop of getOwnPropertyNames(plan)) {
5118
+ for( const prop of ownKeys(plan)) {
5022
5119
  const desc= getOwnPropertyDescriptor(obj, prop);
5023
5120
  if( !desc|| desc.get|| desc.set) {
5024
5121
  // No not a value property, nothing to do.
@@ -5026,10 +5123,8 @@ function enablePropertyOverrides(
5026
5123
  continue;
5027
5124
  }
5028
5125
 
5029
- // Plan has no symbol keys and we use getOwnPropertyNames()
5030
- // so `prop` cannot only be a string, not a symbol. We coerce it in place
5031
- // with `String(..)` anyway just as good hygiene, since these paths are just
5032
- // for diagnostic purposes.
5126
+ // In case `prop` is a symbol, we first coerce it with `String`,
5127
+ // purely for diagnostic purposes.
5033
5128
  const subPath= `${path}.${String(prop)}`;
5034
5129
  const subPlan= plan[prop];
5035
5130
 
@@ -5067,10 +5162,10 @@ function enablePropertyOverrides(
5067
5162
  // Do the repair.
5068
5163
  enableProperties('root', intrinsics, plan);
5069
5164
  }$h‍_once.default( enablePropertyOverrides);
5070
- })
5165
+ })()
5071
5166
  ,
5072
5167
  // === functors[19] ===
5073
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
5168
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
5074
5169
 
5075
5170
 
5076
5171
 
@@ -5151,10 +5246,10 @@ function tameLocaleMethods(intrinsics, localeTaming= 'safe') {
5151
5246
  value: numberToString});
5152
5247
 
5153
5248
  }$h‍_once.default( tameLocaleMethods);
5154
- })
5249
+ })()
5155
5250
  ,
5156
5251
  // === functors[20] ===
5157
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([]); /**
5252
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /**
5158
5253
  * makeEvalFunction()
5159
5254
  * A safe version of the native eval function which relies on
5160
5255
  * the safety of safeEvaluate for confinement.
@@ -5181,10 +5276,10 @@ const makeEvalFunction= (safeEvaluate)=>{
5181
5276
 
5182
5277
  return newEval;
5183
5278
  };$h‍_once.makeEvalFunction(makeEvalFunction);
5184
- })
5279
+ })()
5185
5280
  ,
5186
5281
  // === functors[21] ===
5187
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_FUNCTION,arrayJoin,arrayPop,defineProperties,getPrototypeOf,assert;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5282
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,arrayJoin,arrayPop,defineProperties,getPrototypeOf,assert;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayPop", [$h‍_a => (arrayPop = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5188
5283
 
5189
5284
 
5190
5285
 
@@ -5262,10 +5357,10 @@ const makeFunctionConstructor= (safeEvaluate)=>{
5262
5357
 
5263
5358
  return newFunction;
5264
5359
  };$h‍_once.makeFunctionConstructor(makeFunctionConstructor);
5265
- })
5360
+ })()
5266
5361
  ,
5267
5362
  // === functors[22] ===
5268
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let TypeError,assign,create,defineProperty,entries,freeze,objectHasOwnProperty,unscopablesSymbol,makeEvalFunction,makeFunctionConstructor,constantProperties,universalPropertyNames;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["unscopablesSymbol", [$h‍_a => (unscopablesSymbol = $h‍_a)]]]],["./make-eval-function.js", [["makeEvalFunction", [$h‍_a => (makeEvalFunction = $h‍_a)]]]],["./make-function-constructor.js", [["makeFunctionConstructor", [$h‍_a => (makeFunctionConstructor = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]]]]]);
5363
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,assign,create,defineProperty,entries,freeze,objectHasOwnProperty,unscopablesSymbol,makeEvalFunction,makeFunctionConstructor,constantProperties,universalPropertyNames;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["unscopablesSymbol", [$h‍_a => (unscopablesSymbol = $h‍_a)]]]],["./make-eval-function.js", [["makeEvalFunction", [$h‍_a => (makeEvalFunction = $h‍_a)]]]],["./make-function-constructor.js", [["makeFunctionConstructor", [$h‍_a => (makeFunctionConstructor = $h‍_a)]]]],["./permits.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]]]]]);
5269
5364
 
5270
5365
 
5271
5366
 
@@ -5377,10 +5472,12 @@ const setGlobalObjectMutableProperties= (
5377
5472
  globalThis: globalObject};
5378
5473
 
5379
5474
 
5380
- perCompartmentGlobals.Compartment= makeCompartmentConstructor(
5381
- makeCompartmentConstructor,
5382
- intrinsics,
5383
- markVirtualizedNativeFunction);
5475
+ perCompartmentGlobals.Compartment= freeze(
5476
+ makeCompartmentConstructor(
5477
+ makeCompartmentConstructor,
5478
+ intrinsics,
5479
+ markVirtualizedNativeFunction));
5480
+
5384
5481
 
5385
5482
 
5386
5483
  // TODO These should still be tamed according to the whitelist before
@@ -5412,7 +5509,7 @@ const setGlobalObjectEvaluators= (
5412
5509
  markVirtualizedNativeFunction)=>
5413
5510
  {
5414
5511
  {
5415
- const f= makeEvalFunction(evaluator);
5512
+ const f= freeze(makeEvalFunction(evaluator));
5416
5513
  markVirtualizedNativeFunction(f);
5417
5514
  defineProperty(globalObject, 'eval', {
5418
5515
  value: f,
@@ -5422,7 +5519,7 @@ const setGlobalObjectEvaluators= (
5422
5519
 
5423
5520
  }
5424
5521
  {
5425
- const f= makeFunctionConstructor(evaluator);
5522
+ const f= freeze(makeFunctionConstructor(evaluator));
5426
5523
  markVirtualizedNativeFunction(f);
5427
5524
  defineProperty(globalObject, 'Function', {
5428
5525
  value: f,
@@ -5432,10 +5529,10 @@ const setGlobalObjectEvaluators= (
5432
5529
 
5433
5530
  }
5434
5531
  };$h‍_once.setGlobalObjectEvaluators(setGlobalObjectEvaluators);
5435
- })
5532
+ })()
5436
5533
  ,
5437
5534
  // === functors[23] ===
5438
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Proxy,String,TypeError,ReferenceError,create,freeze,getOwnPropertyDescriptors,globalThis,immutableObject,assert;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5535
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Proxy,String,TypeError,ReferenceError,create,freeze,getOwnPropertyDescriptors,globalThis,immutableObject,assert;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5439
5536
 
5440
5537
 
5441
5538
 
@@ -5527,10 +5624,10 @@ const strictScopeTerminatorHandler= freeze(
5527
5624
  const strictScopeTerminator= new Proxy(
5528
5625
  immutableObject,
5529
5626
  strictScopeTerminatorHandler);$h‍_once.strictScopeTerminator(strictScopeTerminator);
5530
- })
5627
+ })()
5531
5628
  ,
5532
5629
  // === functors[24] ===
5533
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Proxy,create,freeze,getOwnPropertyDescriptors,immutableObject,reflectSet,strictScopeTerminatorHandler,alwaysThrowHandler;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminatorHandler", [$h‍_a => (strictScopeTerminatorHandler = $h‍_a)]],["alwaysThrowHandler", [$h‍_a => (alwaysThrowHandler = $h‍_a)]]]]]);
5630
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Proxy,create,freeze,getOwnPropertyDescriptors,immutableObject,reflectSet,strictScopeTerminatorHandler,alwaysThrowHandler;$h‍_imports([["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminatorHandler", [$h‍_a => (strictScopeTerminatorHandler = $h‍_a)]],["alwaysThrowHandler", [$h‍_a => (alwaysThrowHandler = $h‍_a)]]]]]);
5534
5631
 
5535
5632
 
5536
5633
 
@@ -5584,10 +5681,10 @@ const createSloppyGlobalsScopeTerminator= (globalObject)=>{
5584
5681
  return sloppyGlobalsScopeTerminator;
5585
5682
  };$h‍_once.createSloppyGlobalsScopeTerminator(createSloppyGlobalsScopeTerminator);
5586
5683
  freeze(createSloppyGlobalsScopeTerminator);
5587
- })
5684
+ })()
5588
5685
  ,
5589
5686
  // === functors[25] ===
5590
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_EVAL,create,defineProperties,freeze,assert;$h‍_imports([["./commons.js", [["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5687
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_EVAL,create,defineProperties,freeze,assert;$h‍_imports([["./commons.js", [["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5591
5688
 
5592
5689
 
5593
5690
 
@@ -5676,10 +5773,10 @@ const makeEvalScopeKit= ()=> {
5676
5773
 
5677
5774
  return evalScopeKit;
5678
5775
  };$h‍_once.makeEvalScopeKit(makeEvalScopeKit);
5679
- })
5776
+ })()
5680
5777
  ,
5681
5778
  // === functors[26] ===
5682
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_REG_EXP,regexpExec,stringSlice;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]]]]]);
5779
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_REG_EXP,regexpExec,stringSlice;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]]]]]);
5683
5780
 
5684
5781
  // Captures a key and value of the form #key=value or @key=value
5685
5782
  const sourceMetaEntryRegExp=
@@ -5729,10 +5826,10 @@ const getSourceURL= (src)=>{
5729
5826
 
5730
5827
  return sourceURL;
5731
5828
  };$h‍_once.getSourceURL(getSourceURL);
5732
- })
5829
+ })()
5733
5830
  ,
5734
5831
  // === functors[27] ===
5735
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,freeze,getSourceURL;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]);
5832
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,freeze,getSourceURL;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]);
5736
5833
 
5737
5834
 
5738
5835
 
@@ -5997,10 +6094,10 @@ $h‍_once.applyTransforms(applyTransforms);const transforms=freeze({
5997
6094
  rejectSomeDirectEvalExpressions: freeze(rejectSomeDirectEvalExpressions),
5998
6095
  mandatoryTransforms: freeze(mandatoryTransforms),
5999
6096
  applyTransforms: freeze(applyTransforms)});$h‍_once.transforms(transforms);
6000
- })
6097
+ })()
6001
6098
  ,
6002
6099
  // === functors[28] ===
6003
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,objectHasOwnProperty,regexpTest;$h‍_imports([["./commons.js", [["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]]]]]);
6100
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,objectHasOwnProperty,regexpTest;$h‍_imports([["./commons.js", [["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]]]]]);
6004
6101
 
6005
6102
 
6006
6103
 
@@ -6180,10 +6277,10 @@ const getScopeConstants= (globalObject, moduleLexicals= {})=> {
6180
6277
  moduleLexicalConstants};
6181
6278
 
6182
6279
  };$h‍_once.getScopeConstants(getScopeConstants);
6183
- })
6280
+ })()
6184
6281
  ,
6185
6282
  // === functors[29] ===
6186
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_FUNCTION,arrayJoin,apply,getScopeConstants;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]]]],["./scope-constants.js", [["getScopeConstants", [$h‍_a => (getScopeConstants = $h‍_a)]]]]]);
6283
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,arrayJoin,apply,getScopeConstants;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]]]],["./scope-constants.js", [["getScopeConstants", [$h‍_a => (getScopeConstants = $h‍_a)]]]]]);
6187
6284
 
6188
6285
 
6189
6286
 
@@ -6293,10 +6390,10 @@ const makeEvaluate= (context)=>{
6293
6390
 
6294
6391
  return apply(evaluateFactory, context, []);
6295
6392
  };$h‍_once.makeEvaluate(makeEvaluate);
6296
- })
6393
+ })()
6297
6394
  ,
6298
6395
  // === functors[30] ===
6299
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let apply,freeze,strictScopeTerminator,createSloppyGlobalsScopeTerminator,makeEvalScopeKit,applyTransforms,mandatoryTransforms,makeEvaluate,assert;$h‍_imports([["./commons.js", [["apply", [$h‍_a => (apply = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminator", [$h‍_a => (strictScopeTerminator = $h‍_a)]]]],["./sloppy-globals-scope-terminator.js", [["createSloppyGlobalsScopeTerminator", [$h‍_a => (createSloppyGlobalsScopeTerminator = $h‍_a)]]]],["./eval-scope.js", [["makeEvalScopeKit", [$h‍_a => (makeEvalScopeKit = $h‍_a)]]]],["./transforms.js", [["applyTransforms", [$h‍_a => (applyTransforms = $h‍_a)]],["mandatoryTransforms", [$h‍_a => (mandatoryTransforms = $h‍_a)]]]],["./make-evaluate.js", [["makeEvaluate", [$h‍_a => (makeEvaluate = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6396
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let apply,freeze,strictScopeTerminator,createSloppyGlobalsScopeTerminator,makeEvalScopeKit,applyTransforms,mandatoryTransforms,makeEvaluate,assert;$h‍_imports([["./commons.js", [["apply", [$h‍_a => (apply = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./strict-scope-terminator.js", [["strictScopeTerminator", [$h‍_a => (strictScopeTerminator = $h‍_a)]]]],["./sloppy-globals-scope-terminator.js", [["createSloppyGlobalsScopeTerminator", [$h‍_a => (createSloppyGlobalsScopeTerminator = $h‍_a)]]]],["./eval-scope.js", [["makeEvalScopeKit", [$h‍_a => (makeEvalScopeKit = $h‍_a)]]]],["./transforms.js", [["applyTransforms", [$h‍_a => (applyTransforms = $h‍_a)]],["mandatoryTransforms", [$h‍_a => (mandatoryTransforms = $h‍_a)]]]],["./make-evaluate.js", [["makeEvaluate", [$h‍_a => (makeEvaluate = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6300
6397
 
6301
6398
 
6302
6399
 
@@ -6406,10 +6503,10 @@ const makeSafeEvaluator= ({
6406
6503
 
6407
6504
  return { safeEvaluate};
6408
6505
  };$h‍_once.makeSafeEvaluator(makeSafeEvaluator);
6409
- })
6506
+ })()
6410
6507
  ,
6411
6508
  // === functors[31] ===
6412
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
6509
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
6413
6510
 
6414
6511
 
6415
6512
 
@@ -6459,10 +6556,10 @@ const tameFunctionToString= ()=> {
6459
6556
  }
6460
6557
  return markVirtualizedNativeFunction;
6461
6558
  };$h‍_once.tameFunctionToString(tameFunctionToString);
6462
- })
6559
+ })()
6463
6560
  ,
6464
6561
  // === functors[32] ===
6465
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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);
6562
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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);
6466
6563
 
6467
6564
 
6468
6565
 
@@ -6481,12 +6578,10 @@ function tameDomains(domainTaming= 'safe') {
6481
6578
  }
6482
6579
 
6483
6580
  // Protect against the hazard presented by Node.js domains.
6484
- if( typeof globalThis.process=== 'object'&& globalThis.process!== null) {
6581
+ const globalProcess= globalThis.process|| undefined;
6582
+ if( typeof globalProcess=== 'object') {
6485
6583
  // Check whether domains were initialized.
6486
- const domainDescriptor= getOwnPropertyDescriptor(
6487
- globalThis.process,
6488
- 'domain');
6489
-
6584
+ const domainDescriptor= getOwnPropertyDescriptor(globalProcess, 'domain');
6490
6585
  if( domainDescriptor!== undefined&& domainDescriptor.get!== undefined) {
6491
6586
  // The domain descriptor on Node.js initially has value: null, which
6492
6587
  // becomes a get, set pair after domains initialize.
@@ -6501,7 +6596,7 @@ function tameDomains(domainTaming= 'safe') {
6501
6596
  // The domain module merely throws an exception when it attempts to define
6502
6597
  // the domain property of the process global during its initialization.
6503
6598
  // We have no better recourse because Node.js uses defineProperty too.
6504
- defineProperty(globalThis.process, 'domain', {
6599
+ defineProperty(globalProcess, 'domain', {
6505
6600
  value: null,
6506
6601
  configurable: false,
6507
6602
  writable: false,
@@ -6509,10 +6604,10 @@ function tameDomains(domainTaming= 'safe') {
6509
6604
 
6510
6605
  }
6511
6606
  }
6512
- })
6607
+ })()
6513
6608
  ,
6514
6609
  // === functors[33] ===
6515
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakSet,arrayFilter,arrayMap,arrayPush,defineProperty,freeze,fromEntries,isError,stringEndsWith,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["stringEndsWith", [$h‍_a => (stringEndsWith = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
6610
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let WeakSet,arrayFilter,arrayMap,arrayPush,defineProperty,freeze,fromEntries,isError,stringEndsWith,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["isError", [$h‍_a => (isError = $h‍_a)]],["stringEndsWith", [$h‍_a => (stringEndsWith = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
6516
6611
 
6517
6612
 
6518
6613
 
@@ -6688,6 +6783,10 @@ freeze(ErrorInfo);
6688
6783
 
6689
6784
  /** @type {MakeCausalConsole} */
6690
6785
  const makeCausalConsole= (baseConsole, loggedErrorHandler)=> {
6786
+ if( !baseConsole) {
6787
+ return undefined;
6788
+ }
6789
+
6691
6790
  const { getStackString, tagError, takeMessageLogArgs, takeNoteLogArgsArray}=
6692
6791
  loggedErrorHandler;
6693
6792
 
@@ -6891,10 +6990,10 @@ const filterConsole= (baseConsole, filter, _topic= undefined)=> {
6891
6990
  return (/** @type {VirtualConsole} */ freeze(filteringConsole));
6892
6991
  };$h‍_once.filterConsole(filterConsole);
6893
6992
  freeze(filterConsole);
6894
- })
6993
+ })()
6895
6994
  ,
6896
6995
  // === functors[34] ===
6897
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
6996
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
6898
6997
 
6899
6998
 
6900
6999
 
@@ -7016,10 +7115,15 @@ const makeRejectionHandlers= (reportReason)=>{
7016
7115
  processTerminationHandler};
7017
7116
 
7018
7117
  };$h‍_once.makeRejectionHandlers(makeRejectionHandlers);
7019
- })
7118
+ })()
7020
7119
  ,
7021
7120
  // === functors[35] ===
7022
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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", []]]);
7121
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,apply,defineProperty,freeze,globalThis,defaultHandler,makeCausalConsole,makeRejectionHandlers;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $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", []]]);
7122
+
7123
+
7124
+
7125
+
7126
+
7023
7127
 
7024
7128
 
7025
7129
 
@@ -7028,8 +7132,14 @@ const makeRejectionHandlers= (reportReason)=>{
7028
7132
 
7029
7133
 
7030
7134
 
7031
- // eslint-disable-next-line no-restricted-globals
7032
- const originalConsole= console;
7135
+
7136
+
7137
+ const failFast= (message)=>{
7138
+ throw TypeError(message);
7139
+ };
7140
+
7141
+ const wrapLogger= (logger, thisArg)=>
7142
+ freeze((...args)=> apply(logger, thisArg, args));
7033
7143
 
7034
7144
  /**
7035
7145
  * Wrap console unless suppressed.
@@ -7048,9 +7158,9 @@ const tameConsole= (
7048
7158
  unhandledRejectionTrapping= 'report',
7049
7159
  optGetStackString= undefined)=>
7050
7160
  {
7051
- if( consoleTaming!== 'safe'&& consoleTaming!== 'unsafe') {
7052
- throw TypeError( `unrecognized consoleTaming ${consoleTaming}`);
7053
- }
7161
+ consoleTaming=== 'safe'||
7162
+ consoleTaming=== 'unsafe'||
7163
+ failFast( `unrecognized consoleTaming ${consoleTaming}`);
7054
7164
 
7055
7165
  let loggedErrorHandler;
7056
7166
  if( optGetStackString=== undefined) {
@@ -7061,11 +7171,40 @@ const tameConsole= (
7061
7171
  getStackString: optGetStackString};
7062
7172
 
7063
7173
  }
7064
- const ourConsole=
7174
+
7175
+ // eslint-disable-next-line no-restricted-globals
7176
+ const originalConsole= /** @type {VirtualConsole} */
7177
+ // eslint-disable-next-line no-nested-ternary
7178
+ typeof globalThis.console!== 'undefined'?
7179
+ globalThis.console:
7180
+ typeof globalThis.print=== 'function'?
7181
+ // Make a good-enough console for eshost (including only functions that
7182
+ // log at a specific level with no special argument interpretation).
7183
+ // https://console.spec.whatwg.org/#logging
7184
+ ((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))(
7185
+ // eslint-disable-next-line no-undef
7186
+ wrapLogger(globalThis.print)):
7187
+
7188
+ undefined;
7189
+
7190
+
7191
+ // Upgrade a log-only console (as in `eshost -h SpiderMonkey`).
7192
+ if( originalConsole&& originalConsole.log) {
7193
+ for( const methodName of ['warn', 'error']) {
7194
+ if( !originalConsole[methodName]) {
7195
+ defineProperty(originalConsole, methodName, {
7196
+ value: wrapLogger(originalConsole.log, originalConsole)});
7197
+
7198
+ }
7199
+ }
7200
+ }
7201
+
7202
+ const ourConsole= /** @type {VirtualConsole} */
7065
7203
  consoleTaming=== 'unsafe'?
7066
7204
  originalConsole:
7067
7205
  makeCausalConsole(originalConsole, loggedErrorHandler);
7068
7206
 
7207
+
7069
7208
  // Attach platform-specific error traps such that any error that gets thrown
7070
7209
  // at top-of-turn (the bottom of stack) will get logged by our causal
7071
7210
  // console, revealing the diagnostic information associated with the error,
@@ -7082,21 +7221,36 @@ const tameConsole= (
7082
7221
  /* eslint-disable @endo/no-polymorphic-call */
7083
7222
 
7084
7223
  // Node.js
7085
- if( errorTrapping!== 'none'&& globalThis.process!== undefined) {
7086
- globalThis.process.on('uncaughtException', (error)=>{
7224
+ const globalProcess= globalThis.process|| undefined;
7225
+ if(
7226
+ errorTrapping!== 'none'&&
7227
+ typeof globalProcess=== 'object'&&
7228
+ typeof globalProcess.on=== 'function')
7229
+ {
7230
+ let terminate;
7231
+ if( errorTrapping=== 'platform'|| errorTrapping=== 'exit') {
7232
+ const { exit}= globalProcess;
7233
+ // If there is a function-valued process.on but no function-valued process.exit,
7234
+ // fail early without caring whether errorTrapping is "platform" only by default.
7235
+ typeof exit=== 'function'|| failFast('missing process.exit');
7236
+ terminate= ()=> exit(globalProcess.exitCode|| -1);
7237
+ }else if( errorTrapping=== 'abort') {
7238
+ terminate= globalProcess.abort;
7239
+ typeof terminate=== 'function'|| failFast('missing process.abort');
7240
+ }
7241
+
7242
+ globalProcess.on('uncaughtException', (error)=>{
7087
7243
  // causalConsole is born frozen so not vulnerable to method tampering.
7088
7244
  ourConsole.error(error);
7089
- if( errorTrapping=== 'platform'|| errorTrapping=== 'exit') {
7090
- globalThis.process.exit(globalThis.process.exitCode|| -1);
7091
- }else if( errorTrapping=== 'abort') {
7092
- globalThis.process.abort();
7245
+ if( terminate) {
7246
+ terminate();
7093
7247
  }
7094
7248
  });
7095
7249
  }
7096
-
7097
7250
  if(
7098
7251
  unhandledRejectionTrapping!== 'none'&&
7099
- globalThis.process!== undefined)
7252
+ typeof globalProcess=== 'object'&&
7253
+ typeof globalProcess.on=== 'function')
7100
7254
  {
7101
7255
  const handleRejection= (reason)=>{
7102
7256
  // 'platform' and 'report' just log the reason.
@@ -7106,32 +7260,32 @@ const tameConsole= (
7106
7260
  const h= makeRejectionHandlers(handleRejection);
7107
7261
  if( h) {
7108
7262
  // Rejection handlers are supported.
7109
- globalThis.process.on('unhandledRejection', h.unhandledRejectionHandler);
7110
- globalThis.process.on('rejectionHandled', h.rejectionHandledHandler);
7111
- globalThis.process.on('exit', h.processTerminationHandler);
7263
+ globalProcess.on('unhandledRejection', h.unhandledRejectionHandler);
7264
+ globalProcess.on('rejectionHandled', h.rejectionHandledHandler);
7265
+ globalProcess.on('exit', h.processTerminationHandler);
7112
7266
  }
7113
7267
  }
7114
7268
 
7115
7269
  // Browser
7270
+ const globalWindow= globalThis.window|| undefined;
7116
7271
  if(
7117
7272
  errorTrapping!== 'none'&&
7118
- globalThis.window!== undefined&&
7119
- globalThis.window.addEventListener!== undefined)
7273
+ typeof globalWindow=== 'object'&&
7274
+ typeof globalWindow.addEventListener=== 'function')
7120
7275
  {
7121
- globalThis.window.addEventListener('error', (event)=>{
7276
+ globalWindow.addEventListener('error', (event)=>{
7122
7277
  event.preventDefault();
7123
7278
  // 'platform' and 'report' just log the reason.
7124
7279
  ourConsole.error(event.error);
7125
7280
  if( errorTrapping=== 'exit'|| errorTrapping=== 'abort') {
7126
- globalThis.window.location.href= `about:blank`;
7281
+ globalWindow.location.href= `about:blank`;
7127
7282
  }
7128
7283
  });
7129
7284
  }
7130
-
7131
7285
  if(
7132
7286
  unhandledRejectionTrapping!== 'none'&&
7133
- globalThis.window!== undefined&&
7134
- globalThis.window.addEventListener!== undefined)
7287
+ typeof globalWindow=== 'object'&&
7288
+ typeof globalWindow.addEventListener=== 'function')
7135
7289
  {
7136
7290
  const handleRejection= (reason)=>{
7137
7291
  ourConsole.error('SES_UNHANDLED_REJECTION:', reason);
@@ -7140,17 +7294,17 @@ const tameConsole= (
7140
7294
  const h= makeRejectionHandlers(handleRejection);
7141
7295
  if( h) {
7142
7296
  // Rejection handlers are supported.
7143
- globalThis.window.addEventListener('unhandledrejection', (event)=>{
7297
+ globalWindow.addEventListener('unhandledrejection', (event)=>{
7144
7298
  event.preventDefault();
7145
7299
  h.unhandledRejectionHandler(event.reason, event.promise);
7146
7300
  });
7147
7301
 
7148
- globalThis.window.addEventListener('rejectionhandled', (event)=>{
7302
+ globalWindow.addEventListener('rejectionhandled', (event)=>{
7149
7303
  event.preventDefault();
7150
7304
  h.rejectionHandledHandler(event.promise);
7151
7305
  });
7152
7306
 
7153
- globalThis.window.addEventListener('beforeunload', (_event)=>{
7307
+ globalWindow.addEventListener('beforeunload', (_event)=>{
7154
7308
  h.processTerminationHandler();
7155
7309
  });
7156
7310
  }
@@ -7159,10 +7313,10 @@ const tameConsole= (
7159
7313
 
7160
7314
  return { console: ourConsole};
7161
7315
  };$h‍_once.tameConsole(tameConsole);
7162
- })
7316
+ })()
7163
7317
  ,
7164
7318
  // === functors[36] ===
7165
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,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)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
7319
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,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)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
7166
7320
 
7167
7321
 
7168
7322
 
@@ -7499,10 +7653,10 @@ const tameV8ErrorConstructor= (
7499
7653
 
7500
7654
  return tamedMethods.getStackString;
7501
7655
  };$h‍_once.tameV8ErrorConstructor(tameV8ErrorConstructor);
7502
- })
7656
+ })()
7503
7657
  ,
7504
7658
  // === functors[37] ===
7505
- (({ 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)]]]],["../permits.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]);
7659
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]],["../permits.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]);
7506
7660
 
7507
7661
 
7508
7662
 
@@ -7753,10 +7907,10 @@ function tameErrorConstructor(
7753
7907
  '%SharedError%': SharedError};
7754
7908
 
7755
7909
  }$h‍_once.default( tameErrorConstructor);
7756
- })
7910
+ })()
7757
7911
  ,
7758
7912
  // === functors[38] ===
7759
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let ReferenceError,TypeError,Map,Set,arrayJoin,arrayMap,arrayPush,create,freeze,mapGet,mapHas,mapSet,setAdd,promiseCatch,promiseThen,values,weakmapGet,assert;$h‍_imports([["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["promiseCatch", [$h‍_a => (promiseCatch = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
7913
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let ReferenceError,TypeError,Map,Set,arrayJoin,arrayMap,arrayPush,create,freeze,mapGet,mapHas,mapSet,setAdd,promiseCatch,promiseThen,values,weakmapGet,assert;$h‍_imports([["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["promiseCatch", [$h‍_a => (promiseCatch = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
7760
7914
 
7761
7915
 
7762
7916
 
@@ -8117,10 +8271,11 @@ const load= async(
8117
8271
 
8118
8272
  }
8119
8273
  };$h‍_once.load(load);
8120
- })
8274
+ })()
8121
8275
  ,
8122
8276
  // === functors[39] ===
8123
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,weakmapSet,assert;$h‍_imports([["./module-load.js", [["makeAlias", [$h‍_a => (makeAlias = $h‍_a)]]]],["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectGetOwnPropertyDescriptor", [$h‍_a => (reflectGetOwnPropertyDescriptor = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["reflectIsExtensible", [$h‍_a => (reflectIsExtensible = $h‍_a)]],["reflectPreventExtensions", [$h‍_a => (reflectPreventExtensions = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
8277
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,toStringTagSymbol,weakmapSet,assert;$h‍_imports([["./module-load.js", [["makeAlias", [$h‍_a => (makeAlias = $h‍_a)]]]],["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectGetOwnPropertyDescriptor", [$h‍_a => (reflectGetOwnPropertyDescriptor = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["reflectIsExtensible", [$h‍_a => (reflectIsExtensible = $h‍_a)]],["reflectPreventExtensions", [$h‍_a => (reflectPreventExtensions = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
8278
+
8124
8279
 
8125
8280
 
8126
8281
 
@@ -8173,13 +8328,21 @@ const { quote: q}= assert;
8173
8328
  //
8174
8329
  const deferExports= ()=> {
8175
8330
  let active= false;
8176
- const proxiedExports= create(null);
8331
+ const exportsTarget= create(null, {
8332
+ // Make this appear like an ESM module namespace object.
8333
+ [toStringTagSymbol]: {
8334
+ value: 'Module',
8335
+ writable: false,
8336
+ enumerable: false,
8337
+ configurable: false}});
8338
+
8339
+
8177
8340
  return freeze({
8178
8341
  activate() {
8179
8342
  active= true;
8180
8343
  },
8181
- proxiedExports,
8182
- exportsProxy: new Proxy(proxiedExports, {
8344
+ exportsTarget,
8345
+ exportsProxy: new Proxy(exportsTarget, {
8183
8346
  get(_target, name, receiver) {
8184
8347
  if( !active) {
8185
8348
  throw TypeError(
@@ -8188,7 +8351,7 @@ const deferExports= ()=> {
8188
8351
  } of module exports namespace, the module has not yet begun to execute`);
8189
8352
 
8190
8353
  }
8191
- return reflectGet(proxiedExports, name, receiver);
8354
+ return reflectGet(exportsTarget, name, receiver);
8192
8355
  },
8193
8356
  set(_target, name, _value) {
8194
8357
  throw TypeError(
@@ -8203,7 +8366,7 @@ const deferExports= ()=> {
8203
8366
  }, the module has not yet begun to execute`);
8204
8367
 
8205
8368
  }
8206
- return reflectHas(proxiedExports, name);
8369
+ return reflectHas(exportsTarget, name);
8207
8370
  },
8208
8371
  deleteProperty(_target, name) {
8209
8372
  throw TypeError(
@@ -8216,7 +8379,7 @@ const deferExports= ()=> {
8216
8379
  'Cannot enumerate keys, the module has not yet begun to execute');
8217
8380
 
8218
8381
  }
8219
- return ownKeys(proxiedExports);
8382
+ return ownKeys(exportsTarget);
8220
8383
  },
8221
8384
  getOwnPropertyDescriptor(_target, name) {
8222
8385
  if( !active) {
@@ -8226,7 +8389,7 @@ const deferExports= ()=> {
8226
8389
  }, the module has not yet begun to execute`);
8227
8390
 
8228
8391
  }
8229
- return reflectGetOwnPropertyDescriptor(proxiedExports, name);
8392
+ return reflectGetOwnPropertyDescriptor(exportsTarget, name);
8230
8393
  },
8231
8394
  preventExtensions(_target) {
8232
8395
  if( !active) {
@@ -8234,7 +8397,7 @@ const deferExports= ()=> {
8234
8397
  'Cannot prevent extensions of module exports namespace, the module has not yet begun to execute');
8235
8398
 
8236
8399
  }
8237
- return reflectPreventExtensions(proxiedExports);
8400
+ return reflectPreventExtensions(exportsTarget);
8238
8401
  },
8239
8402
  isExtensible() {
8240
8403
  if( !active) {
@@ -8242,7 +8405,7 @@ const deferExports= ()=> {
8242
8405
  'Cannot check extensibility of module exports namespace, the module has not yet begun to execute');
8243
8406
 
8244
8407
  }
8245
- return reflectIsExtensible(proxiedExports);
8408
+ return reflectIsExtensible(exportsTarget);
8246
8409
  },
8247
8410
  getPrototypeOf(_target) {
8248
8411
  return null;
@@ -8269,12 +8432,31 @@ const deferExports= ()=> {
8269
8432
 
8270
8433
  };
8271
8434
 
8272
- // `getDeferredExports` memoizes the creation of a deferred module exports
8273
- // namespace proxy for any abritrary full specifier in a compartment.
8274
- // It also records the compartment and specifier affiliated with that module
8275
- // exports namespace proxy so it can be used as an alias into another
8276
- // compartment when threaded through a compartment's `moduleMap` argument.
8277
- $h‍_once.deferExports(deferExports);const getDeferredExports=(
8435
+ /**
8436
+ * @typedef {object} DeferredExports
8437
+ * @property {Record<string, any>} exportsTarget - The object to which a
8438
+ * module's exports will be added.
8439
+ * @property {Record<string, any>} exportsProxy - A proxy over the `exportsTarget`,
8440
+ * used to expose its "exports" to other compartments.
8441
+ * @property {() => void} activate - Activate the `exportsProxy` such that it can
8442
+ * be used as a module namespace object.
8443
+ */
8444
+
8445
+ /**
8446
+ * Memoizes the creation of a deferred module exports namespace proxy for any
8447
+ * arbitrary full specifier in a compartment. It also records the compartment
8448
+ * and specifier affiliated with that module exports namespace proxy so it
8449
+ * can be used as an alias into another compartment when threaded through
8450
+ * a compartment's `moduleMap` argument.
8451
+ *
8452
+ * @param {*} compartment - The compartment to retrieve deferred exports from.
8453
+ * @param {*} compartmentPrivateFields - The private fields of the compartment.
8454
+ * @param {*} moduleAliases - The module aliases of the compartment.
8455
+ * @param {string} specifier - The module specifier to retrieve deferred exports for.
8456
+ * @returns {DeferredExports} - The deferred exports for the module specifier of
8457
+ * the compartment.
8458
+ */$h‍_once.deferExports(deferExports);
8459
+ const getDeferredExports= (
8278
8460
  compartment,
8279
8461
  compartmentPrivateFields,
8280
8462
  moduleAliases,
@@ -8292,10 +8474,10 @@ $h‍_once.deferExports(deferExports);const getDeferredExports=(
8292
8474
  }
8293
8475
  return mapGet(deferredExports, specifier);
8294
8476
  };$h‍_once.getDeferredExports(getDeferredExports);
8295
- })
8477
+ })()
8296
8478
  ,
8297
8479
  // === functors[40] ===
8298
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let TypeError,arrayPush,create,getOwnPropertyDescriptors,evadeHtmlCommentTest,evadeImportExpressionTest,rejectSomeDirectEvalExpressions,makeSafeEvaluator;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]]]],["./transforms.js", [["evadeHtmlCommentTest", [$h‍_a => (evadeHtmlCommentTest = $h‍_a)]],["evadeImportExpressionTest", [$h‍_a => (evadeImportExpressionTest = $h‍_a)]],["rejectSomeDirectEvalExpressions", [$h‍_a => (rejectSomeDirectEvalExpressions = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]);
8480
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,arrayPush,create,getOwnPropertyDescriptors,evadeHtmlCommentTest,evadeImportExpressionTest,rejectSomeDirectEvalExpressions,makeSafeEvaluator;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]]]],["./transforms.js", [["evadeHtmlCommentTest", [$h‍_a => (evadeHtmlCommentTest = $h‍_a)]],["evadeImportExpressionTest", [$h‍_a => (evadeImportExpressionTest = $h‍_a)]],["rejectSomeDirectEvalExpressions", [$h‍_a => (rejectSomeDirectEvalExpressions = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]);
8299
8481
 
8300
8482
 
8301
8483
 
@@ -8388,10 +8570,10 @@ const compartmentEvaluate= (compartmentFields, source, options)=> {
8388
8570
  localTransforms});
8389
8571
 
8390
8572
  };$h‍_once.compartmentEvaluate(compartmentEvaluate);
8391
- })
8573
+ })()
8392
8574
  ,
8393
8575
  // === functors[41] ===
8394
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let assert,getDeferredExports,ReferenceError,SyntaxError,TypeError,arrayForEach,arrayIncludes,arrayPush,arraySome,arraySort,create,defineProperty,entries,freeze,isArray,keys,mapGet,weakmapGet,reflectHas,assign,compartmentEvaluate;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySome", [$h‍_a => (arraySome = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]]]);
8576
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let assert,getDeferredExports,ReferenceError,SyntaxError,TypeError,arrayForEach,arrayIncludes,arrayPush,arraySome,arraySort,create,defineProperty,entries,freeze,isArray,keys,mapGet,weakmapGet,reflectHas,assign,compartmentEvaluate;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./commons.js", [["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySome", [$h‍_a => (arraySome = $h‍_a)]],["arraySort", [$h‍_a => (arraySort = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]]]);
8395
8577
 
8396
8578
 
8397
8579
 
@@ -8425,7 +8607,7 @@ const makeThirdPartyModuleInstance= (
8425
8607
  moduleSpecifier,
8426
8608
  resolvedImports)=>
8427
8609
  {
8428
- const { exportsProxy, proxiedExports, activate}= getDeferredExports(
8610
+ const { exportsProxy, exportsTarget, activate}= getDeferredExports(
8429
8611
  compartment,
8430
8612
  weakmapGet(compartmentPrivateFields, compartment),
8431
8613
  moduleAliases,
@@ -8444,7 +8626,7 @@ const makeThirdPartyModuleInstance= (
8444
8626
 
8445
8627
  }
8446
8628
  arrayForEach(staticModuleRecord.exports, (name)=>{
8447
- let value= proxiedExports[name];
8629
+ let value= exportsTarget[name];
8448
8630
  const updaters= [];
8449
8631
 
8450
8632
  const get= ()=> value;
@@ -8456,7 +8638,7 @@ const makeThirdPartyModuleInstance= (
8456
8638
  }
8457
8639
  };
8458
8640
 
8459
- defineProperty(proxiedExports, name, {
8641
+ defineProperty(exportsTarget, name, {
8460
8642
  get,
8461
8643
  set,
8462
8644
  enumerable: true,
@@ -8468,9 +8650,9 @@ const makeThirdPartyModuleInstance= (
8468
8650
  update(value);
8469
8651
  };
8470
8652
  });
8471
- // This is enough to support import * from cjs - the '*' field doesn't need to be in exports nor proxiedExports because import will only ever access it via notifiers
8653
+ // This is enough to support import * from cjs - the '*' field doesn't need to be in exports nor exportsTarget because import will only ever access it via notifiers
8472
8654
  notifiers['*']= (update)=>{
8473
- update(proxiedExports);
8655
+ update(exportsTarget);
8474
8656
  };
8475
8657
  }
8476
8658
 
@@ -8490,7 +8672,7 @@ const makeThirdPartyModuleInstance= (
8490
8672
  try {
8491
8673
  // eslint-disable-next-line @endo/no-polymorphic-call
8492
8674
  staticModuleRecord.execute(
8493
- proxiedExports,
8675
+ exportsTarget,
8494
8676
  compartment,
8495
8677
  resolvedImports);
8496
8678
 
@@ -8536,7 +8718,7 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8536
8718
 
8537
8719
  const { __shimTransforms__, importMetaHook}= compartmentFields;
8538
8720
 
8539
- const { exportsProxy, proxiedExports, activate}= getDeferredExports(
8721
+ const { exportsProxy, exportsTarget, activate}= getDeferredExports(
8540
8722
  compartment,
8541
8723
  compartmentFields,
8542
8724
  moduleAliases,
@@ -8735,7 +8917,7 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8735
8917
 
8736
8918
 
8737
8919
  const notifyStar= (update)=>{
8738
- update(proxiedExports);
8920
+ update(exportsTarget);
8739
8921
  };
8740
8922
  notifiers['*']= notifyStar;
8741
8923
 
@@ -8828,10 +9010,10 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8828
9010
  // and the string must correspond to a valid identifier, sorting these
8829
9011
  // properties works for this specific case.
8830
9012
  arrayForEach(arraySort(keys(exportsProps)), (k)=>
8831
- defineProperty(proxiedExports, k, exportsProps[k]));
9013
+ defineProperty(exportsTarget, k, exportsProps[k]));
8832
9014
 
8833
9015
 
8834
- freeze(proxiedExports);
9016
+ freeze(exportsTarget);
8835
9017
  activate();
8836
9018
  }
8837
9019
 
@@ -8879,10 +9061,10 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8879
9061
  execute});
8880
9062
 
8881
9063
  };$h‍_once.makeModuleInstance(makeModuleInstance);
8882
- })
9064
+ })()
8883
9065
  ,
8884
9066
  // === functors[42] ===
8885
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let assert,makeModuleInstance,makeThirdPartyModuleInstance,Map,ReferenceError,TypeError,entries,isArray,isObject,mapGet,mapHas,mapSet,weakmapGet;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-instance.js", [["makeModuleInstance", [$h‍_a => (makeModuleInstance = $h‍_a)]],["makeThirdPartyModuleInstance", [$h‍_a => (makeThirdPartyModuleInstance = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]]]);
9067
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let assert,makeModuleInstance,makeThirdPartyModuleInstance,Map,ReferenceError,TypeError,entries,isArray,isObject,mapGet,mapHas,mapSet,weakmapGet;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-instance.js", [["makeModuleInstance", [$h‍_a => (makeModuleInstance = $h‍_a)]],["makeThirdPartyModuleInstance", [$h‍_a => (makeThirdPartyModuleInstance = $h‍_a)]]]],["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["isArray", [$h‍_a => (isArray = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]]]]]);
8886
9068
 
8887
9069
 
8888
9070
 
@@ -9059,10 +9241,10 @@ const instantiate= (
9059
9241
 
9060
9242
  return moduleInstance;
9061
9243
  };$h‍_once.instantiate(instantiate);
9062
- })
9244
+ })()
9063
9245
  ,
9064
9246
  // === functors[43] ===
9065
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Map,ReferenceError,TypeError,WeakMap,assign,defineProperties,entries,promiseThen,weakmapGet,weakmapSet,setGlobalObjectSymbolUnscopables,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,sharedGlobalPropertyNames,load,link,getDeferredExports,assert,compartmentEvaluate,makeSafeEvaluator;$h‍_imports([["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectSymbolUnscopables", [$h‍_a => (setGlobalObjectSymbolUnscopables = $h‍_a)]],["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./permits.js", [["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]]]],["./module-load.js", [["load", [$h‍_a => (load = $h‍_a)]]]],["./module-link.js", [["link", [$h‍_a => (link = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]);
9247
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Map,ReferenceError,TypeError,WeakMap,assign,defineProperties,entries,promiseThen,weakmapGet,weakmapSet,setGlobalObjectSymbolUnscopables,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,sharedGlobalPropertyNames,load,link,getDeferredExports,assert,compartmentEvaluate,makeSafeEvaluator;$h‍_imports([["./commons.js", [["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectSymbolUnscopables", [$h‍_a => (setGlobalObjectSymbolUnscopables = $h‍_a)]],["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./permits.js", [["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]]]],["./module-load.js", [["load", [$h‍_a => (load = $h‍_a)]]]],["./module-link.js", [["link", [$h‍_a => (link = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]]]);
9066
9248
 
9067
9249
 
9068
9250
 
@@ -9354,10 +9536,10 @@ const makeCompartmentConstructor= (
9354
9536
 
9355
9537
  return Compartment;
9356
9538
  };$h‍_once.makeCompartmentConstructor(makeCompartmentConstructor);
9357
- })
9539
+ })()
9358
9540
  ,
9359
9541
  // === functors[44] ===
9360
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,globalThis,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)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]);
9542
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,globalThis,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)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]);
9361
9543
 
9362
9544
 
9363
9545
 
@@ -9518,10 +9700,10 @@ const getAnonymousIntrinsics= ()=> {
9518
9700
 
9519
9701
  return intrinsics;
9520
9702
  };$h‍_once.getAnonymousIntrinsics(getAnonymousIntrinsics);
9521
- })
9703
+ })()
9522
9704
  ,
9523
9705
  // === functors[45] ===
9524
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let TypeError,freeze;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]);
9706
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let TypeError,freeze;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]]]);
9525
9707
 
9526
9708
 
9527
9709
  const tameHarden= (safeHarden, hardenTaming)=> {
@@ -9550,10 +9732,10 @@ const tameHarden= (safeHarden, hardenTaming)=> {
9550
9732
  return freeze(fakeHarden);
9551
9733
  };$h‍_once.tameHarden(tameHarden);
9552
9734
  freeze(tameHarden);
9553
- })
9735
+ })()
9554
9736
  ,
9555
9737
  // === functors[46] ===
9556
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let Symbol,entries,fromEntries,getOwnPropertyDescriptors,defineProperties,arrayMap;$h‍_imports([["./commons.js", [["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]]]]]);
9738
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Symbol,entries,fromEntries,getOwnPropertyDescriptors,defineProperties,arrayMap;$h‍_imports([["./commons.js", [["Symbol", [$h‍_a => (Symbol = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]]]]]);
9557
9739
 
9558
9740
 
9559
9741
 
@@ -9618,10 +9800,226 @@ const tameSymbolConstructor= ()=> {
9618
9800
 
9619
9801
  return { '%SharedSymbol%': SharedSymbol};
9620
9802
  };$h‍_once.tameSymbolConstructor(tameSymbolConstructor);
9621
- })
9803
+ })()
9622
9804
  ,
9623
9805
  // === functors[47] ===
9624
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let makeEnvironmentCaptor,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor;$h‍_imports([["@endo/env-options", [["makeEnvironmentCaptor", [$h‍_a => (makeEnvironmentCaptor = $h‍_a)]]]],["./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)]],["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)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-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)]]]],["./permits.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)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]]]);
9806
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getOwnPropertyDescriptor,apply,defineProperty,toStringTagSymbol;$h‍_imports([["./commons.js", [["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
9807
+
9808
+
9809
+
9810
+
9811
+
9812
+
9813
+ const throws= (thunk)=>{
9814
+ try {
9815
+ thunk();
9816
+ return false;
9817
+ }catch( er) {
9818
+ return true;
9819
+ }
9820
+ };
9821
+
9822
+ /**
9823
+ * Exported for convenience of unit testing. Harmless, but not expected
9824
+ * to be useful by itself.
9825
+ *
9826
+ * @param {any} obj
9827
+ * @param {string|symbol} prop
9828
+ * @param {any} expectedValue
9829
+ * @returns {boolean}
9830
+ * Returns whether `tameFauxDataProperty` turned the property in question
9831
+ * from an apparent faux data property into the actual data property it
9832
+ * seemed to emulate.
9833
+ * If this function returns `false`, then we hope no effects happened.
9834
+ * However, sniffing out if an accessor property seems to be a faux data
9835
+ * property requires invoking the getter and setter functions that might
9836
+ * possibly have side effects.
9837
+ * `tameFauxDataProperty` is not in a position to tell.
9838
+ */
9839
+ const tameFauxDataProperty= (obj, prop, expectedValue)=> {
9840
+ if( obj=== undefined) {
9841
+ // The object does not exist in this version of the platform
9842
+ return false;
9843
+ }
9844
+ const desc= getOwnPropertyDescriptor(obj, prop);
9845
+ if( !desc|| 'value'in desc) {
9846
+ // The property either doesn't exist, or is already an actual data property.
9847
+ return false;
9848
+ }
9849
+ const { get, set}= desc;
9850
+ if( typeof get!== 'function'|| typeof set!== 'function') {
9851
+ // A faux data property has both a getter and a setter
9852
+ return false;
9853
+ }
9854
+ if( get()!== expectedValue) {
9855
+ // The getter called by itself should produce the expectedValue
9856
+ return false;
9857
+ }
9858
+ if( apply(get, obj, [])!== expectedValue) {
9859
+ // The getter called with `this === obj` should also return the
9860
+ // expectedValue.
9861
+ return false;
9862
+ }
9863
+ const testValue= 'Seems to be a setter';
9864
+ const subject1= { __proto__: null};
9865
+ apply(set, subject1, [testValue]);
9866
+ if( subject1[prop]!== testValue) {
9867
+ // The setter called with an unrelated object as `this` should
9868
+ // set the property on the object.
9869
+ return false;
9870
+ }
9871
+ const subject2= { __proto__: obj};
9872
+ apply(set, subject2, [testValue]);
9873
+ if( subject2[prop]!== testValue) {
9874
+ // The setter called on an object that inherits from `obj` should
9875
+ // override the property from `obj` as if by assignment.
9876
+ return false;
9877
+ }
9878
+ if( !throws(()=> apply(set, obj, [expectedValue]))) {
9879
+ // The setter called with `this === obj` should throw without having
9880
+ // caused any effect.
9881
+ // This is the test that has the greatest danger of leaving behind some
9882
+ // persistent side effect. The most obvious one is to emulate a
9883
+ // successful assignment to the property. That's why this test
9884
+ // uses `expectedValue`, so that case is likely not to actually
9885
+ // change anything.
9886
+ return false;
9887
+ }
9888
+ if( 'originalValue'in get) {
9889
+ // The ses-shim uniquely, as far as we know, puts an `originalValue`
9890
+ // property on the getter, so that reflect property tranversal algorithms,
9891
+ // like `harden`, will traverse into the enulated value without
9892
+ // calling the getter. That does not happen until `permits-intrinsics.js`
9893
+ // which is much later. So if we see one this early, we should
9894
+ // not assume we understand what's going on.
9895
+ return false;
9896
+ }
9897
+
9898
+ // We assume that this code runs before any untrusted code runs, so
9899
+ // we do not need to worry about the above conditions passing because of
9900
+ // malicious intent. In fact, it runs even before vetted shims are supposed
9901
+ // to run, between repair and hardening. Given that, after all these tests
9902
+ // pass, we have adequately validated that the property in question is
9903
+ // an accessor function whose purpose is suppressing the override mistake,
9904
+ // i.e., enabling a non-writable property to be overridden by assignment.
9905
+ // In that case, here we *temporarily* turn it into the data property
9906
+ // it seems to emulate, but writable so that it does not trigger the
9907
+ // override mistake while in this temporary state.
9908
+
9909
+ // For those properties that are also listed in `enablements.js`,
9910
+ // that phase will re-enable override for these properties, but
9911
+ // via accessor functions that SES controls, so we know what they are
9912
+ // doing. In addition, the getter functions installed by
9913
+ // `enable-property-overrides.js` have an `originalValue` field
9914
+ // enabling meta-traversal code like harden to visit the original value
9915
+ // without calling the getter.
9916
+
9917
+ if( desc.configurable=== false) {
9918
+ // Even though it seems to be a faux data property, we're unable to fix it.
9919
+ return false;
9920
+ }
9921
+
9922
+ // Many of the `return false;` cases above plausibly should be turned into
9923
+ // errors, or an least generate warnings. However, for those, the checks
9924
+ // following this phase are likely to signal an error anyway.
9925
+
9926
+ // At this point, we have passed all our sniff checks for validating that
9927
+ // it seems to be a faux data property with the expected value. Turn
9928
+ // it into the actual data property it emulates, but writable so there is
9929
+ // not yet an override mistake problem.
9930
+
9931
+ defineProperty(obj, prop, {
9932
+ value: expectedValue,
9933
+ writable: true,
9934
+ enumerable: desc.enumerable,
9935
+ configurable: true});
9936
+
9937
+
9938
+ return true;
9939
+ };
9940
+
9941
+ /**
9942
+ * In JavaScript, the so-called "override mistake" is the inability to
9943
+ * override an inherited non-writable data property by assignment. A common
9944
+ * workaround is to instead define an accessor property that acts like
9945
+ * a non-writable data property, except that it allows an object that
9946
+ * inherits this property to override it by assignment. Let's call
9947
+ * an access property that acts this way a "faux data property". In this
9948
+ * ses-shim, `enable-property-overrides.js` makes the properties listed in
9949
+ * `enablements.js` into faux data properties.
9950
+ *
9951
+ * But the ses-shim is not alone in use of this trick. Starting with the
9952
+ * [Iterator Helpers proposal](https://github.com/tc39/proposal-iterator-helpers),
9953
+ * some properties are defined as (what we call) faux data properties.
9954
+ * Some of these are new properties (`Interator.prototype.constructor`) and
9955
+ * some are old data properties converted to accessor properties
9956
+ * (`Iterator.prototype[String.toStringTag]`). So the ses-shim needs to be
9957
+ * prepared for some enumerated set of properties to already be faux data
9958
+ * properties in the platform prior to our initialization.
9959
+ *
9960
+ * For these possible faux data properties, it is important that
9961
+ * `permits.js` describe each as a data property, so that it can further
9962
+ * constrain the apparent value (that allegedly would be returned by the
9963
+ * getter) according to its own permits.
9964
+ *
9965
+ * However, at the time of this writing, the precise behavior specified
9966
+ * by the iterator-helpers proposal for these faux data properties is
9967
+ * novel. We should not be too confident that all further such platform
9968
+ * additions do what we would now expect. So, for each of these possible
9969
+ * faux data properties, we do some sniffing to see if it behaves as we
9970
+ * currently expect a faux data property to act. If not, then
9971
+ * `tameFauxDataProperties` tries not to modify it, leaving it to later
9972
+ * checks, especially `permits-intrinsics.js`, to error when it sees an
9973
+ * unexpected accessor.
9974
+ *
9975
+ * If one of these enumerated accessor properties does seem to be
9976
+ * a faithful faux data property, then `tameFauxDataProperties` itself
9977
+ * *tempoarily* turns it into the actual data property that it seems to emulate.
9978
+ * This data property starts as writable, so that in this state it will
9979
+ * not trigger the override mistake, i.e., assignment to an object inheriting
9980
+ * this property is allowed to succeed at overriding this property.
9981
+ *
9982
+ * For those properties that should be a faux data property rather than an
9983
+ * actual one, such as those from the iterator-helpers proposal,
9984
+ * they should be listed as such in `enablements.js`, so
9985
+ * `enable-property-overrides.js` will turn it back into a faux data property.
9986
+ * But one controlled by the ses-shim, whose behavior we understand.
9987
+ *
9988
+ * `tameFauxDataProperties`, which turns these into actual data properties,
9989
+ * happens during the `repairIntrinsics` phase
9990
+ * of `lockdown`, before even vetted shim are supposed to run.
9991
+ * `enable-property-overrides.js` runs after vetted shims, turning the
9992
+ * appropriate ones back into faux data properties. Thus vetted shims
9993
+ * can observe the possibly non-conforming state where these are temporarily
9994
+ * actual data properties, rather than faux data properties.
9995
+ *
9996
+ * Coordinate the property enumeration here
9997
+ * with `enablements.js`, so the appropriate properties are
9998
+ * turned back to faux data properties.
9999
+ *
10000
+ * @param {Record<any,any>} intrinsics
10001
+ */$h‍_once.tameFauxDataProperty(tameFauxDataProperty);
10002
+ const tameFauxDataProperties= (intrinsics)=>{
10003
+ // https://github.com/tc39/proposal-iterator-helpers
10004
+ tameFauxDataProperty(
10005
+ intrinsics['%IteratorPrototype%'],
10006
+ 'constructor',
10007
+ intrinsics.Iterator);
10008
+
10009
+ // https://github.com/tc39/proposal-iterator-helpers
10010
+ tameFauxDataProperty(
10011
+ intrinsics['%IteratorPrototype%'],
10012
+ toStringTagSymbol,
10013
+ 'Iterator');
10014
+
10015
+ };$h‍_once.tameFauxDataProperties(tameFauxDataProperties);
10016
+ })()
10017
+ ,
10018
+ // === functors[48] ===
10019
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties;$h‍_imports([["@endo/env-options", [["getEnvironmentOption", [$h‍_a => (getenv = $h‍_a)]]]],["./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)]],["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)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-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)]]]],["./permits.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)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]],["./tame-faux-data-properties.js", [["tameFauxDataProperties", [$h‍_a => (tameFauxDataProperties = $h‍_a)]]]]]);
10020
+
10021
+
10022
+
9625
10023
 
9626
10024
 
9627
10025
 
@@ -9774,21 +10172,23 @@ const repairIntrinsics= (options= {})=> {
9774
10172
  // such as those from the infrastructure. However, the bug you're trying to
9775
10173
  // track down might be in the infrastrure, in which case the `'verbose'` setting
9776
10174
  // is useful. See
9777
- // [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
10175
+ // [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/docs/lockdown.md#stackfiltering-options)
9778
10176
  // for an explanation.
9779
10177
 
9780
- const { getEnvironmentOption: getenv}= makeEnvironmentCaptor(globalThis);
9781
-
9782
10178
  const {
9783
10179
  errorTaming= getenv('LOCKDOWN_ERROR_TAMING', 'safe'),
9784
- errorTrapping= getenv('LOCKDOWN_ERROR_TRAPPING', 'platform'),
9785
- unhandledRejectionTrapping= getenv(
9786
- 'LOCKDOWN_UNHANDLED_REJECTION_TRAPPING',
9787
- 'report'),
10180
+ errorTrapping= /** @type {"platform" | "none" | "report" | "abort" | "exit" | undefined} */
10181
+ getenv('LOCKDOWN_ERROR_TRAPPING', 'platform'),
10182
+
10183
+ unhandledRejectionTrapping= /** @type {"none" | "report" | undefined} */
10184
+ getenv('LOCKDOWN_UNHANDLED_REJECTION_TRAPPING', 'report'),
9788
10185
 
9789
10186
  regExpTaming= getenv('LOCKDOWN_REGEXP_TAMING', 'safe'),
9790
10187
  localeTaming= getenv('LOCKDOWN_LOCALE_TAMING', 'safe'),
9791
- consoleTaming= getenv('LOCKDOWN_CONSOLE_TAMING', 'safe'),
10188
+
10189
+ consoleTaming= /** @type {'unsafe' | 'safe' | undefined} */
10190
+ getenv('LOCKDOWN_CONSOLE_TAMING', 'safe'),
10191
+
9792
10192
  overrideTaming= getenv('LOCKDOWN_OVERRIDE_TAMING', 'moderate'),
9793
10193
  stackFiltering= getenv('LOCKDOWN_STACK_FILTERING', 'concise'),
9794
10194
  domainTaming= getenv('LOCKDOWN_DOMAIN_TAMING', 'safe'),
@@ -9899,6 +10299,14 @@ const repairIntrinsics= (options= {})=> {
9899
10299
 
9900
10300
  const intrinsics= finalIntrinsics();
9901
10301
 
10302
+ const hostIntrinsics= { __proto__: null};
10303
+
10304
+ // The Node.js Buffer is a derived class of Uint8Array, and as such is often
10305
+ // passed around where a Uint8Array is expected.
10306
+ if( typeof globalThis.Buffer=== 'function') {
10307
+ hostIntrinsics.Buffer= globalThis.Buffer;
10308
+ }
10309
+
9902
10310
  /**
9903
10311
  * Wrap console unless suppressed.
9904
10312
  * At the moment, the console is considered a host power in the start
@@ -9919,6 +10327,19 @@ const repairIntrinsics= (options= {})=> {
9919
10327
 
9920
10328
  globalThis.console= /** @type {Console} */ consoleRecord.console;
9921
10329
 
10330
+ // The untamed Node.js console cannot itself be hardened as it has mutable
10331
+ // internal properties, but some of these properties expose internal versions
10332
+ // of classes from node's "primordials" concept.
10333
+ // eslint-disable-next-line no-underscore-dangle
10334
+ if( typeof /** @type {any} */ consoleRecord.console. _times=== 'object') {
10335
+ // SafeMap is a derived Map class used internally by Node
10336
+ // There doesn't seem to be a cleaner way to reach it.
10337
+ hostIntrinsics.SafeMap= getPrototypeOf(
10338
+ // eslint-disable-next-line no-underscore-dangle
10339
+ /** @type {any} */ consoleRecord.console. _times);
10340
+
10341
+ }
10342
+
9922
10343
  // @ts-ignore assert is absent on globalThis type def.
9923
10344
  if( errorTaming=== 'unsafe'&& globalThis.assert=== assert) {
9924
10345
  // If errorTaming is 'unsafe' we replace the global assert with
@@ -9933,6 +10354,8 @@ const repairIntrinsics= (options= {})=> {
9933
10354
  // Replace *Locale* methods with their non-locale equivalents
9934
10355
  tameLocaleMethods(intrinsics, localeTaming);
9935
10356
 
10357
+ tameFauxDataProperties(intrinsics);
10358
+
9936
10359
  /**
9937
10360
  * 2. WHITELIST to standardize the environment.
9938
10361
  */
@@ -10006,17 +10429,37 @@ const repairIntrinsics= (options= {})=> {
10006
10429
 
10007
10430
  // Finally register and optionally freeze all the intrinsics. This
10008
10431
  // must be the operation that modifies the intrinsics.
10009
- tamedHarden(intrinsics);
10432
+ const toHarden= {
10433
+ intrinsics,
10434
+ hostIntrinsics,
10435
+ globals: {
10436
+ // Harden evaluators
10437
+ Function: globalThis.Function,
10438
+ eval: globalThis.eval,
10439
+ // @ts-ignore Compartment does exist on globalThis
10440
+ Compartment: globalThis.Compartment,
10441
+
10442
+ // Harden Symbol
10443
+ Symbol: globalThis.Symbol}};
10444
+
10445
+
10446
+
10447
+ // Harden Symbol and properties for initialGlobalPropertyNames in the host realm
10448
+ for( const prop of getOwnPropertyNames(initialGlobalPropertyNames)) {
10449
+ toHarden.globals[prop]= globalThis[prop];
10450
+ }
10451
+
10452
+ tamedHarden(toHarden);
10010
10453
 
10011
10454
  return tamedHarden;
10012
10455
  };
10013
10456
 
10014
10457
  return hardenIntrinsics;
10015
10458
  };$h‍_once.repairIntrinsics(repairIntrinsics);
10016
- })
10459
+ })()
10017
10460
  ,
10018
- // === functors[48] ===
10019
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let globalThis,repairIntrinsics;$h‍_imports([["./assert-sloppy-mode.js", []],["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./lockdown.js", [["repairIntrinsics", [$h‍_a => (repairIntrinsics = $h‍_a)]]]]]);
10461
+ // === functors[49] ===
10462
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,repairIntrinsics;$h‍_imports([["./assert-sloppy-mode.js", []],["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./lockdown.js", [["repairIntrinsics", [$h‍_a => (repairIntrinsics = $h‍_a)]]]]]);
10020
10463
 
10021
10464
 
10022
10465
 
@@ -10051,10 +10494,10 @@ globalThis.repairIntrinsics= (options)=>{
10051
10494
  globalThis.harden= hardenIntrinsics();
10052
10495
  };
10053
10496
  };
10054
- })
10497
+ })()
10055
10498
  ,
10056
- // === functors[49] ===
10057
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let globalThis,makeCompartmentConstructor,tameFunctionToString,getGlobalIntrinsics;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]]]);
10499
+ // === functors[50] ===
10500
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,makeCompartmentConstructor,tameFunctionToString,getGlobalIntrinsics;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]]]);
10058
10501
 
10059
10502
 
10060
10503
 
@@ -10068,18 +10511,18 @@ globalThis.Compartment= makeCompartmentConstructor(
10068
10511
  makeCompartmentConstructor,
10069
10512
  getGlobalIntrinsics(globalThis),
10070
10513
  markVirtualizedNativeFunction);
10071
- })
10514
+ })()
10072
10515
  ,
10073
- // === functors[50] ===
10074
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let globalThis,assert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
10516
+ // === functors[51] ===
10517
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,assert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
10075
10518
 
10076
10519
 
10077
10520
  globalThis.assert= assert;
10078
- })
10521
+ })()
10079
10522
  ,
10080
- // === functors[51] ===
10081
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { $h‍_imports([["./src/lockdown-shim.js", []],["./src/compartment-shim.js", []],["./src/assert-shim.js", []]]);
10082
- })
10523
+ // === functors[52] ===
10524
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./src/lockdown-shim.js", []],["./src/compartment-shim.js", []],["./src/assert-shim.js", []]]);
10525
+ })()
10083
10526
  ,
10084
10527
  ]; // functors end
10085
10528
 
@@ -10241,6 +10684,9 @@ globalThis.assert= assert;
10241
10684
  },
10242
10685
  {
10243
10686
  makeEnvironmentCaptor: cell("makeEnvironmentCaptor"),
10687
+ getEnvironmentOption: cell("getEnvironmentOption"),
10688
+ getEnvironmentOptionsList: cell("getEnvironmentOptionsList"),
10689
+ environmentOptionsListHas: cell("environmentOptionsListHas"),
10244
10690
  },
10245
10691
  {
10246
10692
  },
@@ -10415,6 +10861,10 @@ globalThis.assert= assert;
10415
10861
  {
10416
10862
  tameSymbolConstructor: cell("tameSymbolConstructor"),
10417
10863
  },
10864
+ {
10865
+ tameFauxDataProperty: cell("tameFauxDataProperty"),
10866
+ tameFauxDataProperties: cell("tameFauxDataProperties"),
10867
+ },
10418
10868
  {
10419
10869
  repairIntrinsics: cell("repairIntrinsics"),
10420
10870
  },
@@ -10430,7 +10880,16 @@ globalThis.assert= assert;
10430
10880
 
10431
10881
  Object.defineProperties(cells[3], Object.getOwnPropertyDescriptors(cells[2]));
10432
10882
 
10433
- const namespaces = cells.map(cells => Object.freeze(Object.create(null, cells)));
10883
+ const namespaces = cells.map(cells => Object.freeze(Object.create(null, {
10884
+ ...cells,
10885
+ // Make this appear like an ESM module namespace object.
10886
+ [Symbol.toStringTag]: {
10887
+ value: 'Module',
10888
+ writable: false,
10889
+ enumerable: false,
10890
+ configurable: false,
10891
+ },
10892
+ })));
10434
10893
 
10435
10894
  for (let index = 0; index < namespaces.length; index += 1) {
10436
10895
  cells[index]['*'] = cell('*', namespaces[index]);
@@ -10609,6 +11068,9 @@ function observeImports(map, importName, importIndex) {
10609
11068
  },
10610
11069
  onceVar: {
10611
11070
  makeEnvironmentCaptor: cells[2].makeEnvironmentCaptor.set,
11071
+ getEnvironmentOption: cells[2].getEnvironmentOption.set,
11072
+ getEnvironmentOptionsList: cells[2].getEnvironmentOptionsList.set,
11073
+ environmentOptionsListHas: cells[2].environmentOptionsListHas.set,
10612
11074
  },
10613
11075
  importMeta: {},
10614
11076
  });
@@ -10801,6 +11263,7 @@ function observeImports(map, importName, importIndex) {
10801
11263
  functors[17]({
10802
11264
  imports(entries) {
10803
11265
  const map = new Map(entries);
11266
+ observeImports(map, "./commons.js", 0);
10804
11267
  },
10805
11268
  liveVar: {
10806
11269
  },
@@ -11229,6 +11692,19 @@ function observeImports(map, importName, importIndex) {
11229
11692
  importMeta: {},
11230
11693
  });
11231
11694
  functors[47]({
11695
+ imports(entries) {
11696
+ const map = new Map(entries);
11697
+ observeImports(map, "./commons.js", 0);
11698
+ },
11699
+ liveVar: {
11700
+ },
11701
+ onceVar: {
11702
+ tameFauxDataProperty: cells[47].tameFauxDataProperty.set,
11703
+ tameFauxDataProperties: cells[47].tameFauxDataProperties.set,
11704
+ },
11705
+ importMeta: {},
11706
+ });
11707
+ functors[48]({
11232
11708
  imports(entries) {
11233
11709
  const map = new Map(entries);
11234
11710
  observeImports(map, "@endo/env-options", 3);
@@ -11254,20 +11730,21 @@ function observeImports(map, importName, importIndex) {
11254
11730
  observeImports(map, "./compartment.js", 43);
11255
11731
  observeImports(map, "./tame-harden.js", 45);
11256
11732
  observeImports(map, "./tame-symbol-constructor.js", 46);
11733
+ observeImports(map, "./tame-faux-data-properties.js", 47);
11257
11734
  },
11258
11735
  liveVar: {
11259
11736
  },
11260
11737
  onceVar: {
11261
- repairIntrinsics: cells[47].repairIntrinsics.set,
11738
+ repairIntrinsics: cells[48].repairIntrinsics.set,
11262
11739
  },
11263
11740
  importMeta: {},
11264
11741
  });
11265
- functors[48]({
11742
+ functors[49]({
11266
11743
  imports(entries) {
11267
11744
  const map = new Map(entries);
11268
11745
  observeImports(map, "./assert-sloppy-mode.js", 1);
11269
11746
  observeImports(map, "./commons.js", 0);
11270
- observeImports(map, "./lockdown.js", 47);
11747
+ observeImports(map, "./lockdown.js", 48);
11271
11748
  },
11272
11749
  liveVar: {
11273
11750
  },
@@ -11275,7 +11752,7 @@ function observeImports(map, importName, importIndex) {
11275
11752
  },
11276
11753
  importMeta: {},
11277
11754
  });
11278
- functors[49]({
11755
+ functors[50]({
11279
11756
  imports(entries) {
11280
11757
  const map = new Map(entries);
11281
11758
  observeImports(map, "./commons.js", 0);
@@ -11289,7 +11766,7 @@ function observeImports(map, importName, importIndex) {
11289
11766
  },
11290
11767
  importMeta: {},
11291
11768
  });
11292
- functors[50]({
11769
+ functors[51]({
11293
11770
  imports(entries) {
11294
11771
  const map = new Map(entries);
11295
11772
  observeImports(map, "./commons.js", 0);
@@ -11301,12 +11778,12 @@ function observeImports(map, importName, importIndex) {
11301
11778
  },
11302
11779
  importMeta: {},
11303
11780
  });
11304
- functors[51]({
11781
+ functors[52]({
11305
11782
  imports(entries) {
11306
11783
  const map = new Map(entries);
11307
- observeImports(map, "./src/lockdown-shim.js", 48);
11308
- observeImports(map, "./src/compartment-shim.js", 49);
11309
- observeImports(map, "./src/assert-shim.js", 50);
11784
+ observeImports(map, "./src/lockdown-shim.js", 49);
11785
+ observeImports(map, "./src/compartment-shim.js", 50);
11786
+ observeImports(map, "./src/assert-shim.js", 51);
11310
11787
  },
11311
11788
  liveVar: {
11312
11789
  },
@@ -11332,7 +11809,7 @@ function observeImports(map, importName, importIndex) {
11332
11809
  errorTaming: 'unsafe',
11333
11810
  // shows the full call stack
11334
11811
  stackFiltering: 'verbose',
11335
- // prevent issues when dealing with the "override mistake"
11812
+ // prevents most common override mistake cases from tripping up users
11336
11813
  overrideTaming: 'severe',
11337
11814
  }
11338
11815
 
@@ -11414,16 +11891,32 @@ function observeImports(map, importName, importIndex) {
11414
11891
  const module = { exports }
11415
11892
  ;(function(){
11416
11893
  // START of injected code from endowmentsToolkit
11417
- // the contents of this file will be copied into the prelude template
11418
- // this module has been written so that it required directly or copied and added to the template with a small wrapper
11419
- module.exports = endowmentsToolkit
11894
+ // @ts-check
11420
11895
 
11421
- // utilities for generating the endowments object based on a globalRef and a packagePolicy
11896
+ /**
11897
+ * Utilities for generating the endowments object based on a `globalRef` and a
11898
+ * {@link LMPolicy.PackagePolicy}.
11899
+ *
11900
+ * The contents of this file will be copied into the prelude template this
11901
+ * module has been written so that it required directly or copied and added to
11902
+ * the template with a small wrapper.
11903
+ *
11904
+ * The `PackagePolicy` uses a period-deliminated path notation to pull out deep
11905
+ * values from objects. These utilities help create an object populated with
11906
+ * only the deep properties specified in the `PackagePolicy`.
11907
+ *
11908
+ * @packageDocumentation
11909
+ */
11422
11910
 
11423
- // The packagePolicy uses a period-deliminated path notation to pull out deep values from objects
11424
- // These utilities help create an object populated with only the deep properties specified in the packagePolicy
11911
+ module.exports = endowmentsToolkit
11425
11912
 
11426
- function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrapper } = {}) {
11913
+ /**
11914
+ * @param {object} opts
11915
+ * @param {DefaultWrapperFn} [opts.createFunctionWrapper]
11916
+ */
11917
+ function endowmentsToolkit({
11918
+ createFunctionWrapper = defaultCreateFunctionWrapper,
11919
+ } = {}) {
11427
11920
  return {
11428
11921
  getEndowmentsForConfig,
11429
11922
  makeMinimalViewOfRef,
@@ -11435,71 +11928,153 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11435
11928
  }
11436
11929
 
11437
11930
  /**
11438
- * @function getEndowmentsForConfig Creates an object populated with only the deep properties specified in the packagePolicy
11439
- * @param {object} sourceRef - Object from which to copy properties
11440
- * @param {object} packagePolicy - LavaMoat policy item representing a package
11441
- * @param {object} unwrapTo - For getters and setters, when the this-value is unwrapFrom, is replaced as unwrapTo
11442
- * @param {object} unwrapFrom - For getters and setters, the this-value to replace (default: targetRef)
11443
- * @return {object} - The targetRef
11931
+ * Creates an object populated with only the deep properties specified in the
11932
+ * packagePolicy
11444
11933
  *
11934
+ * @param {object} sourceRef - Object from which to copy properties
11935
+ * @param {LMPolicy.PackagePolicy} packagePolicy - LavaMoat policy item
11936
+ * representing a package
11937
+ * @param {object} unwrapTo - For getters and setters, when the this-value is
11938
+ * unwrapFrom, is replaced as unwrapTo
11939
+ * @param {object} unwrapFrom - For getters and setters, the this-value to
11940
+ * replace (default: targetRef)
11941
+ * @returns {object} - The targetRef
11445
11942
  */
11446
- function getEndowmentsForConfig(sourceRef, packagePolicy, unwrapTo, unwrapFrom) {
11943
+ function getEndowmentsForConfig(
11944
+ sourceRef,
11945
+ packagePolicy,
11946
+ unwrapTo,
11947
+ unwrapFrom
11948
+ ) {
11447
11949
  if (!packagePolicy.globals) {
11448
11950
  return {}
11449
11951
  }
11450
11952
  // validate read access from packagePolicy
11953
+ /** @type {string[]} */
11451
11954
  const whitelistedReads = []
11955
+ /** @type {string[]} */
11452
11956
  const explicitlyBanned = []
11453
- Object.entries(packagePolicy.globals).forEach(([path, packagePolicyValue]) => {
11454
- const pathParts = path.split('.')
11455
- // disallow dunder proto in path
11456
- const pathContainsDunderProto = pathParts.some(pathPart => pathPart === '__proto__')
11457
- if (pathContainsDunderProto) {
11458
- throw new Error(`Lavamoat - "__proto__" disallowed when creating minimal view. saw "${path}"`)
11459
- }
11460
- // false means no access. It's necessary so that overrides can also be used to tighten the policy
11461
- if (packagePolicyValue === false) {
11462
- explicitlyBanned.push(path)
11463
- return
11464
- }
11465
- // write access handled elsewhere
11466
- if (packagePolicyValue === 'write') {
11467
- return
11468
- }
11469
- if (packagePolicyValue !== true) {
11470
- throw new Error(`LavaMoat - unrecognizable policy value (${typeof packagePolicyValue}) for path "${path}"`)
11957
+ Object.entries(packagePolicy.globals).forEach(
11958
+ ([path, packagePolicyValue]) => {
11959
+ const pathParts = path.split('.')
11960
+ // disallow dunder proto in path
11961
+ const pathContainsDunderProto = pathParts.some(
11962
+ (pathPart) => pathPart === '__proto__'
11963
+ )
11964
+ if (pathContainsDunderProto) {
11965
+ throw new Error(
11966
+ `Lavamoat - "__proto__" disallowed when creating minimal view. saw "${path}"`
11967
+ )
11968
+ }
11969
+ // false means no access. It's necessary so that overrides can also be used to tighten the policy
11970
+ if (packagePolicyValue === false) {
11971
+ explicitlyBanned.push(path)
11972
+ return
11973
+ }
11974
+ // write access handled elsewhere
11975
+ if (packagePolicyValue === 'write') {
11976
+ return
11977
+ }
11978
+ if (packagePolicyValue !== true) {
11979
+ throw new Error(
11980
+ `LavaMoat - unrecognizable policy value (${typeof packagePolicyValue}) for path "${path}"`
11981
+ )
11982
+ }
11983
+ whitelistedReads.push(path)
11471
11984
  }
11472
- whitelistedReads.push(path)
11473
- })
11474
- return makeMinimalViewOfRef(sourceRef, whitelistedReads, unwrapTo, unwrapFrom, explicitlyBanned)
11985
+ )
11986
+ return makeMinimalViewOfRef(
11987
+ sourceRef,
11988
+ whitelistedReads,
11989
+ unwrapTo,
11990
+ unwrapFrom,
11991
+ explicitlyBanned
11992
+ )
11475
11993
  }
11476
11994
 
11477
- function makeMinimalViewOfRef(sourceRef, paths, unwrapTo, unwrapFrom, explicitlyBanned = []) {
11995
+ /**
11996
+ * @param {object} sourceRef
11997
+ * @param {string[]} paths
11998
+ * @param {object} unwrapTo
11999
+ * @param {object} unwrapFrom
12000
+ * @param {string[]} explicitlyBanned
12001
+ * @returns {object}
12002
+ */
12003
+ function makeMinimalViewOfRef(
12004
+ sourceRef,
12005
+ paths,
12006
+ unwrapTo,
12007
+ unwrapFrom,
12008
+ explicitlyBanned = []
12009
+ ) {
12010
+ /** @type {object} */
11478
12011
  const targetRef = {}
11479
- paths.forEach(path => {
11480
- copyValueAtPath('', path.split('.'), explicitlyBanned, sourceRef, targetRef, unwrapTo, unwrapFrom)
12012
+ paths.forEach((path) => {
12013
+ copyValueAtPath(
12014
+ '',
12015
+ path.split('.'),
12016
+ explicitlyBanned,
12017
+ sourceRef,
12018
+ targetRef,
12019
+ unwrapTo,
12020
+ unwrapFrom
12021
+ )
11481
12022
  })
11482
12023
  return targetRef
11483
12024
  }
11484
12025
 
12026
+ /**
12027
+ * @param {string} visited
12028
+ * @param {string} next
12029
+ */
11485
12030
  function extendPath(visited, next) {
12031
+ // FIXME: second part of this conditional should be unnecessary
11486
12032
  if (!visited || visited.length === 0) {
11487
12033
  return next
11488
12034
  }
11489
12035
  return `${visited}.${next}`
11490
12036
  }
11491
12037
 
11492
- function copyValueAtPath(visitedPath, pathParts, explicitlyBanned, sourceRef, targetRef, unwrapTo = sourceRef, unwrapFrom = targetRef) {
12038
+ /**
12039
+ * @template T
12040
+ * @param {T | null} value
12041
+ * @returns {value is null}
12042
+ */
12043
+ function isEmpty(value) {
12044
+ return !value
12045
+ }
12046
+
12047
+ /**
12048
+ * @param {string} visitedPath
12049
+ * @param {string[]} pathParts
12050
+ * @param {string[]} explicitlyBanned
12051
+ * @param {object} sourceRef
12052
+ * @param {object} targetRef
12053
+ * @param {object} unwrapTo
12054
+ * @param {object} unwrapFrom
12055
+ */
12056
+ function copyValueAtPath(
12057
+ visitedPath,
12058
+ pathParts,
12059
+ explicitlyBanned,
12060
+ sourceRef,
12061
+ targetRef,
12062
+ unwrapTo = sourceRef,
12063
+ unwrapFrom = targetRef
12064
+ ) {
11493
12065
  if (pathParts.length === 0) {
11494
12066
  throw new Error('unable to copy, must have pathParts, was empty')
11495
12067
  }
11496
12068
  const [nextPart, ...remainingParts] = pathParts
11497
12069
  const currentPath = extendPath(visitedPath, nextPart)
11498
12070
  // get the property from any depth in the property chain
11499
- const { prop: sourcePropDesc } = getPropertyDescriptorDeep(sourceRef, nextPart)
12071
+ const { prop: sourcePropDesc } = getPropertyDescriptorDeep(
12072
+ sourceRef,
12073
+ nextPart
12074
+ )
11500
12075
 
11501
12076
  // if source missing the value to copy, just skip it
11502
- if (!sourcePropDesc) {
12077
+ if (isEmpty(sourcePropDesc)) {
11503
12078
  return
11504
12079
  }
11505
12080
 
@@ -11508,19 +12083,23 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11508
12083
  if (targetPropDesc) {
11509
12084
  // dont attempt to extend a getter or trigger a setter
11510
12085
  if (!('value' in targetPropDesc)) {
11511
- throw new Error(`unable to copy on to targetRef, targetRef has a getter at "${nextPart}"`)
12086
+ throw new Error(
12087
+ `unable to copy on to targetRef, targetRef has a getter at "${nextPart}"`
12088
+ )
11512
12089
  }
11513
12090
  // value must be extensible (cant write properties onto it)
11514
12091
  const targetValue = targetPropDesc.value
11515
12092
  const valueType = typeof targetValue
11516
12093
  if (valueType !== 'object' && valueType !== 'function') {
11517
- throw new Error(`unable to copy on to targetRef, targetRef value is not an obj or func "${nextPart}"`)
12094
+ throw new Error(
12095
+ `unable to copy on to targetRef, targetRef value is not an obj or func "${nextPart}"`
12096
+ )
11518
12097
  }
11519
12098
  }
11520
12099
 
11521
12100
  // if this is not the last path in the assignment, walk into the containing reference
11522
12101
  if (remainingParts.length > 0) {
11523
- const { sourceValue, sourceWritable } = getSourceValue()
12102
+ const { sourceValue, sourceWritable } = getSourceValue(sourcePropDesc)
11524
12103
  const nextSourceRef = sourceValue
11525
12104
  let nextTargetRef
11526
12105
  // check if value exists on target and does not need selective treatment
@@ -11541,7 +12120,13 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11541
12120
  // the newly created container will be the next target
11542
12121
  nextTargetRef = containerRef
11543
12122
  }
11544
- copyValueAtPath(currentPath, remainingParts, explicitlyBanned, nextSourceRef, nextTargetRef)
12123
+ copyValueAtPath(
12124
+ currentPath,
12125
+ remainingParts,
12126
+ explicitlyBanned,
12127
+ nextSourceRef,
12128
+ nextTargetRef
12129
+ )
11545
12130
  return
11546
12131
  }
11547
12132
 
@@ -11555,14 +12140,18 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11555
12140
  // if has getter/setter - apply this-value unwrapping
11556
12141
  if (!('value' in sourcePropDesc)) {
11557
12142
  // wrapper setter/getter with correct receiver
11558
- const wrapperPropDesc = applyGetSetPropDescTransforms(sourcePropDesc, unwrapFrom, unwrapTo)
12143
+ const wrapperPropDesc = applyGetSetPropDescTransforms(
12144
+ sourcePropDesc,
12145
+ unwrapFrom,
12146
+ unwrapTo
12147
+ )
11559
12148
  Reflect.defineProperty(targetRef, nextPart, wrapperPropDesc)
11560
12149
  return
11561
12150
  }
11562
12151
 
11563
12152
  // need to determine the value type in order to copy it with
11564
12153
  // this-value unwrapping support
11565
- const { sourceValue, sourceWritable } = getSourceValue()
12154
+ const { sourceValue, sourceWritable } = getSourceValue(sourcePropDesc)
11566
12155
 
11567
12156
  // not a function - copy as is
11568
12157
  if (typeof sourceValue !== 'function') {
@@ -11570,7 +12159,12 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11570
12159
  return
11571
12160
  }
11572
12161
  // otherwise add workaround for functions to swap back to the sourceal "this" reference
11573
- const unwrapTest = thisValue => thisValue === unwrapFrom
12162
+ /**
12163
+ * @template T
12164
+ * @param {T} thisValue
12165
+ * @returns {thisValue is typeof unwrapFrom}
12166
+ */
12167
+ const unwrapTest = (thisValue) => thisValue === unwrapFrom
11574
12168
  const newValue = createFunctionWrapper(sourceValue, unwrapTest, unwrapTo)
11575
12169
  const newPropDesc = {
11576
12170
  value: newValue,
@@ -11580,7 +12174,11 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11580
12174
  }
11581
12175
  Reflect.defineProperty(targetRef, nextPart, newPropDesc)
11582
12176
 
11583
- function getSourceValue() {
12177
+ /**
12178
+ * @param {TypedPropertyDescriptor<any>} sourcePropDesc
12179
+ * @returns {{ sourceValue: any; sourceWritable: boolean | undefined }}
12180
+ */
12181
+ function getSourceValue(sourcePropDesc) {
11584
12182
  // determine the source value, this coerces getters to values
11585
12183
  // im deeply sorry, respecting getters was complicated and
11586
12184
  // my brain is not very good
@@ -11588,32 +12186,70 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11588
12186
  if ('value' in sourcePropDesc) {
11589
12187
  sourceValue = sourcePropDesc.value
11590
12188
  sourceWritable = sourcePropDesc.writable
11591
- } else if ('get' in sourcePropDesc) {
12189
+ } else if ('get' in sourcePropDesc && sourcePropDesc.get) {
11592
12190
  sourceValue = sourcePropDesc.get.call(unwrapTo)
11593
12191
  sourceWritable = 'set' in sourcePropDesc
11594
12192
  } else {
11595
- throw new Error('getEndowmentsForConfig - property descriptor missing a getter')
12193
+ throw new Error(
12194
+ 'getEndowmentsForConfig - property descriptor missing a getter'
12195
+ )
11596
12196
  }
11597
12197
  return { sourceValue, sourceWritable }
11598
12198
  }
11599
12199
  }
11600
12200
 
11601
- function applyEndowmentPropDescTransforms(propDesc, unwrapFromCompartmentGlobalThis, unwrapToGlobalThis) {
12201
+ /**
12202
+ * @param {PropertyDescriptor} propDesc
12203
+ * @param {object} unwrapFromCompartmentGlobalThis
12204
+ * @param {object} unwrapToGlobalThis
12205
+ * @returns {PropertyDescriptor}
12206
+ */
12207
+ function applyEndowmentPropDescTransforms(
12208
+ propDesc,
12209
+ unwrapFromCompartmentGlobalThis,
12210
+ unwrapToGlobalThis
12211
+ ) {
11602
12212
  let newPropDesc = propDesc
11603
- newPropDesc = applyFunctionPropDescTransform(newPropDesc, unwrapFromCompartmentGlobalThis, unwrapToGlobalThis)
11604
- newPropDesc = applyGetSetPropDescTransforms(newPropDesc, unwrapFromCompartmentGlobalThis, unwrapToGlobalThis)
12213
+ newPropDesc = applyFunctionPropDescTransform(
12214
+ newPropDesc,
12215
+ unwrapFromCompartmentGlobalThis,
12216
+ unwrapToGlobalThis
12217
+ )
12218
+ newPropDesc = applyGetSetPropDescTransforms(
12219
+ newPropDesc,
12220
+ unwrapFromCompartmentGlobalThis,
12221
+ unwrapToGlobalThis
12222
+ )
11605
12223
  return newPropDesc
11606
12224
  }
11607
12225
 
11608
- function applyGetSetPropDescTransforms(sourcePropDesc, unwrapFromGlobalThis, unwrapToGlobalThis) {
12226
+ /**
12227
+ * @param {PropertyDescriptor} sourcePropDesc
12228
+ * @param {object} unwrapFromGlobalThis
12229
+ * @param {object} unwrapToGlobalThis
12230
+ * @returns {PropertyDescriptor}
12231
+ */
12232
+ function applyGetSetPropDescTransforms(
12233
+ sourcePropDesc,
12234
+ unwrapFromGlobalThis,
12235
+ unwrapToGlobalThis
12236
+ ) {
11609
12237
  const wrappedPropDesc = { ...sourcePropDesc }
11610
12238
  if (sourcePropDesc.get) {
11611
12239
  wrappedPropDesc.get = function () {
12240
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
11612
12241
  const receiver = this
11613
12242
  // replace the "receiver" value if it points to fake parent
11614
- const receiverRef = receiver === unwrapFromGlobalThis ? unwrapToGlobalThis : receiver
12243
+ const receiverRef =
12244
+ receiver === unwrapFromGlobalThis ? unwrapToGlobalThis : receiver
11615
12245
  // sometimes getters replace themselves with static properties, as seen wih the FireFox runtime
11616
- const result = Reflect.apply(sourcePropDesc.get, receiverRef, [])
12246
+ const result = Reflect.apply(
12247
+ /** @type {NonNullable<typeof sourcePropDesc.get>} */ (
12248
+ sourcePropDesc.get
12249
+ ),
12250
+ receiverRef,
12251
+ []
12252
+ )
11617
12253
  if (typeof result === 'function') {
11618
12254
  // functions must be wrapped to ensure a good this-value.
11619
12255
  // lockdown causes some propDescs to go to value -> getter,
@@ -11621,7 +12257,15 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11621
12257
  // as well in order to ensure they have their this-value wrapped correctly
11622
12258
  // if this ends up being problematic we can maybe take advantage of lockdown's
11623
12259
  // "getter.originalValue" property being available
11624
- return createFunctionWrapper(result, (thisValue) => thisValue === unwrapFromGlobalThis, unwrapToGlobalThis)
12260
+ return createFunctionWrapper(
12261
+ result,
12262
+ /**
12263
+ * @param {any} thisValue
12264
+ * @returns {thisValue is typeof unwrapFromGlobalThis}
12265
+ */
12266
+ (thisValue) => thisValue === unwrapFromGlobalThis,
12267
+ unwrapToGlobalThis
12268
+ )
11625
12269
  } else {
11626
12270
  return result
11627
12271
  }
@@ -11630,30 +12274,59 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11630
12274
  if (sourcePropDesc.set) {
11631
12275
  wrappedPropDesc.set = function (value) {
11632
12276
  // replace the "receiver" value if it points to fake parent
12277
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
11633
12278
  const receiver = this
11634
- const receiverRef = receiver === unwrapFromGlobalThis ? unwrapToGlobalThis : receiver
11635
- return Reflect.apply(sourcePropDesc.set, receiverRef, [value])
12279
+ const receiverRef =
12280
+ receiver === unwrapFromGlobalThis ? unwrapToGlobalThis : receiver
12281
+ return Reflect.apply(
12282
+ /** @type {(v: any) => void} */ (sourcePropDesc.set),
12283
+ receiverRef,
12284
+ [value]
12285
+ )
11636
12286
  }
11637
12287
  }
11638
12288
  return wrappedPropDesc
11639
12289
  }
11640
12290
 
11641
- function applyFunctionPropDescTransform(propDesc, unwrapFromCompartmentGlobalThis, unwrapToGlobalThis) {
12291
+ /**
12292
+ * @param {PropertyDescriptor} propDesc
12293
+ * @param {object} unwrapFromCompartmentGlobalThis
12294
+ * @param {object} unwrapToGlobalThis
12295
+ * @returns {PropertyDescriptor}
12296
+ */
12297
+ function applyFunctionPropDescTransform(
12298
+ propDesc,
12299
+ unwrapFromCompartmentGlobalThis,
12300
+ unwrapToGlobalThis
12301
+ ) {
11642
12302
  if (!('value' in propDesc && typeof propDesc.value === 'function')) {
11643
12303
  return propDesc
11644
12304
  }
12305
+ /**
12306
+ * @param {any} thisValue
12307
+ * @returns {thisValue is typeof unwrapFromCompartmentGlobalThis}
12308
+ */
11645
12309
  const unwrapTest = (thisValue) => {
11646
12310
  // unwrap function calls this-value to unwrapToGlobalThis when:
11647
12311
  // this value is globalThis ex. globalThis.abc()
11648
12312
  // scope proxy leak workaround ex. abc()
11649
12313
  return thisValue === unwrapFromCompartmentGlobalThis
11650
12314
  }
11651
- const newFn = createFunctionWrapper(propDesc.value, unwrapTest, unwrapToGlobalThis)
12315
+ const newFn = createFunctionWrapper(
12316
+ propDesc.value,
12317
+ unwrapTest,
12318
+ unwrapToGlobalThis
12319
+ )
11652
12320
  return { ...propDesc, value: newFn }
11653
12321
  }
11654
12322
 
11655
-
12323
+ /**
12324
+ * @param {object | null} target
12325
+ * @param {PropertyKey} key
12326
+ * @returns {{ prop: PropertyDescriptor | null; receiver: object | null }}
12327
+ */
11656
12328
  function getPropertyDescriptorDeep(target, key) {
12329
+ /** @type {object | null} */
11657
12330
  let receiver = target
11658
12331
  // eslint-disable-next-line no-constant-condition
11659
12332
  while (true) {
@@ -11673,51 +12346,74 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11673
12346
  } else {
11674
12347
  // prototype lookup for primitives
11675
12348
  // eslint-disable-next-line no-proto
11676
- receiver = receiver.__proto__
12349
+ receiver = /** @type {any} */ (receiver).__proto__
11677
12350
  }
11678
12351
  }
11679
12352
  }
11680
12353
 
11681
- function copyWrappedGlobals(globalRef, target, globalThisRefs = ['globalThis']) {
12354
+ /**
12355
+ * @param {object} globalRef
12356
+ * @param {Record<PropertyKey, any>} target
12357
+ * @param {string[]} globalThisRefs
12358
+ */
12359
+ function copyWrappedGlobals(
12360
+ globalRef,
12361
+ target,
12362
+ globalThisRefs = ['globalThis']
12363
+ ) {
11682
12364
  // find the relevant endowment sources
11683
12365
  const globalProtoChain = getPrototypeChain(globalRef)
11684
12366
  // the index for the common prototypal ancestor, Object.prototype
11685
12367
  // this should always be the last index, but we check just in case
11686
- const commonPrototypeIndex = globalProtoChain.findIndex(globalProtoChainEntry => globalProtoChainEntry === Object.prototype)
12368
+ const commonPrototypeIndex = globalProtoChain.findIndex(
12369
+ (globalProtoChainEntry) => globalProtoChainEntry === Object.prototype
12370
+ )
11687
12371
  if (commonPrototypeIndex === -1) {
11688
12372
  // TODO: fix this error message
11689
- throw new Error('Lavamoat - unable to find common prototype between Compartment and globalRef')
12373
+ throw new Error(
12374
+ 'Lavamoat - unable to find common prototype between Compartment and globalRef'
12375
+ )
11690
12376
  }
11691
12377
  // we will copy endowments from all entries in the prototype chain, excluding Object.prototype
11692
12378
  const endowmentSources = globalProtoChain.slice(0, commonPrototypeIndex)
11693
12379
 
11694
12380
  // call all getters, in case of behavior change (such as with FireFox lazy getters)
11695
12381
  // call on contents of endowmentsSources directly instead of in new array instances. If there is a lazy getter it only changes the original prop desc.
11696
- endowmentSources.forEach(source => {
12382
+ endowmentSources.forEach((source) => {
11697
12383
  const descriptors = Object.getOwnPropertyDescriptors(source)
11698
- Object.values(descriptors).forEach(desc => {
11699
- if ('get' in desc) {
12384
+ Object.values(descriptors).forEach((desc) => {
12385
+ if ('get' in desc && desc.get) {
11700
12386
  try {
11701
12387
  // calling getters can potentially throw (e.g. localStorage inside a sandboxed iframe)
11702
12388
  Reflect.apply(desc.get, globalRef, [])
11703
- } catch { }
12389
+ } catch {}
11704
12390
  }
11705
12391
  })
11706
12392
  })
11707
12393
 
11708
- const endowmentSourceDescriptors = endowmentSources.map(globalProtoChainEntry => Object.getOwnPropertyDescriptors(globalProtoChainEntry))
12394
+ const endowmentSourceDescriptors = endowmentSources.map(
12395
+ (globalProtoChainEntry) =>
12396
+ Object.getOwnPropertyDescriptors(globalProtoChainEntry)
12397
+ )
11709
12398
  // flatten propDesc collections with precedence for globalThis-end of the prototype chain
11710
- const endowmentDescriptorsFlat = Object.assign(Object.create(null), ...endowmentSourceDescriptors.reverse())
12399
+ const endowmentDescriptorsFlat = Object.assign(
12400
+ Object.create(null),
12401
+ ...endowmentSourceDescriptors.reverse()
12402
+ )
11711
12403
  // expose all own properties of globalRef, including non-enumerable
11712
12404
  Object.entries(endowmentDescriptorsFlat)
11713
12405
  // ignore properties already defined on compartment global
11714
12406
  .filter(([key]) => !(key in target))
11715
12407
  // ignore circular globalThis refs
11716
- .filter(([key]) => !(globalThisRefs.includes(key)))
12408
+ .filter(([key]) => !globalThisRefs.includes(key))
11717
12409
  // define property on compartment global
11718
12410
  .forEach(([key, desc]) => {
11719
12411
  // unwrap functions, setters/getters & apply scope proxy workaround
11720
- const wrappedPropDesc = applyEndowmentPropDescTransforms(desc, target, globalRef)
12412
+ const wrappedPropDesc = applyEndowmentPropDescTransforms(
12413
+ desc,
12414
+ target,
12415
+ globalRef
12416
+ )
11721
12417
  Reflect.defineProperty(target, key, wrappedPropDesc)
11722
12418
  })
11723
12419
  // global circular references otherwise added by prepareCompartmentGlobalFromConfig
@@ -11731,12 +12427,20 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11731
12427
  return target
11732
12428
  }
11733
12429
 
11734
- // util for getting the prototype chain as an array
11735
- // includes the provided value in the result
12430
+ /**
12431
+ * Util for getting the prototype chain as an array includes the provided
12432
+ * value in the result
12433
+ *
12434
+ * @param {any} value
12435
+ * @returns {any[]}
12436
+ */
11736
12437
  function getPrototypeChain(value) {
11737
12438
  const protoChain = []
11738
12439
  let current = value
11739
- while (current && (typeof current === 'object' || typeof current === 'function')) {
12440
+ while (
12441
+ current &&
12442
+ (typeof current === 'object' || typeof current === 'function')
12443
+ ) {
11740
12444
  protoChain.push(current)
11741
12445
  current = Reflect.getPrototypeOf(current)
11742
12446
  }
@@ -11744,7 +12448,15 @@ function endowmentsToolkit({ createFunctionWrapper = defaultCreateFunctionWrappe
11744
12448
  }
11745
12449
  }
11746
12450
 
12451
+ /**
12452
+ * @type {DefaultWrapperFn}
12453
+ */
11747
12454
  function defaultCreateFunctionWrapper(sourceValue, unwrapTest, unwrapTo) {
12455
+ /**
12456
+ * @param {...any[]} args
12457
+ * @returns {any}
12458
+ * @this {object}
12459
+ */
11748
12460
  const newValue = function (...args) {
11749
12461
  if (new.target) {
11750
12462
  // handle constructor calls
@@ -11756,10 +12468,21 @@ function defaultCreateFunctionWrapper(sourceValue, unwrapTest, unwrapTo) {
11756
12468
  return Reflect.apply(sourceValue, thisRef, args)
11757
12469
  }
11758
12470
  }
11759
- Object.defineProperties(newValue, Object.getOwnPropertyDescriptors(sourceValue))
12471
+ Object.defineProperties(
12472
+ newValue,
12473
+ Object.getOwnPropertyDescriptors(sourceValue)
12474
+ )
11760
12475
  return newValue
11761
12476
  }
11762
12477
 
12478
+ /**
12479
+ * @callback DefaultWrapperFn
12480
+ * @param {(...args: any[]) => any} sourceValue
12481
+ * @param {(value: any) => boolean} unwrapTest
12482
+ * @param {object} unwrapTo
12483
+ * @returns {(...args: any[]) => any}
12484
+ */
12485
+
11763
12486
  // END of injected code from endowmentsToolkit
11764
12487
  })()
11765
12488
  return module.exports
@@ -11780,33 +12503,48 @@ module.exports = makePrepareRealmGlobalFromConfig
11780
12503
  // The config uses a period-deliminated path notation to pull out deep values from objects
11781
12504
  // These utilities help modify the container global to expose the allowed globals from the globalStore OR the platform global
11782
12505
 
11783
- function makePrepareRealmGlobalFromConfig ({ createFunctionWrapper }) {
12506
+ function makePrepareRealmGlobalFromConfig({ createFunctionWrapper }) {
11784
12507
  return {
11785
12508
  prepareCompartmentGlobalFromConfig,
11786
12509
  getTopLevelReadAccessFromPackageConfig,
11787
12510
  getTopLevelWriteAccessFromPackageConfig,
11788
12511
  }
11789
12512
 
11790
- function getTopLevelReadAccessFromPackageConfig (globalsConfig) {
12513
+ function getTopLevelReadAccessFromPackageConfig(globalsConfig) {
11791
12514
  const result = Object.entries(globalsConfig)
11792
- .filter(([key, value]) => value === 'read' || value === true || (value === 'write' && key.split('.').length > 1))
12515
+ .filter(
12516
+ ([key, value]) =>
12517
+ value === 'read' ||
12518
+ value === true ||
12519
+ (value === 'write' && key.split('.').length > 1)
12520
+ )
11793
12521
  .map(([key]) => key.split('.')[0])
11794
12522
  // return unique array
11795
12523
  return Array.from(new Set(result))
11796
12524
  }
11797
12525
 
11798
- function getTopLevelWriteAccessFromPackageConfig (globalsConfig) {
12526
+ function getTopLevelWriteAccessFromPackageConfig(globalsConfig) {
11799
12527
  const result = Object.entries(globalsConfig)
11800
- .filter(([key, value]) => value === 'write' && key.split('.').length === 1)
12528
+ .filter(
12529
+ ([key, value]) => value === 'write' && key.split('.').length === 1
12530
+ )
11801
12531
  .map(([key]) => key)
11802
12532
  return result
11803
12533
  }
11804
12534
 
11805
- function prepareCompartmentGlobalFromConfig (packageCompartment, globalsConfig, endowments, globalStore, globalThisRefs) {
12535
+ function prepareCompartmentGlobalFromConfig(
12536
+ packageCompartment,
12537
+ globalsConfig,
12538
+ endowments,
12539
+ globalStore,
12540
+ globalThisRefs
12541
+ ) {
11806
12542
  const packageCompartmentGlobal = packageCompartment.globalThis
11807
12543
  // lookup top level read + write access keys
11808
- const topLevelWriteAccessKeys = getTopLevelWriteAccessFromPackageConfig(globalsConfig)
11809
- const topLevelReadAccessKeys = getTopLevelReadAccessFromPackageConfig(globalsConfig)
12544
+ const topLevelWriteAccessKeys =
12545
+ getTopLevelWriteAccessFromPackageConfig(globalsConfig)
12546
+ const topLevelReadAccessKeys =
12547
+ getTopLevelReadAccessFromPackageConfig(globalsConfig)
11810
12548
 
11811
12549
  // NOTE: getters for read should only ever be needed on props marked for 'write' (unless we want to allow sloppy behavior from the root compartment modifying everything...)
11812
12550
  // Making a pass over the entire policy and collecting the names of writable items would limit the number of getters created here to the minimum.
@@ -11816,34 +12554,36 @@ function makePrepareRealmGlobalFromConfig ({ createFunctionWrapper }) {
11816
12554
  // define accessors
11817
12555
 
11818
12556
  // allow read access via globalStore or packageCompartmentGlobal
11819
- topLevelReadAccessKeys.forEach(key => {
12557
+ topLevelReadAccessKeys.forEach((key) => {
11820
12558
  Object.defineProperty(packageCompartmentGlobal, key, {
11821
- get () {
12559
+ get() {
11822
12560
  if (globalStore.has(key)) {
11823
12561
  return globalStore.get(key)
11824
12562
  } else {
11825
12563
  return Reflect.get(endowments, key, this)
11826
12564
  }
11827
12565
  },
11828
- set () {
12566
+ set() {
11829
12567
  // TODO: there should be a config to throw vs silently ignore
11830
- console.warn(`LavaMoat: ignoring write attempt to read-access global "${key}"`)
12568
+ console.warn(
12569
+ `LavaMoat: ignoring write attempt to read-access global "${key}"`
12570
+ )
11831
12571
  },
11832
12572
  })
11833
12573
  })
11834
12574
 
11835
12575
  // allow write access to globalStore
11836
12576
  // read access via globalStore or packageCompartmentGlobal
11837
- topLevelWriteAccessKeys.forEach(key => {
12577
+ topLevelWriteAccessKeys.forEach((key) => {
11838
12578
  Object.defineProperty(packageCompartmentGlobal, key, {
11839
- get () {
12579
+ get() {
11840
12580
  if (globalStore.has(key)) {
11841
12581
  return globalStore.get(key)
11842
12582
  } else {
11843
12583
  return endowments[key]
11844
12584
  }
11845
12585
  },
11846
- set (value) {
12586
+ set(value) {
11847
12587
  globalStore.set(key, value)
11848
12588
  },
11849
12589
  enumerable: true,
@@ -11852,7 +12592,7 @@ function makePrepareRealmGlobalFromConfig ({ createFunctionWrapper }) {
11852
12592
  })
11853
12593
 
11854
12594
  // set circular globalRefs
11855
- globalThisRefs.forEach(key => {
12595
+ globalThisRefs.forEach((key) => {
11856
12596
  // if globalRef is actually an endowment, ignore
11857
12597
  if (topLevelReadAccessKeys.includes(key)) {
11858
12598
  return
@@ -11869,10 +12609,13 @@ function makePrepareRealmGlobalFromConfig ({ createFunctionWrapper }) {
11869
12609
  const origFunction = packageCompartmentGlobal.Function
11870
12610
  const newFunction = function (...args) {
11871
12611
  const fn = origFunction(...args)
11872
- const unwrapTest = thisValue => thisValue === undefined
12612
+ const unwrapTest = (thisValue) => thisValue === undefined
11873
12613
  return createFunctionWrapper(fn, unwrapTest, packageCompartmentGlobal)
11874
12614
  }
11875
- Object.defineProperties(newFunction, Object.getOwnPropertyDescriptors(origFunction))
12615
+ Object.defineProperties(
12616
+ newFunction,
12617
+ Object.getOwnPropertyDescriptors(origFunction)
12618
+ )
11876
12619
  packageCompartmentGlobal.Function = newFunction
11877
12620
  }
11878
12621
  }
@@ -11925,10 +12668,10 @@ const alwaysThrowHandler = new Proxy(
11925
12668
  freeze({
11926
12669
  get(_shadow, prop) {
11927
12670
  assert.fail(
11928
- d`Please report unexpected scope handler trap: ${q(String(prop))}`,
12671
+ d`Please report unexpected scope handler trap: ${q(String(prop))}`
11929
12672
  )
11930
12673
  },
11931
- }),
12674
+ })
11932
12675
  )
11933
12676
 
11934
12677
  /**
@@ -11967,7 +12710,7 @@ const scopeProxyHandlerProperties = {
11967
12710
  const quotedProp = q(String(prop))
11968
12711
  console.warn(
11969
12712
  `getOwnPropertyDescriptor trap on scopeTerminatorHandler for ${quotedProp}`,
11970
- new TypeError().stack,
12713
+ new TypeError().stack
11971
12714
  )
11972
12715
  return undefined
11973
12716
  },
@@ -11979,13 +12722,13 @@ const scopeProxyHandlerProperties = {
11979
12722
  const strictScopeTerminatorHandler = freeze(
11980
12723
  create(
11981
12724
  alwaysThrowHandler,
11982
- getOwnPropertyDescriptors(scopeProxyHandlerProperties),
11983
- ),
12725
+ getOwnPropertyDescriptors(scopeProxyHandlerProperties)
12726
+ )
11984
12727
  )
11985
12728
 
11986
12729
  const strictScopeTerminator = new Proxy(
11987
12730
  immutableObject,
11988
- strictScopeTerminatorHandler,
12731
+ strictScopeTerminatorHandler
11989
12732
  )
11990
12733
 
11991
12734
  module.exports = {
@@ -12062,8 +12805,8 @@ module.exports = {
12062
12805
  }
12063
12806
  }
12064
12807
 
12065
- function performScuttleGlobalThis (globalRef, extraPropsToAvoid = new Array()) {
12066
- const props = new Array()
12808
+ function performScuttleGlobalThis (globalRef, extraPropsToAvoid = []) {
12809
+ const props = []
12067
12810
  getPrototypeChain(globalRef)
12068
12811
  .forEach(proto =>
12069
12812
  props.push(...Object.getOwnPropertyNames(proto)))
@@ -12180,7 +12923,7 @@ module.exports = {
12180
12923
  const parentPackagesWhitelist = parentPackagePolicy.packages
12181
12924
  const parentBuiltinsWhitelist = Object.entries(parentPackagePolicy.builtin)
12182
12925
  .filter(([, allowed]) => allowed === true)
12183
- // eslint-disable-next-line no-unused-vars
12926
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12184
12927
  .map(([packagePath, allowed]) => packagePath.split('.')[0])
12185
12928
 
12186
12929
  // resolve the moduleId from the requestedName
@@ -12230,7 +12973,7 @@ module.exports = {
12230
12973
  // grab all allowed builtin paths that match this package
12231
12974
  .filter(([packagePath, allowed]) => allowed === true && moduleId === packagePath.split('.')[0])
12232
12975
  // only include the paths after the packageName
12233
- // eslint-disable-next-line no-unused-vars
12976
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12234
12977
  .map(([packagePath, allowed]) => packagePath.split('.').slice(1).join('.'))
12235
12978
  .sort()
12236
12979
  )