ses 0.14.1 → 0.15.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 (50) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/NEWS.md +53 -1
  3. package/README.md +0 -1
  4. package/dist/lockdown.cjs +1769 -990
  5. package/dist/lockdown.mjs +1769 -990
  6. package/dist/lockdown.umd.js +1769 -990
  7. package/dist/lockdown.umd.min.js +1 -1
  8. package/dist/ses.cjs +1769 -990
  9. package/dist/ses.mjs +1769 -990
  10. package/dist/ses.umd.js +1769 -990
  11. package/dist/ses.umd.min.js +1 -1
  12. package/index.d.ts +1 -0
  13. package/index.js +6 -13
  14. package/package.json +24 -11
  15. package/src/commons.js +44 -9
  16. package/src/compartment-evaluate.js +102 -0
  17. package/src/compartment-shim.js +78 -106
  18. package/src/enable-property-overrides.js +5 -4
  19. package/src/enablements.js +7 -2
  20. package/src/environment-options.js +125 -0
  21. package/src/error/assert.js +51 -39
  22. package/src/error/console.js +32 -14
  23. package/src/error/fatal-assert.js +2 -0
  24. package/src/error/stringify-utils.js +26 -3
  25. package/src/error/tame-console.js +12 -2
  26. package/src/error/tame-error-constructor.js +18 -17
  27. package/src/error/tame-v8-error-constructor.js +30 -14
  28. package/src/get-anonymous-intrinsics.js +11 -8
  29. package/src/get-source-url.js +4 -4
  30. package/src/global-object.js +33 -26
  31. package/src/intrinsics.js +76 -67
  32. package/src/lockdown-shim.js +111 -119
  33. package/src/make-eval-function.js +3 -5
  34. package/src/make-function-constructor.js +3 -4
  35. package/src/make-safe-evaluator.js +117 -0
  36. package/src/module-instance.js +31 -17
  37. package/src/module-link.js +11 -4
  38. package/src/module-load.js +169 -44
  39. package/src/module-proxy.js +12 -4
  40. package/src/scope-constants.js +6 -3
  41. package/src/scope-handler.js +41 -17
  42. package/src/tame-date-constructor.js +8 -2
  43. package/src/tame-domains.js +46 -0
  44. package/src/tame-function-constructors.js +1 -0
  45. package/src/tame-locale-methods.js +6 -6
  46. package/src/tame-math-object.js +2 -2
  47. package/src/tame-regexp-constructor.js +7 -7
  48. package/src/transforms.js +13 -6
  49. package/src/whitelist-intrinsics.js +9 -3
  50. package/src/evaluate.js +0 -98
package/dist/lockdown.mjs CHANGED
@@ -30,12 +30,12 @@ Object: cell("Object"),
30
30
  Promise: cell("Promise"),
31
31
  Proxy: cell("Proxy"),
32
32
  Reflect: cell("Reflect"),
33
- RegExp: cell("RegExp"),
33
+ FERAL_REG_EXP: cell("FERAL_REG_EXP"),
34
34
  Set: cell("Set"),
35
35
  String: cell("String"),
36
36
  WeakMap: cell("WeakMap"),
37
37
  WeakSet: cell("WeakSet"),
38
- Error: cell("Error"),
38
+ FERAL_ERROR: cell("FERAL_ERROR"),
39
39
  RangeError: cell("RangeError"),
40
40
  ReferenceError: cell("ReferenceError"),
41
41
  SyntaxError: cell("SyntaxError"),
@@ -82,38 +82,56 @@ stringPrototype: cell("stringPrototype"),
82
82
  weakmapPrototype: cell("weakmapPrototype"),
83
83
  weaksetPrototype: cell("weaksetPrototype"),
84
84
  functionPrototype: cell("functionPrototype"),
85
+ promisePrototype: cell("promisePrototype"),
85
86
  uncurryThis: cell("uncurryThis"),
86
87
  objectHasOwnProperty: cell("objectHasOwnProperty"),
87
- arrayForEach: cell("arrayForEach"),
88
88
  arrayFilter: cell("arrayFilter"),
89
+ arrayForEach: cell("arrayForEach"),
90
+ arrayIncludes: cell("arrayIncludes"),
89
91
  arrayJoin: cell("arrayJoin"),
90
- arrayPush: cell("arrayPush"),
92
+ arrayMap: cell("arrayMap"),
91
93
  arrayPop: cell("arrayPop"),
92
- arrayIncludes: cell("arrayIncludes"),
94
+ arrayPush: cell("arrayPush"),
95
+ arraySlice: cell("arraySlice"),
96
+ arraySome: cell("arraySome"),
97
+ arraySort: cell("arraySort"),
98
+ iterateArray: cell("iterateArray"),
93
99
  mapSet: cell("mapSet"),
94
100
  mapGet: cell("mapGet"),
95
101
  mapHas: cell("mapHas"),
102
+ iterateMap: cell("iterateMap"),
96
103
  setAdd: cell("setAdd"),
97
104
  setForEach: cell("setForEach"),
98
105
  setHas: cell("setHas"),
106
+ iterateSet: cell("iterateSet"),
99
107
  regexpTest: cell("regexpTest"),
108
+ regexpExec: cell("regexpExec"),
109
+ matchAllRegExp: cell("matchAllRegExp"),
100
110
  stringEndsWith: cell("stringEndsWith"),
101
111
  stringIncludes: cell("stringIncludes"),
112
+ stringIndexOf: cell("stringIndexOf"),
102
113
  stringMatch: cell("stringMatch"),
114
+ stringReplace: cell("stringReplace"),
103
115
  stringSearch: cell("stringSearch"),
104
116
  stringSlice: cell("stringSlice"),
105
117
  stringSplit: cell("stringSplit"),
106
118
  stringStartsWith: cell("stringStartsWith"),
119
+ iterateString: cell("iterateString"),
120
+ weakmapDelete: cell("weakmapDelete"),
107
121
  weakmapGet: cell("weakmapGet"),
108
- weakmapSet: cell("weakmapSet"),
109
122
  weakmapHas: cell("weakmapHas"),
123
+ weakmapSet: cell("weakmapSet"),
110
124
  weaksetAdd: cell("weaksetAdd"),
111
- weaksetSet: cell("weaksetSet"),
125
+ weaksetGet: cell("weaksetGet"),
112
126
  weaksetHas: cell("weaksetHas"),
113
127
  functionToString: cell("functionToString"),
128
+ promiseAll: cell("promiseAll"),
129
+ promiseCatch: cell("promiseCatch"),
130
+ promiseThen: cell("promiseThen"),
114
131
  getConstructorOf: cell("getConstructorOf"),
115
132
  immutableObject: cell("immutableObject"),
116
133
  isObject: cell("isObject"),
134
+ isError: cell("isError"),
117
135
  FERAL_EVAL: cell("FERAL_EVAL"),
118
136
  FERAL_FUNCTION: cell("FERAL_FUNCTION"),
119
137
 
@@ -124,6 +142,7 @@ FERAL_FUNCTION: cell("FERAL_FUNCTION"),
124
142
  },{
125
143
  an: cell("an"),
126
144
  bestEffortStringify: cell("bestEffortStringify"),
145
+ enJoin: cell("enJoin"),
127
146
 
128
147
 
129
148
  },{
@@ -164,7 +183,12 @@ applyTransforms: cell("applyTransforms"),
164
183
 
165
184
 
166
185
  },{
167
- performEval: cell("performEval"),
186
+ makeSafeEvaluator: cell("makeSafeEvaluator"),
187
+
188
+
189
+ },{
190
+ provideCompartmentEvaluator: cell("provideCompartmentEvaluator"),
191
+ compartmentEvaluate: cell("compartmentEvaluate"),
168
192
 
169
193
 
170
194
  },{
@@ -188,7 +212,8 @@ whitelist: cell("whitelist"),
188
212
 
189
213
 
190
214
  },{
191
- initGlobalObject: cell("initGlobalObject"),
215
+ setGlobalObjectConstantProperties: cell("setGlobalObjectConstantProperties"),
216
+ setGlobalObjectMutableProperties: cell("setGlobalObjectMutableProperties"),
192
217
 
193
218
 
194
219
  },{
@@ -217,10 +242,6 @@ CompartmentPrototype: cell("CompartmentPrototype"),
217
242
  makeCompartmentConstructor: cell("makeCompartmentConstructor"),
218
243
 
219
244
 
220
- },{
221
- getAnonymousIntrinsics: cell("getAnonymousIntrinsics"),
222
-
223
-
224
245
  },{
225
246
  makeIntrinsicsCollector: cell("makeIntrinsicsCollector"),
226
247
  getGlobalIntrinsics: cell("getGlobalIntrinsics"),
@@ -236,6 +257,10 @@ severeEnablements: cell("severeEnablements"),
236
257
  default: cell("default"),
237
258
 
238
259
 
260
+ },{
261
+ makeEnvironmentCaptor: cell("makeEnvironmentCaptor"),
262
+
263
+
239
264
  },{
240
265
  makeLoggingConsoleKit: cell("makeLoggingConsoleKit"),
241
266
  makeCausalConsole: cell("makeCausalConsole"),
@@ -258,6 +283,10 @@ tameV8ErrorConstructor: cell("tameV8ErrorConstructor"),
258
283
  default: cell("default"),
259
284
 
260
285
 
286
+ },{
287
+ getAnonymousIntrinsics: cell("getAnonymousIntrinsics"),
288
+
289
+
261
290
  },{
262
291
  makeHardener: cell("makeHardener"),
263
292
 
@@ -266,6 +295,10 @@ tameV8ErrorConstructor: cell("tameV8ErrorConstructor"),
266
295
  default: cell("default"),
267
296
 
268
297
 
298
+ },{
299
+ tameDomains: cell("tameDomains"),
300
+
301
+
269
302
  },{
270
303
  default: cell("default"),
271
304
 
@@ -292,7 +325,7 @@ tameV8ErrorConstructor: cell("tameV8ErrorConstructor"),
292
325
 
293
326
  },{
294
327
  repairIntrinsics: cell("repairIntrinsics"),
295
- makeLockdown: cell("makeLockdown"),
328
+ lockdown: cell("lockdown"),
296
329
 
297
330
 
298
331
  },{
@@ -328,12 +361,12 @@ makeLockdown: cell("makeLockdown"),
328
361
  Promise: cells[0].Promise.set,
329
362
  Proxy: cells[0].Proxy.set,
330
363
  Reflect: cells[0].Reflect.set,
331
- RegExp: cells[0].RegExp.set,
364
+ FERAL_REG_EXP: cells[0].FERAL_REG_EXP.set,
332
365
  Set: cells[0].Set.set,
333
366
  String: cells[0].String.set,
334
367
  WeakMap: cells[0].WeakMap.set,
335
368
  WeakSet: cells[0].WeakSet.set,
336
- Error: cells[0].Error.set,
369
+ FERAL_ERROR: cells[0].FERAL_ERROR.set,
337
370
  RangeError: cells[0].RangeError.set,
338
371
  ReferenceError: cells[0].ReferenceError.set,
339
372
  SyntaxError: cells[0].SyntaxError.set,
@@ -380,38 +413,56 @@ makeLockdown: cell("makeLockdown"),
380
413
  weakmapPrototype: cells[0].weakmapPrototype.set,
381
414
  weaksetPrototype: cells[0].weaksetPrototype.set,
382
415
  functionPrototype: cells[0].functionPrototype.set,
416
+ promisePrototype: cells[0].promisePrototype.set,
383
417
  uncurryThis: cells[0].uncurryThis.set,
384
418
  objectHasOwnProperty: cells[0].objectHasOwnProperty.set,
385
- arrayForEach: cells[0].arrayForEach.set,
386
419
  arrayFilter: cells[0].arrayFilter.set,
420
+ arrayForEach: cells[0].arrayForEach.set,
421
+ arrayIncludes: cells[0].arrayIncludes.set,
387
422
  arrayJoin: cells[0].arrayJoin.set,
388
- arrayPush: cells[0].arrayPush.set,
423
+ arrayMap: cells[0].arrayMap.set,
389
424
  arrayPop: cells[0].arrayPop.set,
390
- arrayIncludes: cells[0].arrayIncludes.set,
425
+ arrayPush: cells[0].arrayPush.set,
426
+ arraySlice: cells[0].arraySlice.set,
427
+ arraySome: cells[0].arraySome.set,
428
+ arraySort: cells[0].arraySort.set,
429
+ iterateArray: cells[0].iterateArray.set,
391
430
  mapSet: cells[0].mapSet.set,
392
431
  mapGet: cells[0].mapGet.set,
393
432
  mapHas: cells[0].mapHas.set,
433
+ iterateMap: cells[0].iterateMap.set,
394
434
  setAdd: cells[0].setAdd.set,
395
435
  setForEach: cells[0].setForEach.set,
396
436
  setHas: cells[0].setHas.set,
437
+ iterateSet: cells[0].iterateSet.set,
397
438
  regexpTest: cells[0].regexpTest.set,
439
+ regexpExec: cells[0].regexpExec.set,
440
+ matchAllRegExp: cells[0].matchAllRegExp.set,
398
441
  stringEndsWith: cells[0].stringEndsWith.set,
399
442
  stringIncludes: cells[0].stringIncludes.set,
443
+ stringIndexOf: cells[0].stringIndexOf.set,
400
444
  stringMatch: cells[0].stringMatch.set,
445
+ stringReplace: cells[0].stringReplace.set,
401
446
  stringSearch: cells[0].stringSearch.set,
402
447
  stringSlice: cells[0].stringSlice.set,
403
448
  stringSplit: cells[0].stringSplit.set,
404
449
  stringStartsWith: cells[0].stringStartsWith.set,
450
+ iterateString: cells[0].iterateString.set,
451
+ weakmapDelete: cells[0].weakmapDelete.set,
405
452
  weakmapGet: cells[0].weakmapGet.set,
406
- weakmapSet: cells[0].weakmapSet.set,
407
453
  weakmapHas: cells[0].weakmapHas.set,
454
+ weakmapSet: cells[0].weakmapSet.set,
408
455
  weaksetAdd: cells[0].weaksetAdd.set,
409
- weaksetSet: cells[0].weaksetSet.set,
456
+ weaksetGet: cells[0].weaksetGet.set,
410
457
  weaksetHas: cells[0].weaksetHas.set,
411
458
  functionToString: cells[0].functionToString.set,
459
+ promiseAll: cells[0].promiseAll.set,
460
+ promiseCatch: cells[0].promiseCatch.set,
461
+ promiseThen: cells[0].promiseThen.set,
412
462
  getConstructorOf: cells[0].getConstructorOf.set,
413
463
  immutableObject: cells[0].immutableObject.set,
414
464
  isObject: cells[0].isObject.set,
465
+ isError: cells[0].isError.set,
415
466
  FERAL_EVAL: cells[0].FERAL_EVAL.set,
416
467
  FERAL_FUNCTION: cells[0].FERAL_FUNCTION.set,
417
468
 
@@ -449,6 +500,7 @@ makeLockdown: cell("makeLockdown"),
449
500
  onceVar: {
450
501
  an: cells[2].an.set,
451
502
  bestEffortStringify: cells[2].bestEffortStringify.set,
503
+ enJoin: cells[2].enJoin.set,
452
504
 
453
505
  },
454
506
  });
@@ -714,14 +766,23 @@ makeLockdown: cell("makeLockdown"),
714
766
 
715
767
  },
716
768
  onceVar: {
717
- performEval: cells[10].performEval.set,
769
+ makeSafeEvaluator: cells[10].makeSafeEvaluator.set,
718
770
 
719
771
  },
720
772
  });
721
773
  functors[11]({
722
774
  imports(entries) {
723
775
  const map = new Map(entries);
724
- for (const [name, observers] of map.get("./evaluate.js")) {
776
+ for (const [name, observers] of map.get("./commons.js")) {
777
+ const cell = cells[0][name];
778
+ if (cell === undefined) {
779
+ throw new ReferenceError(`Cannot import name ${name}`);
780
+ }
781
+ for (const observer of observers) {
782
+ cell.observe(observer);
783
+ }
784
+ }
785
+ for (const [name, observers] of map.get("./make-safe-evaluator.js")) {
725
786
  const cell = cells[10][name];
726
787
  if (cell === undefined) {
727
788
  throw new ReferenceError(`Cannot import name ${name}`);
@@ -729,6 +790,15 @@ makeLockdown: cell("makeLockdown"),
729
790
  for (const observer of observers) {
730
791
  cell.observe(observer);
731
792
  }
793
+ }
794
+ for (const [name, observers] of map.get("./transforms.js")) {
795
+ const cell = cells[9][name];
796
+ if (cell === undefined) {
797
+ throw new ReferenceError(`Cannot import name ${name}`);
798
+ }
799
+ for (const observer of observers) {
800
+ cell.observe(observer);
801
+ }
732
802
  }
733
803
 
734
804
  },
@@ -736,11 +806,25 @@ makeLockdown: cell("makeLockdown"),
736
806
 
737
807
  },
738
808
  onceVar: {
739
- makeEvalFunction: cells[11].makeEvalFunction.set,
809
+ provideCompartmentEvaluator: cells[11].provideCompartmentEvaluator.set,
810
+ compartmentEvaluate: cells[11].compartmentEvaluate.set,
740
811
 
741
812
  },
742
813
  });
743
814
  functors[12]({
815
+ imports(entries) {
816
+ const map = new Map(entries);
817
+
818
+ },
819
+ liveVar: {
820
+
821
+ },
822
+ onceVar: {
823
+ makeEvalFunction: cells[12].makeEvalFunction.set,
824
+
825
+ },
826
+ });
827
+ functors[13]({
744
828
  imports(entries) {
745
829
  const map = new Map(entries);
746
830
  for (const [name, observers] of map.get("./commons.js")) {
@@ -760,15 +844,6 @@ makeLockdown: cell("makeLockdown"),
760
844
  for (const observer of observers) {
761
845
  cell.observe(observer);
762
846
  }
763
- }
764
- for (const [name, observers] of map.get("./evaluate.js")) {
765
- const cell = cells[10][name];
766
- if (cell === undefined) {
767
- throw new ReferenceError(`Cannot import name ${name}`);
768
- }
769
- for (const observer of observers) {
770
- cell.observe(observer);
771
- }
772
847
  }
773
848
 
774
849
  },
@@ -776,11 +851,11 @@ makeLockdown: cell("makeLockdown"),
776
851
 
777
852
  },
778
853
  onceVar: {
779
- makeFunctionConstructor: cells[12].makeFunctionConstructor.set,
854
+ makeFunctionConstructor: cells[13].makeFunctionConstructor.set,
780
855
 
781
856
  },
782
857
  });
