ses 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lockdown.cjs CHANGED
@@ -1,4 +1,4 @@
1
- // ses@1.0.0
1
+ // ses@1.1.0
2
2
  'use strict';
3
3
  (() => {
4
4
  const functors = [
@@ -312,7 +312,8 @@ if( getThis()) {
312
312
  })()
313
313
  ,
314
314
  // === functors[2] ===
315
- ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); // @ts-check
315
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /* global globalThis */
316
+ // @ts-check
316
317
 
317
318
  // `@endo/env-options` needs to be imported quite early, and so should
318
319
  // avoid importing from ses or anything that depends on ses.
@@ -331,6 +332,8 @@ const uncurryThis=
331
332
  (receiver, ...args)=>
332
333
  apply(fn, receiver, args);
333
334
  const arrayPush= uncurryThis(Array.prototype.push);
335
+ const arrayIncludes= uncurryThis(Array.prototype.includes);
336
+ const stringSplit= uncurryThis(String.prototype.split);
334
337
 
335
338
  const q= JSON.stringify;
336
339
 
@@ -351,8 +354,10 @@ const Fail= (literals, ...args)=> {
351
354
  * the environment variables that were captured.
352
355
  *
353
356
  * @param {object} aGlobal
357
+ * @param {boolean} [dropNames] Defaults to false. If true, don't track
358
+ * names used.
354
359
  */
355
- const makeEnvironmentCaptor= (aGlobal)=>{
360
+ const makeEnvironmentCaptor= (aGlobal, dropNames= false)=> {
356
361
  const capturedEnvironmentOptionNames= [];
357
362
 
358
363
  /**
@@ -361,13 +366,17 @@ const makeEnvironmentCaptor= (aGlobal)=>{
361
366
  *
362
367
  * @param {string} optionName
363
368
  * @param {string} defaultSetting
369
+ * @param {string[]} [optOtherValues]
370
+ * If provided, the option value must be included or match `defaultSetting`.
364
371
  * @returns {string}
365
372
  */
366
- const getEnvironmentOption= (optionName, defaultSetting)=> {
367
- // eslint-disable-next-line @endo/no-polymorphic-call
373
+ const getEnvironmentOption= (
374
+ optionName,
375
+ defaultSetting,
376
+ optOtherValues= undefined)=>
377
+ {
368
378
  typeof optionName=== 'string'||
369
379
  Fail `Environment option name ${q(optionName)} must be a string.`;
370
- // eslint-disable-next-line @endo/no-polymorphic-call
371
380
  typeof defaultSetting=== 'string'||
372
381
  Fail `Environment option default setting ${q(
373
382
  defaultSetting)
@@ -375,36 +384,71 @@ const makeEnvironmentCaptor= (aGlobal)=>{
375
384
 
376
385
  /** @type {string} */
377
386
  let setting= defaultSetting;
378
- const globalProcess= aGlobal.process;
379
- if( globalProcess&& typeof globalProcess=== 'object') {
380
- const globalEnv= globalProcess.env;
381
- if( globalEnv&& typeof globalEnv=== 'object') {
382
- if( optionName in globalEnv) {
387
+ const globalProcess= aGlobal.process|| undefined;
388
+ const globalEnv=
389
+ typeof globalProcess=== 'object'&& globalProcess.env|| undefined;
390
+ if( typeof globalEnv=== 'object') {
391
+ if( optionName in globalEnv) {
392
+ if( !dropNames) {
383
393
  arrayPush(capturedEnvironmentOptionNames, optionName);
384
- const optionValue= globalEnv[optionName];
385
- // eslint-disable-next-line @endo/no-polymorphic-call
386
- typeof optionValue=== 'string'||
387
- Fail `Environment option named ${q(
388
- optionName)
389
- }, if present, must have a corresponding string value, got ${q(
390
- optionValue)
391
- }`;
392
- setting= optionValue;
393
394
  }
395
+ const optionValue= globalEnv[optionName];
396
+ // eslint-disable-next-line @endo/no-polymorphic-call
397
+ typeof optionValue=== 'string'||
398
+ Fail `Environment option named ${q(
399
+ optionName)
400
+ }, if present, must have a corresponding string value, got ${q(
401
+ optionValue)
402
+ }`;
403
+ setting= optionValue;
394
404
  }
395
405
  }
406
+ optOtherValues=== undefined||
407
+ setting=== defaultSetting||
408
+ arrayIncludes(optOtherValues, setting)||
409
+ Fail `Unrecognized ${q(optionName)} value ${q(
410
+ setting)
411
+ }. Expected one of ${q([defaultSetting,...optOtherValues]) }`;
396
412
  return setting;
397
413
  };
398
414
  freeze(getEnvironmentOption);
399
415
 
416
+ /**
417
+ * @param {string} optionName
418
+ * @returns {string[]}
419
+ */
420
+ const getEnvironmentOptionsList= (optionName)=>{
421
+ const option= getEnvironmentOption(optionName, '');
422
+ return freeze(option=== ''? []: stringSplit(option, ','));
423
+ };
424
+ freeze(getEnvironmentOptionsList);
425
+
426
+ const environmentOptionsListHas= (optionName, element)=>
427
+ arrayIncludes(getEnvironmentOptionsList(optionName), element);
428
+
400
429
  const getCapturedEnvironmentOptionNames= ()=> {
401
430
  return freeze([...capturedEnvironmentOptionNames]);
402
431
  };
403
432
  freeze(getCapturedEnvironmentOptionNames);
404
433
 
405
- return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames});
434
+ return freeze({
435
+ getEnvironmentOption,
436
+ getEnvironmentOptionsList,
437
+ environmentOptionsListHas,
438
+ getCapturedEnvironmentOptionNames});
439
+
406
440
  };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
407
441
  freeze(makeEnvironmentCaptor);
442
+
443
+ /**
444
+ * For the simple case, where the global in question is `globalThis` and no
445
+ * reporting of option names is desired.
446
+ */
447
+ const {
448
+ getEnvironmentOption,
449
+ getEnvironmentOptionsList,
450
+ environmentOptionsListHas}=
451
+ makeEnvironmentCaptor(globalThis, true);$h‍_once.getEnvironmentOption(getEnvironmentOption);$h‍_once.getEnvironmentOptionsList(getEnvironmentOptionsList);$h‍_once.environmentOptionsListHas(environmentOptionsListHas);
408
452
  })()
409
453
  ,
410
454
  // === functors[3] ===
@@ -3231,7 +3275,21 @@ const permitted= {
3231
3275
  size: getter,
3232
3276
  values: fn,
3233
3277
  '@@iterator': fn,
3234
- '@@toStringTag': 'string'},
3278
+ '@@toStringTag': 'string',
3279
+ // See https://github.com/tc39/proposal-set-methods
3280
+ intersection: fn,
3281
+ // See https://github.com/tc39/proposal-set-methods
3282
+ union: fn,
3283
+ // See https://github.com/tc39/proposal-set-methods
3284
+ difference: fn,
3285
+ // See https://github.com/tc39/proposal-set-methods
3286
+ symmetricDifference: fn,
3287
+ // See https://github.com/tc39/proposal-set-methods
3288
+ isSubsetOf: fn,
3289
+ // See https://github.com/tc39/proposal-set-methods
3290
+ isSupersetOf: fn,
3291
+ // See https://github.com/tc39/proposal-set-methods
3292
+ isDisjointFrom: fn},
3235
3293
 
3236
3294
 
3237
3295
  '%SetIteratorPrototype%': {
@@ -3881,7 +3939,18 @@ function whitelistIntrinsics(
3881
3939
  intrinsics,
3882
3940
  markVirtualizedNativeFunction)
3883
3941
  {
3884
- // These primitives are allowed allowed for permits.
3942
+ let groupStarted= false;
3943
+ const inConsoleGroup= (level, ...args)=> {
3944
+ if( !groupStarted) {
3945
+ // eslint-disable-next-line @endo/no-polymorphic-call
3946
+ console.groupCollapsed('Removing unpermitted intrinsics');
3947
+ groupStarted= true;
3948
+ }
3949
+ // eslint-disable-next-line @endo/no-polymorphic-call
3950
+ return console[level](...args);
3951
+ };
3952
+
3953
+ // These primitives are allowed for permits.
3885
3954
  const primitives= ['undefined', 'boolean', 'number', 'string', 'symbol'];
3886
3955
 
3887
3956
  // These symbols are allowed as well-known symbols
@@ -4086,11 +4155,7 @@ function whitelistIntrinsics(
4086
4155
  // that we are removing it so we know to look into it, as happens when
4087
4156
  // the language evolves new features to existing intrinsics.
4088
4157
  if( subPermit!== false) {
4089
- // This call to `console.warn` is intentional. It is not a vestige of
4090
- // a debugging attempt. See the comment at top of file for an
4091
- // explanation.
4092
- // eslint-disable-next-line @endo/no-polymorphic-call
4093
- console.warn( `Removing ${subPath}`);
4158
+ inConsoleGroup('warn', `Removing ${subPath}`);
4094
4159
  }
4095
4160
  try {
4096
4161
  delete obj[prop];
@@ -4099,17 +4164,17 @@ function whitelistIntrinsics(
4099
4164
  if( typeof obj=== 'function'&& prop=== 'prototype') {
4100
4165
  obj.prototype= undefined;
4101
4166
  if( obj.prototype=== undefined) {
4102
- // eslint-disable-next-line @endo/no-polymorphic-call
4103
- console.warn( `Tolerating undeletable ${subPath} === undefined`);
4167
+ inConsoleGroup(
4168
+ 'warn',
4169
+ `Tolerating undeletable ${subPath} === undefined`);
4170
+
4104
4171
  // eslint-disable-next-line no-continue
4105
4172
  continue;
4106
4173
  }
4107
4174
  }
4108
- // eslint-disable-next-line @endo/no-polymorphic-call
4109
- console.error( `failed to delete ${subPath}`,err);
4175
+ inConsoleGroup('error', `failed to delete ${subPath}`,err);
4110
4176
  }else {
4111
- // eslint-disable-next-line @endo/no-polymorphic-call
4112
- console.error( `deleting ${subPath} threw`,err);
4177
+ inConsoleGroup('error', `deleting ${subPath} threw`,err);
4113
4178
  }
4114
4179
  throw err;
4115
4180
  }
@@ -4117,9 +4182,16 @@ function whitelistIntrinsics(
4117
4182
  }
4118
4183
  }
4119
4184
 
4120
- // Start path with 'intrinsics' to clarify that properties are not
4121
- // removed from the global object by the whitelisting operation.
4122
- visitProperties('intrinsics', intrinsics, permitted);
4185
+ try {
4186
+ // Start path with 'intrinsics' to clarify that properties are not
4187
+ // removed from the global object by the whitelisting operation.
4188
+ visitProperties('intrinsics', intrinsics, permitted);
4189
+ }finally {
4190
+ if( groupStarted) {
4191
+ // eslint-disable-next-line @endo/no-polymorphic-call
4192
+ console.groupEnd();
4193
+ }
4194
+ }
4123
4195
  }$h‍_once.default( whitelistIntrinsics);
4124
4196
  })()
4125
4197
  ,
@@ -4507,7 +4579,9 @@ function tameRegExpConstructor(regExpTaming= 'safe') {
4507
4579
  })()
4508
4580
  ,
4509
4581
  // === functors[17] ===
4510
- ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([]); /**
4582
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let toStringTagSymbol;$h‍_imports([["./commons.js", [["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
4583
+
4584
+ /**
4511
4585
  * @file Exports {@code enablements}, a recursively defined
4512
4586
  * JSON record defining the optimum set of intrinsics properties
4513
4587
  * that need to be "repaired" before hardening is applied on
@@ -4582,7 +4656,14 @@ const minEnablements= {
4582
4656
 
4583
4657
  '%ErrorPrototype%': {
4584
4658
  name: true // set by "precond", "ava", "node-fetch"
4585
- }};
4659
+ },
4660
+ '%IteratorPrototype%': {
4661
+ toString: true,
4662
+ // https://github.com/tc39/proposal-iterator-helpers
4663
+ constructor: true,
4664
+ // https://github.com/tc39/proposal-iterator-helpers
4665
+ [toStringTagSymbol]: true}};
4666
+
4586
4667
 
4587
4668
 
4588
4669
  /**
@@ -4660,7 +4741,11 @@ const moderateEnablements= {
4660
4741
 
4661
4742
 
4662
4743
  '%IteratorPrototype%': {
4663
- toString: true}};
4744
+ toString: true,
4745
+ // https://github.com/tc39/proposal-iterator-helpers
4746
+ constructor: true,
4747
+ // https://github.com/tc39/proposal-iterator-helpers
4748
+ [toStringTagSymbol]: true}};
4664
4749
 
4665
4750
 
4666
4751
 
@@ -4730,8 +4815,7 @@ const severeEnablements= {
4730
4815
  })()
4731
4816
  ,
4732
4817
  // === functors[18] ===
4733
- ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { 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)]]]]]);
4734
-
4818
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let Set,String,TypeError,arrayForEach,defineProperty,getOwnPropertyDescriptor,getOwnPropertyDescriptors,isObject,objectHasOwnProperty,ownKeys,setHas,minEnablements,moderateEnablements,severeEnablements;$h‍_imports([["./commons.js", [["Set", [$h‍_a => (Set = $h‍_a)]],["String", [$h‍_a => (String = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayForEach", [$h‍_a => (arrayForEach = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["getOwnPropertyDescriptors", [$h‍_a => (getOwnPropertyDescriptors = $h‍_a)]],["isObject", [$h‍_a => (isObject = $h‍_a)]],["objectHasOwnProperty", [$h‍_a => (objectHasOwnProperty = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["setHas", [$h‍_a => (setHas = $h‍_a)]]]],["./enablements.js", [["minEnablements", [$h‍_a => (minEnablements = $h‍_a)]],["moderateEnablements", [$h‍_a => (moderateEnablements = $h‍_a)]],["severeEnablements", [$h‍_a => (severeEnablements = $h‍_a)]]]]]);
4735
4819
 
4736
4820
 
4737
4821
 
@@ -4820,9 +4904,43 @@ function enablePropertyOverrides(
4820
4904
  if( 'value'in desc&& desc.configurable) {
4821
4905
  const { value}= desc;
4822
4906
 
4823
- function getter() {
4824
- return value;
4825
- }
4907
+ const isDebug= setHas(debugProperties, prop);
4908
+
4909
+ // We use concise method syntax to be `this` sensitive, but still
4910
+ // omit a prototype property or [[Construct]] behavior.
4911
+ // @ts-expect-error We know there is an accessor descriptor there
4912
+ const { get: getter, set: setter}= getOwnPropertyDescriptor(
4913
+ {
4914
+ get[ prop]() {
4915
+ return value;
4916
+ },
4917
+ set[ prop](newValue) {
4918
+ if( obj=== this) {
4919
+ throw TypeError(
4920
+ `Cannot assign to read only property '${String(
4921
+ prop)
4922
+ }' of '${path}'`);
4923
+
4924
+ }
4925
+ if( objectHasOwnProperty(this, prop)) {
4926
+ this[prop]= newValue;
4927
+ }else {
4928
+ if( isDebug) {
4929
+ // eslint-disable-next-line @endo/no-polymorphic-call
4930
+ console.error(TypeError( `Override property ${prop}`));
4931
+ }
4932
+ defineProperty(this, prop, {
4933
+ value: newValue,
4934
+ writable: true,
4935
+ enumerable: true,
4936
+ configurable: true});
4937
+
4938
+ }
4939
+ }},
4940
+
4941
+ prop);
4942
+
4943
+
4826
4944
  defineProperty(getter, 'originalValue', {
4827
4945
  value,
4828
4946
  writable: false,
@@ -4830,32 +4948,6 @@ function enablePropertyOverrides(
4830
4948
  configurable: false});
4831
4949
 
4832
4950
 
4833
- const isDebug= setHas(debugProperties, prop);
4834
-
4835
- function setter(newValue) {
4836
- if( obj=== this) {
4837
- throw TypeError(
4838
- `Cannot assign to read only property '${String(
4839
- prop)
4840
- }' of '${path}'`);
4841
-
4842
- }
4843
- if( objectHasOwnProperty(this, prop)) {
4844
- this[prop]= newValue;
4845
- }else {
4846
- if( isDebug) {
4847
- // eslint-disable-next-line @endo/no-polymorphic-call
4848
- console.error(TypeError( `Override property ${prop}`));
4849
- }
4850
- defineProperty(this, prop, {
4851
- value: newValue,
4852
- writable: true,
4853
- enumerable: true,
4854
- configurable: true});
4855
-
4856
- }
4857
- }
4858
-
4859
4951
  defineProperty(obj, prop, {
4860
4952
  get: getter,
4861
4953
  set: setter,
@@ -4880,12 +4972,11 @@ function enablePropertyOverrides(
4880
4972
  }
4881
4973
  // TypeScript does not allow symbols to be used as indexes because it
4882
4974
  // cannot recokon types of symbolized properties.
4883
- // @ts-ignore
4884
4975
  arrayForEach(ownKeys(descs), (prop)=>enable(path, obj, prop, descs[prop]));
4885
4976
  }
4886
4977
 
4887
4978
  function enableProperties(path, obj, plan) {
4888
- for( const prop of getOwnPropertyNames(plan)) {
4979
+ for( const prop of ownKeys(plan)) {
4889
4980
  const desc= getOwnPropertyDescriptor(obj, prop);
4890
4981
  if( !desc|| desc.get|| desc.set) {
4891
4982
  // No not a value property, nothing to do.
@@ -4893,10 +4984,8 @@ function enablePropertyOverrides(
4893
4984
  continue;
4894
4985
  }
4895
4986
 
4896
- // Plan has no symbol keys and we use getOwnPropertyNames()
4897
- // so `prop` cannot only be a string, not a symbol. We coerce it in place
4898
- // with `String(..)` anyway just as good hygiene, since these paths are just
4899
- // for diagnostic purposes.
4987
+ // In case `prop` is a symbol, we first coerce it with `String`,
4988
+ // purely for diagnostic purposes.
4900
4989
  const subPath= `${path}.${String(prop)}`;
4901
4990
  const subPlan= plan[prop];
4902
4991
 
@@ -6350,12 +6439,10 @@ function tameDomains(domainTaming= 'safe') {
6350
6439
  }
6351
6440
 
6352
6441
  // Protect against the hazard presented by Node.js domains.
6353
- if( typeof globalThis.process=== 'object'&& globalThis.process!== null) {
6442
+ const globalProcess= globalThis.process|| undefined;
6443
+ if( typeof globalProcess=== 'object') {
6354
6444
  // Check whether domains were initialized.
6355
- const domainDescriptor= getOwnPropertyDescriptor(
6356
- globalThis.process,
6357
- 'domain');
6358
-
6445
+ const domainDescriptor= getOwnPropertyDescriptor(globalProcess, 'domain');
6359
6446
  if( domainDescriptor!== undefined&& domainDescriptor.get!== undefined) {
6360
6447
  // The domain descriptor on Node.js initially has value: null, which
6361
6448
  // becomes a get, set pair after domains initialize.
@@ -6370,7 +6457,7 @@ function tameDomains(domainTaming= 'safe') {
6370
6457
  // The domain module merely throws an exception when it attempts to define
6371
6458
  // the domain property of the process global during its initialization.
6372
6459
  // We have no better recourse because Node.js uses defineProperty too.
6373
- defineProperty(globalThis.process, 'domain', {
6460
+ defineProperty(globalProcess, 'domain', {
6374
6461
  value: null,
6375
6462
  configurable: false,
6376
6463
  writable: false,
@@ -6907,35 +6994,13 @@ const makeRejectionHandlers= (reportReason)=>{
6907
6994
 
6908
6995
 
6909
6996
 
6910
- const wrapLogger= (logger, thisArg)=>
6911
- freeze((...args)=> apply(logger, thisArg, args));
6912
6997
 
6913
- // eslint-disable-next-line no-restricted-globals
6914
- const originalConsole= /** @type {VirtualConsole} */
6915
- // eslint-disable-next-line no-nested-ternary
6916
- typeof console!== 'undefined'?
6917
- console:
6918
- typeof print=== 'function'?
6919
- // Make a good-enough console for eshost (including only functions that
6920
- // log at a specific level with no special argument interpretation).
6921
- // https://console.spec.whatwg.org/#logging
6922
- ((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))(
6923
- // eslint-disable-next-line no-undef
6924
- wrapLogger(print)):
6925
-
6926
- undefined;
6927
-
6928
-
6929
- // Upgrade a log-only console (as in `eshost -h SpiderMonkey`).
6930
- if( originalConsole&& originalConsole.log) {
6931
- for( const methodName of ['warn', 'error']) {
6932
- if( !originalConsole[methodName]) {
6933
- defineProperty(originalConsole, methodName, {
6934
- value: wrapLogger(originalConsole.log, originalConsole)});
6998
+ const failFast= (message)=>{
6999
+ throw TypeError(message);
7000
+ };
6935
7001
 
6936
- }
6937
- }
6938
- }
7002
+ const wrapLogger= (logger, thisArg)=>
7003
+ freeze((...args)=> apply(logger, thisArg, args));
6939
7004
 
6940
7005
  /**
6941
7006
  * Wrap console unless suppressed.
@@ -6954,9 +7019,9 @@ const tameConsole= (
6954
7019
  unhandledRejectionTrapping= 'report',
6955
7020
  optGetStackString= undefined)=>
6956
7021
  {
6957
- if( consoleTaming!== 'safe'&& consoleTaming!== 'unsafe') {
6958
- throw TypeError( `unrecognized consoleTaming ${consoleTaming}`);
6959
- }
7022
+ consoleTaming=== 'safe'||
7023
+ consoleTaming=== 'unsafe'||
7024
+ failFast( `unrecognized consoleTaming ${consoleTaming}`);
6960
7025
 
6961
7026
  let loggedErrorHandler;
6962
7027
  if( optGetStackString=== undefined) {
@@ -6967,6 +7032,34 @@ const tameConsole= (
6967
7032
  getStackString: optGetStackString};
6968
7033
 
6969
7034
  }
7035
+
7036
+ // eslint-disable-next-line no-restricted-globals
7037
+ const originalConsole= /** @type {VirtualConsole} */
7038
+ // eslint-disable-next-line no-nested-ternary
7039
+ typeof globalThis.console!== 'undefined'?
7040
+ globalThis.console:
7041
+ typeof globalThis.print=== 'function'?
7042
+ // Make a good-enough console for eshost (including only functions that
7043
+ // log at a specific level with no special argument interpretation).
7044
+ // https://console.spec.whatwg.org/#logging
7045
+ ((p)=>freeze({ debug: p, log: p, info: p, warn: p, error: p}))(
7046
+ // eslint-disable-next-line no-undef
7047
+ wrapLogger(globalThis.print)):
7048
+
7049
+ undefined;
7050
+
7051
+
7052
+ // Upgrade a log-only console (as in `eshost -h SpiderMonkey`).
7053
+ if( originalConsole&& originalConsole.log) {
7054
+ for( const methodName of ['warn', 'error']) {
7055
+ if( !originalConsole[methodName]) {
7056
+ defineProperty(originalConsole, methodName, {
7057
+ value: wrapLogger(originalConsole.log, originalConsole)});
7058
+
7059
+ }
7060
+ }
7061
+ }
7062
+
6970
7063
  const ourConsole= /** @type {VirtualConsole} */
6971
7064
  consoleTaming=== 'unsafe'?
6972
7065
  originalConsole:
@@ -6989,21 +7082,36 @@ const tameConsole= (
6989
7082
  /* eslint-disable @endo/no-polymorphic-call */
6990
7083
 
6991
7084
  // Node.js
6992
- if( errorTrapping!== 'none'&& globalThis.process!== undefined) {
6993
- globalThis.process.on('uncaughtException', (error)=>{
7085
+ const globalProcess= globalThis.process|| undefined;
7086
+ if(
7087
+ errorTrapping!== 'none'&&
7088
+ typeof globalProcess=== 'object'&&
7089
+ typeof globalProcess.on=== 'function')
7090
+ {
7091
+ let terminate;
7092
+ if( errorTrapping=== 'platform'|| errorTrapping=== 'exit') {
7093
+ const { exit}= globalProcess;
7094
+ // If there is a function-valued process.on but no function-valued process.exit,
7095
+ // fail early without caring whether errorTrapping is "platform" only by default.
7096
+ typeof exit=== 'function'|| failFast('missing process.exit');
7097
+ terminate= ()=> exit(globalProcess.exitCode|| -1);
7098
+ }else if( errorTrapping=== 'abort') {
7099
+ terminate= globalProcess.abort;
7100
+ typeof terminate=== 'function'|| failFast('missing process.abort');
7101
+ }
7102
+
7103
+ globalProcess.on('uncaughtException', (error)=>{
6994
7104
  // causalConsole is born frozen so not vulnerable to method tampering.
6995
7105
  ourConsole.error(error);
6996
- if( errorTrapping=== 'platform'|| errorTrapping=== 'exit') {
6997
- globalThis.process.exit(globalThis.process.exitCode|| -1);
6998
- }else if( errorTrapping=== 'abort') {
6999
- globalThis.process.abort();
7106
+ if( terminate) {
7107
+ terminate();
7000
7108
  }
7001
7109
  });
7002
7110
  }
7003
-
7004
7111
  if(
7005
7112
  unhandledRejectionTrapping!== 'none'&&
7006
- globalThis.process!== undefined)
7113
+ typeof globalProcess=== 'object'&&
7114
+ typeof globalProcess.on=== 'function')
7007
7115
  {
7008
7116
  const handleRejection= (reason)=>{
7009
7117
  // 'platform' and 'report' just log the reason.
@@ -7013,32 +7121,32 @@ const tameConsole= (
7013
7121
  const h= makeRejectionHandlers(handleRejection);
7014
7122
  if( h) {
7015
7123
  // Rejection handlers are supported.
7016
- globalThis.process.on('unhandledRejection', h.unhandledRejectionHandler);
7017
- globalThis.process.on('rejectionHandled', h.rejectionHandledHandler);
7018
- globalThis.process.on('exit', h.processTerminationHandler);
7124
+ globalProcess.on('unhandledRejection', h.unhandledRejectionHandler);
7125
+ globalProcess.on('rejectionHandled', h.rejectionHandledHandler);
7126
+ globalProcess.on('exit', h.processTerminationHandler);
7019
7127
  }
7020
7128
  }
7021
7129
 
7022
7130
  // Browser
7131
+ const globalWindow= globalThis.window|| undefined;
7023
7132
  if(
7024
7133
  errorTrapping!== 'none'&&
7025
- globalThis.window!== undefined&&
7026
- globalThis.window.addEventListener!== undefined)
7134
+ typeof globalWindow=== 'object'&&
7135
+ typeof globalWindow.addEventListener=== 'function')
7027
7136
  {
7028
- globalThis.window.addEventListener('error', (event)=>{
7137
+ globalWindow.addEventListener('error', (event)=>{
7029
7138
  event.preventDefault();
7030
7139
  // 'platform' and 'report' just log the reason.
7031
7140
  ourConsole.error(event.error);
7032
7141
  if( errorTrapping=== 'exit'|| errorTrapping=== 'abort') {
7033
- globalThis.window.location.href= `about:blank`;
7142
+ globalWindow.location.href= `about:blank`;
7034
7143
  }
7035
7144
  });
7036
7145
  }
7037
-
7038
7146
  if(
7039
7147
  unhandledRejectionTrapping!== 'none'&&
7040
- globalThis.window!== undefined&&
7041
- globalThis.window.addEventListener!== undefined)
7148
+ typeof globalWindow=== 'object'&&
7149
+ typeof globalWindow.addEventListener=== 'function')
7042
7150
  {
7043
7151
  const handleRejection= (reason)=>{
7044
7152
  ourConsole.error('SES_UNHANDLED_REJECTION:', reason);
@@ -7047,17 +7155,17 @@ const tameConsole= (
7047
7155
  const h= makeRejectionHandlers(handleRejection);
7048
7156
  if( h) {
7049
7157
  // Rejection handlers are supported.
7050
- globalThis.window.addEventListener('unhandledrejection', (event)=>{
7158
+ globalWindow.addEventListener('unhandledrejection', (event)=>{
7051
7159
  event.preventDefault();
7052
7160
  h.unhandledRejectionHandler(event.reason, event.promise);
7053
7161
  });
7054
7162
 
7055
- globalThis.window.addEventListener('rejectionhandled', (event)=>{
7163
+ globalWindow.addEventListener('rejectionhandled', (event)=>{
7056
7164
  event.preventDefault();
7057
7165
  h.rejectionHandledHandler(event.promise);
7058
7166
  });
7059
7167
 
7060
- globalThis.window.addEventListener('beforeunload', (_event)=>{
7168
+ globalWindow.addEventListener('beforeunload', (_event)=>{
7061
7169
  h.processTerminationHandler();
7062
7170
  });
7063
7171
  }
@@ -8027,7 +8135,8 @@ const load= async(
8027
8135
  })()
8028
8136
  ,
8029
8137
  // === functors[39] ===
8030
- ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,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)]]]]]);
8138
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let makeAlias,Proxy,TypeError,create,freeze,mapGet,mapHas,mapSet,ownKeys,reflectGet,reflectGetOwnPropertyDescriptor,reflectHas,reflectIsExtensible,reflectPreventExtensions,toStringTagSymbol,weakmapSet,assert;$h‍_imports([["./module-load.js", [["makeAlias", [$h‍_a => (makeAlias = $h‍_a)]]]],["./commons.js", [["Proxy", [$h‍_a => (Proxy = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]],["mapGet", [$h‍_a => (mapGet = $h‍_a)]],["mapHas", [$h‍_a => (mapHas = $h‍_a)]],["mapSet", [$h‍_a => (mapSet = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["reflectGet", [$h‍_a => (reflectGet = $h‍_a)]],["reflectGetOwnPropertyDescriptor", [$h‍_a => (reflectGetOwnPropertyDescriptor = $h‍_a)]],["reflectHas", [$h‍_a => (reflectHas = $h‍_a)]],["reflectIsExtensible", [$h‍_a => (reflectIsExtensible = $h‍_a)]],["reflectPreventExtensions", [$h‍_a => (reflectPreventExtensions = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
8139
+
8031
8140
 
8032
8141
 
8033
8142
 
@@ -8080,13 +8189,21 @@ const { quote: q}= assert;
8080
8189
  //
8081
8190
  const deferExports= ()=> {
8082
8191
  let active= false;
8083
- const proxiedExports= create(null);
8192
+ const exportsTarget= create(null, {
8193
+ // Make this appear like an ESM module namespace object.
8194
+ [toStringTagSymbol]: {
8195
+ value: 'Module',
8196
+ writable: false,
8197
+ enumerable: false,
8198
+ configurable: false}});
8199
+
8200
+
8084
8201
  return freeze({
8085
8202
  activate() {
8086
8203
  active= true;
8087
8204
  },
8088
- proxiedExports,
8089
- exportsProxy: new Proxy(proxiedExports, {
8205
+ exportsTarget,
8206
+ exportsProxy: new Proxy(exportsTarget, {
8090
8207
  get(_target, name, receiver) {
8091
8208
  if( !active) {
8092
8209
  throw TypeError(
@@ -8095,7 +8212,7 @@ const deferExports= ()=> {
8095
8212
  } of module exports namespace, the module has not yet begun to execute`);
8096
8213
 
8097
8214
  }
8098
- return reflectGet(proxiedExports, name, receiver);
8215
+ return reflectGet(exportsTarget, name, receiver);
8099
8216
  },
8100
8217
  set(_target, name, _value) {
8101
8218
  throw TypeError(
@@ -8110,7 +8227,7 @@ const deferExports= ()=> {
8110
8227
  }, the module has not yet begun to execute`);
8111
8228
 
8112
8229
  }
8113
- return reflectHas(proxiedExports, name);
8230
+ return reflectHas(exportsTarget, name);
8114
8231
  },
8115
8232
  deleteProperty(_target, name) {
8116
8233
  throw TypeError(
@@ -8123,7 +8240,7 @@ const deferExports= ()=> {
8123
8240
  'Cannot enumerate keys, the module has not yet begun to execute');
8124
8241
 
8125
8242
  }
8126
- return ownKeys(proxiedExports);
8243
+ return ownKeys(exportsTarget);
8127
8244
  },
8128
8245
  getOwnPropertyDescriptor(_target, name) {
8129
8246
  if( !active) {
@@ -8133,7 +8250,7 @@ const deferExports= ()=> {
8133
8250
  }, the module has not yet begun to execute`);
8134
8251
 
8135
8252
  }
8136
- return reflectGetOwnPropertyDescriptor(proxiedExports, name);
8253
+ return reflectGetOwnPropertyDescriptor(exportsTarget, name);
8137
8254
  },
8138
8255
  preventExtensions(_target) {
8139
8256
  if( !active) {
@@ -8141,7 +8258,7 @@ const deferExports= ()=> {
8141
8258
  'Cannot prevent extensions of module exports namespace, the module has not yet begun to execute');
8142
8259
 
8143
8260
  }
8144
- return reflectPreventExtensions(proxiedExports);
8261
+ return reflectPreventExtensions(exportsTarget);
8145
8262
  },
8146
8263
  isExtensible() {
8147
8264
  if( !active) {
@@ -8149,7 +8266,7 @@ const deferExports= ()=> {
8149
8266
  'Cannot check extensibility of module exports namespace, the module has not yet begun to execute');
8150
8267
 
8151
8268
  }
8152
- return reflectIsExtensible(proxiedExports);
8269
+ return reflectIsExtensible(exportsTarget);
8153
8270
  },
8154
8271
  getPrototypeOf(_target) {
8155
8272
  return null;
@@ -8176,12 +8293,31 @@ const deferExports= ()=> {
8176
8293
 
8177
8294
  };
8178
8295
 
8179
- // `getDeferredExports` memoizes the creation of a deferred module exports
8180
- // namespace proxy for any abritrary full specifier in a compartment.
8181
- // It also records the compartment and specifier affiliated with that module
8182
- // exports namespace proxy so it can be used as an alias into another
8183
- // compartment when threaded through a compartment's `moduleMap` argument.
8184
- $h‍_once.deferExports(deferExports);const getDeferredExports=(
8296
+ /**
8297
+ * @typedef {object} DeferredExports
8298
+ * @property {Record<string, any>} exportsTarget - The object to which a
8299
+ * module's exports will be added.
8300
+ * @property {Record<string, any>} exportsProxy - A proxy over the `exportsTarget`,
8301
+ * used to expose its "exports" to other compartments.
8302
+ * @property {() => void} activate - Activate the `exportsProxy` such that it can
8303
+ * be used as a module namespace object.
8304
+ */
8305
+
8306
+ /**
8307
+ * Memoizes the creation of a deferred module exports namespace proxy for any
8308
+ * arbitrary full specifier in a compartment. It also records the compartment
8309
+ * and specifier affiliated with that module exports namespace proxy so it
8310
+ * can be used as an alias into another compartment when threaded through
8311
+ * a compartment's `moduleMap` argument.
8312
+ *
8313
+ * @param {*} compartment - The compartment to retrieve deferred exports from.
8314
+ * @param {*} compartmentPrivateFields - The private fields of the compartment.
8315
+ * @param {*} moduleAliases - The module aliases of the compartment.
8316
+ * @param {string} specifier - The module specifier to retrieve deferred exports for.
8317
+ * @returns {DeferredExports} - The deferred exports for the module specifier of
8318
+ * the compartment.
8319
+ */$h‍_once.deferExports(deferExports);
8320
+ const getDeferredExports= (
8185
8321
  compartment,
8186
8322
  compartmentPrivateFields,
8187
8323
  moduleAliases,
@@ -8332,7 +8468,7 @@ const makeThirdPartyModuleInstance= (
8332
8468
  moduleSpecifier,
8333
8469
  resolvedImports)=>
8334
8470
  {
8335
- const { exportsProxy, proxiedExports, activate}= getDeferredExports(
8471
+ const { exportsProxy, exportsTarget, activate}= getDeferredExports(
8336
8472
  compartment,
8337
8473
  weakmapGet(compartmentPrivateFields, compartment),
8338
8474
  moduleAliases,
@@ -8351,7 +8487,7 @@ const makeThirdPartyModuleInstance= (
8351
8487
 
8352
8488
  }
8353
8489
  arrayForEach(staticModuleRecord.exports, (name)=>{
8354
- let value= proxiedExports[name];
8490
+ let value= exportsTarget[name];
8355
8491
  const updaters= [];
8356
8492
 
8357
8493
  const get= ()=> value;
@@ -8363,7 +8499,7 @@ const makeThirdPartyModuleInstance= (
8363
8499
  }
8364
8500
  };
8365
8501
 
8366
- defineProperty(proxiedExports, name, {
8502
+ defineProperty(exportsTarget, name, {
8367
8503
  get,
8368
8504
  set,
8369
8505
  enumerable: true,
@@ -8375,9 +8511,9 @@ const makeThirdPartyModuleInstance= (
8375
8511
  update(value);
8376
8512
  };
8377
8513
  });
8378
- // This is enough to support import * from cjs - the '*' field doesn't need to be in exports nor proxiedExports because import will only ever access it via notifiers
8514
+ // This is enough to support import * from cjs - the '*' field doesn't need to be in exports nor exportsTarget because import will only ever access it via notifiers
8379
8515
  notifiers['*']= (update)=>{
8380
- update(proxiedExports);
8516
+ update(exportsTarget);
8381
8517
  };
8382
8518
  }
8383
8519
 
@@ -8397,7 +8533,7 @@ const makeThirdPartyModuleInstance= (
8397
8533
  try {
8398
8534
  // eslint-disable-next-line @endo/no-polymorphic-call
8399
8535
  staticModuleRecord.execute(
8400
- proxiedExports,
8536
+ exportsTarget,
8401
8537
  compartment,
8402
8538
  resolvedImports);
8403
8539
 
@@ -8443,7 +8579,7 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8443
8579
 
8444
8580
  const { __shimTransforms__, importMetaHook}= compartmentFields;
8445
8581
 
8446
- const { exportsProxy, proxiedExports, activate}= getDeferredExports(
8582
+ const { exportsProxy, exportsTarget, activate}= getDeferredExports(
8447
8583
  compartment,
8448
8584
  compartmentFields,
8449
8585
  moduleAliases,
@@ -8642,7 +8778,7 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8642
8778
 
8643
8779
 
8644
8780
  const notifyStar= (update)=>{
8645
- update(proxiedExports);
8781
+ update(exportsTarget);
8646
8782
  };
8647
8783
  notifiers['*']= notifyStar;
8648
8784
 
@@ -8735,10 +8871,10 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
8735
8871
  // and the string must correspond to a valid identifier, sorting these
8736
8872
  // properties works for this specific case.
8737
8873
  arrayForEach(arraySort(keys(exportsProps)), (k)=>
8738
- defineProperty(proxiedExports, k, exportsProps[k]));
8874
+ defineProperty(exportsTarget, k, exportsProps[k]));
8739
8875
 
8740
8876
 
8741
- freeze(proxiedExports);
8877
+ freeze(exportsTarget);
8742
8878
  activate();
8743
8879
  }
8744
8880
 
@@ -9528,7 +9664,222 @@ const tameSymbolConstructor= ()=> {
9528
9664
  })()
9529
9665
  ,
9530
9666
  // === functors[47] ===
9531
- ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let makeEnvironmentCaptor,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor;$h‍_imports([["@endo/env-options", [["makeEnvironmentCaptor", [$h‍_a => (makeEnvironmentCaptor = $h‍_a)]]]],["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["noEvalEvaluate", [$h‍_a => (noEvalEvaluate = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./permits.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]]]);
9667
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getOwnPropertyDescriptor,apply,defineProperty,toStringTagSymbol;$h‍_imports([["./commons.js", [["getOwnPropertyDescriptor", [$h‍_a => (getOwnPropertyDescriptor = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["defineProperty", [$h‍_a => (defineProperty = $h‍_a)]],["toStringTagSymbol", [$h‍_a => (toStringTagSymbol = $h‍_a)]]]]]);
9668
+
9669
+
9670
+
9671
+
9672
+
9673
+
9674
+ const throws= (thunk)=>{
9675
+ try {
9676
+ thunk();
9677
+ return false;
9678
+ }catch( er) {
9679
+ return true;
9680
+ }
9681
+ };
9682
+
9683
+ /**
9684
+ * Exported for convenience of unit testing. Harmless, but not expected
9685
+ * to be useful by itself.
9686
+ *
9687
+ * @param {any} obj
9688
+ * @param {string|symbol} prop
9689
+ * @param {any} expectedValue
9690
+ * @returns {boolean}
9691
+ * Returns whether `tameFauxDataProperty` turned the property in question
9692
+ * from an apparent faux data property into the actual data property it
9693
+ * seemed to emulate.
9694
+ * If this function returns `false`, then we hope no effects happened.
9695
+ * However, sniffing out if an accessor property seems to be a faux data
9696
+ * property requires invoking the getter and setter functions that might
9697
+ * possibly have side effects.
9698
+ * `tameFauxDataProperty` is not in a position to tell.
9699
+ */
9700
+ const tameFauxDataProperty= (obj, prop, expectedValue)=> {
9701
+ if( obj=== undefined) {
9702
+ // The object does not exist in this version of the platform
9703
+ return false;
9704
+ }
9705
+ const desc= getOwnPropertyDescriptor(obj, prop);
9706
+ if( !desc|| 'value'in desc) {
9707
+ // The property either doesn't exist, or is already an actual data property.
9708
+ return false;
9709
+ }
9710
+ const { get, set}= desc;
9711
+ if( typeof get!== 'function'|| typeof set!== 'function') {
9712
+ // A faux data property has both a getter and a setter
9713
+ return false;
9714
+ }
9715
+ if( get()!== expectedValue) {
9716
+ // The getter called by itself should produce the expectedValue
9717
+ return false;
9718
+ }
9719
+ if( apply(get, obj, [])!== expectedValue) {
9720
+ // The getter called with `this === obj` should also return the
9721
+ // expectedValue.
9722
+ return false;
9723
+ }
9724
+ const testValue= 'Seems to be a setter';
9725
+ const subject1= { __proto__: null};
9726
+ apply(set, subject1, [testValue]);
9727
+ if( subject1[prop]!== testValue) {
9728
+ // The setter called with an unrelated object as `this` should
9729
+ // set the property on the object.
9730
+ return false;
9731
+ }
9732
+ const subject2= { __proto__: obj};
9733
+ apply(set, subject2, [testValue]);
9734
+ if( subject2[prop]!== testValue) {
9735
+ // The setter called on an object that inherits from `obj` should
9736
+ // override the property from `obj` as if by assignment.
9737
+ return false;
9738
+ }
9739
+ if( !throws(()=> apply(set, obj, [expectedValue]))) {
9740
+ // The setter called with `this === obj` should throw without having
9741
+ // caused any effect.
9742
+ // This is the test that has the greatest danger of leaving behind some
9743
+ // persistent side effect. The most obvious one is to emulate a
9744
+ // successful assignment to the property. That's why this test
9745
+ // uses `expectedValue`, so that case is likely not to actually
9746
+ // change anything.
9747
+ return false;
9748
+ }
9749
+ if( 'originalValue'in get) {
9750
+ // The ses-shim uniquely, as far as we know, puts an `originalValue`
9751
+ // property on the getter, so that reflect property tranversal algorithms,
9752
+ // like `harden`, will traverse into the enulated value without
9753
+ // calling the getter. That does not happen until `permits-intrinsics.js`
9754
+ // which is much later. So if we see one this early, we should
9755
+ // not assume we understand what's going on.
9756
+ return false;
9757
+ }
9758
+
9759
+ // We assume that this code runs before any untrusted code runs, so
9760
+ // we do not need to worry about the above conditions passing because of
9761
+ // malicious intent. In fact, it runs even before vetted shims are supposed
9762
+ // to run, between repair and hardening. Given that, after all these tests
9763
+ // pass, we have adequately validated that the property in question is
9764
+ // an accessor function whose purpose is suppressing the override mistake,
9765
+ // i.e., enabling a non-writable property to be overridden by assignment.
9766
+ // In that case, here we *temporarily* turn it into the data property
9767
+ // it seems to emulate, but writable so that it does not trigger the
9768
+ // override mistake while in this temporary state.
9769
+
9770
+ // For those properties that are also listed in `enablements.js`,
9771
+ // that phase will re-enable override for these properties, but
9772
+ // via accessor functions that SES controls, so we know what they are
9773
+ // doing. In addition, the getter functions installed by
9774
+ // `enable-property-overrides.js` have an `originalValue` field
9775
+ // enabling meta-traversal code like harden to visit the original value
9776
+ // without calling the getter.
9777
+
9778
+ if( desc.configurable=== false) {
9779
+ // Even though it seems to be a faux data property, we're unable to fix it.
9780
+ return false;
9781
+ }
9782
+
9783
+ // Many of the `return false;` cases above plausibly should be turned into
9784
+ // errors, or an least generate warnings. However, for those, the checks
9785
+ // following this phase are likely to signal an error anyway.
9786
+
9787
+ // At this point, we have passed all our sniff checks for validating that
9788
+ // it seems to be a faux data property with the expected value. Turn
9789
+ // it into the actual data property it emulates, but writable so there is
9790
+ // not yet an override mistake problem.
9791
+
9792
+ defineProperty(obj, prop, {
9793
+ value: expectedValue,
9794
+ writable: true,
9795
+ enumerable: desc.enumerable,
9796
+ configurable: true});
9797
+
9798
+
9799
+ return true;
9800
+ };
9801
+
9802
+ /**
9803
+ * In JavaScript, the so-called "override mistake" is the inability to
9804
+ * override an inherited non-writable data property by assignment. A common
9805
+ * workaround is to instead define an accessor property that acts like
9806
+ * a non-writable data property, except that it allows an object that
9807
+ * inherits this property to override it by assignment. Let's call
9808
+ * an access property that acts this way a "faux data property". In this
9809
+ * ses-shim, `enable-property-overrides.js` makes the properties listed in
9810
+ * `enablements.js` into faux data properties.
9811
+ *
9812
+ * But the ses-shim is not alone in use of this trick. Starting with the
9813
+ * [Iterator Helpers proposal](https://github.com/tc39/proposal-iterator-helpers),
9814
+ * some properties are defined as (what we call) faux data properties.
9815
+ * Some of these are new properties (`Interator.prototype.constructor`) and
9816
+ * some are old data properties converted to accessor properties
9817
+ * (`Iterator.prototype[String.toStringTag]`). So the ses-shim needs to be
9818
+ * prepared for some enumerated set of properties to already be faux data
9819
+ * properties in the platform prior to our initialization.
9820
+ *
9821
+ * For these possible faux data properties, it is important that
9822
+ * `permits.js` describe each as a data property, so that it can further
9823
+ * constrain the apparent value (that allegedly would be returned by the
9824
+ * getter) according to its own permits.
9825
+ *
9826
+ * However, at the time of this writing, the precise behavior specified
9827
+ * by the iterator-helpers proposal for these faux data properties is
9828
+ * novel. We should not be too confident that all further such platform
9829
+ * additions do what we would now expect. So, for each of these possible
9830
+ * faux data properties, we do some sniffing to see if it behaves as we
9831
+ * currently expect a faux data property to act. If not, then
9832
+ * `tameFauxDataProperties` tries not to modify it, leaving it to later
9833
+ * checks, especially `permits-intrinsics.js`, to error when it sees an
9834
+ * unexpected accessor.
9835
+ *
9836
+ * If one of these enumerated accessor properties does seem to be
9837
+ * a faithful faux data property, then `tameFauxDataProperties` itself
9838
+ * *tempoarily* turns it into the actual data property that it seems to emulate.
9839
+ * This data property starts as writable, so that in this state it will
9840
+ * not trigger the override mistake, i.e., assignment to an object inheriting
9841
+ * this property is allowed to succeed at overriding this property.
9842
+ *
9843
+ * For those properties that should be a faux data property rather than an
9844
+ * actual one, such as those from the iterator-helpers proposal,
9845
+ * they should be listed as such in `enablements.js`, so
9846
+ * `enable-property-overrides.js` will turn it back into a faux data property.
9847
+ * But one controlled by the ses-shim, whose behavior we understand.
9848
+ *
9849
+ * `tameFauxDataProperties`, which turns these into actual data properties,
9850
+ * happens during the `repairIntrinsics` phase
9851
+ * of `lockdown`, before even vetted shim are supposed to run.
9852
+ * `enable-property-overrides.js` runs after vetted shims, turning the
9853
+ * appropriate ones back into faux data properties. Thus vetted shims
9854
+ * can observe the possibly non-conforming state where these are temporarily
9855
+ * actual data properties, rather than faux data properties.
9856
+ *
9857
+ * Coordinate the property enumeration here
9858
+ * with `enablements.js`, so the appropriate properties are
9859
+ * turned back to faux data properties.
9860
+ *
9861
+ * @param {Record<any,any>} intrinsics
9862
+ */$h‍_once.tameFauxDataProperty(tameFauxDataProperty);
9863
+ const tameFauxDataProperties= (intrinsics)=>{
9864
+ // https://github.com/tc39/proposal-iterator-helpers
9865
+ tameFauxDataProperty(
9866
+ intrinsics['%IteratorPrototype%'],
9867
+ 'constructor',
9868
+ intrinsics.Iterator);
9869
+
9870
+ // https://github.com/tc39/proposal-iterator-helpers
9871
+ tameFauxDataProperty(
9872
+ intrinsics['%IteratorPrototype%'],
9873
+ toStringTagSymbol,
9874
+ 'Iterator');
9875
+
9876
+ };$h‍_once.tameFauxDataProperties(tameFauxDataProperties);
9877
+ })()
9878
+ ,
9879
+ // === functors[48] ===
9880
+ ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties;$h‍_imports([["@endo/env-options", [["getEnvironmentOption", [$h‍_a => (getenv = $h‍_a)]]]],["./commons.js", [["FERAL_FUNCTION", [$h‍_a => (FERAL_FUNCTION = $h‍_a)]],["FERAL_EVAL", [$h‍_a => (FERAL_EVAL = $h‍_a)]],["TypeError", [$h‍_a => (TypeError = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["globalThis", [$h‍_a => (globalThis = $h‍_a)]],["is", [$h‍_a => (is = $h‍_a)]],["ownKeys", [$h‍_a => (ownKeys = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["noEvalEvaluate", [$h‍_a => (noEvalEvaluate = $h‍_a)]],["getOwnPropertyNames", [$h‍_a => (getOwnPropertyNames = $h‍_a)]],["getPrototypeOf", [$h‍_a => (getPrototypeOf = $h‍_a)]]]],["./make-hardener.js", [["makeHardener", [$h‍_a => (makeHardener = $h‍_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h‍_a => (makeIntrinsicsCollector = $h‍_a)]]]],["./permits-intrinsics.js", [["default", [$h‍_a => (whitelistIntrinsics = $h‍_a)]]]],["./tame-function-constructors.js", [["default", [$h‍_a => (tameFunctionConstructors = $h‍_a)]]]],["./tame-date-constructor.js", [["default", [$h‍_a => (tameDateConstructor = $h‍_a)]]]],["./tame-math-object.js", [["default", [$h‍_a => (tameMathObject = $h‍_a)]]]],["./tame-regexp-constructor.js", [["default", [$h‍_a => (tameRegExpConstructor = $h‍_a)]]]],["./enable-property-overrides.js", [["default", [$h‍_a => (enablePropertyOverrides = $h‍_a)]]]],["./tame-locale-methods.js", [["default", [$h‍_a => (tameLocaleMethods = $h‍_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h‍_a => (setGlobalObjectConstantProperties = $h‍_a)]],["setGlobalObjectMutableProperties", [$h‍_a => (setGlobalObjectMutableProperties = $h‍_a)]],["setGlobalObjectEvaluators", [$h‍_a => (setGlobalObjectEvaluators = $h‍_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h‍_a => (makeSafeEvaluator = $h‍_a)]]]],["./permits.js", [["initialGlobalPropertyNames", [$h‍_a => (initialGlobalPropertyNames = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./tame-domains.js", [["tameDomains", [$h‍_a => (tameDomains = $h‍_a)]]]],["./error/tame-console.js", [["tameConsole", [$h‍_a => (tameConsole = $h‍_a)]]]],["./error/tame-error-constructor.js", [["default", [$h‍_a => (tameErrorConstructor = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]],["makeAssert", [$h‍_a => (makeAssert = $h‍_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h‍_a => (getAnonymousIntrinsics = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-harden.js", [["tameHarden", [$h‍_a => (tameHarden = $h‍_a)]]]],["./tame-symbol-constructor.js", [["tameSymbolConstructor", [$h‍_a => (tameSymbolConstructor = $h‍_a)]]]],["./tame-faux-data-properties.js", [["tameFauxDataProperties", [$h‍_a => (tameFauxDataProperties = $h‍_a)]]]]]);
9881
+
9882
+
9532
9883
 
9533
9884
 
9534
9885
 
@@ -9685,8 +10036,6 @@ const repairIntrinsics= (options= {})=> {
9685
10036
  // [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/docs/lockdown.md#stackfiltering-options)
9686
10037
  // for an explanation.
9687
10038
 
9688
- const { getEnvironmentOption: getenv}= makeEnvironmentCaptor(globalThis);
9689
-
9690
10039
  const {
9691
10040
  errorTaming= getenv('LOCKDOWN_ERROR_TAMING', 'safe'),
9692
10041
  errorTrapping= /** @type {"platform" | "none" | "report" | "abort" | "exit" | undefined} */
@@ -9811,6 +10160,14 @@ const repairIntrinsics= (options= {})=> {
9811
10160
 
9812
10161
  const intrinsics= finalIntrinsics();
9813
10162
 
10163
+ const hostIntrinsics= { __proto__: null};
10164
+
10165
+ // The Node.js Buffer is a derived class of Uint8Array, and as such is often
10166
+ // passed around where a Uint8Array is expected.
10167
+ if( typeof globalThis.Buffer=== 'function') {
10168
+ hostIntrinsics.Buffer= globalThis.Buffer;
10169
+ }
10170
+
9814
10171
  /**
9815
10172
  * Wrap console unless suppressed.
9816
10173
  * At the moment, the console is considered a host power in the start
@@ -9831,6 +10188,19 @@ const repairIntrinsics= (options= {})=> {
9831
10188
 
9832
10189
  globalThis.console= /** @type {Console} */ consoleRecord.console;
9833
10190
 
10191
+ // The untamed Node.js console cannot itself be hardened as it has mutable
10192
+ // internal properties, but some of these properties expose internal versions
10193
+ // of classes from node's "primordials" concept.
10194
+ // eslint-disable-next-line no-underscore-dangle
10195
+ if( typeof /** @type {any} */ consoleRecord.console. _times=== 'object') {
10196
+ // SafeMap is a derived Map class used internally by Node
10197
+ // There doesn't seem to be a cleaner way to reach it.
10198
+ hostIntrinsics.SafeMap= getPrototypeOf(
10199
+ // eslint-disable-next-line no-underscore-dangle
10200
+ /** @type {any} */ consoleRecord.console. _times);
10201
+
10202
+ }
10203
+
9834
10204
  // @ts-ignore assert is absent on globalThis type def.
9835
10205
  if( errorTaming=== 'unsafe'&& globalThis.assert=== assert) {
9836
10206
  // If errorTaming is 'unsafe' we replace the global assert with
@@ -9845,6 +10215,8 @@ const repairIntrinsics= (options= {})=> {
9845
10215
  // Replace *Locale* methods with their non-locale equivalents
9846
10216
  tameLocaleMethods(intrinsics, localeTaming);
9847
10217
 
10218
+ tameFauxDataProperties(intrinsics);
10219
+
9848
10220
  /**
9849
10221
  * 2. WHITELIST to standardize the environment.
9850
10222
  */
@@ -9918,20 +10290,28 @@ const repairIntrinsics= (options= {})=> {
9918
10290
 
9919
10291
  // Finally register and optionally freeze all the intrinsics. This
9920
10292
  // must be the operation that modifies the intrinsics.
9921
- tamedHarden(intrinsics);
10293
+ const toHarden= {
10294
+ intrinsics,
10295
+ hostIntrinsics,
10296
+ globals: {
10297
+ // Harden evaluators
10298
+ Function: globalThis.Function,
10299
+ eval: globalThis.eval,
10300
+ // @ts-ignore Compartment does exist on globalThis
10301
+ Compartment: globalThis.Compartment,
10302
+
10303
+ // Harden Symbol
10304
+ Symbol: globalThis.Symbol}};
10305
+
9922
10306
 
9923
- // Harden evaluators
9924
- tamedHarden(globalThis.Function);
9925
- tamedHarden(globalThis.eval);
9926
- // @ts-ignore Compartment does exist on globalThis
9927
- tamedHarden(globalThis.Compartment);
9928
10307
 
9929
10308
  // Harden Symbol and properties for initialGlobalPropertyNames in the host realm
9930
- tamedHarden(globalThis.Symbol);
9931
10309
  for( const prop of getOwnPropertyNames(initialGlobalPropertyNames)) {
9932
- tamedHarden(globalThis[prop]);
10310
+ toHarden.globals[prop]= globalThis[prop];
9933
10311
  }
9934
10312
 
10313
+ tamedHarden(toHarden);
10314
+
9935
10315
  return tamedHarden;
9936
10316
  };
9937
10317
 
@@ -9939,7 +10319,7 @@ const repairIntrinsics= (options= {})=> {
9939
10319
  };$h‍_once.repairIntrinsics(repairIntrinsics);
9940
10320
  })()
9941
10321
  ,
9942
- // === functors[48] ===
10322
+ // === functors[49] ===
9943
10323
  ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,repairIntrinsics;$h‍_imports([["./assert-sloppy-mode.js", []],["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./lockdown.js", [["repairIntrinsics", [$h‍_a => (repairIntrinsics = $h‍_a)]]]]]);
9944
10324
 
9945
10325
 
@@ -9977,7 +10357,7 @@ globalThis.repairIntrinsics= (options)=>{
9977
10357
  };
9978
10358
  })()
9979
10359
  ,
9980
- // === functors[49] ===
10360
+ // === functors[50] ===
9981
10361
  ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,makeCompartmentConstructor,tameFunctionToString,getGlobalIntrinsics;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./compartment.js", [["makeCompartmentConstructor", [$h‍_a => (makeCompartmentConstructor = $h‍_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h‍_a => (tameFunctionToString = $h‍_a)]]]],["./intrinsics.js", [["getGlobalIntrinsics", [$h‍_a => (getGlobalIntrinsics = $h‍_a)]]]]]);
9982
10362
 
9983
10363
 
@@ -9994,14 +10374,14 @@ globalThis.Compartment= makeCompartmentConstructor(
9994
10374
  markVirtualizedNativeFunction);
9995
10375
  })()
9996
10376
  ,
9997
- // === functors[50] ===
10377
+ // === functors[51] ===
9998
10378
  ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { let globalThis,assert;$h‍_imports([["./commons.js", [["globalThis", [$h‍_a => (globalThis = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
9999
10379
 
10000
10380
 
10001
10381
  globalThis.assert= assert;
10002
10382
  })()
10003
10383
  ,
10004
- // === functors[51] ===
10384
+ // === functors[52] ===
10005
10385
  ({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => (function () { $h‍_imports([["./src/lockdown-shim.js", []],["./src/compartment-shim.js", []],["./src/assert-shim.js", []]]);
10006
10386
  })()
10007
10387
  ,
@@ -10165,6 +10545,9 @@ globalThis.assert= assert;
10165
10545
  },
10166
10546
  {
10167
10547
  makeEnvironmentCaptor: cell("makeEnvironmentCaptor"),
10548
+ getEnvironmentOption: cell("getEnvironmentOption"),
10549
+ getEnvironmentOptionsList: cell("getEnvironmentOptionsList"),
10550
+ environmentOptionsListHas: cell("environmentOptionsListHas"),
10168
10551
  },
10169
10552
  {
10170
10553
  },
@@ -10339,6 +10722,10 @@ globalThis.assert= assert;
10339
10722
  {
10340
10723
  tameSymbolConstructor: cell("tameSymbolConstructor"),
10341
10724
  },
10725
+ {
10726
+ tameFauxDataProperty: cell("tameFauxDataProperty"),
10727
+ tameFauxDataProperties: cell("tameFauxDataProperties"),
10728
+ },
10342
10729
  {
10343
10730
  repairIntrinsics: cell("repairIntrinsics"),
10344
10731
  },
@@ -10354,7 +10741,16 @@ globalThis.assert= assert;
10354
10741
 
10355
10742
  Object.defineProperties(cells[3], Object.getOwnPropertyDescriptors(cells[2]));
10356
10743
 
10357
- const namespaces = cells.map(cells => Object.freeze(Object.create(null, cells)));
10744
+ const namespaces = cells.map(cells => Object.freeze(Object.create(null, {
10745
+ ...cells,
10746
+ // Make this appear like an ESM module namespace object.
10747
+ [Symbol.toStringTag]: {
10748
+ value: 'Module',
10749
+ writable: false,
10750
+ enumerable: false,
10751
+ configurable: false,
10752
+ },
10753
+ })));
10358
10754
 
10359
10755
  for (let index = 0; index < namespaces.length; index += 1) {
10360
10756
  cells[index]['*'] = cell('*', namespaces[index]);
@@ -10533,6 +10929,9 @@ function observeImports(map, importName, importIndex) {
10533
10929
  },
10534
10930
  onceVar: {
10535
10931
  makeEnvironmentCaptor: cells[2].makeEnvironmentCaptor.set,
10932
+ getEnvironmentOption: cells[2].getEnvironmentOption.set,
10933
+ getEnvironmentOptionsList: cells[2].getEnvironmentOptionsList.set,
10934
+ environmentOptionsListHas: cells[2].environmentOptionsListHas.set,
10536
10935
  },
10537
10936
  importMeta: {},
10538
10937
  });
@@ -10725,6 +11124,7 @@ function observeImports(map, importName, importIndex) {
10725
11124
  functors[17]({
10726
11125
  imports(entries) {
10727
11126
  const map = new Map(entries);
11127
+ observeImports(map, "./commons.js", 0);
10728
11128
  },
10729
11129
  liveVar: {
10730
11130
  },
@@ -11153,6 +11553,19 @@ function observeImports(map, importName, importIndex) {
11153
11553
  importMeta: {},
11154
11554
  });
11155
11555
  functors[47]({
11556
+ imports(entries) {
11557
+ const map = new Map(entries);
11558
+ observeImports(map, "./commons.js", 0);
11559
+ },
11560
+ liveVar: {
11561
+ },
11562
+ onceVar: {
11563
+ tameFauxDataProperty: cells[47].tameFauxDataProperty.set,
11564
+ tameFauxDataProperties: cells[47].tameFauxDataProperties.set,
11565
+ },
11566
+ importMeta: {},
11567
+ });
11568
+ functors[48]({
11156
11569
  imports(entries) {
11157
11570
  const map = new Map(entries);
11158
11571
  observeImports(map, "@endo/env-options", 3);
@@ -11178,20 +11591,21 @@ function observeImports(map, importName, importIndex) {
11178
11591
  observeImports(map, "./compartment.js", 43);
11179
11592
  observeImports(map, "./tame-harden.js", 45);
11180
11593
  observeImports(map, "./tame-symbol-constructor.js", 46);
11594
+ observeImports(map, "./tame-faux-data-properties.js", 47);
11181
11595
  },
11182
11596
  liveVar: {
11183
11597
  },
11184
11598
  onceVar: {
11185
- repairIntrinsics: cells[47].repairIntrinsics.set,
11599
+ repairIntrinsics: cells[48].repairIntrinsics.set,
11186
11600
  },
11187
11601
  importMeta: {},
11188
11602
  });
11189
- functors[48]({
11603
+ functors[49]({
11190
11604
  imports(entries) {
11191
11605
  const map = new Map(entries);
11192
11606
  observeImports(map, "./assert-sloppy-mode.js", 1);
11193
11607
  observeImports(map, "./commons.js", 0);
11194
- observeImports(map, "./lockdown.js", 47);
11608
+ observeImports(map, "./lockdown.js", 48);
11195
11609
  },
11196
11610
  liveVar: {
11197
11611
  },
@@ -11199,7 +11613,7 @@ function observeImports(map, importName, importIndex) {
11199
11613
  },
11200
11614
  importMeta: {},
11201
11615
  });
11202
- functors[49]({
11616
+ functors[50]({
11203
11617
  imports(entries) {
11204
11618
  const map = new Map(entries);
11205
11619
  observeImports(map, "./commons.js", 0);
@@ -11213,7 +11627,7 @@ function observeImports(map, importName, importIndex) {
11213
11627
  },
11214
11628
  importMeta: {},
11215
11629
  });
11216
- functors[50]({
11630
+ functors[51]({
11217
11631
  imports(entries) {
11218
11632
  const map = new Map(entries);
11219
11633
  observeImports(map, "./commons.js", 0);
@@ -11225,12 +11639,12 @@ function observeImports(map, importName, importIndex) {
11225
11639
  },
11226
11640
  importMeta: {},
11227
11641
  });
11228
- functors[51]({
11642
+ functors[52]({
11229
11643
  imports(entries) {
11230
11644
  const map = new Map(entries);
11231
- observeImports(map, "./src/lockdown-shim.js", 48);
11232
- observeImports(map, "./src/compartment-shim.js", 49);
11233
- observeImports(map, "./src/assert-shim.js", 50);
11645
+ observeImports(map, "./src/lockdown-shim.js", 49);
11646
+ observeImports(map, "./src/compartment-shim.js", 50);
11647
+ observeImports(map, "./src/assert-shim.js", 51);
11234
11648
  },
11235
11649
  liveVar: {
11236
11650
  },