783
- functors[13]({
858
+ functors[14]({
784
859
  imports(entries) {
785
860
  const map = new Map(entries);
786
861
 
@@ -789,19 +864,19 @@ makeLockdown: cell("makeLockdown"),
789
864
 
790
865
  },
791
866
  onceVar: {
792
- constantProperties: cells[13].constantProperties.set,
793
- universalPropertyNames: cells[13].universalPropertyNames.set,
794
- initialGlobalPropertyNames: cells[13].initialGlobalPropertyNames.set,
795
- sharedGlobalPropertyNames: cells[13].sharedGlobalPropertyNames.set,
796
- uniqueGlobalPropertyNames: cells[13].uniqueGlobalPropertyNames.set,
797
- NativeErrors: cells[13].NativeErrors.set,
798
- FunctionInstance: cells[13].FunctionInstance.set,
799
- isAccessorPermit: cells[13].isAccessorPermit.set,
800
- whitelist: cells[13].whitelist.set,
867
+ constantProperties: cells[14].constantProperties.set,
868
+ universalPropertyNames: cells[14].universalPropertyNames.set,
869
+ initialGlobalPropertyNames: cells[14].initialGlobalPropertyNames.set,
870
+ sharedGlobalPropertyNames: cells[14].sharedGlobalPropertyNames.set,
871
+ uniqueGlobalPropertyNames: cells[14].uniqueGlobalPropertyNames.set,
872
+ NativeErrors: cells[14].NativeErrors.set,
873
+ FunctionInstance: cells[14].FunctionInstance.set,
874
+ isAccessorPermit: cells[14].isAccessorPermit.set,
875
+ whitelist: cells[14].whitelist.set,
801
876
 
802
877
  },
803
878
  });
804
- functors[14]({
879
+ functors[15]({
805
880
  imports(entries) {
806
881
  const map = new Map(entries);
807
882
  for (const [name, observers] of map.get("./commons.js")) {
@@ -814,7 +889,7 @@ makeLockdown: cell("makeLockdown"),
814
889
  }
815
890
  }
816
891
  for (const [name, observers] of map.get("./make-eval-function.js")) {
817
- const cell = cells[11][name];
892
+ const cell = cells[12][name];
818
893
  if (cell === undefined) {
819
894
  throw new ReferenceError(`Cannot import name ${name}`);
820
895
  }
@@ -823,7 +898,7 @@ makeLockdown: cell("makeLockdown"),
823
898
  }
824
899
  }
825
900
  for (const [name, observers] of map.get("./make-function-constructor.js")) {
826
- const cell = cells[12][name];
901
+ const cell = cells[13][name];
827
902
  if (cell === undefined) {
828
903
  throw new ReferenceError(`Cannot import name ${name}`);
829
904
  }
@@ -832,7 +907,7 @@ makeLockdown: cell("makeLockdown"),
832
907
  }
833
908
  }
834
909
  for (const [name, observers] of map.get("./whitelist.js")) {
835
- const cell = cells[13][name];
910
+ const cell = cells[14][name];
836
911
  if (cell === undefined) {
837
912
  throw new ReferenceError(`Cannot import name ${name}`);
838
913
  }
@@ -846,11 +921,12 @@ makeLockdown: cell("makeLockdown"),
846
921
 
847
922
  },
848
923
  onceVar: {
849
- initGlobalObject: cells[14].initGlobalObject.set,
924
+ setGlobalObjectConstantProperties: cells[15].setGlobalObjectConstantProperties.set,
925
+ setGlobalObjectMutableProperties: cells[15].setGlobalObjectMutableProperties.set,
850
926
 
851
927
  },
852
928
  });
853
- functors[15]({
929
+ functors[16]({
854
930
  imports(entries) {
855
931
  const map = new Map(entries);
856
932
  for (const [name, observers] of map.get("./commons.js")) {
@@ -877,12 +953,12 @@ makeLockdown: cell("makeLockdown"),
877
953
 
878
954
  },
879
955
  onceVar: {
880
- makeAlias: cells[15].makeAlias.set,
881
- load: cells[15].load.set,
956
+ makeAlias: cells[16].makeAlias.set,
957
+ load: cells[16].load.set,
882
958
 
883
959
  },
884
960
  });
885
- functors[16]({
961
+ functors[17]({
886
962
  imports(entries) {
887
963
  const map = new Map(entries);
888
964
  for (const [name, observers] of map.get("./commons.js")) {
@@ -904,7 +980,7 @@ makeLockdown: cell("makeLockdown"),
904
980
  }
905
981
  }
906
982
  for (const [name, observers] of map.get("./module-load.js")) {
907
- const cell = cells[15][name];
983
+ const cell = cells[16][name];
908
984
  if (cell === undefined) {
909
985
  throw new ReferenceError(`Cannot import name ${name}`);
910
986
  }
@@ -918,12 +994,12 @@ makeLockdown: cell("makeLockdown"),
918
994
 
919
995
  },
920
996
  onceVar: {
921
- deferExports: cells[16].deferExports.set,
922
- getDeferredExports: cells[16].getDeferredExports.set,
997
+ deferExports: cells[17].deferExports.set,
998
+ getDeferredExports: cells[17].getDeferredExports.set,
923
999
 
924
1000
  },
925
1001
  });
926
- functors[17]({
1002
+ functors[18]({
927
1003
  imports(entries) {
928
1004
  const map = new Map(entries);
929
1005
  for (const [name, observers] of map.get("./commons.js")) {
@@ -934,6 +1010,15 @@ makeLockdown: cell("makeLockdown"),
934
1010
  for (const observer of observers) {
935
1011
  cell.observe(observer);
936
1012
  }
1013
+ }
1014
+ for (const [name, observers] of map.get("./compartment-evaluate.js")) {
1015
+ const cell = cells[11][name];
1016
+ if (cell === undefined) {
1017
+ throw new ReferenceError(`Cannot import name ${name}`);
1018
+ }
1019
+ for (const observer of observers) {
1020
+ cell.observe(observer);
1021
+ }
937
1022
  }
938
1023
  for (const [name, observers] of map.get("./error/assert.js")) {
939
1024
  const cell = cells[4][name];
@@ -945,7 +1030,7 @@ makeLockdown: cell("makeLockdown"),
945
1030
  }
946
1031
  }
947
1032
  for (const [name, observers] of map.get("./module-proxy.js")) {
948
- const cell = cells[16][name];
1033
+ const cell = cells[17][name];
949
1034
  if (cell === undefined) {
950
1035
  throw new ReferenceError(`Cannot import name ${name}`);
951
1036
  }
@@ -959,12 +1044,12 @@ makeLockdown: cell("makeLockdown"),
959
1044
 
960
1045
  },
961
1046
  onceVar: {
962
- makeThirdPartyModuleInstance: cells[17].makeThirdPartyModuleInstance.set,
963
- makeModuleInstance: cells[17].makeModuleInstance.set,
1047
+ makeThirdPartyModuleInstance: cells[18].makeThirdPartyModuleInstance.set,
1048
+ makeModuleInstance: cells[18].makeModuleInstance.set,
964
1049
 
965
1050
  },
966
1051
  });
967
- functors[18]({
1052
+ functors[19]({
968
1053
  imports(entries) {
969
1054
  const map = new Map(entries);
970
1055
  for (const [name, observers] of map.get("./commons.js")) {
@@ -986,7 +1071,7 @@ makeLockdown: cell("makeLockdown"),
986
1071
  }
987
1072
  }
988
1073
  for (const [name, observers] of map.get("./module-instance.js")) {
989
- const cell = cells[17][name];
1074
+ const cell = cells[18][name];
990
1075
  if (cell === undefined) {
991
1076
  throw new ReferenceError(`Cannot import name ${name}`);
992
1077
  }
@@ -1000,12 +1085,12 @@ makeLockdown: cell("makeLockdown"),
1000
1085
 
1001
1086
  },
1002
1087
  onceVar: {
1003
- link: cells[18].link.set,
1004
- instantiate: cells[18].instantiate.set,
1088
+ link: cells[19].link.set,
1089
+ instantiate: cells[19].instantiate.set,
1005
1090
 
1006
1091
  },
1007
1092
  });
1008
- functors[19]({
1093
+ functors[20]({
1009
1094
  imports(entries) {
1010
1095
  const map = new Map(entries);
1011
1096
  for (const [name, observers] of map.get("./commons.js")) {
@@ -1017,8 +1102,8 @@ makeLockdown: cell("makeLockdown"),
1017
1102
  cell.observe(observer);
1018
1103
  }
1019
1104
  }
1020
- for (const [name, observers] of map.get("./error/assert.js")) {
1021
- const cell = cells[4][name];
1105
+ for (const [name, observers] of map.get("./compartment-evaluate.js")) {
1106
+ const cell = cells[11][name];
1022
1107
  if (cell === undefined) {
1023
1108
  throw new ReferenceError(`Cannot import name ${name}`);
1024
1109
  }
@@ -1026,8 +1111,8 @@ makeLockdown: cell("makeLockdown"),
1026
1111
  cell.observe(observer);
1027
1112
  }
1028
1113
  }
1029
- for (const [name, observers] of map.get("./evaluate.js")) {
1030
- const cell = cells[10][name];
1114
+ for (const [name, observers] of map.get("./error/assert.js")) {
1115
+ const cell = cells[4][name];
1031
1116
  if (cell === undefined) {
1032
1117
  throw new ReferenceError(`Cannot import name ${name}`);
1033
1118
  }
@@ -1036,7 +1121,7 @@ makeLockdown: cell("makeLockdown"),
1036
1121
  }
1037
1122
  }
1038
1123
  for (const [name, observers] of map.get("./global-object.js")) {
1039
- const cell = cells[14][name];
1124
+ const cell = cells[15][name];
1040
1125
  if (cell === undefined) {
1041
1126
  throw new ReferenceError(`Cannot import name ${name}`);
1042
1127
  }
@@ -1044,8 +1129,8 @@ makeLockdown: cell("makeLockdown"),
1044
1129
  cell.observe(observer);
1045
1130
  }
1046
1131
  }
1047
- for (const [name, observers] of map.get("./module-link.js")) {
1048
- const cell = cells[18][name];
1132
+ for (const [name, observers] of map.get("./make-safe-evaluator.js")) {
1133
+ const cell = cells[10][name];
1049
1134
  if (cell === undefined) {
1050
1135
  throw new ReferenceError(`Cannot import name ${name}`);
1051
1136
  }
@@ -1053,8 +1138,8 @@ makeLockdown: cell("makeLockdown"),
1053
1138
  cell.observe(observer);
1054
1139
  }
1055
1140
  }
1056
- for (const [name, observers] of map.get("./module-load.js")) {
1057
- const cell = cells[15][name];
1141
+ for (const [name, observers] of map.get("./module-link.js")) {
1142
+ const cell = cells[19][name];
1058
1143
  if (cell === undefined) {
1059
1144
  throw new ReferenceError(`Cannot import name ${name}`);
1060
1145
  }
@@ -1062,7 +1147,7 @@ makeLockdown: cell("makeLockdown"),
1062
1147
  cell.observe(observer);
1063
1148
  }
1064
1149
  }
1065
- for (const [name, observers] of map.get("./module-proxy.js")) {
1150
+ for (const [name, observers] of map.get("./module-load.js")) {
1066
1151
  const cell = cells[16][name];
1067
1152
  if (cell === undefined) {
1068
1153
  throw new ReferenceError(`Cannot import name ${name}`);
@@ -1071,8 +1156,8 @@ makeLockdown: cell("makeLockdown"),
1071
1156
  cell.observe(observer);
1072
1157
  }
1073
1158
  }
1074
- for (const [name, observers] of map.get("./scope-constants.js")) {
1075
- const cell = cells[6][name];
1159
+ for (const [name, observers] of map.get("./module-proxy.js")) {
1160
+ const cell = cells[17][name];
1076
1161
  if (cell === undefined) {
1077
1162
  throw new ReferenceError(`Cannot import name ${name}`);
1078
1163
  }
@@ -1080,8 +1165,8 @@ makeLockdown: cell("makeLockdown"),
1080
1165
  cell.observe(observer);
1081
1166
  }
1082
1167
  }
1083
- for (const [name, observers] of map.get("./transforms.js")) {
1084
- const cell = cells[9][name];
1168
+ for (const [name, observers] of map.get("./scope-constants.js")) {
1169
+ const cell = cells[6][name];
1085
1170
  if (cell === undefined) {
1086
1171
  throw new ReferenceError(`Cannot import name ${name}`);
1087
1172
  }
@@ -1090,7 +1175,7 @@ makeLockdown: cell("makeLockdown"),
1090
1175
  }
1091
1176
  }
1092
1177
  for (const [name, observers] of map.get("./whitelist.js")) {
1093
- const cell = cells[13][name];
1178
+ const cell = cells[14][name];
1094
1179
  if (cell === undefined) {
1095
1180
  throw new ReferenceError(`Cannot import name ${name}`);
1096
1181
  }
@@ -1104,13 +1189,13 @@ makeLockdown: cell("makeLockdown"),
1104
1189
 
1105
1190
  },
1106
1191
  onceVar: {
1107
- InertCompartment: cells[19].InertCompartment.set,
1108
- CompartmentPrototype: cells[19].CompartmentPrototype.set,
1109
- makeCompartmentConstructor: cells[19].makeCompartmentConstructor.set,
1192
+ InertCompartment: cells[20].InertCompartment.set,
1193
+ CompartmentPrototype: cells[20].CompartmentPrototype.set,
1194
+ makeCompartmentConstructor: cells[20].makeCompartmentConstructor.set,
1110
1195
 
1111
1196
  },
1112
1197
  });
1113
- functors[20]({
1198
+ functors[21]({
1114
1199
  imports(entries) {
1115
1200
  const map = new Map(entries);
1116
1201
  for (const [name, observers] of map.get("./commons.js")) {
@@ -1122,8 +1207,8 @@ makeLockdown: cell("makeLockdown"),
1122
1207
  cell.observe(observer);
1123
1208
  }
1124
1209
  }
1125
- for (const [name, observers] of map.get("./compartment-shim.js")) {
1126
- const cell = cells[19][name];
1210
+ for (const [name, observers] of map.get("./whitelist.js")) {
1211
+ const cell = cells[14][name];
1127
1212
  if (cell === undefined) {
1128
1213
  throw new ReferenceError(`Cannot import name ${name}`);
1129
1214
  }
@@ -1137,11 +1222,27 @@ makeLockdown: cell("makeLockdown"),
1137
1222
 
1138
1223
  },
1139
1224
  onceVar: {
1140
- getAnonymousIntrinsics: cells[20].getAnonymousIntrinsics.set,
1225
+ makeIntrinsicsCollector: cells[21].makeIntrinsicsCollector.set,
1226
+ getGlobalIntrinsics: cells[21].getGlobalIntrinsics.set,
1141
1227
 
1142
1228
  },
1143
1229
  });
1144
- functors[21]({
1230
+ functors[22]({
1231
+ imports(entries) {
1232
+ const map = new Map(entries);
1233
+
1234
+ },
1235
+ liveVar: {
1236
+
1237
+ },
1238
+ onceVar: {
1239
+ minEnablements: cells[22].minEnablements.set,
1240
+ moderateEnablements: cells[22].moderateEnablements.set,
1241
+ severeEnablements: cells[22].severeEnablements.set,
1242
+
1243
+ },
1244
+ });
1245
+ functors[23]({
1145
1246
  imports(entries) {
1146
1247
  const map = new Map(entries);
1147
1248
  for (const [name, observers] of map.get("./commons.js")) {
@@ -1153,8 +1254,8 @@ makeLockdown: cell("makeLockdown"),
1153
1254
  cell.observe(observer);
1154
1255
  }
1155
1256
  }
1156
- for (const [name, observers] of map.get("./whitelist.js")) {
1157
- const cell = cells[13][name];
1257
+ for (const [name, observers] of map.get("./enablements.js")) {
1258
+ const cell = cells[22][name];
1158
1259
  if (cell === undefined) {
1159
1260
  throw new ReferenceError(`Cannot import name ${name}`);
1160
1261
  }
@@ -1168,27 +1269,11 @@ makeLockdown: cell("makeLockdown"),
1168
1269
 
1169
1270
  },
1170
1271
  onceVar: {
1171
- makeIntrinsicsCollector: cells[21].makeIntrinsicsCollector.set,
1172
- getGlobalIntrinsics: cells[21].getGlobalIntrinsics.set,
1173
-
1174
- },
1175
- });
1176
- functors[22]({
1177
- imports(entries) {
1178
- const map = new Map(entries);
1179
-
1180
- },
1181
- liveVar: {
1182
-
1183
- },
1184
- onceVar: {
1185
- minEnablements: cells[22].minEnablements.set,
1186
- moderateEnablements: cells[22].moderateEnablements.set,
1187
- severeEnablements: cells[22].severeEnablements.set,
1272
+ default: cells[23].default.set,
1188
1273
 
1189
1274
  },
1190
1275
  });
1191
- functors[23]({
1276
+ functors[24]({
1192
1277
  imports(entries) {
1193
1278
  const map = new Map(entries);
1194
1279
  for (const [name, observers] of map.get("./commons.js")) {
@@ -1200,8 +1285,8 @@ makeLockdown: cell("makeLockdown"),
1200
1285
  cell.observe(observer);
1201
1286
  }
1202
1287
  }
1203
- for (const [name, observers] of map.get("./enablements.js")) {
1204
- const cell = cells[22][name];
1288
+ for (const [name, observers] of map.get("./error/assert.js")) {
1289
+ const cell = cells[4][name];
1205
1290
  if (cell === undefined) {
1206
1291
  throw new ReferenceError(`Cannot import name ${name}`);
1207
1292
  }
@@ -1215,11 +1300,11 @@ makeLockdown: cell("makeLockdown"),
1215
1300
 
1216
1301
  },
1217
1302
  onceVar: {
1218
- default: cells[23].default.set,
1303
+ makeEnvironmentCaptor: cells[24].makeEnvironmentCaptor.set,
1219
1304
 
1220
1305
  },
1221
1306
  });
1222
- functors[24]({
1307
+ functors[25]({
1223
1308
  imports(entries) {
1224
1309
  const map = new Map(entries);
1225
1310
  for (const [name, observers] of map.get("../commons.js")) {
@@ -1255,15 +1340,15 @@ makeLockdown: cell("makeLockdown"),
1255
1340
 
1256
1341
  },
1257
1342
  onceVar: {
1258
- makeLoggingConsoleKit: cells[24].makeLoggingConsoleKit.set,
1259
- makeCausalConsole: cells[24].makeCausalConsole.set,
1260
- filterConsole: cells[24].filterConsole.set,
1261
- consoleWhitelist: cells[24].consoleWhitelist.set,
1262
- BASE_CONSOLE_LEVEL: cells[24].BASE_CONSOLE_LEVEL.set,
1343
+ makeLoggingConsoleKit: cells[25].makeLoggingConsoleKit.set,
1344
+ makeCausalConsole: cells[25].makeCausalConsole.set,
1345
+ filterConsole: cells[25].filterConsole.set,
1346
+ consoleWhitelist: cells[25].consoleWhitelist.set,
1347
+ BASE_CONSOLE_LEVEL: cells[25].BASE_CONSOLE_LEVEL.set,
1263
1348
 
1264
1349
  },
1265
1350
  });
1266
- functors[25]({
1351
+ functors[26]({
1267
1352
  imports(entries) {
1268
1353
  const map = new Map(entries);
1269
1354
  for (const [name, observers] of map.get("../commons.js")) {
@@ -1285,7 +1370,7 @@ makeLockdown: cell("makeLockdown"),
1285
1370
  }
1286
1371
  }
1287
1372
  for (const [name, observers] of map.get("./console.js")) {
1288
- const cell = cells[24][name];
1373
+ const cell = cells[25][name];
1289
1374
  if (cell === undefined) {
1290
1375
  throw new ReferenceError(`Cannot import name ${name}`);
1291
1376
  }
@@ -1317,11 +1402,11 @@ makeLockdown: cell("makeLockdown"),
1317
1402
 
1318
1403
  },
1319
1404
  onceVar: {
1320
- tameConsole: cells[25].tameConsole.set,
1405
+ tameConsole: cells[26].tameConsole.set,
1321
1406
 
1322
1407
  },
1323
1408
  });
1324
- functors[26]({
1409
+ functors[27]({
1325
1410
  imports(entries) {
1326
1411
  const map = new Map(entries);
1327
1412
  for (const [name, observers] of map.get("../commons.js")) {
@@ -1339,13 +1424,13 @@ makeLockdown: cell("makeLockdown"),
1339
1424
 
1340
1425
  },
1341
1426
  onceVar: {
1342
- filterFileName: cells[26].filterFileName.set,
1343
- shortenCallSiteString: cells[26].shortenCallSiteString.set,
1344
- tameV8ErrorConstructor: cells[26].tameV8ErrorConstructor.set,
1427
+ filterFileName: cells[27].filterFileName.set,
1428
+ shortenCallSiteString: cells[27].shortenCallSiteString.set,
1429
+ tameV8ErrorConstructor: cells[27].tameV8ErrorConstructor.set,
1345
1430
 
1346
1431
  },
1347
1432
  });
1348
- functors[27]({
1433
+ functors[28]({
1349
1434
  imports(entries) {
1350
1435
  const map = new Map(entries);
1351
1436
  for (const [name, observers] of map.get("../commons.js")) {
@@ -1358,7 +1443,7 @@ makeLockdown: cell("makeLockdown"),
1358
1443
  }
1359
1444
  }
1360
1445
  for (const [name, observers] of map.get("../whitelist.js")) {
1361
- const cell = cells[13][name];
1446
+ const cell = cells[14][name];
1362
1447
  if (cell === undefined) {
1363
1448
  throw new ReferenceError(`Cannot import name ${name}`);
1364
1449
  }
@@ -1367,7 +1452,7 @@ makeLockdown: cell("makeLockdown"),
1367
1452
  }
1368
1453
  }
1369
1454
  for (const [name, observers] of map.get("./tame-v8-error-constructor.js")) {
1370
- const cell = cells[26][name];
1455
+ const cell = cells[27][name];
1371
1456
  if (cell === undefined) {
1372
1457
  throw new ReferenceError(`Cannot import name ${name}`);
1373
1458
  }
@@ -1381,11 +1466,11 @@ makeLockdown: cell("makeLockdown"),
1381
1466
 
1382
1467
  },
1383
1468
  onceVar: {
1384
- default: cells[27].default.set,
1469
+ default: cells[28].default.set,
1385
1470
 
1386
1471
  },
1387
1472
  });
1388
- functors[28]({
1473
+ functors[29]({
1389
1474
  imports(entries) {
1390
1475
  const map = new Map(entries);
1391
1476
  for (const [name, observers] of map.get("./commons.js")) {
@@ -1397,21 +1482,8 @@ makeLockdown: cell("makeLockdown"),
1397
1482
  cell.observe(observer);
1398
1483
  }
1399
1484
  }
1400
-
1401
- },
1402
- liveVar: {
1403
-
1404
- },
1405
- onceVar: {
1406
- makeHardener: cells[28].makeHardener.set,
1407
-
1408
- },
1409
- });
1410
- functors[29]({
1411
- imports(entries) {
1412
- const map = new Map(entries);
1413
- for (const [name, observers] of map.get("./commons.js")) {
1414
- const cell = cells[0][name];
1485
+ for (const [name, observers] of map.get("./compartment-shim.js")) {
1486
+ const cell = cells[20][name];
1415
1487
  if (cell === undefined) {
1416
1488
  throw new ReferenceError(`Cannot import name ${name}`);
1417
1489
  }
@@ -1425,7 +1497,7 @@ makeLockdown: cell("makeLockdown"),
1425
1497
 
1426
1498
  },
1427
1499
  onceVar: {
1428
- default: cells[29].default.set,
1500
+ getAnonymousIntrinsics: cells[29].getAnonymousIntrinsics.set,
1429
1501
 
1430
1502
  },
1431
1503
  });
@@ -1447,7 +1519,7 @@ makeLockdown: cell("makeLockdown"),
1447
1519
 
1448
1520
  },
1449
1521
  onceVar: {
1450
- default: cells[30].default.set,
1522
+ makeHardener: cells[30].makeHardener.set,
1451
1523
 
1452
1524
  },
1453
1525
  });
@@ -1469,7 +1541,7 @@ makeLockdown: cell("makeLockdown"),
1469
1541
 
1470
1542
  },
1471
1543
  onceVar: {
1472
- tameFunctionToString: cells[31].tameFunctionToString.set,
1544
+ default: cells[31].default.set,
1473
1545
 
1474
1546
  },
1475
1547
  });
@@ -1484,15 +1556,6 @@ makeLockdown: cell("makeLockdown"),
1484
1556
  for (const observer of observers) {
1485
1557
  cell.observe(observer);
1486
1558
  }
1487
- }
1488
- for (const [name, observers] of map.get("./error/assert.js")) {
1489
- const cell = cells[4][name];
1490
- if (cell === undefined) {
1491
- throw new ReferenceError(`Cannot import name ${name}`);
1492
- }
1493
- for (const observer of observers) {
1494
- cell.observe(observer);
1495
- }
1496
1559
  }
1497
1560
 
1498
1561
  },
@@ -1500,7 +1563,7 @@ makeLockdown: cell("makeLockdown"),
1500
1563
 
1501
1564
  },
1502
1565
  onceVar: {
1503
- default: cells[32].default.set,
1566
+ tameDomains: cells[32].tameDomains.set,
1504
1567
 
1505
1568
  },
1506
1569
  });
@@ -1544,7 +1607,7 @@ makeLockdown: cell("makeLockdown"),
1544
1607
 
1545
1608
  },
1546
1609
  onceVar: {
1547
- default: cells[34].default.set,
1610
+ tameFunctionToString: cells[34].tameFunctionToString.set,
1548
1611
 
1549
1612
  },
1550
1613
  });
@@ -1560,8 +1623,8 @@ makeLockdown: cell("makeLockdown"),
1560
1623
  cell.observe(observer);
1561
1624
  }
1562
1625
  }
1563
- for (const [name, observers] of map.get("./whitelist.js")) {
1564
- const cell = cells[13][name];
1626
+ for (const [name, observers] of map.get("./error/assert.js")) {
1627
+ const cell = cells[4][name];
1565
1628
  if (cell === undefined) {
1566
1629
  throw new ReferenceError(`Cannot import name ${name}`);
1567
1630
  }
@@ -1591,17 +1654,119 @@ makeLockdown: cell("makeLockdown"),
1591
1654
  cell.observe(observer);
1592
1655
  }
1593
1656
  }
1594
- for (const [name, observers] of map.get("./enable-property-overrides.js")) {
1595
- const cell = cells[23][name];
1596
- if (cell === undefined) {
1597
- throw new ReferenceError(`Cannot import name ${name}`);
1598
- }
1599
- for (const observer of observers) {
1600
- cell.observe(observer);
1601
- }
1602
- }
1603
- for (const [name, observers] of map.get("./error/assert.js")) {
1604
- const cell = cells[4][name];
1657
+
1658
+ },
1659
+ liveVar: {
1660
+
1661
+ },
1662
+ onceVar: {
1663
+ default: cells[36].default.set,
1664
+
1665
+ },
1666
+ });
1667
+ functors[37]({
1668
+ imports(entries) {
1669
+ const map = new Map(entries);
1670
+ for (const [name, observers] of map.get("./commons.js")) {
1671
+ const cell = cells[0][name];
1672
+ if (cell === undefined) {
1673
+ throw new ReferenceError(`Cannot import name ${name}`);
1674
+ }
1675
+ for (const observer of observers) {
1676
+ cell.observe(observer);
1677
+ }
1678
+ }
1679
+
1680
+ },
1681
+ liveVar: {
1682
+
1683
+ },
1684
+ onceVar: {
1685
+ default: cells[37].default.set,
1686
+
1687
+ },
1688
+ });
1689
+ functors[38]({
1690
+ imports(entries) {
1691
+ const map = new Map(entries);
1692
+ for (const [name, observers] of map.get("./commons.js")) {
1693
+ const cell = cells[0][name];
1694
+ if (cell === undefined) {
1695
+ throw new ReferenceError(`Cannot import name ${name}`);
1696
+ }
1697
+ for (const observer of observers) {
1698
+ cell.observe(observer);
1699
+ }
1700
+ }
1701
+ for (const [name, observers] of map.get("./whitelist.js")) {
1702
+ const cell = cells[14][name];
1703
+ if (cell === undefined) {
1704
+ throw new ReferenceError(`Cannot import name ${name}`);
1705
+ }
1706
+ for (const observer of observers) {
1707
+ cell.observe(observer);
1708
+ }
1709
+ }
1710
+
1711
+ },
1712
+ liveVar: {
1713
+
1714
+ },
1715
+ onceVar: {
1716
+ default: cells[38].default.set,
1717
+
1718
+ },
1719
+ });
1720
+ functors[39]({
1721
+ imports(entries) {
1722
+ const map = new Map(entries);
1723
+ for (const [name, observers] of map.get("./commons.js")) {
1724
+ const cell = cells[0][name];
1725
+ if (cell === undefined) {
1726
+ throw new ReferenceError(`Cannot import name ${name}`);
1727
+ }
1728
+ for (const observer of observers) {
1729
+ cell.observe(observer);
1730
+ }
1731
+ }
1732
+ for (const [name, observers] of map.get("./compartment-shim.js")) {
1733
+ const cell = cells[20][name];
1734
+ if (cell === undefined) {
1735
+ throw new ReferenceError(`Cannot import name ${name}`);
1736
+ }
1737
+ for (const observer of observers) {
1738
+ cell.observe(observer);
1739
+ }
1740
+ }
1741
+ for (const [name, observers] of map.get("./enable-property-overrides.js")) {
1742
+ const cell = cells[23][name];
1743
+ if (cell === undefined) {
1744
+ throw new ReferenceError(`Cannot import name ${name}`);
1745
+ }
1746
+ for (const observer of observers) {
1747
+ cell.observe(observer);
1748
+ }
1749
+ }
1750
+ for (const [name, observers] of map.get("./environment-options.js")) {
1751
+ const cell = cells[24][name];
1752
+ if (cell === undefined) {
1753
+ throw new ReferenceError(`Cannot import name ${name}`);
1754
+ }
1755
+ for (const observer of observers) {
1756
+ cell.observe(observer);
1757
+ }
1758
+ }
1759
+ for (const [name, observers] of map.get("./error/assert.js")) {
1760
+ const cell = cells[4][name];
1761
+ if (cell === undefined) {
1762
+ throw new ReferenceError(`Cannot import name ${name}`);
1763
+ }
1764
+ for (const observer of observers) {
1765
+ cell.observe(observer);
1766
+ }
1767
+ }
1768
+ for (const [name, observers] of map.get("./error/stringify-utils.js")) {
1769
+ const cell = cells[2][name];
1605
1770
  if (cell === undefined) {
1606
1771
  throw new ReferenceError(`Cannot import name ${name}`);
1607
1772
  }
@@ -1610,7 +1775,7 @@ makeLockdown: cell("makeLockdown"),
1610
1775
  }
1611
1776
  }
1612
1777
  for (const [name, observers] of map.get("./error/tame-console.js")) {
1613
- const cell = cells[25][name];
1778
+ const cell = cells[26][name];
1614
1779
  if (cell === undefined) {
1615
1780
  throw new ReferenceError(`Cannot import name ${name}`);
1616
1781
  }
@@ -1619,7 +1784,16 @@ makeLockdown: cell("makeLockdown"),
1619
1784
  }
1620
1785
  }
1621
1786
  for (const [name, observers] of map.get("./error/tame-error-constructor.js")) {
1622
- const cell = cells[27][name];
1787
+ const cell = cells[28][name];
1788
+ if (cell === undefined) {
1789
+ throw new ReferenceError(`Cannot import name ${name}`);
1790
+ }
1791
+ for (const observer of observers) {
1792
+ cell.observe(observer);
1793
+ }
1794
+ }
1795
+ for (const [name, observers] of map.get("./get-anonymous-intrinsics.js")) {
1796
+ const cell = cells[29][name];
1623
1797
  if (cell === undefined) {
1624
1798
  throw new ReferenceError(`Cannot import name ${name}`);
1625
1799
  }
@@ -1628,7 +1802,7 @@ makeLockdown: cell("makeLockdown"),
1628
1802
  }
1629
1803
  }
1630
1804
  for (const [name, observers] of map.get("./global-object.js")) {
1631
- const cell = cells[14][name];
1805
+ const cell = cells[15][name];
1632
1806
  if (cell === undefined) {
1633
1807
  throw new ReferenceError(`Cannot import name ${name}`);
1634
1808
  }
@@ -1646,7 +1820,16 @@ makeLockdown: cell("makeLockdown"),
1646
1820
  }
1647
1821
  }
1648
1822
  for (const [name, observers] of map.get("./make-hardener.js")) {
1649
- const cell = cells[28][name];
1823
+ const cell = cells[30][name];
1824
+ if (cell === undefined) {
1825
+ throw new ReferenceError(`Cannot import name ${name}`);
1826
+ }
1827
+ for (const observer of observers) {
1828
+ cell.observe(observer);
1829
+ }
1830
+ }
1831
+ for (const [name, observers] of map.get("./make-safe-evaluator.js")) {
1832
+ const cell = cells[10][name];
1650
1833
  if (cell === undefined) {
1651
1834
  throw new ReferenceError(`Cannot import name ${name}`);
1652
1835
  }
@@ -1655,7 +1838,16 @@ makeLockdown: cell("makeLockdown"),
1655
1838
  }
1656
1839
  }
1657
1840
  for (const [name, observers] of map.get("./tame-date-constructor.js")) {
1658
- const cell = cells[29][name];
1841
+ const cell = cells[31][name];
1842
+ if (cell === undefined) {
1843
+ throw new ReferenceError(`Cannot import name ${name}`);
1844
+ }
1845
+ for (const observer of observers) {
1846
+ cell.observe(observer);
1847
+ }
1848
+ }
1849
+ for (const [name, observers] of map.get("./tame-domains.js")) {
1850
+ const cell = cells[32][name];
1659
1851
  if (cell === undefined) {
1660
1852
  throw new ReferenceError(`Cannot import name ${name}`);
1661
1853
  }
@@ -1664,7 +1856,7 @@ makeLockdown: cell("makeLockdown"),
1664
1856
  }
1665
1857
  }
1666
1858
  for (const [name, observers] of map.get("./tame-function-constructors.js")) {
1667
- const cell = cells[30][name];
1859
+ const cell = cells[33][name];
1668
1860
  if (cell === undefined) {
1669
1861
  throw new ReferenceError(`Cannot import name ${name}`);
1670
1862
  }
@@ -1673,7 +1865,7 @@ makeLockdown: cell("makeLockdown"),
1673
1865
  }
1674
1866
  }
1675
1867
  for (const [name, observers] of map.get("./tame-function-tostring.js")) {
1676
- const cell = cells[31][name];
1868
+ const cell = cells[34][name];
1677
1869
  if (cell === undefined) {
1678
1870
  throw new ReferenceError(`Cannot import name ${name}`);
1679
1871
  }
@@ -1682,7 +1874,7 @@ makeLockdown: cell("makeLockdown"),
1682
1874
  }
1683
1875
  }
1684
1876
  for (const [name, observers] of map.get("./tame-locale-methods.js")) {
1685
- const cell = cells[32][name];
1877
+ const cell = cells[35][name];
1686
1878
  if (cell === undefined) {
1687
1879
  throw new ReferenceError(`Cannot import name ${name}`);
1688
1880
  }
@@ -1691,7 +1883,7 @@ makeLockdown: cell("makeLockdown"),
1691
1883
  }
1692
1884
  }
1693
1885
  for (const [name, observers] of map.get("./tame-math-object.js")) {
1694
- const cell = cells[33][name];
1886
+ const cell = cells[36][name];
1695
1887
  if (cell === undefined) {
1696
1888
  throw new ReferenceError(`Cannot import name ${name}`);
1697
1889
  }
@@ -1700,7 +1892,7 @@ makeLockdown: cell("makeLockdown"),
1700
1892
  }
1701
1893
  }
1702
1894
  for (const [name, observers] of map.get("./tame-regexp-constructor.js")) {
1703
- const cell = cells[34][name];
1895
+ const cell = cells[37][name];
1704
1896
  if (cell === undefined) {
1705
1897
  throw new ReferenceError(`Cannot import name ${name}`);
1706
1898
  }
@@ -1709,7 +1901,7 @@ makeLockdown: cell("makeLockdown"),
1709
1901
  }
1710
1902
  }
1711
1903
  for (const [name, observers] of map.get("./whitelist-intrinsics.js")) {
1712
- const cell = cells[35][name];
1904
+ const cell = cells[38][name];
1713
1905
  if (cell === undefined) {
1714
1906
  throw new ReferenceError(`Cannot import name ${name}`);
1715
1907
  }
@@ -1718,7 +1910,7 @@ makeLockdown: cell("makeLockdown"),
1718
1910
  }
1719
1911
  }
1720
1912
  for (const [name, observers] of map.get("./whitelist.js")) {
1721
- const cell = cells[13][name];
1913
+ const cell = cells[14][name];
1722
1914
  if (cell === undefined) {
1723
1915
  throw new ReferenceError(`Cannot import name ${name}`);
1724
1916
  }
@@ -1732,12 +1924,12 @@ makeLockdown: cell("makeLockdown"),
1732
1924
 
1733
1925
  },
1734
1926
  onceVar: {
1735
- repairIntrinsics: cells[36].repairIntrinsics.set,
1736
- makeLockdown: cells[36].makeLockdown.set,
1927
+ repairIntrinsics: cells[39].repairIntrinsics.set,
1928
+ lockdown: cells[39].lockdown.set,
1737
1929
 
1738
1930
  },
1739
1931
  });
1740
- functors[37]({
1932
+ functors[40]({
1741
1933
  imports(entries) {
1742
1934
  const map = new Map(entries);
1743
1935
  for (const [name, observers] of map.get("./src/commons.js")) {
@@ -1750,7 +1942,7 @@ makeLockdown: cell("makeLockdown"),
1750
1942
  }
1751
1943
  }
1752
1944
  for (const [name, observers] of map.get("./src/compartment-shim.js")) {
1753
- const cell = cells[19][name];
1945
+ const cell = cells[20][name];
1754
1946
  if (cell === undefined) {
1755
1947
  throw new ReferenceError(`Cannot import name ${name}`);
1756
1948
  }
@@ -1766,15 +1958,6 @@ makeLockdown: cell("makeLockdown"),
1766
1958
  for (const observer of observers) {
1767
1959
  cell.observe(observer);
1768
1960
  }
1769
- }
1770
- for (const [name, observers] of map.get("./src/get-anonymous-intrinsics.js")) {
1771
- const cell = cells[20][name];
1772
- if (cell === undefined) {
1773
- throw new ReferenceError(`Cannot import name ${name}`);
1774
- }
1775
- for (const observer of observers) {
1776
- cell.observe(observer);
1777
- }
1778
1961
  }
1779
1962
  for (const [name, observers] of map.get("./src/intrinsics.js")) {
1780
1963
  const cell = cells[21][name];
@@ -1786,7 +1969,7 @@ makeLockdown: cell("makeLockdown"),
1786
1969
  }
1787
1970
  }
1788
1971
  for (const [name, observers] of map.get("./src/lockdown-shim.js")) {
1789
- const cell = cells[36][name];
1972
+ const cell = cells[39][name];
1790
1973
  if (cell === undefined) {
1791
1974
  throw new ReferenceError(`Cannot import name ${name}`);
1792
1975
  }
@@ -1795,7 +1978,7 @@ makeLockdown: cell("makeLockdown"),
1795
1978
  }
1796
1979
  }
1797
1980
  for (const [name, observers] of map.get("./src/tame-function-tostring.js")) {
1798
- const cell = cells[31][name];
1981
+ const cell = cells[34][name];
1799
1982
  if (cell === undefined) {
1800
1983
  throw new ReferenceError(`Cannot import name ${name}`);
1801
1984
  }
@@ -1845,20 +2028,23 @@ const {
1845
2028
  Promise,
1846
2029
  Proxy,
1847
2030
  Reflect,
1848
- RegExp,
2031
+ RegExp: FERAL_REG_EXP,
1849
2032
  Set,
1850
2033
  String,
1851
2034
  WeakMap,
1852
2035
  WeakSet } =
1853
- globalThis;$h‍_once.Array(Array);$h‍_once.Date(Date);$h‍_once.Float32Array(Float32Array);$h‍_once.JSON(JSON);$h‍_once.Map(Map);$h‍_once.Math(Math);$h‍_once.Object(Object);$h‍_once.Promise(Promise);$h‍_once.Proxy(Proxy);$h‍_once.Reflect(Reflect);$h‍_once.RegExp(RegExp);$h‍_once.Set(Set);$h‍_once.String(String);$h‍_once.WeakMap(WeakMap);$h‍_once.WeakSet(WeakSet);
2036
+ globalThis;$h‍_once.Array(Array);$h‍_once.Date(Date);$h‍_once.Float32Array(Float32Array);$h‍_once.JSON(JSON);$h‍_once.Map(Map);$h‍_once.Math(Math);$h‍_once.Object(Object);$h‍_once.Promise(Promise);$h‍_once.Proxy(Proxy);$h‍_once.Reflect(Reflect);$h‍_once.FERAL_REG_EXP(FERAL_REG_EXP);$h‍_once.Set(Set);$h‍_once.String(String);$h‍_once.WeakMap(WeakMap);$h‍_once.WeakSet(WeakSet);
1854
2037
 
1855
2038
  const {
1856
- Error,
2039
+ // The feral Error constructor is safe for internal use, but must not be
2040
+ // revealed to post-lockdown code in any compartment including the start
2041
+ // compartment since in V8 at least it bears stack inspection capabilities.
2042
+ Error: FERAL_ERROR,
1857
2043
  RangeError,
1858
2044
  ReferenceError,
1859
2045
  SyntaxError,
1860
2046
  TypeError } =
1861
- globalThis;$h‍_once.Error(Error);$h‍_once.RangeError(RangeError);$h‍_once.ReferenceError(ReferenceError);$h‍_once.SyntaxError(SyntaxError);$h‍_once.TypeError(TypeError);
2047
+ globalThis;$h‍_once.FERAL_ERROR(FERAL_ERROR);$h‍_once.RangeError(RangeError);$h‍_once.ReferenceError(ReferenceError);$h‍_once.SyntaxError(SyntaxError);$h‍_once.TypeError(TypeError);
1862
2048
 
1863
2049
  const {
1864
2050
  assign,
@@ -1919,7 +2105,7 @@ const defineProperty = (object, prop, descriptor) => {
1919
2105
  const result = originalDefineProperty(object, prop, descriptor);
1920
2106
  if (result !== object) {
1921
2107
  throw TypeError(
1922
- `Please report that the original defineProperty silently failed to set ${JSON.stringify(
2108
+ `Please report that the original defineProperty silently failed to set ${stringifyJson(
1923
2109
  String(prop))
1924
2110
  }. (SES_DEFINE_PROPERTY_FAILED_SILENTLY)`);
1925
2111
 
@@ -1947,7 +2133,8 @@ const { prototype: setPrototype } = Set;$h‍_once.setPrototype(setPrototype);
1947
2133
  const { prototype: stringPrototype } = String;$h‍_once.stringPrototype(stringPrototype);
1948
2134
  const { prototype: weakmapPrototype } = WeakMap;$h‍_once.weakmapPrototype(weakmapPrototype);
1949
2135
  const { prototype: weaksetPrototype } = WeakSet;$h‍_once.weaksetPrototype(weaksetPrototype);
1950
- const { prototype: functionPrototype } = Function;
2136
+ const { prototype: functionPrototype } = Function;$h‍_once.functionPrototype(functionPrototype);
2137
+ const { prototype: promisePrototype } = Promise;
1951
2138
 
1952
2139
  /**
1953
2140
  * uncurryThis()
@@ -1963,58 +2150,76 @@ const { prototype: functionPrototype } = Function;
1963
2150
  * http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
1964
2151
  *
1965
2152
  * @param {(thisArg: Object, ...args: any[]) => any} fn
1966
- */$h‍_once.functionPrototype(functionPrototype);
2153
+ */$h‍_once.promisePrototype(promisePrototype);
1967
2154
  const uncurryThis = (fn) => (thisArg, ...args) => apply(fn, thisArg, args);$h‍_once.uncurryThis(uncurryThis);
1968
2155
 
1969
2156
  const objectHasOwnProperty = uncurryThis(objectPrototype.hasOwnProperty);
1970
2157
  //
1971
- $h‍_once.objectHasOwnProperty(objectHasOwnProperty);const arrayForEach = uncurryThis(arrayPrototype.forEach);$h‍_once.arrayForEach(arrayForEach);
1972
- const arrayFilter = uncurryThis(arrayPrototype.filter);$h‍_once.arrayFilter(arrayFilter);
2158
+ $h‍_once.objectHasOwnProperty(objectHasOwnProperty);const arrayFilter = uncurryThis(arrayPrototype.filter);$h‍_once.arrayFilter(arrayFilter);
2159
+ const arrayForEach = uncurryThis(arrayPrototype.forEach);$h‍_once.arrayForEach(arrayForEach);
2160
+ const arrayIncludes = uncurryThis(arrayPrototype.includes);$h‍_once.arrayIncludes(arrayIncludes);
1973
2161
  const arrayJoin = uncurryThis(arrayPrototype.join);$h‍_once.arrayJoin(arrayJoin);
1974
- const arrayPush = uncurryThis(arrayPrototype.push);$h‍_once.arrayPush(arrayPush);
2162
+ const arrayMap = uncurryThis(arrayPrototype.map);$h‍_once.arrayMap(arrayMap);
1975
2163
  const arrayPop = uncurryThis(arrayPrototype.pop);$h‍_once.arrayPop(arrayPop);
1976
- const arrayIncludes = uncurryThis(arrayPrototype.includes);
2164
+ const arrayPush = uncurryThis(arrayPrototype.push);$h‍_once.arrayPush(arrayPush);
2165
+ const arraySlice = uncurryThis(arrayPrototype.slice);$h‍_once.arraySlice(arraySlice);
2166
+ const arraySome = uncurryThis(arrayPrototype.some);$h‍_once.arraySome(arraySome);
2167
+ const arraySort = uncurryThis(arrayPrototype.sort);$h‍_once.arraySort(arraySort);
2168
+ const iterateArray = uncurryThis(arrayPrototype[iteratorSymbol]);
1977
2169
  //
1978
- $h‍_once.arrayIncludes(arrayIncludes);const mapSet = uncurryThis(mapPrototype.set);$h‍_once.mapSet(mapSet);
2170
+ $h‍_once.iterateArray(iterateArray);const mapSet = uncurryThis(mapPrototype.set);$h‍_once.mapSet(mapSet);
1979
2171
  const mapGet = uncurryThis(mapPrototype.get);$h‍_once.mapGet(mapGet);
1980
- const mapHas = uncurryThis(mapPrototype.has);
2172
+ const mapHas = uncurryThis(mapPrototype.has);$h‍_once.mapHas(mapHas);
2173
+ const iterateMap = uncurryThis(mapPrototype[iteratorSymbol]);
1981
2174
  //
1982
- $h‍_once.mapHas(mapHas);const setAdd = uncurryThis(setPrototype.add);$h‍_once.setAdd(setAdd);
2175
+ $h‍_once.iterateMap(iterateMap);const setAdd = uncurryThis(setPrototype.add);$h‍_once.setAdd(setAdd);
1983
2176
  const setForEach = uncurryThis(setPrototype.forEach);$h‍_once.setForEach(setForEach);
1984
- const setHas = uncurryThis(setPrototype.has);
2177
+ const setHas = uncurryThis(setPrototype.has);$h‍_once.setHas(setHas);
2178
+ const iterateSet = uncurryThis(setPrototype[iteratorSymbol]);
1985
2179
  //
1986
- $h‍_once.setHas(setHas);const regexpTest = uncurryThis(regexpPrototype.test);
2180
+ $h‍_once.iterateSet(iterateSet);const regexpTest = uncurryThis(regexpPrototype.test);$h‍_once.regexpTest(regexpTest);
2181
+ const regexpExec = uncurryThis(regexpPrototype.exec);$h‍_once.regexpExec(regexpExec);
2182
+ const matchAllRegExp = uncurryThis(regexpPrototype[matchAllSymbol]);
1987
2183
  //
1988
- $h‍_once.regexpTest(regexpTest);const stringEndsWith = uncurryThis(stringPrototype.endsWith);$h‍_once.stringEndsWith(stringEndsWith);
2184
+ $h‍_once.matchAllRegExp(matchAllRegExp);const stringEndsWith = uncurryThis(stringPrototype.endsWith);$h‍_once.stringEndsWith(stringEndsWith);
1989
2185
  const stringIncludes = uncurryThis(stringPrototype.includes);$h‍_once.stringIncludes(stringIncludes);
2186
+ const stringIndexOf = uncurryThis(stringPrototype.indexOf);$h‍_once.stringIndexOf(stringIndexOf);
1990
2187
  const stringMatch = uncurryThis(stringPrototype.match);$h‍_once.stringMatch(stringMatch);
2188
+ const stringReplace = uncurryThis(stringPrototype.replace);$h‍_once.stringReplace(stringReplace);
1991
2189
  const stringSearch = uncurryThis(stringPrototype.search);$h‍_once.stringSearch(stringSearch);
1992
2190
  const stringSlice = uncurryThis(stringPrototype.slice);$h‍_once.stringSlice(stringSlice);
1993
2191
  const stringSplit = uncurryThis(stringPrototype.split);$h‍_once.stringSplit(stringSplit);
1994
- const stringStartsWith = uncurryThis(stringPrototype.startsWith);
2192
+ const stringStartsWith = uncurryThis(stringPrototype.startsWith);$h‍_once.stringStartsWith(stringStartsWith);
2193
+ const iterateString = uncurryThis(stringPrototype[iteratorSymbol]);
1995
2194
  //
1996
- $h‍_once.stringStartsWith(stringStartsWith);const weakmapGet = uncurryThis(weakmapPrototype.get);$h‍_once.weakmapGet(weakmapGet);
1997
- const weakmapSet = uncurryThis(weakmapPrototype.set);$h‍_once.weakmapSet(weakmapSet);
1998
- const weakmapHas = uncurryThis(weakmapPrototype.has);
2195
+ $h‍_once.iterateString(iterateString);const weakmapDelete = uncurryThis(weakmapPrototype.delete);$h‍_once.weakmapDelete(weakmapDelete);
2196
+ const weakmapGet = uncurryThis(weakmapPrototype.get);$h‍_once.weakmapGet(weakmapGet);
2197
+ const weakmapHas = uncurryThis(weakmapPrototype.has);$h‍_once.weakmapHas(weakmapHas);
2198
+ const weakmapSet = uncurryThis(weakmapPrototype.set);
1999
2199
  //
2000
- $h‍_once.weakmapHas(weakmapHas);const weaksetAdd = uncurryThis(weaksetPrototype.add);$h‍_once.weaksetAdd(weaksetAdd);
2001
- const weaksetSet = uncurryThis(weaksetPrototype.set);$h‍_once.weaksetSet(weaksetSet);
2200
+ $h‍_once.weakmapSet(weakmapSet);const weaksetAdd = uncurryThis(weaksetPrototype.add);$h‍_once.weaksetAdd(weaksetAdd);
2201
+ const weaksetGet = uncurryThis(weaksetPrototype.get);$h‍_once.weaksetGet(weaksetGet);
2002
2202
  const weaksetHas = uncurryThis(weaksetPrototype.has);
2003
2203
  //
2004
2204
  $h‍_once.weaksetHas(weaksetHas);const functionToString = uncurryThis(functionPrototype.toString);
2205
+ //
2206
+ $h‍_once.functionToString(functionToString);const { all } = Promise;
2207
+ const promiseAll = (promises) => apply(all, Promise, [promises]);$h‍_once.promiseAll(promiseAll);
2208
+ const promiseCatch = uncurryThis(promisePrototype.catch);$h‍_once.promiseCatch(promiseCatch);
2209
+ const promiseThen = uncurryThis(promisePrototype.then);
2005
2210
 
2006
2211
  /**
2007
2212
  * getConstructorOf()
2008
2213
  * Return the constructor from an instance.
2009
2214
  *
2010
2215
  * @param {Function} fn
2011
- */$h‍_once.functionToString(functionToString);
2216
+ */$h‍_once.promiseThen(promiseThen);
2012
2217
  const getConstructorOf = (fn) =>
2013
2218
  reflectGet(getPrototypeOf(fn), 'constructor');
2014
2219
 
2015
2220
  /**
2016
2221
  * immutableObject
2017
- * An immutable (frozen) exotic object and is safe to share.
2222
+ * An immutable (frozen) empty object that is safe to share.
2018
2223
  */$h‍_once.getConstructorOf(getConstructorOf);
2019
2224
  const immutableObject = freeze(create(null));
2020
2225
 
@@ -2037,11 +2242,24 @@ const immutableObject = freeze(create(null));
2037
2242
  */$h‍_once.immutableObject(immutableObject);
2038
2243
  const isObject = (value) => Object(value) === value;
2039
2244
 
2245
+ /**
2246
+ * isError tests whether an object inherits from the intrinsic
2247
+ * `Error.prototype`.
2248
+ * We capture the original error constructor as FERAL_ERROR to provide a clear
2249
+ * signal for reviewers that we are handling an object with excess authority,
2250
+ * like stack trace inspection, that we are carefully hiding from client code.
2251
+ * Checking instanceof happens to be safe, but to avoid uttering FERAL_ERROR
2252
+ * for such a trivial case outside commons.js, we provide a utility function.
2253
+ *
2254
+ * @param {any} value
2255
+ */$h‍_once.isObject(isObject);
2256
+ const isError = (value) => value instanceof FERAL_ERROR;
2257
+
2040
2258
  // The original unsafe untamed eval function, which must not escape.
2041
2259
  // Sample at module initialization time, which is before lockdown can
2042
2260
  // repair it. Use it only to build powerless abstractions.
2043
2261
  // eslint-disable-next-line no-eval
2044
- $h‍_once.isObject(isObject);const FERAL_EVAL = eval;
2262
+ $h‍_once.isError(isError);const FERAL_EVAL = eval;
2045
2263
 
2046
2264
  // The original unsafe untamed Function constructor, which must not escape.
2047
2265
  // Sample at module initialization time, which is before lockdown can
@@ -2142,7 +2360,8 @@ $h‍_once.FERAL_EVAL(FERAL_EVAL);const FERAL_FUNCTION = Function;$h‍_once.FER
2142
2360
  })
2143
2361
 
2144
2362
  ,
2145
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Set,String,freeze,is,setAdd,setHas,stringStartsWith,stringIncludes,stringifyJson,toStringTagSymbol;$h‍_imports([["../commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]],["stringStartsWith", [$h‍_a => (stringStartsWith = $h‍_a)]],["stringIncludes", [$h‍_a => (stringIncludes = $h‍_a)]],["stringifyJson", [$h‍_a => (stringifyJson = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
2363
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Set,String,arrayJoin,arraySlice,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)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $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)]]]]]);
2364
+
2146
2365
 
2147
2366
 
2148
2367
 
@@ -2158,13 +2377,35 @@ $h‍_once.FERAL_EVAL(FERAL_EVAL);const FERAL_FUNCTION = Function;$h‍_once.FER
2158
2377
 
2159
2378
 
2160
2379
 
2380
+
2381
+ /**
2382
+ * Joins English terms with commas and an optional conjunction.
2383
+ *
2384
+ * @param {string[]} terms
2385
+ * @param {"and" | "or"} conjunction
2386
+ */
2387
+ const enJoin = (terms, conjunction) => {
2388
+ if (terms.length === 0) {
2389
+ return '(none)';
2390
+ } else if (terms.length === 1) {
2391
+ return terms[0];
2392
+ } else if (terms.length === 2) {
2393
+ const [first, second] = terms;
2394
+ return `${first} ${conjunction} ${second}`;
2395
+ } else {
2396
+ return `${arrayJoin(arraySlice(terms, 0, -1), ', ')}, ${conjunction} ${
2397
+ terms[terms.length - 1]
2398
+ }`;
2399
+ }
2400
+ };
2401
+
2161
2402
  /**
2162
2403
  * Prepend the correct indefinite article onto a noun, typically a typeof
2163
2404
  * result, e.g., "an object" vs. "a number"
2164
2405
  *
2165
2406
  * @param {string} str The noun to prepend
2166
2407
  * @returns {string} The noun prepended with a/an
2167
- */
2408
+ */$h‍_once.enJoin(enJoin);
2168
2409
  const an = (str) => {
2169
2410
  str = `${str}`;
2170
2411
  if (str.length >= 1 && stringIncludes('aeiouAEIOU', str[0])) {
@@ -2214,7 +2455,7 @@ const bestEffortStringify = (payload, spaces = undefined) => {
2214
2455
  return '[Seen]';
2215
2456
  }
2216
2457
  setAdd(seenSet, val);
2217
- if (val instanceof Error) {
2458
+ if (isError(val)) {
2218
2459
  return `[${val.name}: ${val.message}]`;
2219
2460
  }
2220
2461
  if (toStringTagSymbol in val) {
@@ -2643,7 +2884,17 @@ freeze(bestEffortStringify);
2643
2884
  })
2644
2885
 
2645
2886
  ,
2646
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,RangeError,TypeError,WeakMap,assign,freeze,globalThis,is,weakmapGet,weakmapSet,an,bestEffortStringify;$h‍_imports([["../commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["RangeError", [$h‍_a => (RangeError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $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)]],["weakmapGet", [$h‍_a => (weakmapGet = $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", []]]);
2887
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,globalThis,is,isError,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,an,bestEffortStringify;$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)]],["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", []]]);
2888
+
2889
+
2890
+
2891
+
2892
+
2893
+
2894
+
2895
+
2896
+
2897
+
2647
2898
 
2648
2899
 
2649
2900
 
@@ -2685,7 +2936,7 @@ const quote = (payload, spaces = undefined) => {
2685
2936
  const result = freeze({
2686
2937
  toString: freeze(() => bestEffortStringify(payload, spaces)) });
2687
2938
 
2688
- declassifiers.set(result, payload);
2939
+ weakmapSet(declassifiers, result, payload);
2689
2940
  return result;
2690
2941
  };
2691
2942
  freeze(quote);
@@ -2718,16 +2969,16 @@ const getMessageString = ({ template, args }) => {
2718
2969
  for (let i = 0; i < args.length; i += 1) {
2719
2970
  const arg = args[i];
2720
2971
  let argStr;
2721
- if (declassifiers.has(arg)) {
2972
+ if (weakmapHas(declassifiers, arg)) {
2722
2973
  argStr = `${arg}`;
2723
- } else if (arg instanceof Error) {
2974
+ } else if (isError(arg)) {
2724
2975
  argStr = `(${an(arg.name)})`;
2725
2976
  } else {
2726
2977
  argStr = `(${an(typeof arg)})`;
2727
2978
  }
2728
- parts.push(argStr, template[i + 1]);
2979
+ arrayPush(parts, argStr, template[i + 1]);
2729
2980
  }
2730
- return parts.join('');
2981
+ return arrayJoin(parts, '');
2731
2982
  };
2732
2983
 
2733
2984
  /**
@@ -2744,7 +2995,7 @@ const getMessageString = ({ template, args }) => {
2744
2995
  */
2745
2996
  const DetailsTokenProto = freeze({
2746
2997
  toString() {
2747
- const hiddenDetails = hiddenDetailsMap.get(this);
2998
+ const hiddenDetails = weakmapGet(hiddenDetailsMap, this);
2748
2999
  if (hiddenDetails === undefined) {
2749
3000
  return '[Not a DetailsToken]';
2750
3001
  }
@@ -2770,7 +3021,7 @@ const redactedDetails = (template, ...args) => {
2770
3021
  // possible. Hence we store what we've got with little processing, postponing
2771
3022
  // all the work to happen only if needed, for example, if an assertion fails.
2772
3023
  const detailsToken = freeze({ __proto__: DetailsTokenProto });
2773
- hiddenDetailsMap.set(detailsToken, { template, args });
3024
+ weakmapSet(hiddenDetailsMap, detailsToken, { template, args });
2774
3025
  return detailsToken;
2775
3026
  };
2776
3027
  freeze(redactedDetails);
@@ -2789,7 +3040,9 @@ freeze(redactedDetails);
2789
3040
  * @type {DetailsTag}
2790
3041
  */
2791
3042
  const unredactedDetails = (template, ...args) => {
2792
- args = args.map((arg) => declassifiers.has(arg) ? arg : quote(arg));
3043
+ args = arrayMap(args, (arg) =>
3044
+ weakmapHas(declassifiers, arg) ? arg : quote(arg));
3045
+
2793
3046
  return redactedDetails(template, ...args);
2794
3047
  };$h‍_once.unredactedDetails(unredactedDetails);
2795
3048
  freeze(unredactedDetails);
@@ -2803,20 +3056,20 @@ const getLogArgs = ({ template, args }) => {
2803
3056
  const logArgs = [template[0]];
2804
3057
  for (let i = 0; i < args.length; i += 1) {
2805
3058
  let arg = args[i];
2806
- if (declassifiers.has(arg)) {
2807
- arg = declassifiers.get(arg);
3059
+ if (weakmapHas(declassifiers, arg)) {
3060
+ arg = weakmapGet(declassifiers, arg);
2808
3061
  }
2809
3062
  // Remove the extra spaces (since console.error puts them
2810
3063
  // between each cause).
2811
- const priorWithoutSpace = (logArgs.pop() || '').replace(/ $/, '');
3064
+ const priorWithoutSpace = stringReplace(arrayPop(logArgs) || '', / $/, '');
2812
3065
  if (priorWithoutSpace !== '') {
2813
- logArgs.push(priorWithoutSpace);
3066
+ arrayPush(logArgs, priorWithoutSpace);
2814
3067
  }
2815
- const nextWithoutSpace = template[i + 1].replace(/^ /, '');
2816
- logArgs.push(arg, nextWithoutSpace);
3068
+ const nextWithoutSpace = stringReplace(template[i + 1], /^ /, '');
3069
+ arrayPush(logArgs, arg, nextWithoutSpace);
2817
3070
  }
2818
3071
  if (logArgs[logArgs.length - 1] === '') {
2819
- logArgs.pop();
3072
+ arrayPop(logArgs);
2820
3073
  }
2821
3074
  return logArgs;
2822
3075
  };
@@ -2859,7 +3112,7 @@ const tagError = (err, optErrorName = err.name) => {
2859
3112
  */
2860
3113
  const makeError = (
2861
3114
  optDetails = redactedDetails`Assert failed`,
2862
- ErrorConstructor = Error,
3115
+ ErrorConstructor = globalThis.Error,
2863
3116
  { errorName = undefined } = {}) =>
2864
3117
  {
2865
3118
  if (typeof optDetails === 'string') {
@@ -2867,13 +3120,13 @@ ErrorConstructor = Error,
2867
3120
  // it doesn't get quoted.
2868
3121
  optDetails = redactedDetails([optDetails]);
2869
3122
  }
2870
- const hiddenDetails = hiddenDetailsMap.get(optDetails);
3123
+ const hiddenDetails = weakmapGet(hiddenDetailsMap, optDetails);
2871
3124
  if (hiddenDetails === undefined) {
2872
- throw new Error(`unrecognized details ${quote(optDetails)}`);
3125
+ throw new TypeError(`unrecognized details ${quote(optDetails)}`);
2873
3126
  }
2874
3127
  const messageString = getMessageString(hiddenDetails);
2875
3128
  const error = new ErrorConstructor(messageString);
2876
- hiddenMessageLogArgs.set(error, getLogArgs(hiddenDetails));
3129
+ weakmapSet(hiddenMessageLogArgs, error, getLogArgs(hiddenDetails));
2877
3130
  if (errorName !== undefined) {
2878
3131
  tagError(error, errorName);
2879
3132
  }
@@ -2917,22 +3170,22 @@ const note = (error, detailsNote) => {
2917
3170
  // it doesn't get quoted.
2918
3171
  detailsNote = redactedDetails([detailsNote]);
2919
3172
  }
2920
- const hiddenDetails = hiddenDetailsMap.get(detailsNote);
3173
+ const hiddenDetails = weakmapGet(hiddenDetailsMap, detailsNote);
2921
3174
  if (hiddenDetails === undefined) {
2922
- throw new Error(`unrecognized details ${quote(detailsNote)}`);
3175
+ throw new TypeError(`unrecognized details ${quote(detailsNote)}`);
2923
3176
  }
2924
3177
  const logArgs = getLogArgs(hiddenDetails);
2925
- const callbacks = hiddenNoteCallbackArrays.get(error);
3178
+ const callbacks = weakmapGet(hiddenNoteCallbackArrays, error);
2926
3179
  if (callbacks !== undefined) {
2927
3180
  for (const callback of callbacks) {
2928
3181
  callback(error, logArgs);
2929
3182
  }
2930
3183
  } else {
2931
- const logArgsArray = hiddenNoteLogArgsArrays.get(error);
3184
+ const logArgsArray = weakmapGet(hiddenNoteLogArgsArrays, error);
2932
3185
  if (logArgsArray !== undefined) {
2933
- logArgsArray.push(logArgs);
3186
+ arrayPush(logArgsArray, logArgs);
2934
3187
  } else {
2935
- hiddenNoteLogArgsArrays.set(error, [logArgs]);
3188
+ weakmapSet(hiddenNoteLogArgsArrays, error, [logArgs]);
2936
3189
  }
2937
3190
  }
2938
3191
  };
@@ -2951,11 +3204,11 @@ const defaultGetStackString = (error) => {
2951
3204
  return '';
2952
3205
  }
2953
3206
  const stackString = `${error.stack}`;
2954
- const pos = stackString.indexOf('\n');
2955
- if (stackString.startsWith(' ') || pos === -1) {
3207
+ const pos = stringIndexOf(stackString, '\n');
3208
+ if (stringStartsWith(stackString, ' ') || pos === -1) {
2956
3209
  return stackString;
2957
3210
  }
2958
- return stackString.slice(pos + 1); // exclude the initial newline
3211
+ return stringSlice(stackString, pos + 1); // exclude the initial newline
2959
3212
  };
2960
3213
 
2961
3214
  /** @type {LoggedErrorHandler} */
@@ -2965,21 +3218,21 @@ const loggedErrorHandler = {
2965
3218
  resetErrorTagNum: () => {
2966
3219
  errorTagNum = 0;
2967
3220
  },
2968
- getMessageLogArgs: (error) => hiddenMessageLogArgs.get(error),
3221
+ getMessageLogArgs: (error) => weakmapGet(hiddenMessageLogArgs, error),
2969
3222
  takeMessageLogArgs: (error) => {
2970
- const result = hiddenMessageLogArgs.get(error);
2971
- hiddenMessageLogArgs.delete(error);
3223
+ const result = weakmapGet(hiddenMessageLogArgs, error);
3224
+ weakmapDelete(hiddenMessageLogArgs, error);
2972
3225
  return result;
2973
3226
  },
2974
3227
  takeNoteLogArgsArray: (error, callback) => {
2975
- const result = hiddenNoteLogArgsArrays.get(error);
2976
- hiddenNoteLogArgsArrays.delete(error);
3228
+ const result = weakmapGet(hiddenNoteLogArgsArrays, error);
3229
+ weakmapDelete(hiddenNoteLogArgsArrays, error);
2977
3230
  if (callback !== undefined) {
2978
- const callbacks = hiddenNoteCallbackArrays.get(error);
3231
+ const callbacks = weakmapGet(hiddenNoteCallbackArrays, error);
2979
3232
  if (callbacks) {
2980
- callbacks.push(callback);
3233
+ arrayPush(callbacks, callback);
2981
3234
  } else {
2982
- hiddenNoteCallbackArrays.set(error, [callback]);
3235
+ weakmapSet(hiddenNoteCallbackArrays, error, [callback]);
2983
3236
  }
2984
3237
  }
2985
3238
  return result || [];
@@ -2998,7 +3251,7 @@ const makeAssert = (optRaise = undefined, unredacted = false) => {
2998
3251
  /** @type {AssertFail} */
2999
3252
  const fail = (
3000
3253
  optDetails = details`Assert failed`,
3001
- ErrorConstructor = Error) =>
3254
+ ErrorConstructor = globalThis.Error) =>
3002
3255
  {
3003
3256
  const reason = makeError(optDetails, ErrorConstructor);
3004
3257
  if (optRaise !== undefined) {
@@ -3015,7 +3268,7 @@ const makeAssert = (optRaise = undefined, unredacted = false) => {
3015
3268
  function baseAssert(
3016
3269
  flag,
3017
3270
  optDetails = details`Check failed`,
3018
- ErrorConstructor = Error)
3271
+ ErrorConstructor = globalThis.Error)
3019
3272
  {
3020
3273
  if (!flag) {
3021
3274
  throw fail(optDetails, ErrorConstructor);
@@ -3153,7 +3406,8 @@ const makeEvaluateFactory = (constants = []) => {
3153
3406
  })
3154
3407
 
3155
3408
  ,
3156
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,objectHasOwnProperty,regexpTest;$h‍_imports([["./commons.js", [["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)]]]]]);
3409
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
3410
+
3157
3411
 
3158
3412
 
3159
3413
 
@@ -3307,18 +3561,20 @@ const getScopeConstants = (globalObject, localObject = {}) => {
3307
3561
  const localNames = getOwnPropertyNames(localObject);
3308
3562
 
3309
3563
  // Collect all valid & immutable identifiers from the endowments.
3310
- const localConstants = localNames.filter(
3564
+ const localConstants = arrayFilter(
3565
+ localNames,
3311
3566
  (name) =>
3312
3567
  isValidIdentifierName(name) && isImmutableDataProperty(localObject, name));
3313
3568
 
3314
3569
 
3315
3570
  // Collect all valid & immutable identifiers from the global that
3316
3571
  // are also not present in the endwoments (immutable or not).
3317
- const globalConstants = globalNames.filter(
3572
+ const globalConstants = arrayFilter(
3573
+ globalNames,
3318
3574
  (name) =>
3319
3575
  // Can't define a constant: it would prevent a
3320
3576
  // lookup on the endowments.
3321
- !localNames.includes(name) &&
3577
+ !arrayIncludes(localNames, name) &&
3322
3578
  isValidIdentifierName(name) &&
3323
3579
  isImmutableDataProperty(globalObject, name));
3324
3580
 
@@ -3328,7 +3584,9 @@ const getScopeConstants = (globalObject, localObject = {}) => {
3328
3584
  })
3329
3585
 
3330
3586
  ,
3331
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,FERAL_EVAL,Proxy,String,freeze,getOwnPropertyDescriptor,globalThis,immutableObject,objectHasOwnProperty,reflectGet,reflectSet,assert;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
3587
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_EVAL,Proxy,String,TypeError,create,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,immutableObject,objectHasOwnProperty,reflectGet,reflectSet,assert;$h‍_imports([["./commons.js", [["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $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)]],["immutableObject", [$h‍_a => (immutableObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
3588
+
3589
+
3332
3590
 
3333
3591
 
3334
3592
 
@@ -3352,18 +3610,22 @@ const { details: d, quote: q } = assert;
3352
3610
  * It's made from a proxy with a get trap that throws. It's safe to
3353
3611
  * create one and share it between all scopeHandlers.
3354
3612
  */
3355
- const alwaysThrowHandler = new Proxy(immutableObject, {
3613
+ const alwaysThrowHandler = new Proxy(
3614
+ immutableObject,
3615
+ freeze({
3356
3616
  get(_shadow, prop) {
3617
+ // eslint-disable-next-line @endo/no-polymorphic-call
3357
3618
  assert.fail(
3358
3619
  d`Please report unexpected scope handler trap: ${q(String(prop))}`);
3359
3620
 
3360
- } });
3621
+ } }));
3622
+
3361
3623
 
3362
3624
 
3363
3625
  /*
3364
3626
  * createScopeHandler()
3365
3627
  * ScopeHandler manages a Proxy which serves as the global scope for the
3366
- * performEval operation (the Proxy is the argument of a 'with' binding).
3628
+ * safeEvaluate operation (the Proxy is the argument of a 'with' binding).
3367
3629
  * As described in createSafeEvaluator(), it has several functions:
3368
3630
  * - allow the very first (and only the very first) use of 'eval' to map to
3369
3631
  * the real (unsafe) eval function, so it acts as a 'direct eval' and can
@@ -3395,11 +3657,7 @@ localObject = {},
3395
3657
  return wasSet;
3396
3658
  };
3397
3659
 
3398
- const scopeHandler = freeze({
3399
- // The scope handler throws if any trap other than get/set/has are run
3400
- // (e.g. getOwnPropertyDescriptors, apply, getPrototypeOf).
3401
- __proto__: alwaysThrowHandler,
3402
-
3660
+ const scopeProxyHandlerProperties = {
3403
3661
  get(_shadow, prop) {
3404
3662
  if (typeof prop === 'symbol') {
3405
3663
  return undefined;
@@ -3480,9 +3738,20 @@ localObject = {},
3480
3738
  // at the expense of 'typeof' being wrong for those properties. For
3481
3739
  // example, in the browser, evaluating 'document = 3', will add
3482
3740
  // a property to globalObject instead of throwing a ReferenceError.
3741
+
3742
+ // !!!!! WARNING: DANGER ZONE !!!!!!
3743
+ // The order of the conditions in the `||` expression below is of the
3744
+ // utmost importance. Under no circumstances should `eval` be checked
3745
+ // after `globalObject`. The prototype of the global object is under
3746
+ // full control of user code and may be replaced by a proxy with a
3747
+ // `has` trap. If we allow that trap to trigger while the
3748
+ // `allowNextEvalToBeUnsafe` flag is down, it could allow user code
3749
+ // to get a hold of `FERAL_EVAL`, resulting in a complete escape of
3750
+ // the compartment.
3751
+ // !!!!! WARNING: DANGER ZONE !!!!!!
3483
3752
  return (
3484
3753
  sloppyGlobalsMode ||
3485
- prop === 'eval' ||
3754
+ allowNextEvalToBeUnsafe && prop === 'eval' ||
3486
3755
  prop in localObject ||
3487
3756
  prop in globalObject ||
3488
3757
  prop in globalThis);
@@ -3503,12 +3772,23 @@ localObject = {},
3503
3772
  getOwnPropertyDescriptor(_target, prop) {
3504
3773
  // Coerce with `String` in case prop is a symbol.
3505
3774
  const quotedProp = q(String(prop));
3775
+ // eslint-disable-next-line @endo/no-polymorphic-call
3506
3776
  console.warn(
3507
3777
  `getOwnPropertyDescriptor trap on scopeHandler for ${quotedProp}`,
3508
- new Error().stack);
3778
+ new TypeError().stack);
3509
3779
 
3510
3780
  return undefined;
3511
- } });
3781
+ } };
3782
+
3783
+
3784
+ // The scope handler's prototype is a proxy that throws if any trap other
3785
+ // than get/set/has are run (like getOwnPropertyDescriptors, apply,
3786
+ // getPrototypeOf).
3787
+ const scopeHandler = freeze(
3788
+ create(
3789
+ alwaysThrowHandler,
3790
+ getOwnPropertyDescriptors(scopeProxyHandlerProperties)));
3791
+
3512
3792
 
3513
3793
 
3514
3794
  return {
@@ -3520,7 +3800,7 @@ localObject = {},
3520
3800
  })
3521
3801
 
3522
3802
  ,
3523
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let RegExp;$h‍_imports([["./commons.js", [["RegExp", [$h‍_a => (RegExp = $h‍_a)]]]]]);
3803
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
3524
3804
 
3525
3805
  // Captures a key and value of the form #key=value or @key=value
3526
3806
  const sourceMetaEntryRegExp =
@@ -3531,7 +3811,7 @@ const sourceMetaEntryRegExp =
3531
3811
  // On account of the mechanics of regular expressions, scanning from the end
3532
3812
  // does not allow us to capture every pair, so getSourceURL must capture and
3533
3813
  // trim until there are no matching comments.
3534
- const sourceMetaEntriesRegExp = new RegExp(
3814
+ const sourceMetaEntriesRegExp = new FERAL_REG_EXP(
3535
3815
  `(?:\\s*//${sourceMetaEntryRegExp}|/\\*${sourceMetaEntryRegExp}\\s*\\*/)\\s*$`);
3536
3816
 
3537
3817
 
@@ -3546,11 +3826,11 @@ const getSourceURL = (src) => {
3546
3826
  // So, we sublimate the comments out of the source until no source or no
3547
3827
  // comments remain.
3548
3828
  while (src.length > 0) {
3549
- const match = sourceMetaEntriesRegExp.exec(src);
3829
+ const match = regexpExec(sourceMetaEntriesRegExp, src);
3550
3830
  if (match === null) {
3551
3831
  break;
3552
3832
  }
3553
- src = src.slice(0, src.length - match[0].length);
3833
+ src = stringSlice(src, 0, src.length - match[0].length);
3554
3834
 
3555
3835
  // We skip $0 since it contains the entire match.
3556
3836
  // The match contains four capture groups,
@@ -3570,7 +3850,8 @@ const getSourceURL = (src) => {
3570
3850
  })
3571
3851
 
3572
3852
  ,
3573
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let RegExp,SyntaxError,stringSearch,stringSlice,stringSplit,getSourceURL;$h‍_imports([["./commons.js", [["RegExp", [$h‍_a => (RegExp = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]);
3853
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,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)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]);
3854
+
3574
3855
 
3575
3856
 
3576
3857
 
@@ -3605,7 +3886,7 @@ function getLineNumber(src, pattern) {
3605
3886
 
3606
3887
  // /////////////////////////////////////////////////////////////////////////////
3607
3888
 
3608
- const htmlCommentPattern = new RegExp(`(?:${'<'}!--|--${'>'})`, 'g');
3889
+ const htmlCommentPattern = new FERAL_REG_EXP(`(?:${'<'}!--|--${'>'})`, 'g');
3609
3890
 
3610
3891
  /**
3611
3892
  * Conservatively reject the source text if it may contain text that some
@@ -3669,12 +3950,15 @@ const rejectHtmlComments = (src) => {
3669
3950
  */$h‍_once.rejectHtmlComments(rejectHtmlComments);
3670
3951
  const evadeHtmlCommentTest = (src) => {
3671
3952
  const replaceFn = (match) => match[0] === '<' ? '< ! --' : '-- >';
3672
- return src.replace(htmlCommentPattern, replaceFn);
3953
+ return stringReplace(src, htmlCommentPattern, replaceFn);
3673
3954
  };
3674
3955
 
3675
3956
  // /////////////////////////////////////////////////////////////////////////////
3676
3957
  $h‍_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
3677
- const importPattern = new RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g');
3958
+ const importPattern = new FERAL_REG_EXP(
3959
+ '(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
3960
+ 'g');
3961
+
3678
3962
 
3679
3963
  /**
3680
3964
  * Conservatively reject the source text if it may contain a dynamic
@@ -3735,12 +4019,15 @@ const rejectImportExpressions = (src) => {
3735
4019
  */$h‍_once.rejectImportExpressions(rejectImportExpressions);
3736
4020
  const evadeImportExpressionTest = (src) => {
3737
4021
  const replaceFn = (_, p1, p2) => `${p1}__import__${p2}`;
3738
- return src.replace(importPattern, replaceFn);
4022
+ return stringReplace(src, importPattern, replaceFn);
3739
4023
  };
3740
4024
 
3741
4025
  // /////////////////////////////////////////////////////////////////////////////
3742
4026
  $h‍_once.evadeImportExpressionTest(evadeImportExpressionTest);
3743
- const someDirectEvalPattern = new RegExp('(^|[^.])\\beval(\\s*\\()', 'g');
4027
+ const someDirectEvalPattern = new FERAL_REG_EXP(
4028
+ '(^|[^.])\\beval(\\s*\\()',
4029
+ 'g');
4030
+
3744
4031
 
3745
4032
  /**
3746
4033
  * Heuristically reject some text that seems to contain a direct eval
@@ -3835,39 +4122,27 @@ const applyTransforms = (source, transforms) => {
3835
4122
 
3836
4123
  const { details: d } = assert;
3837
4124
 
4125
+ // TODO: rename localObject to scopeObject
4126
+
3838
4127
  /**
3839
- * performEval()
3840
- * The low-level operation used by all evaluators:
3841
- * eval(), Function(), Evalutator.prototype.evaluate().
4128
+ * makeSafeEvaluator()
4129
+ * Build the low-level operation used by all evaluators:
4130
+ * eval(), Function(), Compartment.prototype.evaluate().
3842
4131
  *
3843
- * @param {string} source
3844
- * @param {Object} globalObject
3845
- * @param {Objeect} localObject
3846
- * @param {Object} [options]
3847
- * @param {Array<Transform>} [options.localTransforms]
4132
+ * @param {Object} options
4133
+ * @param {Object} options.globalObject
4134
+ * @param {Object} [options.localObject]
3848
4135
  * @param {Array<Transform>} [options.globalTransforms]
3849
4136
  * @param {bool} [options.sloppyGlobalsMode]
3850
4137
  * @param {WeakSet} [options.knownScopeProxies]
3851
4138
  */
3852
- const performEval = (
3853
- source,
3854
- globalObject,
3855
- localObject = {},
3856
- {
3857
- localTransforms = [],
4139
+ const makeSafeEvaluator = ({
4140
+ globalObject,
4141
+ localObject = {},
3858
4142
  globalTransforms = [],
3859
4143
  sloppyGlobalsMode = false,
3860
4144
  knownScopeProxies = new WeakSet() } =
3861
- {}) =>
3862
- {
3863
- // Execute the mandatory transforms last to ensure that any rewritten code
3864
- // meets those mandatory requirements.
3865
- source = applyTransforms(source, [
3866
- ...localTransforms,
3867
- ...globalTransforms,
3868
- mandatoryTransforms]);
3869
-
3870
-
4145
+ {}) => {
3871
4146
  const {
3872
4147
  scopeHandler,
3873
4148
  admitOneUnsafeEvalNext,
@@ -3875,80 +4150,81 @@ localObject = {},
3875
4150
  createScopeHandler(globalObject, localObject, {
3876
4151
  sloppyGlobalsMode });
3877
4152
 
3878
- const scopeProxyRevocable = proxyRevocable(immutableObject, scopeHandler);
4153
+ const { proxy: scopeProxy, revoke: revokeScopeProxy } = proxyRevocable(
4154
+ immutableObject,
4155
+ scopeHandler);
4156
+
4157
+ weaksetAdd(knownScopeProxies, scopeProxy);
4158
+
4159
+ // Defer creating the actual evaluator to first use.
4160
+ // Creating a compartment should be possible in no-eval environments
4161
+ // It also allows more global constants to be captured by the optimizer
4162
+ let evaluate;
4163
+ const makeEvaluate = () => {
4164
+ if (!evaluate) {
4165
+ const constants = getScopeConstants(globalObject, localObject);
4166
+ const evaluateFactory = makeEvaluateFactory(constants);
4167
+ evaluate = apply(evaluateFactory, scopeProxy, []);
4168
+ }
4169
+ };
3879
4170
 
3880
- const constants = getScopeConstants(globalObject, localObject);
3881
- const evaluateFactory = makeEvaluateFactory(constants);
3882
- const evaluate = apply(evaluateFactory, scopeProxyRevocable.proxy, []);
4171
+ /**
4172
+ * @param {string} source
4173
+ * @param {Object} [options]
4174
+ * @param {Array<Transform>} [options.localTransforms]
4175
+ */
4176
+ const safeEvaluate = (source, { localTransforms = [] } = {}) => {
4177
+ makeEvaluate();
3883
4178
 
3884
- admitOneUnsafeEvalNext();
3885
- let err;
3886
- try {
3887
- // Ensure that "this" resolves to the safe global.
3888
- weaksetAdd(knownScopeProxies, scopeProxyRevocable.proxy);
3889
- return apply(evaluate, globalObject, [source]);
3890
- } catch (e) {
3891
- // stash the child-code error in hopes of debugging the internal failure
3892
- err = e;
3893
- throw e;
3894
- } finally {
3895
- if (resetOneUnsafeEvalNext()) {
3896
- // Barring a defect in the SES shim, the scope proxy should allow the
3897
- // powerful, unsafe `eval` to be used by `evaluate` exactly once, as the
3898
- // very first name that it attempts to access from the lexical scope.
3899
- // A defect in the SES shim could throw an exception after our call to
3900
- // `admitOneUnsafeEvalNext()` and before `evaluate` calls `eval`
3901
- // internally.
3902
- // If we get here, SES is very broken.
3903
- // This condition is one where this vat is now hopelessly confused, and
3904
- // the vat as a whole should be aborted.
3905
- // No further code should run.
3906
- // All immediately reachable state should be abandoned.
3907
- // However, that is not yet possible, so we at least prevent further
3908
- // variable resolution via the scopeHandler, and throw an error with
3909
- // diagnostic info including the thrown error if any from evaluating the
3910
- // source code.
3911
- scopeProxyRevocable.revoke();
3912
- // TODO A GOOD PLACE TO PANIC(), i.e., kill the vat incarnation.
3913
- // See https://github.com/Agoric/SES-shim/issues/490
3914
- assert.fail(d`handler did not reset allowNextEvalToBeUnsafe ${err}`);
3915
- }
3916
- }
3917
- };$h‍_once.performEval(performEval);
3918
- })
4179
+ // Execute the mandatory transforms last to ensure that any rewritten code
4180
+ // meets those mandatory requirements.
4181
+ source = applyTransforms(source, [
4182
+ ...localTransforms,
4183
+ ...globalTransforms,
4184
+ mandatoryTransforms]);
3919
4185
 
3920
- ,
3921
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let performEval;$h‍_imports([["./evaluate.js", [["performEval", [$h‍_a => (performEval = $h‍_a)]]]]]);
3922
4186
 
3923
- /*
3924
- * makeEvalFunction()
3925
- * A safe version of the native eval function which relies on
3926
- * the safety of performEval for confinement.
3927
- */
3928
- const makeEvalFunction = (globalObject, options = {}) => {
3929
- // We use the the concise method syntax to create an eval without a
3930
- // [[Construct]] behavior (such that the invocation "new eval()" throws
3931
- // TypeError: eval is not a constructor"), but which still accepts a
3932
- // 'this' binding.
3933
- const newEval = {
3934
- eval(source) {
3935
- if (typeof source !== 'string') {
3936
- // As per the runtime semantic of PerformEval [ECMAScript 18.2.1.1]:
3937
- // If Type(source) is not String, return source.
3938
- // TODO Recent proposals from Mike Samuel may change this non-string
3939
- // rule. Track.
3940
- return source;
4187
+ admitOneUnsafeEvalNext();
4188
+ let err;
4189
+ try {
4190
+ // Ensure that "this" resolves to the safe global.
4191
+ return apply(evaluate, globalObject, [source]);
4192
+ } catch (e) {
4193
+ // stash the child-code error in hopes of debugging the internal failure
4194
+ err = e;
4195
+ throw e;
4196
+ } finally {
4197
+ if (resetOneUnsafeEvalNext()) {
4198
+ // Barring a defect in the SES shim, the scope proxy should allow the
4199
+ // powerful, unsafe `eval` to be used by `evaluate` exactly once, as the
4200
+ // very first name that it attempts to access from the lexical scope.
4201
+ // A defect in the SES shim could throw an exception after our call to
4202
+ // `admitOneUnsafeEvalNext()` and before `evaluate` calls `eval`
4203
+ // internally.
4204
+ // If we get here, SES is very broken.
4205
+ // This condition is one where this vat is now hopelessly confused, and
4206
+ // the vat as a whole should be aborted.
4207
+ // No further code should run.
4208
+ // All immediately reachable state should be abandoned.
4209
+ // However, that is not yet possible, so we at least prevent further
4210
+ // variable resolution via the scopeHandler, and throw an error with
4211
+ // diagnostic info including the thrown error if any from evaluating the
4212
+ // source code.
4213
+ revokeScopeProxy();
4214
+ // TODO A GOOD PLACE TO PANIC(), i.e., kill the vat incarnation.
4215
+ // See https://github.com/Agoric/SES-shim/issues/490
4216
+ // eslint-disable-next-line @endo/no-polymorphic-call
4217
+ assert.fail(d`handler did not reset allowNextEvalToBeUnsafe ${err}`);
3941
4218
  }
3942
- return performEval(source, globalObject, {}, options);
3943
- } }.
3944
- eval;
4219
+ }
4220
+ };
3945
4221
 
3946
- return newEval;
3947
- };$h‍_once.makeEvalFunction(makeEvalFunction);
4222
+ return { safeEvaluate };
4223
+ };$h‍_once.makeSafeEvaluator(makeSafeEvaluator);
3948
4224
  })
3949
4225
 
3950
4226
  ,
3951
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,arrayJoin,arrayPop,defineProperties,getPrototypeOf,performEval,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)]]]],["./evaluate.js", [["performEval", [$h‍_a => (performEval = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
4227
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,arrayPush,create,defineProperties,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)]],["defineProperties", [$h‍_a => (defineProperties = $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)]]]]]);
3952
4228
 
3953
4229
 
3954
4230
 
@@ -3958,23 +4234,155 @@ const makeEvalFunction = (globalObject, options = {}) => {
3958
4234
 
3959
4235
 
3960
4236
 
3961
- /*
3962
- * makeFunctionConstructor()
3963
- * A safe version of the native Function which relies on
3964
- * the safety of performEval for confinement.
3965
- */
3966
- const makeFunctionConstructor = (globaObject, options = {}) => {
3967
- // Define an unused parameter to ensure Function.length === 1
3968
- const newFunction = function Function(_body) {
3969
- // Sanitize all parameters at the entry point.
3970
- // eslint-disable-next-line prefer-rest-params
3971
- const bodyText = `${arrayPop(arguments) || ''}`;
3972
- // eslint-disable-next-line prefer-rest-params
3973
- const parameters = `${arrayJoin(arguments, ',')}`;
3974
4237
 
3975
- // Are parameters and bodyText valid code, or is someone
3976
- // attempting an injection attack? This will throw a SyntaxError if:
3977
- // - parameters doesn't parse as parameters
4238
+
4239
+
4240
+
4241
+
4242
+ const provideCompartmentEvaluator = (compartmentFields, options) => {
4243
+ const {
4244
+ sloppyGlobalsMode = false,
4245
+ __moduleShimLexicals__ = undefined } =
4246
+ options;
4247
+
4248
+ let safeEvaluate;
4249
+
4250
+ if (__moduleShimLexicals__ === undefined && !sloppyGlobalsMode) {
4251
+ ({ safeEvaluate } = compartmentFields);
4252
+ } else {
4253
+ // The scope proxy or global lexicals are different from the
4254
+ // shared evaluator so we need to build a new one
4255
+
4256
+ let { globalTransforms } = compartmentFields;
4257
+ const {
4258
+ globalObject,
4259
+ globalLexicals,
4260
+ knownScopeProxies } =
4261
+ compartmentFields;
4262
+
4263
+ let localObject = globalLexicals;
4264
+ if (__moduleShimLexicals__ !== undefined) {
4265
+ // When using `evaluate` for ESM modules, as should only occur from the
4266
+ // module-shim's module-instance.js, we do not reveal the SES-shim's
4267
+ // module-to-program translation, as this is not standardizable behavior.
4268
+ // However, the `localTransforms` will come from the `__shimTransforms__`
4269
+ // Compartment option in this case, which is a non-standardizable escape
4270
+ // hatch so programs designed specifically for the SES-shim
4271
+ // implementation may opt-in to use the same transforms for `evaluate`
4272
+ // and `import`, at the expense of being tightly coupled to SES-shim.
4273
+ globalTransforms = undefined;
4274
+
4275
+ localObject = create(null, getOwnPropertyDescriptors(globalLexicals));
4276
+ defineProperties(
4277
+ localObject,
4278
+ getOwnPropertyDescriptors(__moduleShimLexicals__));
4279
+
4280
+ }
4281
+
4282
+ ({ safeEvaluate } = makeSafeEvaluator({
4283
+ globalObject,
4284
+ localObject,
4285
+ globalTransforms,
4286
+ sloppyGlobalsMode,
4287
+ knownScopeProxies }));
4288
+
4289
+ }
4290
+
4291
+ return { safeEvaluate };
4292
+ };$h‍_once.provideCompartmentEvaluator(provideCompartmentEvaluator);
4293
+
4294
+ const compartmentEvaluate = (compartmentFields, source, options) => {
4295
+ // Perform this check first to avoid unecessary sanitizing.
4296
+ // TODO Maybe relax string check and coerce instead:
4297
+ // https://github.com/tc39/proposal-dynamic-code-brand-checks
4298
+ if (typeof source !== 'string') {
4299
+ throw new TypeError('first argument of evaluate() must be a string');
4300
+ }
4301
+
4302
+ // Extract options, and shallow-clone transforms.
4303
+ const {
4304
+ transforms = [],
4305
+ __evadeHtmlCommentTest__ = false,
4306
+ __evadeImportExpressionTest__ = false,
4307
+ __rejectSomeDirectEvalExpressions__ = true // Note default on
4308
+ } = options;
4309
+ const localTransforms = [...transforms];
4310
+ if (__evadeHtmlCommentTest__ === true) {
4311
+ arrayPush(localTransforms, evadeHtmlCommentTest);
4312
+ }
4313
+ if (__evadeImportExpressionTest__ === true) {
4314
+ arrayPush(localTransforms, evadeImportExpressionTest);
4315
+ }
4316
+ if (__rejectSomeDirectEvalExpressions__ === true) {
4317
+ arrayPush(localTransforms, rejectSomeDirectEvalExpressions);
4318
+ }
4319
+
4320
+ const { safeEvaluate } = provideCompartmentEvaluator(
4321
+ compartmentFields,
4322
+ options);
4323
+
4324
+
4325
+ return safeEvaluate(source, {
4326
+ localTransforms });
4327
+
4328
+ };$h‍_once.compartmentEvaluate(compartmentEvaluate);
4329
+ })
4330
+
4331
+ ,
4332
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { $h‍_imports([]); /*
4333
+ * makeEvalFunction()
4334
+ * A safe version of the native eval function which relies on
4335
+ * the safety of safeEvaluate for confinement.
4336
+ */
4337
+ const makeEvalFunction = (safeEvaluate) => {
4338
+ // We use the the concise method syntax to create an eval without a
4339
+ // [[Construct]] behavior (such that the invocation "new eval()" throws
4340
+ // TypeError: eval is not a constructor"), but which still accepts a
4341
+ // 'this' binding.
4342
+ const newEval = {
4343
+ eval(source) {
4344
+ if (typeof source !== 'string') {
4345
+ // As per the runtime semantic of PerformEval [ECMAScript 18.2.1.1]:
4346
+ // If Type(source) is not String, return source.
4347
+ // TODO Recent proposals from Mike Samuel may change this non-string
4348
+ // rule. Track.
4349
+ return source;
4350
+ }
4351
+ return safeEvaluate(source);
4352
+ } }.
4353
+ eval;
4354
+
4355
+ return newEval;
4356
+ };$h‍_once.makeEvalFunction(makeEvalFunction);
4357
+ })
4358
+
4359
+ ,
4360
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
4361
+
4362
+
4363
+
4364
+
4365
+
4366
+
4367
+
4368
+
4369
+ /*
4370
+ * makeFunctionConstructor()
4371
+ * A safe version of the native Function which relies on
4372
+ * the safety of safeEvaluate for confinement.
4373
+ */
4374
+ const makeFunctionConstructor = (safeEvaluate) => {
4375
+ // Define an unused parameter to ensure Function.length === 1
4376
+ const newFunction = function Function(_body) {
4377
+ // Sanitize all parameters at the entry point.
4378
+ // eslint-disable-next-line prefer-rest-params
4379
+ const bodyText = `${arrayPop(arguments) || ''}`;
4380
+ // eslint-disable-next-line prefer-rest-params
4381
+ const parameters = `${arrayJoin(arguments, ',')}`;
4382
+
4383
+ // Are parameters and bodyText valid code, or is someone
4384
+ // attempting an injection attack? This will throw a SyntaxError if:
4385
+ // - parameters doesn't parse as parameters
3978
4386
  // - bodyText doesn't parse as a function body
3979
4387
  // - either contain a call to super() or references a super property.
3980
4388
  //
@@ -4003,7 +4411,7 @@ const makeFunctionConstructor = (globaObject, options = {}) => {
4003
4411
  // TODO: since we create an anonymous function, the 'this' value
4004
4412
  // isn't bound to the global object as per specs, but set as undefined.
4005
4413
  const src = `(function anonymous(${parameters}\n) {\n${bodyText}\n})`;
4006
- return performEval(src, globaObject, {}, options);
4414
+ return safeEvaluate(src);
4007
4415
  };
4008
4416
 
4009
4417
  defineProperties(newFunction, {
@@ -5394,29 +5802,14 @@ const whitelist = {
5394
5802
 
5395
5803
 
5396
5804
  /**
5397
- * initGlobalObject()
5398
- * Create new global object using a process similar to ECMA specifications
5399
- * (portions of SetRealmGlobalObject and SetDefaultGlobalBindings).
5400
- * `newGlobalPropertyNames` should be either `initialGlobalPropertyNames` or
5401
- * `sharedGlobalPropertyNames`.
5805
+ * setGlobalObjectConstantProperties()
5806
+ * Initializes a new global object using a process similar to ECMA specifications
5807
+ * (SetDefaultGlobalBindings). This process is split between this function and
5808
+ * `setGlobalObjectMutableProperties`.
5402
5809
  *
5403
5810
  * @param {Object} globalObject
5404
- * @param {Object} intrinsics
5405
- * @param {Object} newGlobalPropertyNames
5406
- * @param {Function} makeCompartmentConstructor
5407
- * @param {Object} compartmentPrototype
5408
- * @param {Object} [options]
5409
- * @param {Array<Transform>} [options.globalTransforms]
5410
- * @param {(Object) => void} [options.markVirtualizedNativeFunction]
5411
5811
  */
5412
- const initGlobalObject = (
5413
- globalObject,
5414
- intrinsics,
5415
- newGlobalPropertyNames,
5416
- makeCompartmentConstructor,
5417
- compartmentPrototype,
5418
- { globalTransforms, markVirtualizedNativeFunction }) =>
5419
- {
5812
+ const setGlobalObjectConstantProperties = (globalObject) => {
5420
5813
  for (const [name, constant] of entries(constantProperties)) {
5421
5814
  defineProperty(globalObject, name, {
5422
5815
  value: constant,
@@ -5425,7 +5818,33 @@ compartmentPrototype,
5425
5818
  configurable: false });
5426
5819
 
5427
5820
  }
5821
+ };
5822
+
5823
+ /**
5824
+ * setGlobalObjectMutableProperties()
5825
+ * Create new global object using a process similar to ECMA specifications
5826
+ * (portions of SetRealmGlobalObject and SetDefaultGlobalBindings).
5827
+ * `newGlobalPropertyNames` should be either `initialGlobalPropertyNames` or
5828
+ * `sharedGlobalPropertyNames`.
5829
+ *
5830
+ * @param {Object} globalObject
5831
+ * @param {Object} param1
5832
+ * @param {Object} param1.intrinsics
5833
+ * @param {Object} param1.newGlobalPropertyNames
5834
+ * @param {Function} param1.makeCompartmentConstructor
5835
+ * @param {(string, Object?) => any} param1.safeEvaluate
5836
+ * @param {(Object) => void} param1.markVirtualizedNativeFunction
5837
+ */$h‍_once.setGlobalObjectConstantProperties(setGlobalObjectConstantProperties);
5838
+ const setGlobalObjectMutableProperties = (
5839
+ globalObject,
5840
+ {
5841
+ intrinsics,
5842
+ newGlobalPropertyNames,
5843
+ makeCompartmentConstructor,
5844
+ safeEvaluate,
5845
+ markVirtualizedNativeFunction }) =>
5428
5846
 
5847
+ {
5429
5848
  for (const [name, intrinsicName] of entries(universalPropertyNames)) {
5430
5849
  if (objectHasOwnProperty(intrinsics, intrinsicName)) {
5431
5850
  defineProperty(globalObject, name, {
@@ -5450,12 +5869,8 @@ compartmentPrototype,
5450
5869
 
5451
5870
  const perCompartmentGlobals = {
5452
5871
  globalThis: globalObject,
5453
- eval: makeEvalFunction(globalObject, {
5454
- globalTransforms }),
5455
-
5456
- Function: makeFunctionConstructor(globalObject, {
5457
- globalTransforms }) };
5458
-
5872
+ eval: makeEvalFunction(safeEvaluate),
5873
+ Function: makeFunctionConstructor(safeEvaluate) };
5459
5874
 
5460
5875
 
5461
5876
  perCompartmentGlobals.Compartment = makeCompartmentConstructor(
@@ -5477,11 +5892,22 @@ compartmentPrototype,
5477
5892
  markVirtualizedNativeFunction(value);
5478
5893
  }
5479
5894
  }
5480
- };$h‍_once.initGlobalObject(initGlobalObject);
5895
+ };$h‍_once.setGlobalObjectMutableProperties(setGlobalObjectMutableProperties);
5481
5896
  })
5482
5897
 
5483
5898
  ,
5484
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Promise,TypeError,ReferenceError,create,values,freeze,assert;$h‍_imports([["./commons.js", [["Promise", [$h‍_a => (Promise = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
5899
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
5900
+
5901
+
5902
+
5903
+
5904
+
5905
+
5906
+
5907
+
5908
+
5909
+
5910
+
5485
5911
 
5486
5912
 
5487
5913
 
@@ -5501,6 +5927,8 @@ compartmentPrototype,
5501
5927
 
5502
5928
  const { details: d, quote: q } = assert;
5503
5929
 
5930
+ const noop = () => {};
5931
+
5504
5932
  // `makeAlias` constructs compartment specifier tuples for the `aliases`
5505
5933
  // private field of compartments.
5506
5934
  // These aliases allow a compartment to alias an internal module specifier to a
@@ -5529,9 +5957,13 @@ compartmentPrivateFields,
5529
5957
  moduleAliases,
5530
5958
  compartment,
5531
5959
  moduleSpecifier,
5532
- staticModuleRecord) =>
5960
+ staticModuleRecord,
5961
+ pendingJobs,
5962
+ moduleLoads,
5963
+ errors) =>
5533
5964
  {
5534
- const { resolveHook, moduleRecords } = compartmentPrivateFields.get(
5965
+ const { resolveHook, moduleRecords } = weakmapGet(
5966
+ compartmentPrivateFields,
5535
5967
  compartment);
5536
5968
 
5537
5969
 
@@ -5548,18 +5980,29 @@ staticModuleRecord) =>
5548
5980
  resolvedImports });
5549
5981
 
5550
5982
 
5551
- // Memoize.
5552
- moduleRecords.set(moduleSpecifier, moduleRecord);
5553
-
5554
- // Await all dependencies to load, recursively.
5555
- await Promise.all(
5556
- values(resolvedImports).map((fullSpecifier) =>
5557
- // Behold: recursion.
5558
- // eslint-disable-next-line no-use-before-define
5559
- load(compartmentPrivateFields, moduleAliases, compartment, fullSpecifier)));
5983
+ // Enqueue jobs to load this module's shallow dependencies.
5984
+ for (const fullSpecifier of values(resolvedImports)) {
5985
+ // Behold: recursion.
5986
+ // eslint-disable-next-line no-use-before-define
5987
+ const dependencyLoaded = memoizedLoadWithErrorAnnotation(
5988
+ compartmentPrivateFields,
5989
+ moduleAliases,
5990
+ compartment,
5991
+ fullSpecifier,
5992
+ pendingJobs,
5993
+ moduleLoads,
5994
+ errors);
5560
5995
 
5996
+ setAdd(
5997
+ pendingJobs,
5998
+ promiseThen(dependencyLoaded, noop, (error) => {
5999
+ arrayPush(errors, error);
6000
+ }));
5561
6001
 
6002
+ }
5562
6003
 
6004
+ // Memoize.
6005
+ mapSet(moduleRecords, moduleSpecifier, moduleRecord);
5563
6006
  return moduleRecord;
5564
6007
  };
5565
6008
 
@@ -5567,14 +6010,15 @@ const loadWithoutErrorAnnotation = async (
5567
6010
  compartmentPrivateFields,
5568
6011
  moduleAliases,
5569
6012
  compartment,
5570
- moduleSpecifier) =>
6013
+ moduleSpecifier,
6014
+ pendingJobs,
6015
+ moduleLoads,
6016
+ errors) =>
5571
6017
  {
5572
- const {
5573
- importHook,
5574
- moduleMap,
5575
- moduleMapHook,
5576
- moduleRecords } =
5577
- compartmentPrivateFields.get(compartment);
6018
+ const { importHook, moduleMap, moduleMapHook, moduleRecords } = weakmapGet(
6019
+ compartmentPrivateFields,
6020
+ compartment);
6021
+
5578
6022
 
5579
6023
  // Follow moduleMap, or moduleMapHook if present.
5580
6024
  let aliasNamespace = moduleMap[moduleSpecifier];
@@ -5582,6 +6026,7 @@ moduleSpecifier) =>
5582
6026
  aliasNamespace = moduleMapHook(moduleSpecifier);
5583
6027
  }
5584
6028
  if (typeof aliasNamespace === 'string') {
6029
+ // eslint-disable-next-line @endo/no-polymorphic-call
5585
6030
  assert.fail(
5586
6031
  d`Cannot map module ${q(moduleSpecifier)} to ${q(
5587
6032
  aliasNamespace)
@@ -5589,8 +6034,9 @@ moduleSpecifier) =>
5589
6034
  TypeError);
5590
6035
 
5591
6036
  } else if (aliasNamespace !== undefined) {
5592
- const alias = moduleAliases.get(aliasNamespace);
6037
+ const alias = weakmapGet(moduleAliases, aliasNamespace);
5593
6038
  if (alias === undefined) {
6039
+ // eslint-disable-next-line @endo/no-polymorphic-call
5594
6040
  assert.fail(
5595
6041
  d`Cannot map module ${q(
5596
6042
  moduleSpecifier)
@@ -5600,25 +6046,27 @@ moduleSpecifier) =>
5600
6046
  }
5601
6047
  // Behold: recursion.
5602
6048
  // eslint-disable-next-line no-use-before-define
5603
- const aliasRecord = await load(
6049
+ const aliasRecord = await memoizedLoadWithErrorAnnotation(
5604
6050
  compartmentPrivateFields,
5605
6051
  moduleAliases,
5606
6052
  alias.compartment,
5607
- alias.specifier);
6053
+ alias.specifier,
6054
+ pendingJobs,
6055
+ moduleLoads,
6056
+ errors);
5608
6057
 
5609
- // Memoize.
5610
- moduleRecords.set(moduleSpecifier, aliasRecord);
6058
+ mapSet(moduleRecords, moduleSpecifier, aliasRecord);
5611
6059
  return aliasRecord;
5612
6060
  }
5613
6061
 
5614
- // Memoize.
5615
- if (moduleRecords.has(moduleSpecifier)) {
5616
- return moduleRecords.get(moduleSpecifier);
6062
+ if (mapHas(moduleRecords, moduleSpecifier)) {
6063
+ return mapGet(moduleRecords, moduleSpecifier);
5617
6064
  }
5618
6065
 
5619
6066
  const staticModuleRecord = await importHook(moduleSpecifier);
5620
6067
 
5621
6068
  if (staticModuleRecord === null || typeof staticModuleRecord !== 'object') {
6069
+ // eslint-disable-next-line @endo/no-polymorphic-call
5622
6070
  assert.fail(
5623
6071
  d`importHook must return a promise for an object, for module ${q(
5624
6072
  moduleSpecifier)
@@ -5638,10 +6086,12 @@ moduleSpecifier) =>
5638
6086
  moduleAliases,
5639
6087
  aliasCompartment,
5640
6088
  aliasSpecifier,
5641
- aliasModuleRecord);
6089
+ aliasModuleRecord,
6090
+ pendingJobs,
6091
+ moduleLoads,
6092
+ errors);
5642
6093
 
5643
- // Memoize by aliased specifier.
5644
- moduleRecords.set(moduleSpecifier, aliasRecord);
6094
+ mapSet(moduleRecords, moduleSpecifier, aliasRecord);
5645
6095
  return aliasRecord;
5646
6096
  }
5647
6097
 
@@ -5650,41 +6100,135 @@ moduleSpecifier) =>
5650
6100
  moduleAliases,
5651
6101
  compartment,
5652
6102
  moduleSpecifier,
5653
- staticModuleRecord);
6103
+ staticModuleRecord,
6104
+ pendingJobs,
6105
+ moduleLoads,
6106
+ errors);
5654
6107
 
5655
6108
  };
5656
6109
 
5657
- // `load` asynchronously loads `StaticModuleRecords` and creates a complete
5658
- // graph of `ModuleCompartmentRecords`.
5659
- // The module records refer to each other by a reference to the dependency's
5660
- // compartment and the specifier of the module within its own compartment.
5661
- // This graph is then ready to be synchronously linked and executed.
5662
- const load = async (
6110
+ const memoizedLoadWithErrorAnnotation = async (
5663
6111
  compartmentPrivateFields,
5664
6112
  moduleAliases,
5665
6113
  compartment,
5666
- moduleSpecifier) =>
6114
+ moduleSpecifier,
6115
+ pendingJobs,
6116
+ moduleLoads,
6117
+ errors) =>
5667
6118
  {
5668
- return loadWithoutErrorAnnotation(
6119
+ const { name: compartmentName } = weakmapGet(
6120
+ compartmentPrivateFields,
6121
+ compartment);
6122
+
6123
+
6124
+ // Prevent data-lock from recursion into branches visited in dependent loads.
6125
+ let compartmentLoading = mapGet(moduleLoads, compartment);
6126
+ if (compartmentLoading === undefined) {
6127
+ compartmentLoading = new Map();
6128
+ mapSet(moduleLoads, compartment, compartmentLoading);
6129
+ }
6130
+ let moduleLoading = mapGet(compartmentLoading, moduleSpecifier);
6131
+ if (moduleLoading !== undefined) {
6132
+ return moduleLoading;
6133
+ }
6134
+
6135
+ moduleLoading = promiseCatch(
6136
+ loadWithoutErrorAnnotation(
5669
6137
  compartmentPrivateFields,
5670
6138
  moduleAliases,
5671
6139
  compartment,
5672
- moduleSpecifier).
5673
- catch((error) => {
5674
- const { name } = compartmentPrivateFields.get(compartment);
6140
+ moduleSpecifier,
6141
+ pendingJobs,
6142
+ moduleLoads,
6143
+ errors),
6144
+
6145
+ (error) => {
6146
+ // eslint-disable-next-line @endo/no-polymorphic-call
5675
6147
  assert.note(
5676
6148
  error,
5677
6149
  d`${error.message}, loading ${q(moduleSpecifier)} in compartment ${q(
5678
- name)
6150
+ compartmentName)
5679
6151
  }`);
5680
6152
 
5681
6153
  throw error;
5682
6154
  });
6155
+
6156
+
6157
+ mapSet(compartmentLoading, moduleSpecifier, moduleLoading);
6158
+
6159
+ return moduleLoading;
6160
+ };
6161
+
6162
+ /*
6163
+ * `load` asynchronously gathers the `StaticModuleRecord`s for a module and its
6164
+ * transitive dependencies.
6165
+ * The module records refer to each other by a reference to the dependency's
6166
+ * compartment and the specifier of the module within its own compartment.
6167
+ * This graph is then ready to be synchronously linked and executed.
6168
+ */
6169
+ const load = async (
6170
+ compartmentPrivateFields,
6171
+ moduleAliases,
6172
+ compartment,
6173
+ moduleSpecifier) =>
6174
+ {
6175
+ const { name: compartmentName } = weakmapGet(
6176
+ compartmentPrivateFields,
6177
+ compartment);
6178
+
6179
+
6180
+ /** @type {Set<Promise<undefined>>} */
6181
+ const pendingJobs = new Set();
6182
+ /** @type {Map<Object, Map<string, Promise<Record>>} */
6183
+ const moduleLoads = new Map();
6184
+ /** @type {Array<Error>} */
6185
+ const errors = [];
6186
+
6187
+ const dependencyLoaded = memoizedLoadWithErrorAnnotation(
6188
+ compartmentPrivateFields,
6189
+ moduleAliases,
6190
+ compartment,
6191
+ moduleSpecifier,
6192
+ pendingJobs,
6193
+ moduleLoads,
6194
+ errors);
6195
+
6196
+ setAdd(
6197
+ pendingJobs,
6198
+ promiseThen(dependencyLoaded, noop, (error) => {
6199
+ arrayPush(errors, error);
6200
+ }));
6201
+
6202
+
6203
+ // Drain pending jobs queue.
6204
+ // Each job is a promise for undefined, regardless of success or failure.
6205
+ // Before we add a job to the queue, we catch any error and push it into the
6206
+ // `errors` accumulator.
6207
+ for (const job of pendingJobs) {
6208
+ // eslint-disable-next-line no-await-in-loop
6209
+ await job;
6210
+ }
6211
+
6212
+ // Throw an aggregate error if there were any errors.
6213
+ if (errors.length > 0) {
6214
+ throw new TypeError(
6215
+ `Failed to load module ${q(moduleSpecifier)} in package ${q(
6216
+ compartmentName)
6217
+ } (${errors.length} underlying failures: ${arrayJoin(
6218
+ arrayMap(errors, (error) => error.message),
6219
+ ', ')
6220
+ }`);
6221
+
6222
+ }
5683
6223
  };$h‍_once.load(load);
5684
6224
  })
5685
6225
 
5686
6226
  ,
5687
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let makeAlias,Proxy,TypeError,create,freeze,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,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)]],["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)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6227
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
6228
+
6229
+
6230
+
6231
+
5688
6232
 
5689
6233
 
5690
6234
 
@@ -5841,17 +6385,28 @@ moduleAliases,
5841
6385
  specifier) =>
5842
6386
  {
5843
6387
  const { deferredExports } = compartmentPrivateFields;
5844
- if (!deferredExports.has(specifier)) {
6388
+ if (!mapHas(deferredExports, specifier)) {
5845
6389
  const deferred = deferExports();
5846
- moduleAliases.set(deferred.exportsProxy, makeAlias(compartment, specifier));
5847
- deferredExports.set(specifier, deferred);
6390
+ weakmapSet(
6391
+ moduleAliases,
6392
+ deferred.exportsProxy,
6393
+ makeAlias(compartment, specifier));
6394
+
6395
+ mapSet(deferredExports, specifier, deferred);
5848
6396
  }
5849
- return deferredExports.get(specifier);
6397
+ return mapGet(deferredExports, specifier);
5850
6398
  };$h‍_once.getDeferredExports(getDeferredExports);
5851
6399
  })
5852
6400
 
5853
6401
  ,
5854
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let assert,getDeferredExports,Error,ReferenceError,SyntaxError,TypeError,create,defineProperty,entries,freeze,isArray,keys;$h‍_imports([["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]],["./module-proxy.js", [["getDeferredExports", [$h‍_a => (getDeferredExports = $h‍_a)]]]],["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $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)]]]]]);
6402
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let assert,getDeferredExports,ReferenceError,SyntaxError,TypeError,arrayForEach,arrayIncludes,arrayPush,arraySome,arraySort,create,defineProperty,entries,freeze,isArray,keys,mapGet,weakmapGet,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)]]]],["./compartment-evaluate.js", [["compartmentEvaluate", [$h‍_a => (compartmentEvaluate = $h‍_a)]]]]]);
6403
+
6404
+
6405
+
6406
+
6407
+
6408
+
6409
+
5855
6410
 
5856
6411
 
5857
6412
 
@@ -5878,7 +6433,7 @@ resolvedImports) =>
5878
6433
  {
5879
6434
  const { exportsProxy, proxiedExports, activate } = getDeferredExports(
5880
6435
  compartment,
5881
- compartmentPrivateFields.get(compartment),
6436
+ weakmapGet(compartmentPrivateFields, compartment),
5882
6437
  moduleAliases,
5883
6438
  moduleSpecifier);
5884
6439
 
@@ -5888,13 +6443,13 @@ resolvedImports) =>
5888
6443
  if (staticModuleRecord.exports) {
5889
6444
  if (
5890
6445
  !isArray(staticModuleRecord.exports) ||
5891
- staticModuleRecord.exports.some((name) => typeof name !== 'string'))
6446
+ arraySome(staticModuleRecord.exports, (name) => typeof name !== 'string'))
5892
6447
  {
5893
6448
  throw new TypeError(
5894
6449
  `SES third-party static module record "exports" property must be an array of strings for module ${moduleSpecifier}`);
5895
6450
 
5896
6451
  }
5897
- staticModuleRecord.exports.forEach((name) => {
6452
+ arrayForEach(staticModuleRecord.exports, (name) => {
5898
6453
  let value = proxiedExports[name];
5899
6454
  const updaters = [];
5900
6455
 
@@ -5915,7 +6470,7 @@ resolvedImports) =>
5915
6470
 
5916
6471
 
5917
6472
  notifiers[name] = (update) => {
5918
- updaters.push(update);
6473
+ arrayPush(updaters, update);
5919
6474
  update(value);
5920
6475
  };
5921
6476
  });
@@ -5929,6 +6484,7 @@ resolvedImports) =>
5929
6484
  if (!activated) {
5930
6485
  activate();
5931
6486
  activated = true;
6487
+ // eslint-disable-next-line @endo/no-polymorphic-call
5932
6488
  staticModuleRecord.execute(
5933
6489
  proxiedExports,
5934
6490
  compartment,
@@ -5960,7 +6516,7 @@ importedInstances) =>
5960
6516
  __liveExportMap__: liveExportMap = {} } =
5961
6517
  staticModuleRecord;
5962
6518
 
5963
- const compartmentFields = privateFields.get(compartment);
6519
+ const compartmentFields = weakmapGet(privateFields, compartment);
5964
6520
 
5965
6521
  const { __shimTransforms__ } = compartmentFields;
5966
6522
 
@@ -5996,7 +6552,7 @@ importedInstances) =>
5996
6552
  // be notified when this binding is initialized or updated.
5997
6553
  const notifiers = create(null);
5998
6554
 
5999
- entries(fixedExportMap).forEach(([fixedExportName, [localName]]) => {
6555
+ arrayForEach(entries(fixedExportMap), ([fixedExportName, [localName]]) => {
6000
6556
  let fixedGetNotify = localGetNotify[localName];
6001
6557
  if (!fixedGetNotify) {
6002
6558
  // fixed binding state
@@ -6019,7 +6575,7 @@ importedInstances) =>
6019
6575
  // init with initValue of a declared const binding, and return
6020
6576
  // it.
6021
6577
  if (!tdz) {
6022
- throw new Error(
6578
+ throw new TypeError(
6023
6579
  `Internal: binding ${q(localName)} already initialized`);
6024
6580
 
6025
6581
  }
@@ -6041,7 +6597,7 @@ importedInstances) =>
6041
6597
  return;
6042
6598
  }
6043
6599
  if (tdz) {
6044
- optUpdaters.push(updater);
6600
+ arrayPush(optUpdaters, updater);
6045
6601
  } else {
6046
6602
  updater(value);
6047
6603
  }
@@ -6066,7 +6622,8 @@ importedInstances) =>
6066
6622
  notifiers[fixedExportName] = fixedGetNotify.notify;
6067
6623
  });
6068
6624
 
6069
- entries(liveExportMap).forEach(
6625
+ arrayForEach(
6626
+ entries(liveExportMap),
6070
6627
  ([liveExportName, [localName, setProxyTrap]]) => {
6071
6628
  let liveGetNotify = localGetNotify[localName];
6072
6629
  if (!liveGetNotify) {
@@ -6122,7 +6679,7 @@ importedInstances) =>
6122
6679
  // Prevent recursion.
6123
6680
  return;
6124
6681
  }
6125
- updaters.push(updater);
6682
+ arrayPush(updaters, updater);
6126
6683
  if (!tdz) {
6127
6684
  updater(value);
6128
6685
  }
@@ -6180,7 +6737,12 @@ importedInstances) =>
6180
6737
  const candidateAll = create(null);
6181
6738
  candidateAll.default = false;
6182
6739
  for (const [specifier, importUpdaters] of updateRecord) {
6183
- const instance = importedInstances.get(specifier);
6740
+ const instance = mapGet(importedInstances, specifier);
6741
+ // The module instance object is an internal literal, does not bind this,
6742
+ // and never revealed outside the SES shim.
6743
+ // There are two instantiation sites for instances and they are both in
6744
+ // this module.
6745
+ // eslint-disable-next-line @endo/no-polymorphic-call
6184
6746
  instance.execute(); // bottom up cycle tolerant
6185
6747
  const { notifiers: importNotifiers } = instance;
6186
6748
  for (const [importName, updaters] of importUpdaters) {
@@ -6194,7 +6756,7 @@ importedInstances) =>
6194
6756
  importNotify(updater);
6195
6757
  }
6196
6758
  }
6197
- if (exportAlls.includes(specifier)) {
6759
+ if (arrayIncludes(exportAlls, specifier)) {
6198
6760
  // Make all these imports candidates.
6199
6761
  for (const [importName, importNotify] of entries(importNotifiers)) {
6200
6762
  if (candidateAll[importName] === undefined) {
@@ -6235,15 +6797,15 @@ importedInstances) =>
6235
6797
  // since all properties of the exports namespace must be keyed by a string
6236
6798
  // and the string must correspond to a valid identifier, sorting these
6237
6799
  // properties works for this specific case.
6238
- keys(exportsProps).
6239
- sort().
6240
- forEach((k) => defineProperty(proxiedExports, k, exportsProps[k]));
6800
+ arrayForEach(arraySort(keys(exportsProps)), (k) =>
6801
+ defineProperty(proxiedExports, k, exportsProps[k]));
6802
+
6241
6803
 
6242
6804
  freeze(proxiedExports);
6243
6805
  activate();
6244
6806
  }
6245
6807
 
6246
- let optFunctor = compartment.evaluate(functorSource, {
6808
+ let optFunctor = compartmentEvaluate(compartmentFields, functorSource, {
6247
6809
  globalObject: compartment.globalThis,
6248
6810
  transforms: __shimTransforms__,
6249
6811
  __moduleShimLexicals__: localLexicals });
@@ -6284,7 +6846,7 @@ importedInstances) =>
6284
6846
  })
6285
6847
 
6286
6848
  ,
6287
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let assert,makeModuleInstance,makeThirdPartyModuleInstance,Error,Map,ReferenceError,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", [["Error", [$h‍_a => (Error = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $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)]]]]]);
6849
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
6288
6850
 
6289
6851
 
6290
6852
 
@@ -6326,11 +6888,18 @@ moduleAliases,
6326
6888
  compartment,
6327
6889
  moduleSpecifier) =>
6328
6890
  {
6329
- const { moduleRecords } = weakmapGet(compartmentPrivateFields, compartment);
6891
+ const { name: compartmentName, moduleRecords } = weakmapGet(
6892
+ compartmentPrivateFields,
6893
+ compartment);
6894
+
6330
6895
 
6331
6896
  const moduleRecord = mapGet(moduleRecords, moduleSpecifier);
6332
6897
  if (moduleRecord === undefined) {
6333
- throw new ReferenceError(`Missing link to module ${q(moduleSpecifier)}`);
6898
+ throw new ReferenceError(
6899
+ `Missing link to module ${q(moduleSpecifier)} from compartment ${q(
6900
+ compartmentName)
6901
+ }`);
6902
+
6334
6903
  }
6335
6904
 
6336
6905
  // Mutual recursion so there's no confusion about which
@@ -6449,7 +7018,7 @@ moduleRecord) =>
6449
7018
  resolvedImports);
6450
7019
 
6451
7020
  } else {
6452
- throw new Error(
7021
+ throw new TypeError(
6453
7022
  `importHook must return a static module record, got ${q(
6454
7023
  staticModuleRecord)
6455
7024
  }`);
@@ -6475,8 +7044,7 @@ moduleRecord) =>
6475
7044
  })
6476
7045
 
6477
7046
  ,
6478
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Map,ReferenceError,TypeError,WeakMap,WeakSet,assign,create,defineProperties,entries,freeze,getOwnPropertyDescriptors,getOwnPropertyNames,weakmapGet,weakmapSet,weaksetHas,initGlobalObject,performEval,isValidIdentifierName,sharedGlobalPropertyNames,evadeHtmlCommentTest,evadeImportExpressionTest,rejectSomeDirectEvalExpressions,load,link,getDeferredExports,assert;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["ReferenceError", [$h‍_a => (ReferenceError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./global-object.js", [["initGlobalObject", [$h‍_a => (initGlobalObject = $h‍_a)]]]],["./evaluate.js", [["performEval", [$h‍_a => (performEval = $h‍_a)]]]],["./scope-constants.js", [["isValidIdentifierName", [$h‍_a => (isValidIdentifierName = $h‍_a)]]]],["./whitelist.js", [["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]]]],["./transforms.js", [["evadeHtmlCommentTest", [$h‍_a => (evadeHtmlCommentTest = $h‍_a)]],["evadeImportExpressionTest", [$h‍_a => (evadeImportExpressionTest = $h‍_a)]],["rejectSomeDirectEvalExpressions", [$h‍_a => (rejectSomeDirectEvalExpressions = $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)]]]]]);
6479
-
7047
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Map,ReferenceError,TypeError,WeakMap,WeakSet,arrayFilter,arrayJoin,assign,defineProperties,entries,freeze,getOwnPropertyNames,promiseThen,weakmapGet,weakmapSet,weaksetHas,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,isValidIdentifierName,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)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["entries", [$h‍_a => (entries = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["promiseThen", [$h‍_a => (promiseThen = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]]]],["./scope-constants.js", [["isValidIdentifierName", [$h‍_a => (isValidIdentifierName = $h‍_a)]]]],["./whitelist.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)]]]]]);
6480
7048
 
6481
7049
 
6482
7050
 
@@ -6549,7 +7117,22 @@ _options = {})
6549
7117
  throw new TypeError(
6550
7118
  'Compartment.prototype.constructor is not a valid constructor.');
6551
7119
 
6552
- };$h‍_once.InertCompartment(InertCompartment);
7120
+ };
7121
+
7122
+ /**
7123
+ * @param {Compartment} compartment
7124
+ * @param {string} specifier
7125
+ */$h‍_once.InertCompartment(InertCompartment);
7126
+ const compartmentImportNow = (compartment, specifier) => {
7127
+ const { execute, exportsProxy } = link(
7128
+ privateFields,
7129
+ moduleAliases,
7130
+ compartment,
7131
+ specifier);
7132
+
7133
+ execute();
7134
+ return exportsProxy;
7135
+ };
6553
7136
 
6554
7137
  const CompartmentPrototype = {
6555
7138
  constructor: InertCompartment,
@@ -6573,66 +7156,8 @@ const CompartmentPrototype = {
6573
7156
  * @param {boolean} [options.__rejectSomeDirectEvalExpressions__]
6574
7157
  */
6575
7158
  evaluate(source, options = {}) {
6576
- // Perform this check first to avoid unecessary sanitizing.
6577
- // TODO Maybe relax string check and coerce instead:
6578
- // https://github.com/tc39/proposal-dynamic-code-brand-checks
6579
- if (typeof source !== 'string') {
6580
- throw new TypeError('first argument of evaluate() must be a string');
6581
- }
6582
-
6583
- // Extract options, and shallow-clone transforms.
6584
- const {
6585
- transforms = [],
6586
- sloppyGlobalsMode = false,
6587
- __moduleShimLexicals__ = undefined,
6588
- __evadeHtmlCommentTest__ = false,
6589
- __evadeImportExpressionTest__ = false,
6590
- __rejectSomeDirectEvalExpressions__ = true // Note default on
6591
- } = options;
6592
- const localTransforms = [...transforms];
6593
- if (__evadeHtmlCommentTest__ === true) {
6594
- localTransforms.push(evadeHtmlCommentTest);
6595
- }
6596
- if (__evadeImportExpressionTest__ === true) {
6597
- localTransforms.push(evadeImportExpressionTest);
6598
- }
6599
- if (__rejectSomeDirectEvalExpressions__ === true) {
6600
- localTransforms.push(rejectSomeDirectEvalExpressions);
6601
- }
6602
-
6603
7159
  const compartmentFields = weakmapGet(privateFields, this);
6604
- let { globalTransforms } = compartmentFields;
6605
- const {
6606
- globalObject,
6607
- globalLexicals,
6608
- knownScopeProxies } =
6609
- compartmentFields;
6610
-
6611
- let localObject = globalLexicals;
6612
- if (__moduleShimLexicals__ !== undefined) {
6613
- // When using `evaluate` for ESM modules, as should only occur from the
6614
- // module-shim's module-instance.js, we do not reveal the SES-shim's
6615
- // module-to-program translation, as this is not standardizable behavior.
6616
- // However, the `localTransforms` will come from the `__shimTransforms__`
6617
- // Compartment option in this case, which is a non-standardizable escape
6618
- // hatch so programs designed specifically for the SES-shim
6619
- // implementation may opt-in to use the same transforms for `evaluate`
6620
- // and `import`, at the expense of being tightly coupled to SES-shim.
6621
- globalTransforms = undefined;
6622
-
6623
- localObject = create(null, getOwnPropertyDescriptors(globalLexicals));
6624
- defineProperties(
6625
- localObject,
6626
- getOwnPropertyDescriptors(__moduleShimLexicals__));
6627
-
6628
- }
6629
-
6630
- return performEval(source, globalObject, localObject, {
6631
- globalTransforms,
6632
- localTransforms,
6633
- sloppyGlobalsMode,
6634
- knownScopeProxies });
6635
-
7160
+ return compartmentEvaluate(compartmentFields, source, options);
6636
7161
  },
6637
7162
 
6638
7163
  toString() {
@@ -6669,12 +7194,15 @@ const CompartmentPrototype = {
6669
7194
 
6670
7195
  assertModuleHooks(this);
6671
7196
 
6672
- return load(privateFields, moduleAliases, this, specifier).then(() => {
7197
+ return promiseThen(
7198
+ load(privateFields, moduleAliases, this, specifier),
7199
+ () => {
6673
7200
  // The namespace box is a contentious design and likely to be a breaking
6674
7201
  // change in an appropriately numbered future version.
6675
- const namespace = this.importNow(specifier);
7202
+ const namespace = compartmentImportNow(this, specifier);
6676
7203
  return { namespace };
6677
7204
  });
7205
+
6678
7206
  },
6679
7207
 
6680
7208
  async load(specifier) {
@@ -6694,9 +7222,7 @@ const CompartmentPrototype = {
6694
7222
 
6695
7223
  assertModuleHooks(this);
6696
7224
 
6697
- const moduleInstance = link(privateFields, moduleAliases, this, specifier);
6698
- moduleInstance.execute();
6699
- return moduleInstance.exportsProxy;
7225
+ return compartmentImportNow(this, specifier);
6700
7226
  } };$h‍_once.CompartmentPrototype(CompartmentPrototype);
6701
7227
 
6702
7228
 
@@ -6730,7 +7256,7 @@ markVirtualizedNativeFunction) =>
6730
7256
  name = '<unknown>',
6731
7257
  transforms = [],
6732
7258
  __shimTransforms__ = [],
6733
- globalLexicals = {},
7259
+ globalLexicals: globalLexicalsOption = {},
6734
7260
  resolveHook,
6735
7261
  importHook,
6736
7262
  moduleMapHook } =
@@ -6768,48 +7294,63 @@ markVirtualizedNativeFunction) =>
6768
7294
  }
6769
7295
  }
6770
7296
 
6771
- const globalObject = {};
6772
- initGlobalObject(
6773
- globalObject,
6774
- intrinsics,
6775
- sharedGlobalPropertyNames,
6776
- targetMakeCompartmentConstructor,
6777
- this.constructor.prototype,
6778
- {
6779
- globalTransforms,
6780
- markVirtualizedNativeFunction });
6781
-
6782
-
6783
-
6784
- assign(globalObject, endowments);
6785
-
6786
- const invalidNames = getOwnPropertyNames(globalLexicals).filter(
7297
+ const invalidNames = arrayFilter(
7298
+ getOwnPropertyNames(globalLexicalsOption),
6787
7299
  (identifier) => !isValidIdentifierName(identifier));
6788
7300
 
6789
7301
  if (invalidNames.length) {
6790
- throw new Error(
6791
- `Cannot create compartment with invalid names for global lexicals: ${invalidNames.join(
7302
+ throw new TypeError(
7303
+ `Cannot create compartment with invalid names for global lexicals: ${arrayJoin(
7304
+ invalidNames,
6792
7305
  ', ')
6793
7306
  }; these names would not be lexically mentionable`);
6794
7307
 
6795
7308
  }
7309
+ // The caller continues to own the globalLexicals object they passed to
7310
+ // the compartment constructor, but the compartment only respects the
7311
+ // original values and they are constants in the scope of evaluated
7312
+ // programs and executed modules.
7313
+ // This shallow copy captures only the values of enumerable own
7314
+ // properties, erasing accessors.
7315
+ // The snapshot is frozen to ensure that the properties are immutable
7316
+ // when transferred-by-property-descriptor onto local scope objects.
7317
+ const globalLexicals = freeze({ ...globalLexicalsOption });
7318
+
7319
+ const globalObject = {};
7320
+
7321
+ // We must initialize all constant properties first because
7322
+ // `makeSafeEvaluator` may use them to create optimized bindings
7323
+ // in the evaluator.
7324
+ // TODO: consider merging into a single initialization if internal
7325
+ // evaluator is no longer eagerly created
7326
+ setGlobalObjectConstantProperties(globalObject);
6796
7327
 
6797
7328
  const knownScopeProxies = new WeakSet();
7329
+ const { safeEvaluate } = makeSafeEvaluator({
7330
+ globalObject,
7331
+ localObject: globalLexicals,
7332
+ globalTransforms,
7333
+ sloppyGlobalsMode: false,
7334
+ knownScopeProxies });
7335
+
7336
+
7337
+ setGlobalObjectMutableProperties(globalObject, {
7338
+ intrinsics,
7339
+ newGlobalPropertyNames: sharedGlobalPropertyNames,
7340
+ makeCompartmentConstructor: targetMakeCompartmentConstructor,
7341
+ safeEvaluate,
7342
+ markVirtualizedNativeFunction });
7343
+
7344
+
7345
+ assign(globalObject, endowments);
6798
7346
 
6799
7347
  weakmapSet(privateFields, this, {
6800
7348
  name,
6801
7349
  globalTransforms,
6802
7350
  globalObject,
6803
7351
  knownScopeProxies,
6804
- // The caller continues to own the globalLexicals object they passed to
6805
- // the compartment constructor, but the compartment only respects the
6806
- // original values and they are constants in the scope of evaluated
6807
- // programs and executed modules.
6808
- // This shallow copy captures only the values of enumerable own
6809
- // properties, erasing accessors.
6810
- // The snapshot is frozen to ensure that the properties are immutable
6811
- // when transferred-by-property-descriptor onto local scope objects.
6812
- globalLexicals: freeze({ ...globalLexicals }),
7352
+ globalLexicals,
7353
+ safeEvaluate,
6813
7354
  resolveHook,
6814
7355
  importHook,
6815
7356
  moduleMap,
@@ -6828,145 +7369,8 @@ markVirtualizedNativeFunction) =>
6828
7369
  })
6829
7370
 
6830
7371
  ,
6831
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Array,FERAL_FUNCTION,Float32Array,Map,RegExp,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iteratorSymbol,matchAllSymbol,InertCompartment;$h‍_imports([["./commons.js", [["Array", [$h‍_a => (Array = $h‍_a)]],["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["Float32Array", [$h‍_a => (Float32Array = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["RegExp", [$h‍_a => (RegExp = $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)]],["iteratorSymbol", [$h‍_a => (iteratorSymbol = $h‍_a)]],["matchAllSymbol", [$h‍_a => (matchAllSymbol = $h‍_a)]]]],["./compartment-shim.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]);
6832
-
6833
-
6834
-
6835
-
6836
-
6837
-
6838
-
6839
-
6840
-
6841
-
6842
-
6843
-
6844
-
6845
-
6846
- /**
6847
- * Object.getConstructorOf()
6848
- * Helper function to improve readability, similar to Object.getPrototypeOf().
6849
- *
6850
- * @param {Object} obj
6851
- */
6852
- function getConstructorOf(obj) {
6853
- return getPrototypeOf(obj).constructor;
6854
- }
6855
-
6856
- // getAnonymousIntrinsics uses a utility function to construct an arguments
6857
- // object, since it cannot have one of its own and also be a const export.
6858
- function makeArguments() {
6859
- // eslint-disable-next-line prefer-rest-params
6860
- return arguments;
6861
- }
6862
-
6863
- /**
6864
- * getAnonymousIntrinsics()
6865
- * Get the intrinsics not otherwise reachable by named own property
6866
- * traversal from the global object.
6867
- *
6868
- * @returns {Object}
6869
- */
6870
- const getAnonymousIntrinsics = () => {
6871
- const InertFunction = FERAL_FUNCTION.prototype.constructor;
6872
-
6873
- // 9.2.4.1 %ThrowTypeError%
6874
-
6875
- const ThrowTypeError = getOwnPropertyDescriptor(makeArguments(), 'callee').
6876
- get;
6877
-
6878
- // 21.1.5.2 The %StringIteratorPrototype% Object
6879
-
6880
- // eslint-disable-next-line no-new-wrappers
6881
- const StringIteratorObject = new String()[iteratorSymbol]();
6882
- const StringIteratorPrototype = getPrototypeOf(StringIteratorObject);
6883
-
6884
- // 21.2.7.1 The %RegExpStringIteratorPrototype% Object
6885
- const RegExpStringIterator =
6886
- RegExp.prototype[matchAllSymbol] && new RegExp()[matchAllSymbol]();
6887
- const RegExpStringIteratorPrototype =
6888
- RegExpStringIterator && getPrototypeOf(RegExpStringIterator);
6889
-
6890
- // 22.1.5.2 The %ArrayIteratorPrototype% Object
6891
-
6892
- // eslint-disable-next-line no-array-constructor
6893
- const ArrayIteratorObject = new Array()[iteratorSymbol]();
6894
- const ArrayIteratorPrototype = getPrototypeOf(ArrayIteratorObject);
6895
-
6896
- // 22.2.1 The %TypedArray% Intrinsic Object
6897
-
6898
- const TypedArray = getPrototypeOf(Float32Array);
6899
-
6900
- // 23.1.5.2 The %MapIteratorPrototype% Object
6901
-
6902
- const MapIteratorObject = new Map()[iteratorSymbol]();
6903
- const MapIteratorPrototype = getPrototypeOf(MapIteratorObject);
6904
-
6905
- // 23.2.5.2 The %SetIteratorPrototype% Object
6906
-
6907
- const SetIteratorObject = new Set()[iteratorSymbol]();
6908
- const SetIteratorPrototype = getPrototypeOf(SetIteratorObject);
6909
-
6910
- // 25.1.2 The %IteratorPrototype% Object
6911
-
6912
- const IteratorPrototype = getPrototypeOf(ArrayIteratorPrototype);
7372
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,WeakSet,arrayFilter,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,isObject,objectHasOwnProperty,values,weaksetHas,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,whitelist;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $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)]]]],["./whitelist.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["whitelist", [$h‍_a => (whitelist = $h‍_a)]]]]]);
6913
7373
 
6914
- // 25.2.1 The GeneratorFunction Constructor
6915
-
6916
- // eslint-disable-next-line no-empty-function
6917
- function* GeneratorFunctionInstance() {}
6918
- const GeneratorFunction = getConstructorOf(GeneratorFunctionInstance);
6919
-
6920
- // 25.2.3 Properties of the GeneratorFunction Prototype Object
6921
-
6922
- const Generator = GeneratorFunction.prototype;
6923
-
6924
- // 25.3.1 The AsyncGeneratorFunction Constructor
6925
-
6926
- // eslint-disable-next-line no-empty-function
6927
- async function* AsyncGeneratorFunctionInstance() {}
6928
- const AsyncGeneratorFunction = getConstructorOf(
6929
- AsyncGeneratorFunctionInstance);
6930
-
6931
-
6932
- // 25.3.2.2 AsyncGeneratorFunction.prototype
6933
- const AsyncGenerator = AsyncGeneratorFunction.prototype;
6934
- // 25.5.1 Properties of the AsyncGenerator Prototype Object
6935
- const AsyncGeneratorPrototype = AsyncGenerator.prototype;
6936
- const AsyncIteratorPrototype = getPrototypeOf(AsyncGeneratorPrototype);
6937
-
6938
- // 25.7.1 The AsyncFunction Constructor
6939
-
6940
- // eslint-disable-next-line no-empty-function
6941
- async function AsyncFunctionInstance() {}
6942
- const AsyncFunction = getConstructorOf(AsyncFunctionInstance);
6943
-
6944
- const intrinsics = {
6945
- '%InertFunction%': InertFunction,
6946
- '%ArrayIteratorPrototype%': ArrayIteratorPrototype,
6947
- '%InertAsyncFunction%': AsyncFunction,
6948
- '%AsyncGenerator%': AsyncGenerator,
6949
- '%InertAsyncGeneratorFunction%': AsyncGeneratorFunction,
6950
- '%AsyncGeneratorPrototype%': AsyncGeneratorPrototype,
6951
- '%AsyncIteratorPrototype%': AsyncIteratorPrototype,
6952
- '%Generator%': Generator,
6953
- '%InertGeneratorFunction%': GeneratorFunction,
6954
- '%IteratorPrototype%': IteratorPrototype,
6955
- '%MapIteratorPrototype%': MapIteratorPrototype,
6956
- '%RegExpStringIteratorPrototype%': RegExpStringIteratorPrototype,
6957
- '%SetIteratorPrototype%': SetIteratorPrototype,
6958
- '%StringIteratorPrototype%': StringIteratorPrototype,
6959
- '%ThrowTypeError%': ThrowTypeError,
6960
- '%TypedArray%': TypedArray,
6961
- '%InertCompartment%': InertCompartment };
6962
-
6963
-
6964
- return intrinsics;
6965
- };$h‍_once.getAnonymousIntrinsics(getAnonymousIntrinsics);
6966
- })
6967
-
6968
- ,
6969
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let WeakSet,Error,Object,defineProperty,entries,freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors,globalThis,is,objectHasOwnProperty,values,arrayFilter,constantProperties,sharedGlobalPropertyNames,universalPropertyNames,whitelist;$h‍_imports([["./commons.js", [["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["Error", [$h‍_a => (Error = $h‍_a)]],["Object", [$h‍_a => (Object = $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)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["values", [$h‍_a => (values = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]]]],["./whitelist.js", [["constantProperties", [$h‍_a => (constantProperties = $h‍_a)]],["sharedGlobalPropertyNames", [$h‍_a => (sharedGlobalPropertyNames = $h‍_a)]],["universalPropertyNames", [$h‍_a => (universalPropertyNames = $h‍_a)]],["whitelist", [$h‍_a => (whitelist = $h‍_a)]]]]]);
6970
7374
 
6971
7375
 
6972
7376
 
@@ -7008,7 +7412,7 @@ function initProperty(obj, name, desc) {
7008
7412
  preDesc.enumerable !== desc.enumerable ||
7009
7413
  preDesc.configurable !== desc.configurable)
7010
7414
  {
7011
- throw new Error(`Conflicting definitions of ${name}`);
7415
+ throw new TypeError(`Conflicting definitions of ${name}`);
7012
7416
  }
7013
7417
  }
7014
7418
  defineProperty(obj, name, desc);
@@ -7040,68 +7444,78 @@ const makeIntrinsicsCollector = () => {
7040
7444
  const intrinsics = { __proto__: null };
7041
7445
  let pseudoNatives;
7042
7446
 
7043
- const intrinsicsCollector = {
7044
- addIntrinsics(newIntrinsics) {
7045
- initProperties(intrinsics, getOwnPropertyDescriptors(newIntrinsics));
7046
- },
7047
-
7048
- // For each intrinsic, if it has a `.prototype` property, use the
7049
- // whitelist to find out the intrinsic name for that prototype and add it
7050
- // to the intrinsics.
7051
- completePrototypes() {
7052
- for (const [name, intrinsic] of entries(intrinsics)) {
7053
- if (intrinsic !== Object(intrinsic)) {
7054
- // eslint-disable-next-line no-continue
7055
- continue;
7056
- }
7057
- if (!objectHasOwnProperty(intrinsic, 'prototype')) {
7058
- // eslint-disable-next-line no-continue
7059
- continue;
7060
- }
7061
- const permit = whitelist[name];
7062
- if (typeof permit !== 'object') {
7063
- throw new Error(`Expected permit object at whitelist.${name}`);
7064
- }
7065
- const namePrototype = permit.prototype;
7066
- if (!namePrototype) {
7067
- throw new Error(`${name}.prototype property not whitelisted`);
7068
- }
7069
- if (
7070
- typeof namePrototype !== 'string' ||
7071
- !objectHasOwnProperty(whitelist, namePrototype))
7072
- {
7073
- throw new Error(`Unrecognized ${name}.prototype whitelist entry`);
7074
- }
7075
- const intrinsicPrototype = intrinsic.prototype;
7076
- if (objectHasOwnProperty(intrinsics, namePrototype)) {
7077
- if (intrinsics[namePrototype] !== intrinsicPrototype) {
7078
- throw new Error(`Conflicting bindings of ${namePrototype}`);
7079
- }
7080
- // eslint-disable-next-line no-continue
7081
- continue;
7447
+ const addIntrinsics = (newIntrinsics) => {
7448
+ initProperties(intrinsics, getOwnPropertyDescriptors(newIntrinsics));
7449
+ };
7450
+ freeze(addIntrinsics);
7451
+
7452
+ // For each intrinsic, if it has a `.prototype` property, use the
7453
+ // whitelist to find out the intrinsic name for that prototype and add it
7454
+ // to the intrinsics.
7455
+ const completePrototypes = () => {
7456
+ for (const [name, intrinsic] of entries(intrinsics)) {
7457
+ if (!isObject(intrinsic)) {
7458
+ // eslint-disable-next-line no-continue
7459
+ continue;
7460
+ }
7461
+ if (!objectHasOwnProperty(intrinsic, 'prototype')) {
7462
+ // eslint-disable-next-line no-continue
7463
+ continue;
7464
+ }
7465
+ const permit = whitelist[name];
7466
+ if (typeof permit !== 'object') {
7467
+ throw new TypeError(`Expected permit object at whitelist.${name}`);
7468
+ }
7469
+ const namePrototype = permit.prototype;
7470
+ if (!namePrototype) {
7471
+ throw new TypeError(`${name}.prototype property not whitelisted`);
7472
+ }
7473
+ if (
7474
+ typeof namePrototype !== 'string' ||
7475
+ !objectHasOwnProperty(whitelist, namePrototype))
7476
+ {
7477
+ throw new TypeError(`Unrecognized ${name}.prototype whitelist entry`);
7478
+ }
7479
+ const intrinsicPrototype = intrinsic.prototype;
7480
+ if (objectHasOwnProperty(intrinsics, namePrototype)) {
7481
+ if (intrinsics[namePrototype] !== intrinsicPrototype) {
7482
+ throw new TypeError(`Conflicting bindings of ${namePrototype}`);
7082
7483
  }
7083
- intrinsics[namePrototype] = intrinsicPrototype;
7484
+ // eslint-disable-next-line no-continue
7485
+ continue;
7084
7486
  }
7085
- },
7086
- finalIntrinsics() {
7087
- freeze(intrinsics);
7088
- pseudoNatives = new WeakSet(arrayFilter(values(intrinsics), isFunction));
7089
- return intrinsics;
7090
- },
7091
- isPseudoNative(obj) {
7092
- if (!pseudoNatives) {
7093
- throw new Error(
7094
- 'isPseudoNative can only be called after finalIntrinsics');
7487
+ intrinsics[namePrototype] = intrinsicPrototype;
7488
+ }
7489
+ };
7490
+ freeze(completePrototypes);
7095
7491
 
7096
- }
7097
- return pseudoNatives.has(obj);
7098
- } };
7492
+ const finalIntrinsics = () => {
7493
+ freeze(intrinsics);
7494
+ pseudoNatives = new WeakSet(arrayFilter(values(intrinsics), isFunction));
7495
+ return intrinsics;
7496
+ };
7497
+ freeze(finalIntrinsics);
7099
7498
 
7499
+ const isPseudoNative = (obj) => {
7500
+ if (!pseudoNatives) {
7501
+ throw new TypeError(
7502
+ 'isPseudoNative can only be called after finalIntrinsics');
7100
7503
 
7101
- intrinsicsCollector.addIntrinsics(constantProperties);
7102
- intrinsicsCollector.addIntrinsics(
7103
- sampleGlobals(globalThis, universalPropertyNames));
7504
+ }
7505
+ return weaksetHas(pseudoNatives, obj);
7506
+ };
7507
+ freeze(isPseudoNative);
7508
+
7509
+ const intrinsicsCollector = {
7510
+ addIntrinsics,
7511
+ completePrototypes,
7512
+ finalIntrinsics,
7513
+ isPseudoNative };
7514
+
7515
+ freeze(intrinsicsCollector);
7104
7516
 
7517
+ addIntrinsics(constantProperties);
7518
+ addIntrinsics(sampleGlobals(globalThis, universalPropertyNames));
7105
7519
 
7106
7520
  return intrinsicsCollector;
7107
7521
  };
@@ -7120,13 +7534,11 @@ const makeIntrinsicsCollector = () => {
7120
7534
  * @param {Object} globalObject
7121
7535
  */$h‍_once.makeIntrinsicsCollector(makeIntrinsicsCollector);
7122
7536
  const getGlobalIntrinsics = (globalObject) => {
7123
- const intrinsicsCollector = makeIntrinsicsCollector();
7537
+ const { addIntrinsics, finalIntrinsics } = makeIntrinsicsCollector();
7124
7538
 
7125
- intrinsicsCollector.addIntrinsics(
7126
- sampleGlobals(globalObject, sharedGlobalPropertyNames));
7539
+ addIntrinsics(sampleGlobals(globalObject, sharedGlobalPropertyNames));
7127
7540
 
7128
-
7129
- return intrinsicsCollector.finalIntrinsics();
7541
+ return finalIntrinsics();
7130
7542
  };$h‍_once.getGlobalIntrinsics(getGlobalIntrinsics);
7131
7543
  })
7132
7544
 
@@ -7236,34 +7648,39 @@ const moderateEnablements = {
7236
7648
  '%ErrorPrototype%': {
7237
7649
  constructor: true, // set by "fast-json-patch", "node-fetch"
7238
7650
  message: true,
7239
- name: true, // set by "precond", "ava", "node-fetch"
7651
+ name: true, // set by "precond", "ava", "node-fetch", "node 14"
7240
7652
  toString: true // set by "bluebird"
7241
7653
  },
7242
7654
 
7243
7655
  '%TypeErrorPrototype%': {
7244
7656
  constructor: true, // set by "readable-stream"
7245
7657
  message: true, // set by "tape"
7246
- name: true // set by "readable-stream"
7658
+ name: true // set by "readable-stream", "node 14"
7247
7659
  },
7248
7660
 
7249
7661
  '%SyntaxErrorPrototype%': {
7250
- message: true // to match TypeErrorPrototype.message
7662
+ message: true, // to match TypeErrorPrototype.message
7663
+ name: true // set by "node 14"
7251
7664
  },
7252
7665
 
7253
7666
  '%RangeErrorPrototype%': {
7254
- message: true // to match TypeErrorPrototype.message
7667
+ message: true, // to match TypeErrorPrototype.message
7668
+ name: true // set by "node 14"
7255
7669
  },
7256
7670
 
7257
7671
  '%URIErrorPrototype%': {
7258
- message: true // to match TypeErrorPrototype.message
7672
+ message: true, // to match TypeErrorPrototype.message
7673
+ name: true // set by "node 14"
7259
7674
  },
7260
7675
 
7261
7676
  '%EvalErrorPrototype%': {
7262
- message: true // to match TypeErrorPrototype.message
7677
+ message: true, // to match TypeErrorPrototype.message
7678
+ name: true // set by "node 14"
7263
7679
  },
7264
7680
 
7265
7681
  '%ReferenceErrorPrototype%': {
7266
- message: true // to match TypeErrorPrototype.message
7682
+ message: true, // to match TypeErrorPrototype.message
7683
+ name: true // set by "node 14"
7267
7684
  },
7268
7685
 
7269
7686
  '%PromisePrototype%': {
@@ -7332,7 +7749,7 @@ const severeEnablements = {
7332
7749
  })
7333
7750
 
7334
7751
  ,
7335
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Set,String,TypeError,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,getOwnPropertyNames,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $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)]]]]]);
7752
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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)]]]]]);
7336
7753
 
7337
7754
 
7338
7755
 
@@ -7446,7 +7863,8 @@ overrideDebug = [])
7446
7863
  this[prop] = newValue;
7447
7864
  } else {
7448
7865
  if (isDebug) {
7449
- console.error(new Error(`Override property ${prop}`));
7866
+ // eslint-disable-next-line @endo/no-polymorphic-call
7867
+ console.error(new TypeError(`Override property ${prop}`));
7450
7868
  }
7451
7869
  defineProperty(this, prop, {
7452
7870
  value: newValue,
@@ -7482,7 +7900,7 @@ overrideDebug = [])
7482
7900
  // TypeScript does not allow symbols to be used as indexes because it
7483
7901
  // cannot recokon types of symbolized properties.
7484
7902
  // @ts-ignore
7485
- ownKeys(descs).forEach((prop) => enable(path, obj, prop, descs[prop]));
7903
+ arrayForEach(ownKeys(descs), (prop) => enable(path, obj, prop, descs[prop]));
7486
7904
  }
7487
7905
 
7488
7906
  function enableProperties(path, obj, plan) {
@@ -7528,17 +7946,149 @@ overrideDebug = [])
7528
7946
  break;
7529
7947
  }
7530
7948
  default:{
7531
- throw new Error(`unrecognized overrideTaming ${overrideTaming}`);
7949
+ throw new TypeError(`unrecognized overrideTaming ${overrideTaming}`);
7532
7950
  }}
7533
7951
 
7534
7952
 
7535
- // Do the repair.
7536
- enableProperties('root', intrinsics, plan);
7537
- }$h‍_once.default(enablePropertyOverrides);
7953
+ // Do the repair.
7954
+ enableProperties('root', intrinsics, plan);
7955
+ }$h‍_once.default(enablePropertyOverrides);
7956
+ })
7957
+
7958
+ ,
7959
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let arrayPush,arraySlice,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
7960
+
7961
+
7962
+
7963
+
7964
+
7965
+
7966
+ const { details: X, quote: q } = assert;
7967
+
7968
+ /**
7969
+ * JavaScript module semantics resists attempts to parameterize a module's
7970
+ * initialization behavior. A module initializes in order according to
7971
+ * the path by which it is first imported, and then the initialized module
7972
+ * is reused by all the other times it is imported. Compartments give us
7973
+ * the opportunity to bind the same import name to different imported
7974
+ * modules, depending on the package/compartment doing the import. Compartments
7975
+ * also address the difficulty of parameterizing a module's initialization
7976
+ * logic, but not in a pleasant manner.
7977
+ *
7978
+ * A pleasant parameterization would be for a static module to be function-like
7979
+ * with explicit parameters, and for the parameterization to be like
7980
+ * calling the static module with parameters in order to derive from it a
7981
+ * module instance. Compartments instead lets us parameterize the meaning
7982
+ * of a module instance derived from a static module according to the
7983
+ * three namespaces provided by the JavaScript semantics, affecting the
7984
+ * meaning of a module instance.
7985
+ * * The global variable namespaces.
7986
+ * * The global scope, aliased to properties of the global object.
7987
+ * This is necessarily compartment-wide, and therefore in our
7988
+ * recommened usage pattern, package-wide.
7989
+ * * The global lexical scope. The SES-shim compartments support
7990
+ * these both compartment-wide as well as per-module. But it is
7991
+ * not yet clear what we will propose in the Compartment proposal.
7992
+ * * The import namespace.
7993
+ * * The host hooks.
7994
+ *
7995
+ * This `environment-options.js` module looks for a setting of an
7996
+ * `optionName` parameter rooted in the global scope. If follows the Node
7997
+ * precedent for finding Unix environment variable settings, looking for a
7998
+ * global `process` object holding an `env` object,
7999
+ * optionally holding a property named for the `optionName` whose value is the
8000
+ * configuration setting of that option. For example, for the optionName
8001
+ * `ALLOW_IMPLICIT_REMOTABLES` it would look in
8002
+ * `globalThis.process.env.ALLOW_IMPLICIT_REMOTABLES`.
8003
+ *
8004
+ * If setting is either absent or `undefined`, that indicates that
8005
+ * this configuration option should have its default behavior, whatever that is.
8006
+ * Otherwise, reflecting Unix environment variables, the setting must be a
8007
+ * string. This also helps ensure that this channel is used only to pass data,
8008
+ * not authority beyond the ability to read this global state.
8009
+ */
8010
+
8011
+ /**
8012
+ * makeEnvironmentCaptor provides a mechanism for getting environment
8013
+ * variables, if they are needed, and a way to catalog the names of all
8014
+ * the environment variables that were captured.
8015
+ *
8016
+ * @param {Object} aGlobal
8017
+ */
8018
+ const makeEnvironmentCaptor = (aGlobal) => {
8019
+ const capturedEnvironmentOptionNames = [];
8020
+
8021
+ /**
8022
+ * Gets an environment option by name and returns the option value or the
8023
+ * given default.
8024
+ *
8025
+ * @param {string} optionName
8026
+ * @param {string} defaultSetting
8027
+ * @returns {string}
8028
+ */
8029
+ const getEnvironmentOption = (optionName, defaultSetting) => {
8030
+ // eslint-disable-next-line @endo/no-polymorphic-call
8031
+ assert.typeof(
8032
+ optionName,
8033
+ 'string',
8034
+ X`Environment option name ${q(optionName)} must be a string.`);
8035
+
8036
+ // eslint-disable-next-line @endo/no-polymorphic-call
8037
+ assert.typeof(
8038
+ defaultSetting,
8039
+ 'string',
8040
+ X`Environment option default setting ${q(
8041
+ defaultSetting)
8042
+ } must be a string.`);
8043
+
8044
+
8045
+ /** @type {string} */
8046
+ let setting = defaultSetting;
8047
+ const globalProcess = aGlobal.process;
8048
+ if (globalProcess && typeof globalProcess === 'object') {
8049
+ const globalEnv = globalProcess.env;
8050
+ if (globalEnv && typeof globalEnv === 'object') {
8051
+ if (optionName in globalEnv) {
8052
+ arrayPush(capturedEnvironmentOptionNames, optionName);
8053
+ const optionValue = globalEnv[optionName];
8054
+ // eslint-disable-next-line @endo/no-polymorphic-call
8055
+ assert.typeof(
8056
+ optionValue,
8057
+ 'string',
8058
+ X`Environment option named ${q(
8059
+ optionName)
8060
+ }, if present, must have a corresponding string value, got ${q(
8061
+ optionValue)
8062
+ }`);
8063
+
8064
+ setting = optionValue;
8065
+ }
8066
+ }
8067
+ }
8068
+ assert(
8069
+ setting === undefined || typeof setting === 'string',
8070
+ X`Environment option value ${q(setting)}, if present, must be a string.`);
8071
+
8072
+ return setting;
8073
+ };
8074
+ freeze(getEnvironmentOption);
8075
+
8076
+ const getCapturedEnvironmentOptionNames = () => {
8077
+ return freeze(arraySlice(capturedEnvironmentOptionNames));
8078
+ };
8079
+ freeze(getCapturedEnvironmentOptionNames);
8080
+
8081
+ return { getEnvironmentOption, getCapturedEnvironmentOptionNames };
8082
+ };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
8083
+ freeze(makeEnvironmentCaptor);
7538
8084
  })
7539
8085
 
7540
8086
  ,
7541
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,WeakSet,defineProperty,freeze,fromEntries,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
8087
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { 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", []]]);
8088
+
8089
+
8090
+
8091
+
7542
8092
 
7543
8093
 
7544
8094
 
@@ -7661,6 +8211,7 @@ loggedErrorHandler,
7661
8211
  { shouldResetForDebugging = false } = {}) =>
7662
8212
  {
7663
8213
  if (shouldResetForDebugging) {
8214
+ // eslint-disable-next-line @endo/no-polymorphic-call
7664
8215
  loggedErrorHandler.resetErrorTagNum();
7665
8216
  }
7666
8217
 
@@ -7668,7 +8219,7 @@ loggedErrorHandler,
7668
8219
  let logArray = [];
7669
8220
 
7670
8221
  const loggingConsole = fromEntries(
7671
- consoleWhitelist.map(([name, _]) => {
8222
+ arrayMap(consoleWhitelist, ([name, _]) => {
7672
8223
  // Use an arrow function so that it doesn't come with its own name in
7673
8224
  // its printed form. Instead, we're hoping that tooling uses only
7674
8225
  // the `.name` property set below.
@@ -7676,7 +8227,7 @@ loggedErrorHandler,
7676
8227
  * @param {...any} args
7677
8228
  */
7678
8229
  const method = (...args) => {
7679
- logArray.push([name, ...args]);
8230
+ arrayPush(logArray, [name, ...args]);
7680
8231
  };
7681
8232
  defineProperty(method, 'name', { value: name });
7682
8233
  return [name, freeze(method)];
@@ -7731,9 +8282,9 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7731
8282
  * @returns {any}
7732
8283
  */
7733
8284
  const extractErrorArgs = (logArgs, subErrorsSink) => {
7734
- const argTags = logArgs.map((arg) => {
7735
- if (arg instanceof Error) {
7736
- subErrorsSink.push(arg);
8285
+ const argTags = arrayMap(logArgs, (arg) => {
8286
+ if (isError(arg)) {
8287
+ arrayPush(subErrorsSink, arg);
7737
8288
  return `(${tagError(arg)})`;
7738
8289
  }
7739
8290
  return arg;
@@ -7752,6 +8303,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7752
8303
  const errorName =
7753
8304
  kind === ErrorInfo.MESSAGE ? `${errorTag}:` : `${errorTag} ${kind}`;
7754
8305
  const argTags = extractErrorArgs(logArgs, subErrorsSink);
8306
+ // eslint-disable-next-line @endo/no-polymorphic-call
7755
8307
  baseConsole[BASE_CONSOLE_LEVEL](errorName, ...argTags);
7756
8308
  };
7757
8309
 
@@ -7780,6 +8332,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7780
8332
  if (optTag !== undefined) {
7781
8333
  label = `${label} under ${optTag}`;
7782
8334
  }
8335
+ // eslint-disable-next-line @endo/no-polymorphic-call
7783
8336
  baseConsole.group(label);
7784
8337
  try {
7785
8338
  for (const subError of subErrors) {
@@ -7787,6 +8340,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7787
8340
  logError(subError);
7788
8341
  }
7789
8342
  } finally {
8343
+ // eslint-disable-next-line @endo/no-polymorphic-call
7790
8344
  baseConsole.groupEnd();
7791
8345
  }
7792
8346
  };
@@ -7818,6 +8372,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7818
8372
  if (messageLogArgs === undefined) {
7819
8373
  // If there is no message log args, then just show the message that
7820
8374
  // the error itself carries.
8375
+ // eslint-disable-next-line @endo/no-polymorphic-call
7821
8376
  baseConsole[BASE_CONSOLE_LEVEL](`${errorTag}:`, error.message);
7822
8377
  } else {
7823
8378
  // If there is one, we take it to be strictly more informative than the
@@ -7829,10 +8384,11 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7829
8384
  if (
7830
8385
  typeof stackString === 'string' &&
7831
8386
  stackString.length >= 1 &&
7832
- !stackString.endsWith('\n'))
8387
+ !stringEndsWith(stackString, '\n'))
7833
8388
  {
7834
8389
  stackString += '\n';
7835
8390
  }
8391
+ // eslint-disable-next-line @endo/no-polymorphic-call
7836
8392
  baseConsole[BASE_CONSOLE_LEVEL](stackString);
7837
8393
  // Show the other annotations on error
7838
8394
  for (const noteLogArgs of noteLogArgsArray) {
@@ -7842,7 +8398,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7842
8398
  logSubErrors(subErrors, errorTag);
7843
8399
  };
7844
8400
 
7845
- const levelMethods = consoleLevelMethods.map(([level, _]) => {
8401
+ const levelMethods = arrayMap(consoleLevelMethods, ([level, _]) => {
7846
8402
  /**
7847
8403
  * @param {...any} logArgs
7848
8404
  */
@@ -7850,21 +8406,24 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7850
8406
  const subErrors = [];
7851
8407
  const argTags = extractErrorArgs(logArgs, subErrors);
7852
8408
  // @ts-ignore
8409
+ // eslint-disable-next-line @endo/no-polymorphic-call
7853
8410
  baseConsole[level](...argTags);
7854
8411
  logSubErrors(subErrors);
7855
8412
  };
7856
8413
  defineProperty(levelMethod, 'name', { value: level });
7857
8414
  return [level, freeze(levelMethod)];
7858
8415
  });
7859
- const otherMethodNames = consoleOtherMethods.filter(
8416
+ const otherMethodNames = arrayFilter(
8417
+ consoleOtherMethods,
7860
8418
  ([name, _]) => name in baseConsole);
7861
8419
 
7862
- const otherMethods = otherMethodNames.map(([name, _]) => {
8420
+ const otherMethods = arrayMap(otherMethodNames, ([name, _]) => {
7863
8421
  /**
7864
8422
  * @param {...any} args
7865
8423
  */
7866
8424
  const otherMethod = (...args) => {
7867
8425
  // @ts-ignore
8426
+ // eslint-disable-next-line @endo/no-polymorphic-call
7868
8427
  baseConsole[name](...args);
7869
8428
  return undefined;
7870
8429
  };
@@ -7873,7 +8432,7 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
7873
8432
  });
7874
8433
 
7875
8434
  const causalConsole = fromEntries([...levelMethods, ...otherMethods]);
7876
- return freeze(causalConsole);
8435
+ return (/** @type {VirtualConsole} */freeze(causalConsole));
7877
8436
  };$h‍_once.makeCausalConsole(makeCausalConsole);
7878
8437
  freeze(makeCausalConsole);
7879
8438
 
@@ -7883,27 +8442,32 @@ freeze(makeCausalConsole);
7883
8442
  /** @type {FilterConsole} */
7884
8443
  const filterConsole = (baseConsole, filter, _topic = undefined) => {
7885
8444
  // TODO do something with optional topic string
7886
- const whilelist = consoleWhitelist.filter(([name, _]) => name in baseConsole);
7887
- const methods = whilelist.map(([name, severity]) => {
8445
+ const whitelist = arrayFilter(
8446
+ consoleWhitelist,
8447
+ ([name, _]) => name in baseConsole);
8448
+
8449
+ const methods = arrayMap(whitelist, ([name, severity]) => {
7888
8450
  /**
7889
8451
  * @param {...any} args
7890
8452
  */
7891
8453
  const method = (...args) => {
8454
+ // eslint-disable-next-line @endo/no-polymorphic-call
7892
8455
  if (severity === undefined || filter.canLog(severity)) {
7893
8456
  // @ts-ignore
8457
+ // eslint-disable-next-line @endo/no-polymorphic-call
7894
8458
  baseConsole[name](...args);
7895
8459
  }
7896
8460
  };
7897
8461
  return [name, freeze(method)];
7898
8462
  });
7899
8463
  const filteringConsole = fromEntries(methods);
7900
- return freeze(filteringConsole);
8464
+ return (/** @type {VirtualConsole} */freeze(filteringConsole));
7901
8465
  };$h‍_once.filterConsole(filterConsole);
7902
8466
  freeze(filterConsole);
7903
8467
  })
7904
8468
 
7905
8469
  ,
7906
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,globalThis,defaultHandler,makeCausalConsole;$h‍_imports([["../commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
8470
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,globalThis,defaultHandler,makeCausalConsole;$h‍_imports([["../commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./assert.js", [["loggedErrorHandler", [$h‍_a => (defaultHandler = $h‍_a)]]]],["./console.js", [["makeCausalConsole", [$h‍_a => (makeCausalConsole = $h‍_a)]]]],["./types.js", []],["./internal-types.js", []]]);
7907
8471
 
7908
8472
 
7909
8473
 
@@ -7911,6 +8475,7 @@ freeze(filterConsole);
7911
8475
 
7912
8476
 
7913
8477
 
8478
+ // eslint-disable-next-line no-restricted-globals
7914
8479
  const originalConsole = console;
7915
8480
 
7916
8481
  /**
@@ -7929,7 +8494,7 @@ errorTrapping = 'platform',
7929
8494
  optGetStackString = undefined) =>
7930
8495
  {
7931
8496
  if (consoleTaming !== 'safe' && consoleTaming !== 'unsafe') {
7932
- throw new Error(`unrecognized consoleTaming ${consoleTaming}`);
8497
+ throw new TypeError(`unrecognized consoleTaming ${consoleTaming}`);
7933
8498
  }
7934
8499
 
7935
8500
  if (consoleTaming === 'unsafe') {
@@ -7959,11 +8524,16 @@ optGetStackString = undefined) =>
7959
8524
 
7960
8525
  // Node.js
7961
8526
  if (errorTrapping !== 'none' && globalThis.process !== undefined) {
8527
+ // eslint-disable-next-line @endo/no-polymorphic-call
7962
8528
  globalThis.process.on('uncaughtException', (error) => {
8529
+ // causalConsole is born frozen so not vulnerable to method tampering.
8530
+ // eslint-disable-next-line @endo/no-polymorphic-call
7963
8531
  causalConsole.error(error);
7964
8532
  if (errorTrapping === 'platform' || errorTrapping === 'exit') {
8533
+ // eslint-disable-next-line @endo/no-polymorphic-call
7965
8534
  globalThis.process.exit(globalThis.process.exitCode || -1);
7966
8535
  } else if (errorTrapping === 'abort') {
8536
+ // eslint-disable-next-line @endo/no-polymorphic-call
7967
8537
  globalThis.process.abort();
7968
8538
  }
7969
8539
  });
@@ -7971,9 +8541,13 @@ optGetStackString = undefined) =>
7971
8541
 
7972
8542
  // Browser
7973
8543
  if (errorTrapping !== 'none' && globalThis.window !== undefined) {
8544
+ // eslint-disable-next-line @endo/no-polymorphic-call
7974
8545
  globalThis.window.addEventListener('error', (event) => {
8546
+ // eslint-disable-next-line @endo/no-polymorphic-call
7975
8547
  event.preventDefault();
8548
+ // eslint-disable-next-line @endo/no-polymorphic-call
7976
8549
  const stackString = loggedErrorHandler.getStackString(event.error);
8550
+ // eslint-disable-next-line @endo/no-polymorphic-call
7977
8551
  causalConsole.error(stackString);
7978
8552
  if (errorTrapping === 'exit' || errorTrapping === 'abort') {
7979
8553
  globalThis.window.location.href = `about:blank`;
@@ -7986,7 +8560,14 @@ optGetStackString = undefined) =>
7986
8560
  })
7987
8561
 
7988
8562
  ,
7989
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let WeakMap,WeakSet,weaksetHas,weaksetAdd,weakmapSet,weakmapGet,weakmapHas,create,defineProperties,fromEntries,reflectSet;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $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)]]]]]);
8563
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapHas,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
8564
+
8565
+
8566
+
8567
+
8568
+
8569
+
8570
+
7990
8571
 
7991
8572
 
7992
8573
 
@@ -8032,12 +8613,15 @@ const safeV8CallSiteMethodNames = [
8032
8613
  // TODO this is a ridiculously expensive way to attenuate callsites.
8033
8614
  // Before that matters, we should switch to a reasonable representation.
8034
8615
  const safeV8CallSiteFacet = (callSite) => {
8035
- const methodEntry = (name) => [name, () => callSite[name]()];
8036
- const o = fromEntries(safeV8CallSiteMethodNames.map(methodEntry));
8616
+ const methodEntry = (name) => {
8617
+ const method = callSite[name];
8618
+ return [name, () => apply(method, callSite, [])];
8619
+ };
8620
+ const o = fromEntries(arrayMap(safeV8CallSiteMethodNames, methodEntry));
8037
8621
  return create(o, {});
8038
8622
  };
8039
8623
 
8040
- const safeV8SST = (sst) => sst.map(safeV8CallSiteFacet);
8624
+ const safeV8SST = (sst) => arrayMap(sst, safeV8CallSiteFacet);
8041
8625
 
8042
8626
  // If it has `/node_modules/` anywhere in it, on Node it is likely
8043
8627
  // to be a dependent package of the current package, and so to
@@ -8081,7 +8665,7 @@ const filterFileName = (fileName) => {
8081
8665
  return true;
8082
8666
  }
8083
8667
  for (const filter of FILENAME_CENSORS) {
8084
- if (filter.test(fileName)) {
8668
+ if (regexpTest(filter, fileName)) {
8085
8669
  return false;
8086
8670
  }
8087
8671
  }
@@ -8129,9 +8713,9 @@ CALLSITE_PACKAGES_PATTERN];
8129
8713
  // TODO Move so that it applies not just to v8.
8130
8714
  const shortenCallSiteString = (callSiteString) => {
8131
8715
  for (const filter of CALLSITE_PATTERNS) {
8132
- const match = filter.exec(callSiteString);
8716
+ const match = regexpExec(filter, callSiteString);
8133
8717
  if (match) {
8134
- return match.slice(1).join('');
8718
+ return arrayJoin(arraySlice(match, 1), '');
8135
8719
  }
8136
8720
  }
8137
8721
  return callSiteString;
@@ -8143,11 +8727,14 @@ InitialError,
8143
8727
  errorTaming,
8144
8728
  stackFiltering) =>
8145
8729
  {
8730
+ const originalCaptureStackTrace = OriginalError.captureStackTrace;
8731
+
8146
8732
  // const callSiteFilter = _callSite => true;
8147
8733
  const callSiteFilter = (callSite) => {
8148
8734
  if (stackFiltering === 'verbose') {
8149
8735
  return true;
8150
8736
  }
8737
+ // eslint-disable-next-line @endo/no-polymorphic-call
8151
8738
  return filterFileName(callSite.getFileName());
8152
8739
  };
8153
8740
 
@@ -8160,7 +8747,10 @@ stackFiltering) =>
8160
8747
  };
8161
8748
 
8162
8749
  const stackStringFromSST = (_error, sst) =>
8163
- [...sst.filter(callSiteFilter).map(callSiteStringifier)].join('');
8750
+ arrayJoin(
8751
+ arrayMap(arrayFilter(sst, callSiteFilter), callSiteStringifier),
8752
+ '');
8753
+
8164
8754
 
8165
8755
  // Mapping from error instance to the structured stack trace capturing the
8166
8756
  // stack for that instance.
@@ -8174,9 +8764,9 @@ stackFiltering) =>
8174
8764
  // but instead calls the real one, if no other cutoff is provided,
8175
8765
  // we cut this one off.
8176
8766
  captureStackTrace(error, optFn = tamedMethods.captureStackTrace) {
8177
- if (typeof OriginalError.captureStackTrace === 'function') {
8767
+ if (typeof originalCaptureStackTrace === 'function') {
8178
8768
  // OriginalError.captureStackTrace is only on v8
8179
- OriginalError.captureStackTrace(error, optFn);
8769
+ apply(originalCaptureStackTrace, OriginalError, [error, optFn]);
8180
8770
  return;
8181
8771
  }
8182
8772
  reflectSet(error, 'stack', '');
@@ -8276,7 +8866,8 @@ stackFiltering) =>
8276
8866
  })
8277
8867
 
8278
8868
  ,
8279
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,NativeErrors,tameV8ErrorConstructor;$h‍_imports([["../commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]]]],["../whitelist.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]);
8869
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_ERROR,TypeError,apply,construct,defineProperties,setPrototypeOf,getOwnPropertyDescriptor,NativeErrors,tameV8ErrorConstructor;$h‍_imports([["../commons.js", [["FERAL_ERROR", [$h‍_a => (FERAL_ERROR = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]]]],["../whitelist.js", [["NativeErrors", [$h‍_a => (NativeErrors = $h‍_a)]]]],["./tame-v8-error-constructor.js", [["tameV8ErrorConstructor", [$h‍_a => (tameV8ErrorConstructor = $h‍_a)]]]]]);
8870
+
8280
8871
 
8281
8872
 
8282
8873
 
@@ -8289,7 +8880,7 @@ stackFiltering) =>
8289
8880
 
8290
8881
  // Present on at least FF. Proposed by Error-proposal. Not on SES whitelist
8291
8882
  // so grab it before it is removed.
8292
- const stackDesc = getOwnPropertyDescriptor(Error.prototype, 'stack');
8883
+ const stackDesc = getOwnPropertyDescriptor(FERAL_ERROR.prototype, 'stack');
8293
8884
  const stackGetter = stackDesc && stackDesc.get;
8294
8885
 
8295
8886
  // Use concise methods to obtain named functions without constructors.
@@ -8310,29 +8901,29 @@ errorTaming = 'safe',
8310
8901
  stackFiltering = 'concise')
8311
8902
  {
8312
8903
  if (errorTaming !== 'safe' && errorTaming !== 'unsafe') {
8313
- throw new Error(`unrecognized errorTaming ${errorTaming}`);
8904
+ throw new TypeError(`unrecognized errorTaming ${errorTaming}`);
8314
8905
  }
8315
8906
  if (stackFiltering !== 'concise' && stackFiltering !== 'verbose') {
8316
- throw new Error(`unrecognized stackFiltering ${stackFiltering}`);
8907
+ throw new TypeError(`unrecognized stackFiltering ${stackFiltering}`);
8317
8908
  }
8318
- const OriginalError = Error;
8319
- const ErrorPrototype = OriginalError.prototype;
8909
+ const ErrorPrototype = FERAL_ERROR.prototype;
8320
8910
 
8321
8911
  const platform =
8322
- typeof OriginalError.captureStackTrace === 'function' ? 'v8' : 'unknown';
8912
+ typeof FERAL_ERROR.captureStackTrace === 'function' ? 'v8' : 'unknown';
8913
+ const { captureStackTrace: originalCaptureStackTrace } = FERAL_ERROR;
8323
8914
 
8324
8915
  const makeErrorConstructor = (_ = {}) => {
8325
8916
  // eslint-disable-next-line no-shadow
8326
8917
  const ResultError = function Error(...rest) {
8327
8918
  let error;
8328
8919
  if (new.target === undefined) {
8329
- error = apply(OriginalError, this, rest);
8920
+ error = apply(FERAL_ERROR, this, rest);
8330
8921
  } else {
8331
- error = construct(OriginalError, rest, new.target);
8922
+ error = construct(FERAL_ERROR, rest, new.target);
8332
8923
  }
8333
8924
  if (platform === 'v8') {
8334
8925
  // TODO Likely expensive!
8335
- OriginalError.captureStackTrace(error, ResultError);
8926
+ apply(originalCaptureStackTrace, FERAL_ERROR, [error, ResultError]);
8336
8927
  }
8337
8928
  return error;
8338
8929
  };
@@ -8377,9 +8968,9 @@ stackFiltering = 'concise')
8377
8968
  defineProperties(InitialError, {
8378
8969
  stackTraceLimit: {
8379
8970
  get() {
8380
- if (typeof OriginalError.stackTraceLimit === 'number') {
8381
- // OriginalError.stackTraceLimit is only on v8
8382
- return OriginalError.stackTraceLimit;
8971
+ if (typeof FERAL_ERROR.stackTraceLimit === 'number') {
8972
+ // FERAL_ERROR.stackTraceLimit is only on v8
8973
+ return FERAL_ERROR.stackTraceLimit;
8383
8974
  }
8384
8975
  return undefined;
8385
8976
  },
@@ -8391,9 +8982,9 @@ stackFiltering = 'concise')
8391
8982
  // harmless seems the safer option.
8392
8983
  return;
8393
8984
  }
8394
- if (typeof OriginalError.stackTraceLimit === 'number') {
8395
- // OriginalError.stackTraceLimit is only on v8
8396
- OriginalError.stackTraceLimit = newLimit;
8985
+ if (typeof FERAL_ERROR.stackTraceLimit === 'number') {
8986
+ // FERAL_ERROR.stackTraceLimit is only on v8
8987
+ FERAL_ERROR.stackTraceLimit = newLimit;
8397
8988
  // We place the useless return on the next line to ensure
8398
8989
  // that anything we place after the if in the future only
8399
8990
  // happens if the then-case does not.
@@ -8426,7 +9017,7 @@ stackFiltering = 'concise')
8426
9017
  let initialGetStackString = tamedMethods.getStackString;
8427
9018
  if (platform === 'v8') {
8428
9019
  initialGetStackString = tameV8ErrorConstructor(
8429
- OriginalError,
9020
+ FERAL_ERROR,
8430
9021
  InitialError,
8431
9022
  errorTaming,
8432
9023
  stackFiltering);
@@ -8440,6 +9031,147 @@ stackFiltering = 'concise')
8440
9031
  }$h‍_once.default(tameErrorConstructor);
8441
9032
  })
8442
9033
 
9034
+ ,
9035
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,Float32Array,Map,Set,String,getOwnPropertyDescriptor,getPrototypeOf,iterateArray,iterateMap,iterateSet,iterateString,matchAllRegExp,matchAllSymbol,regexpPrototype,InertCompartment;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["Float32Array", [$h‍_a => (Float32Array = $h‍_a)]],["Map", [$h‍_a => (Map = $h‍_a)]],["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["iterateArray", [$h‍_a => (iterateArray = $h‍_a)]],["iterateMap", [$h‍_a => (iterateMap = $h‍_a)]],["iterateSet", [$h‍_a => (iterateSet = $h‍_a)]],["iterateString", [$h‍_a => (iterateString = $h‍_a)]],["matchAllRegExp", [$h‍_a => (matchAllRegExp = $h‍_a)]],["matchAllSymbol", [$h‍_a => (matchAllSymbol = $h‍_a)]],["regexpPrototype", [$h‍_a => (regexpPrototype = $h‍_a)]]]],["./compartment-shim.js", [["InertCompartment", [$h‍_a => (InertCompartment = $h‍_a)]]]]]);
9036
+
9037
+
9038
+
9039
+
9040
+
9041
+
9042
+
9043
+
9044
+
9045
+
9046
+
9047
+
9048
+
9049
+
9050
+
9051
+
9052
+
9053
+ /**
9054
+ * Object.getConstructorOf()
9055
+ * Helper function to improve readability, similar to Object.getPrototypeOf().
9056
+ *
9057
+ * @param {Object} obj
9058
+ */
9059
+ function getConstructorOf(obj) {
9060
+ return getPrototypeOf(obj).constructor;
9061
+ }
9062
+
9063
+ // getAnonymousIntrinsics uses a utility function to construct an arguments
9064
+ // object, since it cannot have one of its own and also be a const export.
9065
+ function makeArguments() {
9066
+ // eslint-disable-next-line prefer-rest-params
9067
+ return arguments;
9068
+ }
9069
+
9070
+ /**
9071
+ * getAnonymousIntrinsics()
9072
+ * Get the intrinsics not otherwise reachable by named own property
9073
+ * traversal from the global object.
9074
+ *
9075
+ * @returns {Object}
9076
+ */
9077
+ const getAnonymousIntrinsics = () => {
9078
+ const InertFunction = FERAL_FUNCTION.prototype.constructor;
9079
+
9080
+ // 9.2.4.1 %ThrowTypeError%
9081
+
9082
+ const ThrowTypeError = getOwnPropertyDescriptor(makeArguments(), 'callee').
9083
+ get;
9084
+
9085
+ // 21.1.5.2 The %StringIteratorPrototype% Object
9086
+
9087
+ // eslint-disable-next-line no-new-wrappers
9088
+ const StringIteratorObject = iterateString(new String());
9089
+ const StringIteratorPrototype = getPrototypeOf(StringIteratorObject);
9090
+
9091
+ // 21.2.7.1 The %RegExpStringIteratorPrototype% Object
9092
+ const RegExpStringIterator =
9093
+ regexpPrototype[matchAllSymbol] && matchAllRegExp(/./);
9094
+ const RegExpStringIteratorPrototype =
9095
+ RegExpStringIterator && getPrototypeOf(RegExpStringIterator);
9096
+
9097
+ // 22.1.5.2 The %ArrayIteratorPrototype% Object
9098
+
9099
+ // eslint-disable-next-line no-array-constructor
9100
+ const ArrayIteratorObject = iterateArray([]);
9101
+ const ArrayIteratorPrototype = getPrototypeOf(ArrayIteratorObject);
9102
+
9103
+ // 22.2.1 The %TypedArray% Intrinsic Object
9104
+
9105
+ const TypedArray = getPrototypeOf(Float32Array);
9106
+
9107
+ // 23.1.5.2 The %MapIteratorPrototype% Object
9108
+
9109
+ const MapIteratorObject = iterateMap(new Map());
9110
+ const MapIteratorPrototype = getPrototypeOf(MapIteratorObject);
9111
+
9112
+ // 23.2.5.2 The %SetIteratorPrototype% Object
9113
+
9114
+ const SetIteratorObject = iterateSet(new Set());
9115
+ const SetIteratorPrototype = getPrototypeOf(SetIteratorObject);
9116
+
9117
+ // 25.1.2 The %IteratorPrototype% Object
9118
+
9119
+ const IteratorPrototype = getPrototypeOf(ArrayIteratorPrototype);
9120
+
9121
+ // 25.2.1 The GeneratorFunction Constructor
9122
+
9123
+ // eslint-disable-next-line no-empty-function
9124
+ function* GeneratorFunctionInstance() {}
9125
+ const GeneratorFunction = getConstructorOf(GeneratorFunctionInstance);
9126
+
9127
+ // 25.2.3 Properties of the GeneratorFunction Prototype Object
9128
+
9129
+ const Generator = GeneratorFunction.prototype;
9130
+
9131
+ // 25.3.1 The AsyncGeneratorFunction Constructor
9132
+
9133
+ // eslint-disable-next-line no-empty-function
9134
+ async function* AsyncGeneratorFunctionInstance() {}
9135
+ const AsyncGeneratorFunction = getConstructorOf(
9136
+ AsyncGeneratorFunctionInstance);
9137
+
9138
+
9139
+ // 25.3.2.2 AsyncGeneratorFunction.prototype
9140
+ const AsyncGenerator = AsyncGeneratorFunction.prototype;
9141
+ // 25.5.1 Properties of the AsyncGenerator Prototype Object
9142
+ const AsyncGeneratorPrototype = AsyncGenerator.prototype;
9143
+ const AsyncIteratorPrototype = getPrototypeOf(AsyncGeneratorPrototype);
9144
+
9145
+ // 25.7.1 The AsyncFunction Constructor
9146
+
9147
+ // eslint-disable-next-line no-empty-function
9148
+ async function AsyncFunctionInstance() {}
9149
+ const AsyncFunction = getConstructorOf(AsyncFunctionInstance);
9150
+
9151
+ const intrinsics = {
9152
+ '%InertFunction%': InertFunction,
9153
+ '%ArrayIteratorPrototype%': ArrayIteratorPrototype,
9154
+ '%InertAsyncFunction%': AsyncFunction,
9155
+ '%AsyncGenerator%': AsyncGenerator,
9156
+ '%InertAsyncGeneratorFunction%': AsyncGeneratorFunction,
9157
+ '%AsyncGeneratorPrototype%': AsyncGeneratorPrototype,
9158
+ '%AsyncIteratorPrototype%': AsyncIteratorPrototype,
9159
+ '%Generator%': Generator,
9160
+ '%InertGeneratorFunction%': GeneratorFunction,
9161
+ '%IteratorPrototype%': IteratorPrototype,
9162
+ '%MapIteratorPrototype%': MapIteratorPrototype,
9163
+ '%RegExpStringIteratorPrototype%': RegExpStringIteratorPrototype,
9164
+ '%SetIteratorPrototype%': SetIteratorPrototype,
9165
+ '%StringIteratorPrototype%': StringIteratorPrototype,
9166
+ '%ThrowTypeError%': ThrowTypeError,
9167
+ '%TypedArray%': TypedArray,
9168
+ '%InertCompartment%': InertCompartment };
9169
+
9170
+
9171
+ return intrinsics;
9172
+ };$h‍_once.getAnonymousIntrinsics(getAnonymousIntrinsics);
9173
+ })
9174
+
8443
9175
  ,
8444
9176
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Set,String,TypeError,WeakMap,WeakSet,arrayForEach,freeze,getOwnPropertyDescriptors,getPrototypeOf,isObject,objectHasOwnProperty,ownKeys,setAdd,setForEach,setHas,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$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)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setAdd", [$h‍_a => (setAdd = $h‍_a)]],["setForEach", [$h‍_a => (setForEach = $h‍_a)]],["setHas", [$h‍_a => (setHas = $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)]]]]]);
8445
9177
 
@@ -8605,13 +9337,19 @@ const makeHardener = () => {
8605
9337
  })
8606
9338
 
8607
9339
  ,
8608
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Date,apply,construct,defineProperties;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Date", [$h‍_a => (Date = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]]]]]);
9340
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Date,TypeError,apply,construct,defineProperties;$h‍_imports([["./commons.js", [["Date", [$h‍_a => (Date = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]]]]]);
9341
+
9342
+
9343
+
9344
+
9345
+
9346
+
8609
9347
 
8610
9348
 
8611
9349
 
8612
9350
  function tameDateConstructor(dateTaming = 'safe') {
8613
9351
  if (dateTaming !== 'safe' && dateTaming !== 'unsafe') {
8614
- throw new Error(`unrecognized dateTaming ${dateTaming}`);
9352
+ throw new TypeError(`unrecognized dateTaming ${dateTaming}`);
8615
9353
  }
8616
9354
  const OriginalDate = Date;
8617
9355
  const DatePrototype = OriginalDate.prototype;
@@ -8715,6 +9453,55 @@ function tameDateConstructor(dateTaming = 'safe') {
8715
9453
  }$h‍_once.default(tameDateConstructor);
8716
9454
  })
8717
9455
 
9456
+ ,
9457
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,globalThis,getOwnPropertyDescriptor,defineProperty;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]]]);Object.defineProperty(tameDomains, 'name', {value: "tameDomains"});$h‍_once.tameDomains(tameDomains);
9458
+
9459
+
9460
+
9461
+
9462
+
9463
+
9464
+
9465
+
9466
+ function tameDomains(domainTaming = 'safe') {
9467
+ if (domainTaming !== 'safe' && domainTaming !== 'unsafe') {
9468
+ throw new TypeError(`unrecognized domainTaming ${domainTaming}`);
9469
+ }
9470
+
9471
+ if (domainTaming === 'unsafe') {
9472
+ return;
9473
+ }
9474
+
9475
+ // Protect against the hazard presented by Node.js domains.
9476
+ if (typeof globalThis.process === 'object' && globalThis.process !== null) {
9477
+ // Check whether domains were initialized.
9478
+ const domainDescriptor = getOwnPropertyDescriptor(
9479
+ globalThis.process,
9480
+ 'domain');
9481
+
9482
+ if (domainDescriptor !== undefined && domainDescriptor.get !== undefined) {
9483
+ // The domain descriptor on Node.js initially has value: null, which
9484
+ // becomes a get, set pair after domains initialize.
9485
+ throw new TypeError(
9486
+ `SES failed to lockdown, Node.js domains have been initialized (SES_NO_DOMAINS)`);
9487
+
9488
+ }
9489
+ // Prevent domains from initializing.
9490
+ // This is clunky because the exception thrown from the domains package does
9491
+ // not direct the user's gaze toward a knowledge base about the problem.
9492
+ // The domain module merely throws an exception when it attempts to define
9493
+ // the domain property of the process global during its initialization.
9494
+ // We have no better recourse because Node.js uses defineProperty too.
9495
+ defineProperty(globalThis.process, 'domain', {
9496
+ value: null,
9497
+ configurable: false,
9498
+ writable: false,
9499
+ enumerable: false });
9500
+
9501
+ }
9502
+ }
9503
+ })
9504
+
8718
9505
  ,
8719
9506
  (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_FUNCTION,SyntaxError,TypeError,defineProperties,getPrototypeOf,setPrototypeOf;$h‍_imports([["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["setPrototypeOf", [$h‍_a => (setPrototypeOf = $h‍_a)]]]]]);
8720
9507
 
@@ -8763,6 +9550,7 @@ function tameDateConstructor(dateTaming = 'safe') {
8763
9550
  function tameFunctionConstructors() {
8764
9551
  try {
8765
9552
  // Verify that the method is not callable.
9553
+ // eslint-disable-next-line @endo/no-polymorphic-call
8766
9554
  FERAL_FUNCTION.prototype.constructor('return 1');
8767
9555
  } catch (ignore) {
8768
9556
  // Throws, no need to patch.
@@ -8906,7 +9694,7 @@ const tameFunctionToString = () => {
8906
9694
  })
8907
9695
 
8908
9696
  ,
8909
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Object,String,TypeError,getOwnPropertyNames,defineProperty,assert;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Object", [$h‍_a => (Object = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
9697
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h‍_imports([["./commons.js", [["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)]]]]]);
8910
9698
 
8911
9699
 
8912
9700
 
@@ -8947,7 +9735,7 @@ const nonLocaleCompare = tamedMethods.localeCompare;
8947
9735
 
8948
9736
  function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
8949
9737
  if (localeTaming !== 'safe' && localeTaming !== 'unsafe') {
8950
- throw new Error(`unrecognized dateTaming ${localeTaming}`);
9738
+ throw new TypeError(`unrecognized localeTaming ${localeTaming}`);
8951
9739
  }
8952
9740
  if (localeTaming === 'unsafe') {
8953
9741
  return;
@@ -8959,9 +9747,9 @@ function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
8959
9747
 
8960
9748
  for (const intrinsicName of getOwnPropertyNames(intrinsics)) {
8961
9749
  const intrinsic = intrinsics[intrinsicName];
8962
- if (intrinsic === Object(intrinsic)) {
9750
+ if (isObject(intrinsic)) {
8963
9751
  for (const methodName of getOwnPropertyNames(intrinsic)) {
8964
- const match = localePattern.exec(methodName);
9752
+ const match = regexpExec(localePattern, methodName);
8965
9753
  if (match) {
8966
9754
  assert(
8967
9755
  typeof intrinsic[methodName] === 'function',
@@ -8982,7 +9770,7 @@ function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
8982
9770
  })
8983
9771
 
8984
9772
  ,
8985
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,Math,create,getOwnPropertyDescriptors,objectPrototype;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["Math", [$h‍_a => (Math = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]]]]]);
9773
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Math,TypeError,create,getOwnPropertyDescriptors,objectPrototype;$h‍_imports([["./commons.js", [["Math", [$h‍_a => (Math = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["objectPrototype", [$h‍_a => (objectPrototype = $h‍_a)]]]]]);
8986
9774
 
8987
9775
 
8988
9776
 
@@ -8992,7 +9780,7 @@ function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
8992
9780
 
8993
9781
  function tameMathObject(mathTaming = 'safe') {
8994
9782
  if (mathTaming !== 'safe' && mathTaming !== 'unsafe') {
8995
- throw new Error(`unrecognized mathTaming ${mathTaming}`);
9783
+ throw new TypeError(`unrecognized mathTaming ${mathTaming}`);
8996
9784
  }
8997
9785
  const originalMath = Math;
8998
9786
  const initialMath = originalMath; // to follow the naming pattern
@@ -9011,7 +9799,7 @@ function tameMathObject(mathTaming = 'safe') {
9011
9799
  })
9012
9800
 
9013
9801
  ,
9014
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let Error,OriginalRegExp,construct,defineProperties,getOwnPropertyDescriptor,speciesSymbol;$h‍_imports([["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["RegExp", [$h‍_a => (OriginalRegExp = $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)]]]]]);
9802
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let FERAL_REG_EXP,TypeError,construct,defineProperties,getOwnPropertyDescriptor,speciesSymbol;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["construct", [$h‍_a => (construct = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["speciesSymbol", [$h‍_a => (speciesSymbol = $h‍_a)]]]]]);
9015
9803
 
9016
9804
 
9017
9805
 
@@ -9022,17 +9810,17 @@ function tameMathObject(mathTaming = 'safe') {
9022
9810
 
9023
9811
  function tameRegExpConstructor(regExpTaming = 'safe') {
9024
9812
  if (regExpTaming !== 'safe' && regExpTaming !== 'unsafe') {
9025
- throw new Error(`unrecognized regExpTaming ${regExpTaming}`);
9813
+ throw new TypeError(`unrecognized regExpTaming ${regExpTaming}`);
9026
9814
  }
9027
- const RegExpPrototype = OriginalRegExp.prototype;
9815
+ const RegExpPrototype = FERAL_REG_EXP.prototype;
9028
9816
 
9029
9817
  const makeRegExpConstructor = (_ = {}) => {
9030
9818
  // RegExp has non-writable static properties we need to omit.
9031
9819
  const ResultRegExp = function RegExp(...rest) {
9032
9820
  if (new.target === undefined) {
9033
- return OriginalRegExp(...rest);
9821
+ return FERAL_REG_EXP(...rest);
9034
9822
  }
9035
- return construct(OriginalRegExp, rest, new.target);
9823
+ return construct(FERAL_REG_EXP, rest, new.target);
9036
9824
  };
9037
9825
 
9038
9826
  defineProperties(ResultRegExp, {
@@ -9043,7 +9831,7 @@ function tameRegExpConstructor(regExpTaming = 'safe') {
9043
9831
  enumerable: false,
9044
9832
  configurable: false },
9045
9833
 
9046
- [speciesSymbol]: getOwnPropertyDescriptor(OriginalRegExp, speciesSymbol) });
9834
+ [speciesSymbol]: getOwnPropertyDescriptor(FERAL_REG_EXP, speciesSymbol) });
9047
9835
 
9048
9836
  return ResultRegExp;
9049
9837
  };
@@ -9066,7 +9854,8 @@ function tameRegExpConstructor(regExpTaming = 'safe') {
9066
9854
  })
9067
9855
 
9068
9856
  ,
9069
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let whitelist,FunctionInstance,isAccessorPermit,Error,TypeError,arrayIncludes,getOwnPropertyDescriptor,getPrototypeOf,isObject,objectHasOwnProperty,ownKeys;$h‍_imports([["./whitelist.js", [["whitelist", [$h‍_a => (whitelist = $h‍_a)]],["FunctionInstance", [$h‍_a => (FunctionInstance = $h‍_a)]],["isAccessorPermit", [$h‍_a => (isAccessorPermit = $h‍_a)]]]],["./commons.js", [["Error", [$h‍_a => (Error = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]]]]]);
9857
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let whitelist,FunctionInstance,isAccessorPermit,String,TypeError,arrayIncludes,getOwnPropertyDescriptor,getPrototypeOf,isObject,objectHasOwnProperty,ownKeys,stringSlice;$h‍_imports([["./whitelist.js", [["whitelist", [$h‍_a => (whitelist = $h‍_a)]],["FunctionInstance", [$h‍_a => (FunctionInstance = $h‍_a)]],["isAccessorPermit", [$h‍_a => (isAccessorPermit = $h‍_a)]]]],["./commons.js", [["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayIncludes", [$h‍_a => (arrayIncludes = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]]]]]);
9858
+
9070
9859
 
9071
9860
 
9072
9861
 
@@ -9135,7 +9924,7 @@ function asStringPropertyName(path, prop) {
9135
9924
  }
9136
9925
 
9137
9926
  if (typeof prop === 'symbol') {
9138
- return `@@${prop.toString().slice(14, -1)}`;
9927
+ return `@@${stringSlice(String(prop), 14, -1)}`;
9139
9928
  }
9140
9929
 
9141
9930
  throw new TypeError(`Unexpected property name type ${path} ${prop}`);
@@ -9182,7 +9971,9 @@ markVirtualizedNativeFunction)
9182
9971
  }
9183
9972
 
9184
9973
  // We can't clean [[prototype]], therefore abort.
9185
- throw new Error(`Unexpected intrinsic ${path}.__proto__ at ${protoName}`);
9974
+ throw new TypeError(
9975
+ `Unexpected intrinsic ${path}.__proto__ at ${protoName}`);
9976
+
9186
9977
  }
9187
9978
 
9188
9979
  /*
@@ -9312,14 +10103,17 @@ markVirtualizedNativeFunction)
9312
10103
  // This call to `console.log` is intentional. It is not a vestige
9313
10104
  // of a debugging attempt. See the comment at top of file for an
9314
10105
  // explanation.
10106
+ // eslint-disable-next-line @endo/no-polymorphic-call
9315
10107
  console.log(`Removing ${subPath}`);
9316
10108
  }
9317
10109
  try {
9318
10110
  delete obj[prop];
9319
10111
  } catch (err) {
9320
10112
  if (prop in obj) {
10113
+ // eslint-disable-next-line @endo/no-polymorphic-call
9321
10114
  console.error(`failed to delete ${subPath}`, err);
9322
10115
  } else {
10116
+ // eslint-disable-next-line @endo/no-polymorphic-call
9323
10117
  console.error(`deleting ${subPath} threw`, err);
9324
10118
  }
9325
10119
  throw err;
@@ -9335,7 +10129,24 @@ markVirtualizedNativeFunction)
9335
10129
  })
9336
10130
 
9337
10131
  ,
9338
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let globalThis,is,keys,ownKeys,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,initGlobalObject,initialGlobalPropertyNames,tameFunctionToString,tameConsole,tameErrorConstructor,assert,makeAssert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["keys", [$h‍_a => (keys = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./whitelist-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["initGlobalObject", [$h‍_a => (initGlobalObject = $h‍_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $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)]]]]]);
10132
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h‍_imports([["./commons.js", [["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h‍_a => (enJoin = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./whitelist-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h‍_a => (makeEnvironmentCaptor = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]]]);
10133
+
10134
+
10135
+
10136
+
10137
+
10138
+
10139
+
10140
+
10141
+
10142
+
10143
+
10144
+
10145
+
10146
+
10147
+
10148
+
10149
+
9339
10150
 
9340
10151
 
9341
10152
 
@@ -9373,7 +10184,8 @@ markVirtualizedNativeFunction)
9373
10184
 
9374
10185
  const { details: d, quote: q } = assert;
9375
10186
 
9376
- let firstOptions;
10187
+ /** @type {Error=} */
10188
+ let priorLockdown;
9377
10189
 
9378
10190
  // Build a harden() with an empty fringe.
9379
10191
  // Gate it on lockdown.
@@ -9384,8 +10196,6 @@ let firstOptions;
9384
10196
  */
9385
10197
  const harden = makeHardener();
9386
10198
 
9387
- const alreadyHardenedIntrinsics = () => false;
9388
-
9389
10199
  /**
9390
10200
  * @callback Transform
9391
10201
  * @param {string} source
@@ -9402,44 +10212,17 @@ const alreadyHardenedIntrinsics = () => false;
9402
10212
  * @param {Object} [options.globalLexicals]
9403
10213
  */
9404
10214
 
9405
- /**
9406
- * @callback CompartmentConstructorMaker
9407
- * @param {CompartmentConstructorMaker} targetMakeCompartmentConstructor
9408
- * @param {Object} intrinsics
9409
- * @param {(func: Function) => void} markVirtualizedNativeFunction
9410
- * @returns {CompartmentConstructor}
9411
- */
9412
-
9413
10215
  // TODO https://github.com/endojs/endo/issues/814
9414
10216
  // Lockdown currently allows multiple calls provided that the specified options
9415
10217
  // of every call agree. With experience, we have observed that lockdown should
9416
10218
  // only ever need to be called once and that simplifying lockdown will improve
9417
10219
  // the quality of audits.
9418
10220
 
9419
- // TODO https://github.com/endojs/endo/issues/815
9420
- // Lockdown receives makeCompartmentConstructor and compartmentPrototype.
9421
- // This is a vestige of an earlier version of SES where makeLockdown was called
9422
- // from two different entry points: one for a layer of SES that had a
9423
- // Compartment that only supported evaluating programs, and a second layer that
9424
- // extended Compartment to support modules, but at the expense of entraining a
9425
- // dependency on Babel.
9426
- // SES currently externalizes the dependency on Babel and one version of
9427
- // makeCompartmentConstructor is sufficient for all uses, so this can be
9428
- // simplified.
9429
-
9430
10221
  /**
9431
- * @param {CompartmentConstructorMaker} makeCompartmentConstructor
9432
- * @param {Object} compartmentPrototype
9433
- * @param {() => Object} getAnonymousIntrinsics
9434
10222
  * @param {LockdownOptions} [options]
9435
- * @returns {() => {}} repairIntrinsics
10223
+ * @returns {() => void} repairIntrinsics
9436
10224
  */
9437
- const repairIntrinsics = (
9438
- makeCompartmentConstructor,
9439
- compartmentPrototype,
9440
- getAnonymousIntrinsics,
9441
- options = {}) =>
9442
- {
10225
+ const repairIntrinsics = (options = {}) => {
9443
10226
  // First time, absent options default to 'safe'.
9444
10227
  // Subsequent times, absent options default to first options.
9445
10228
  // Thus, all present options must agree with first options.
@@ -9464,23 +10247,46 @@ options = {}) =>
9464
10247
  // is useful. See
9465
10248
  // [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
9466
10249
  // for an explanation.
9467
- options = /** @type {LockdownOptions} */{ ...firstOptions, ...options };
10250
+
10251
+ const {
10252
+ getEnvironmentOption: getenv,
10253
+ getCapturedEnvironmentOptionNames } =
10254
+ makeEnvironmentCaptor(globalThis);
10255
+
9468
10256
  const {
10257
+ errorTaming = getenv('LOCKDOWN_ERROR_TAMING', 'safe'),
10258
+ errorTrapping = getenv('LOCKDOWN_ERROR_TRAPPING', 'platform'),
10259
+ regExpTaming = getenv('LOCKDOWN_REGEXP_TAMING', 'safe'),
10260
+ localeTaming = getenv('LOCKDOWN_LOCALE_TAMING', 'safe'),
10261
+ consoleTaming = getenv('LOCKDOWN_CONSOLE_TAMING', 'safe'),
10262
+ overrideTaming = getenv('LOCKDOWN_OVERRIDE_TAMING', 'moderate'),
10263
+ stackFiltering = getenv('LOCKDOWN_STACK_FILTERING', 'concise'),
10264
+ domainTaming = getenv('LOCKDOWN_DOMAIN_TAMING', 'safe'),
10265
+ overrideDebug = arrayFilter(
10266
+ stringSplit(getenv('LOCKDOWN_OVERRIDE_DEBUG', ''), ','),
10267
+ /** @param {string} debugName */
10268
+ (debugName) => debugName !== ''),
10269
+
10270
+ __allowUnsafeMonkeyPatching__ = getenv(
10271
+ '__LOCKDOWN_ALLOW_UNSAFE_MONKEY_PATCHING__',
10272
+ 'safe'),
10273
+
9469
10274
  dateTaming = 'safe', // deprecated
9470
- errorTaming = 'safe',
9471
10275
  mathTaming = 'safe', // deprecated
9472
- errorTrapping = 'platform',
9473
- regExpTaming = 'safe',
9474
- localeTaming = 'safe',
9475
- consoleTaming = 'safe',
9476
- overrideTaming = 'moderate',
9477
- overrideDebug = [],
9478
- stackFiltering = 'concise',
9479
- __allowUnsafeMonkeyPatching__ = 'safe',
9480
-
9481
10276
  ...extraOptions } =
9482
10277
  options;
9483
10278
 
10279
+ const capturedEnvironmentOptionNames = getCapturedEnvironmentOptionNames();
10280
+ if (capturedEnvironmentOptionNames.length > 0) {
10281
+ // eslint-disable-next-line @endo/no-polymorphic-call
10282
+ console.warn(
10283
+ `SES Lockdown using options from environment variables ${enJoin(
10284
+ arrayMap(capturedEnvironmentOptionNames, q),
10285
+ 'and')
10286
+ }`);
10287
+
10288
+ }
10289
+
9484
10290
  // Assert that only supported options were passed.
9485
10291
  // Use Reflect.ownKeys to reject symbol-named properties as well.
9486
10292
  const extraOptionsNames = ownKeys(extraOptions);
@@ -9489,35 +10295,21 @@ options = {}) =>
9489
10295
  d`lockdown(): non supported option ${q(extraOptionsNames)}`);
9490
10296
 
9491
10297
 
9492
- // Asserts for multiple invocation of lockdown().
9493
- if (firstOptions) {
9494
- for (const name of keys(firstOptions)) {
9495
- assert(
9496
- options[name] === firstOptions[name],
9497
- d`lockdown(): cannot re-invoke with different option ${q(name)}`);
9498
-
9499
- }
9500
- return alreadyHardenedIntrinsics;
9501
- }
9502
-
9503
- firstOptions = {
9504
- dateTaming, // deprecated
9505
- errorTaming,
9506
- mathTaming, // deprecated
9507
- regExpTaming,
9508
- localeTaming,
9509
- consoleTaming,
9510
- overrideTaming,
9511
- overrideDebug,
9512
- stackFiltering,
9513
- __allowUnsafeMonkeyPatching__ };
10298
+ assert(
10299
+ priorLockdown === undefined,
10300
+ `Already locked down at ${priorLockdown} (SES_ALREADY_LOCKED_DOWN)`,
10301
+ TypeError);
9514
10302
 
10303
+ priorLockdown = new TypeError('Prior lockdown (SES_ALREADY_LOCKED_DOWN)');
10304
+ // Tease V8 to generate the stack string and release the closures the stack
10305
+ // trace retained:
10306
+ priorLockdown.stack;
9515
10307
 
9516
10308
  /**
9517
10309
  * Because of packagers and bundlers, etc, multiple invocations of lockdown
9518
10310
  * might happen in separate instantiations of the source of this module.
9519
10311
  * In that case, each one sees its own `firstOptions` variable, so the test
9520
- * above will not detect that lockdown has already happened. Instead, we
10312
+ * above will not detect that lockdown has already happened. We
9521
10313
  * unreliably test some telltale signs that lockdown has run, to avoid
9522
10314
  * trying to lock down a locked down environment. Although the test is
9523
10315
  * unreliable, this is consistent with the SES threat model. SES provides
@@ -9528,12 +10320,7 @@ options = {}) =>
9528
10320
  * tests without actually locking down counts as corrupting code.
9529
10321
  *
9530
10322
  * The specifics of what this tests for may change over time, but it
9531
- * should be consistent with any setting of the lockdown options. We
9532
- * do no checking that the state is consistent with current lockdown
9533
- * options. So a call to lockdown with one set of options may silently
9534
- * succeed with a state not reflecting those options, but only
9535
- * if a previous lockdown happened from something other than this
9536
- * instance of this module.
10323
+ * should be consistent with any setting of the lockdown options.
9537
10324
  */
9538
10325
  const seemsToBeLockedDown = () => {
9539
10326
  return (
@@ -9543,36 +10330,44 @@ options = {}) =>
9543
10330
  globalThis.Date.prototype.constructor !== globalThis.Date &&
9544
10331
  typeof globalThis.Date.now === 'function' &&
9545
10332
  // @ts-ignore
10333
+ // eslint-disable-next-line @endo/no-polymorphic-call
9546
10334
  is(globalThis.Date.prototype.constructor.now(), NaN));
9547
10335
 
9548
10336
  };
9549
10337
 
9550
10338
  if (seemsToBeLockedDown()) {
9551
- console.log('Seems to already be locked down. Skipping second lockdown');
9552
- return alreadyHardenedIntrinsics;
10339
+ // eslint-disable-next-line @endo/no-polymorphic-call
10340
+ throw new TypeError(
10341
+ `Already locked down but not by this SES instance (SES_MULTIPLE_INSTANCES)`);
10342
+
9553
10343
  }
9554
10344
 
9555
10345
  /**
9556
10346
  * 1. TAME powers & gather intrinsics first.
9557
10347
  */
9558
- const intrinsicsCollector = makeIntrinsicsCollector();
9559
10348
 
9560
- intrinsicsCollector.addIntrinsics({ harden });
10349
+ tameDomains(domainTaming);
10350
+
10351
+ const {
10352
+ addIntrinsics,
10353
+ completePrototypes,
10354
+ finalIntrinsics } =
10355
+ makeIntrinsicsCollector();
9561
10356
 
9562
- intrinsicsCollector.addIntrinsics(tameFunctionConstructors());
10357
+ addIntrinsics({ harden });
9563
10358
 
9564
- intrinsicsCollector.addIntrinsics(tameDateConstructor(dateTaming));
9565
- intrinsicsCollector.addIntrinsics(
9566
- tameErrorConstructor(errorTaming, stackFiltering));
10359
+ addIntrinsics(tameFunctionConstructors());
9567
10360
 
9568
- intrinsicsCollector.addIntrinsics(tameMathObject(mathTaming));
9569
- intrinsicsCollector.addIntrinsics(tameRegExpConstructor(regExpTaming));
10361
+ addIntrinsics(tameDateConstructor(dateTaming));
10362
+ addIntrinsics(tameErrorConstructor(errorTaming, stackFiltering));
10363
+ addIntrinsics(tameMathObject(mathTaming));
10364
+ addIntrinsics(tameRegExpConstructor(regExpTaming));
9570
10365
 
9571
- intrinsicsCollector.addIntrinsics(getAnonymousIntrinsics());
10366
+ addIntrinsics(getAnonymousIntrinsics());
9572
10367
 
9573
- intrinsicsCollector.completePrototypes();
10368
+ completePrototypes();
9574
10369
 
9575
- const intrinsics = intrinsicsCollector.finalIntrinsics();
10370
+ const intrinsics = finalIntrinsics();
9576
10371
 
9577
10372
  // Wrap console unless suppressed.
9578
10373
  // At the moment, the console is considered a host power in the start
@@ -9583,6 +10378,7 @@ options = {}) =>
9583
10378
  optGetStackString = intrinsics['%InitialGetStackString%'];
9584
10379
  }
9585
10380
  const consoleRecord = tameConsole(
10381
+ // @ts-ignore tameConsole does its own input validation
9586
10382
  consoleTaming,
9587
10383
  errorTrapping,
9588
10384
  optGetStackString);
@@ -9616,19 +10412,26 @@ options = {}) =>
9616
10412
 
9617
10413
  // Initialize the powerful initial global, i.e., the global of the
9618
10414
  // start compartment, from the intrinsics.
9619
- initGlobalObject(
9620
- globalThis,
9621
- intrinsics,
9622
- initialGlobalPropertyNames,
9623
- makeCompartmentConstructor,
9624
- compartmentPrototype,
9625
- {
9626
- markVirtualizedNativeFunction });
9627
10415
 
10416
+ setGlobalObjectConstantProperties(globalThis);
10417
+
10418
+ const { safeEvaluate } = makeSafeEvaluator({ globalObject: globalThis });
10419
+
10420
+ setGlobalObjectMutableProperties(globalThis, {
10421
+ intrinsics,
10422
+ newGlobalPropertyNames: initialGlobalPropertyNames,
10423
+ makeCompartmentConstructor,
10424
+ safeEvaluate,
10425
+ markVirtualizedNativeFunction });
9628
10426
 
9629
10427
 
9630
10428
  /**
9631
10429
  * 3. HARDEN to share the intrinsics.
10430
+ *
10431
+ * We define hardenIntrinsics here so that options are in scope, but return
10432
+ * it to the caller because we intend to eventually allow vetted shims to run
10433
+ * between repairs and the hardening of intrinsics and so we can benchmark
10434
+ * repair separately from hardening.
9632
10435
  */
9633
10436
 
9634
10437
  function hardenIntrinsics() {
@@ -9636,6 +10439,7 @@ options = {}) =>
9636
10439
  // TODO consider moving this to the end of the repair phase, and
9637
10440
  // therefore before vetted shims rather than afterwards. It is not
9638
10441
  // clear yet which is better.
10442
+ // @ts-ignore enablePropertyOverrides does its own input validation
9639
10443
  enablePropertyOverrides(intrinsics, overrideTaming, overrideDebug);
9640
10444
 
9641
10445
  if (__allowUnsafeMonkeyPatching__ !== 'unsafe') {
@@ -9661,37 +10465,16 @@ options = {}) =>
9661
10465
  };
9662
10466
 
9663
10467
  /**
9664
- * @param {CompartmentConstructorMaker} makeCompartmentConstructor
9665
- * @param {Object} compartmentPrototype
9666
- * @param {() => Object} getAnonymousIntrinsics
9667
- * @returns {import('../index.js').Lockdown}
10468
+ * @param {LockdownOptions} [options]
9668
10469
  */$h‍_once.repairIntrinsics(repairIntrinsics);
9669
- const makeLockdown = (
9670
- makeCompartmentConstructor,
9671
- compartmentPrototype,
9672
- getAnonymousIntrinsics) =>
9673
- {
9674
- /**
9675
- * @param {LockdownOptions} [options]
9676
- */
9677
- const lockdown = (options = {}) => {
9678
- const maybeHardenIntrinsics = repairIntrinsics(
9679
- makeCompartmentConstructor,
9680
- compartmentPrototype,
9681
- getAnonymousIntrinsics,
9682
- options);
9683
-
9684
- return maybeHardenIntrinsics();
9685
- };
9686
- return lockdown;
9687
- };$h‍_once.makeLockdown(makeLockdown);
10470
+ const lockdown = (options = {}) => {
10471
+ const hardenIntrinsics = repairIntrinsics(options);
10472
+ hardenIntrinsics();
10473
+ };$h‍_once.lockdown(lockdown);
9688
10474
  })
9689
10475
 
9690
10476
  ,
9691
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let globalThis,Error,assign,tameFunctionToString,getGlobalIntrinsics,getAnonymousIntrinsics,makeLockdown,makeCompartmentConstructor,CompartmentPrototype,assert;$h‍_imports([["./src/commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["Error", [$h‍_a => (Error = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./src/tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./src/intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]],["./src/get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./src/lockdown-shim.js", [["makeLockdown", [$h‍_a => (makeLockdown = $h‍_a)]]]],["./src/compartment-shim.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]],["CompartmentPrototype", [$h‍_a => (CompartmentPrototype = $h‍_a)]]]],["./src/error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
9692
-
9693
-
9694
-
10477
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, }) => { let globalThis,TypeError,assign,tameFunctionToString,getGlobalIntrinsics,lockdown,makeCompartmentConstructor,assert;$h‍_imports([["./src/commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["assign", [$h‍_a => (assign = $h‍_a)]]]],["./src/tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./src/intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]],["./src/lockdown-shim.js", [["lockdown", [$h‍_a => (lockdown = $h‍_a)]]]],["./src/compartment-shim.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./src/error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
9695
10478
 
9696
10479
 
9697
10480
 
@@ -9719,7 +10502,7 @@ function getThis() {
9719
10502
  }
9720
10503
 
9721
10504
  if (getThis()) {
9722
- throw new Error(`SES failed to initialize, sloppy mode (SES_NO_SLOPPY)`);
10505
+ throw new TypeError(`SES failed to initialize, sloppy mode (SES_NO_SLOPPY)`);
9723
10506
  }
9724
10507
 
9725
10508
  const markVirtualizedNativeFunction = tameFunctionToString();
@@ -9731,11 +10514,7 @@ markVirtualizedNativeFunction);
9731
10514
 
9732
10515
 
9733
10516
  assign(globalThis, {
9734
- lockdown: makeLockdown(
9735
- makeCompartmentConstructor,
9736
- CompartmentPrototype,
9737
- getAnonymousIntrinsics),
9738
-
10517
+ lockdown,
9739
10518
  Compartment,
9740
10519
  assert });
9741
10520
  })