ses 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ses.cjs CHANGED
@@ -101,6 +101,7 @@ const defineProperty= (object, prop, descriptor)=> {
101
101
  // Instead, to workaround the Safari bug
102
102
  const result= originalDefineProperty(object, prop, descriptor);
103
103
  if( result!== object) {
104
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_DEFINE_PROPERTY_FAILED_SILENTLY.md
104
105
  throw TypeError(
105
106
  `Please report that the original defineProperty silently failed to set ${stringifyJson(
106
107
  String(prop))
@@ -283,6 +284,7 @@ $h‍_once.isError(isError);const FERAL_EVAL=eval;
283
284
  $h‍_once.FERAL_EVAL(FERAL_EVAL);const FERAL_FUNCTION=Function;$h‍_once.FERAL_FUNCTION(FERAL_FUNCTION);
284
285
 
285
286
  const noEvalEvaluate= ()=> {
287
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_EVAL.md
286
288
  throw new TypeError(
287
289
  'Cannot eval with evalTaming set to "noEval" (SES_NO_EVAL)');
288
290
 
@@ -317,7 +319,7 @@ const noEvalEvaluate= ()=> {
317
319
  */
318
320
 
319
321
  /**
320
- * @typedef {Object} LoggedErrorHandler
322
+ * @typedef {object} LoggedErrorHandler
321
323
  *
322
324
  * Used to parameterize `makeCausalConsole` to give it access to potentially
323
325
  * hidden information to augment the logging of errors.
@@ -337,13 +339,13 @@ const noEvalEvaluate= ()=> {
337
339
  */
338
340
 
339
341
  /**
340
- * @typedef {Object} LoggingConsoleKit
342
+ * @typedef {object} LoggingConsoleKit
341
343
  * @property {VirtualConsole} loggingConsole
342
344
  * @property {() => readonly LogRecord[]} takeLog
343
345
  */
344
346
 
345
347
  /**
346
- * @typedef {Object} MakeLoggingConsoleKitOptions
348
+ * @typedef {object} MakeLoggingConsoleKitOptions
347
349
  * @property {boolean=} shouldResetForDebugging
348
350
  */
349
351
 
@@ -589,8 +591,9 @@ freeze(bestEffortStringify);
589
591
  *
590
592
  * The `assert.fail` method.
591
593
  *
592
- * Fail an assertion, recording details to the console and
593
- * raising an exception with just type information.
594
+ * Fail an assertion, recording full details to the console and
595
+ * raising an exception with a message in which `details` substitution values
596
+ * have been redacted.
594
597
  *
595
598
  * The optional `optDetails` can be a string for backwards compatibility
596
599
  * with the nodejs assertion library.
@@ -696,14 +699,15 @@ freeze(bestEffortStringify);
696
699
  * Assert an expected typeof result.
697
700
  * @param {any} specimen The value to get the typeof
698
701
  * @param {Details=} optDetails The details to throw
702
+ * @returns {asserts specimen is string}
699
703
  */
700
704
 
701
705
  /**
702
706
  * @callback AssertNote
703
707
  * The `assert.note` method.
704
708
  *
705
- * Annotate this error with these details, potentially to be used by an
706
- * augmented console, like the causal console of `console.js`, to
709
+ * Annotate an error with details, potentially to be used by an
710
+ * augmented console such as the causal console of `console.js`, to
707
711
  * provide extra information associated with logged errors.
708
712
  *
709
713
  * @param {Error} error
@@ -733,38 +737,24 @@ freeze(bestEffortStringify);
733
737
 
734
738
  /**
735
739
  * To "declassify" and quote a substitution value used in a
736
- * details`...` template literal, enclose that substitution expression
737
- * in a call to `quote`. This states that the argument should appear quoted
738
- * (as if with `JSON.stringify`), in the error message of the thrown error. The
740
+ * ``` details`...` ``` template literal, enclose that substitution expression
741
+ * in a call to `quote`. This makes the value appear quoted
742
+ * (as if with `JSON.stringify`) in the message of the thrown error. The
739
743
  * payload itself is still passed unquoted to the console as it would be
740
744
  * without `quote`.
741
745
  *
742
- * Starting from the example in the `details` comment, say instead that the
743
- * color the sky is supposed to be is also computed. Say that we still don't
744
- * want to reveal the sky's actual color, but we do want the thrown error's
745
- * message to reveal what color the sky was supposed to be:
746
+ * For example, the following will reveal the expected sky color, but not the
747
+ * actual incorrect sky color, in the thrown error's message:
746
748
  * ```js
747
- * assert.equal(
748
- * sky.color,
749
- * color,
750
- * details`${sky.color} should be ${quote(color)}`,
751
- * );
749
+ * sky.color === expectedColor || Fail`${sky.color} should be ${quote(expectedColor)}`;
752
750
  * ```
753
751
  *
754
752
  * // TODO Update SES-shim to new convention, where `details` is
755
753
  * // renamed to `X` rather than `d`.
756
- * The normal convention is to locally rename `quote` to `q` and
757
- * `details` to `d`
758
- * ```js
759
- * const { details: d, quote: q } = assert;
760
- * ```
761
- * so the above example would then be
754
+ * The normal convention is to locally rename `details` to `d` and `quote` to `q`
755
+ * like `const { details: d, quote: q } = assert;`, so the above example would then be
762
756
  * ```js
763
- * assert.equal(
764
- * sky.color,
765
- * color,
766
- * d`${sky.color} should be ${q(color)}`,
767
- * );
757
+ * sky.color === expectedColor || Fail`${sky.color} should be ${q(expectedColor)}`;
768
758
  * ```
769
759
  *
770
760
  * @callback AssertQuote
@@ -816,75 +806,68 @@ freeze(bestEffortStringify);
816
806
  * ```js
817
807
  * assert(sky.isBlue(), details`${sky.color} should be "blue"`);
818
808
  * ```
809
+ * // TODO Update SES-shim to new convention, where `details` is
810
+ * // renamed to `X` rather than `d`.
811
+ * or following the normal convention to locally rename `details` to `d`
812
+ * and `quote` to `q` like `const { details: d, quote: q } = assert;`:
813
+ * ```js
814
+ * assert(sky.isBlue(), d`${sky.color} should be "blue"`);
815
+ * ```
816
+ * However, note that in most cases it is preferable to instead use the `Fail`
817
+ * template literal tag (which has the same input signature as `details`
818
+ * but automatically creates and throws an error):
819
+ * ```js
820
+ * sky.isBlue() || Fail`${sky.color} should be "blue"`;
821
+ * ```
822
+ *
819
823
  * The details template tag returns a `DetailsToken` object that can print
820
824
  * itself with the formatted message in two ways.
821
- * It will report the real details to
822
- * the console but include only the typeof information in the thrown error
825
+ * It will report full details to the console, but
826
+ * mask embedded substitution values with their typeof information in the thrown error
823
827
  * to prevent revealing secrets up the exceptional path. In the example
824
828
  * above, the thrown error may reveal only that `sky.color` is a string,
825
829
  * whereas the same diagnostic printed to the console reveals that the
826
- * sky was green.
830
+ * sky was green. This masking can be disabled for an individual substitution value
831
+ * using `quote`.
827
832
  *
828
- * The `raw` member of a `template` is ignored, so a simple
829
- * `string[]` can also be used as a template.
833
+ * The `raw` property of an input template array is ignored, so a simple
834
+ * array of strings may be provided directly.
830
835
  */
831
836
 
832
837
  /**
833
838
  * @typedef {(template: TemplateStringsArray | string[], ...args: any) => never} FailTag
834
- * The `Fail` tamplate tag supports replacing patterns like
835
- * ```js
836
- * assert(cond, X`...complaint...`);
837
- * ```
838
- * or
839
- * ```js
840
- * cond || assert.fail(X`...complaint...`);
841
- * ```
842
- * with patterns like
843
- * ```js
844
- * cond || Fail`...complaint...`;
845
- * ```
846
839
  *
847
- * However, due to [weakness in current
848
- * TypeScript](https://github.com/microsoft/TypeScript/issues/51426), the `||`
849
- * patterns are not as powerful as the `assert(...)` call at enabling static
850
- * reasoning. Of the `||`, again due to weaknesses in current TypeScript,
851
- * the
840
+ * Use the `Fail` function as a template literal tag to efficiently
841
+ * create and throw a `details`-style error only when a condition is not satisfied.
852
842
  * ```js
853
- * cond || Fail`...complaint...`
843
+ * condition || Fail`...complaint...`;
854
844
  * ```
855
- * pattern is not as powerful as the
845
+ * This avoids the overhead of creating usually-unnecessary errors like
856
846
  * ```js
857
- * cond || assert.fail(X`...complaint...`);
847
+ * assert(condition, details`...complaint...`);
858
848
  * ```
859
- * at enabling static resoning. Despite these problems, we do not want to
860
- * return to the
849
+ * while improving readability over alternatives like
861
850
  * ```js
862
- * assert(cond, X`...complaint...`)
851
+ * condition || assert.fail(details`...complaint...`);
863
852
  * ```
864
- * style because of the substantial overhead in
865
- * evaluating the `X` template in the typical `true` case where it is not
866
- * needed. And we do not want to return to the
867
- * ```js
868
- * assert.fail(X`...complaint...`)`
869
- * ```
870
- * because of the verbosity and loss of readability. Instead, until/unless
871
- * https://github.com/microsoft/TypeScript/issues/51426 is fixed, for those
872
- * new-style assertions where this loss of static reasoning is a problem,
853
+ *
854
+ * However, due to current weakness in TypeScript, static reasoning
855
+ * is less powerful with the `||` patterns than with an `assert` call.
856
+ * Until/unless https://github.com/microsoft/TypeScript/issues/51426 is fixed,
857
+ * for `||`-style assertions where this loss of static reasoning is a problem,
873
858
  * instead express the assertion as
874
859
  * ```js
875
- * if (!cond) {
860
+ * if (!condition) {
876
861
  * Fail`...complaint...`;
877
862
  * }
878
863
  * ```
879
864
  * or, if needed,
880
865
  * ```js
881
- * if (!cond) {
882
- * // `throw` is noop since `Fail` throws. But linter confused
866
+ * if (!condition) {
867
+ * // `throw` is noop since `Fail` throws, but it improves static analysis
883
868
  * throw Fail`...complaint...`;
884
869
  * }
885
870
  * ```
886
- * This avoid the TypeScript bugs that cause the loss of static reasoning,
887
- * but with no loss of efficiency and little loss of readability.
888
871
  */
889
872
 
890
873
  /**
@@ -922,7 +905,7 @@ freeze(bestEffortStringify);
922
905
  // /////////////////////////////////////////////////////////////////////////////
923
906
 
924
907
  /**
925
- * @typedef {Object} VirtualConsole
908
+ * @typedef {object} VirtualConsole
926
909
  * @property {Console['debug']} debug
927
910
  * @property {Console['log']} log
928
911
  * @property {Console['info']} info
@@ -1039,7 +1022,7 @@ freeze(quote);
1039
1022
  // /////////////////////////////////////////////////////////////////////////////
1040
1023
 
1041
1024
  /**
1042
- * @typedef {Object} HiddenDetails
1025
+ * @typedef {object} HiddenDetails
1043
1026
  *
1044
1027
  * Captures the arguments passed to the `details` template string tag.
1045
1028
  *
@@ -1343,9 +1326,11 @@ freeze(loggedErrorHandler);
1343
1326
  */
1344
1327
  const makeAssert= (optRaise= undefined, unredacted= false)=> {
1345
1328
  const details= unredacted? unredactedDetails: redactedDetails;
1329
+ const assertFailedDetails= details `Check failed`;
1330
+
1346
1331
  /** @type {AssertFail} */
1347
1332
  const fail= (
1348
- optDetails= details `Assert failed`,
1333
+ optDetails= assertFailedDetails,
1349
1334
  ErrorConstructor= globalThis.Error)=>
1350
1335
  {
1351
1336
  const reason= makeError(optDetails, ErrorConstructor);
@@ -1365,30 +1350,36 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> {
1365
1350
  /** @type {BaseAssert} */
1366
1351
  function baseAssert(
1367
1352
  flag,
1368
- optDetails= details `Check failed`,
1369
- ErrorConstructor= globalThis.Error)
1353
+ optDetails= undefined,
1354
+ ErrorConstructor= undefined)
1370
1355
  {
1371
- if( !flag) {
1372
- throw fail(optDetails, ErrorConstructor);
1373
- }
1356
+ flag|| fail(optDetails, ErrorConstructor);
1374
1357
  }
1375
1358
 
1376
1359
  /** @type {AssertEqual} */
1377
1360
  const equal= (
1378
1361
  actual,
1379
1362
  expected,
1380
- optDetails= details `Expected ${actual} is same as ${expected}`,
1381
- ErrorConstructor= RangeError)=>
1363
+ optDetails= undefined,
1364
+ ErrorConstructor= undefined)=>
1382
1365
  {
1383
- baseAssert(is(actual, expected), optDetails, ErrorConstructor);
1366
+ is(actual, expected)||
1367
+ fail(
1368
+ optDetails|| details `Expected ${actual} is same as ${expected}`,
1369
+ ErrorConstructor|| RangeError);
1370
+
1384
1371
  };
1385
1372
  freeze(equal);
1386
1373
 
1387
1374
  /** @type {AssertTypeof} */
1388
1375
  const assertTypeof= (specimen, typename, optDetails)=> {
1389
- baseAssert(
1390
- typeof typename=== 'string',
1391
- details `${quote(typename)} must be a string`);
1376
+ // This will safely fall through if typename is not a string,
1377
+ // which is what we want.
1378
+ // eslint-disable-next-line valid-typeof
1379
+ if( typeof specimen=== typename) {
1380
+ return;
1381
+ }
1382
+ typeof typename=== 'string'|| Fail `${quote(typename)} must be a string`;
1392
1383
 
1393
1384
  if( optDetails=== undefined) {
1394
1385
  // Like
@@ -1399,12 +1390,12 @@ const makeAssert= (optRaise= undefined, unredacted= false)=> {
1399
1390
  // so it doesn't get quoted.
1400
1391
  optDetails= details(['', ` must be ${an(typename)}`],specimen);
1401
1392
  }
1402
- equal(typeof specimen, typename, optDetails, TypeError);
1393
+ fail(optDetails, TypeError);
1403
1394
  };
1404
1395
  freeze(assertTypeof);
1405
1396
 
1406
1397
  /** @type {AssertString} */
1407
- const assertString= (specimen, optDetails)=>
1398
+ const assertString= (specimen, optDetails= undefined)=>
1408
1399
  assertTypeof(specimen, 'string', optDetails);
1409
1400
 
1410
1401
  // Note that "assert === baseAssert"
@@ -1666,8 +1657,8 @@ function isImmutableDataProperty(obj, name) {
1666
1657
  * service if any of the names are keywords or keyword-like. This is
1667
1658
  * safe and only prevent performance optimization.
1668
1659
  *
1669
- * @param {Object} globalObject
1670
- * @param {Object} moduleLexicals
1660
+ * @param {object} globalObject
1661
+ * @param {object} moduleLexicals
1671
1662
  */
1672
1663
  const getScopeConstants= (globalObject, moduleLexicals= {})=> {
1673
1664
  // getOwnPropertyNames() does ignore Symbols so we don't need to
@@ -1959,6 +1950,7 @@ const createSloppyGlobalsScopeTerminator= (globalObject)=>{
1959
1950
 
1960
1951
  return sloppyGlobalsScopeTerminator;
1961
1952
  };$h‍_once.createSloppyGlobalsScopeTerminator(createSloppyGlobalsScopeTerminator);
1953
+ freeze(createSloppyGlobalsScopeTerminator);
1962
1954
  })
1963
1955
  ,
1964
1956
  // === functors[10] ===
@@ -1977,6 +1969,9 @@ const sourceMetaEntriesRegExp= new FERAL_REG_EXP(
1977
1969
  `(?:\\s*//${sourceMetaEntryRegExp}|/\\*${sourceMetaEntryRegExp}\\s*\\*/)\\s*$`);
1978
1970
 
1979
1971
 
1972
+ /**
1973
+ * @param {string} src
1974
+ */
1980
1975
  const getSourceURL= (src)=>{
1981
1976
  let sourceURL= '<unknown>';
1982
1977
 
@@ -2012,7 +2007,8 @@ const getSourceURL= (src)=>{
2012
2007
  })
2013
2008
  ,
2014
2009
  // === functors[11] ===
2015
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { 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)]]]]]);
2010
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let FERAL_REG_EXP,SyntaxError,stringReplace,stringSearch,stringSlice,stringSplit,freeze,getSourceURL;$h‍_imports([["./commons.js", [["FERAL_REG_EXP", [$h‍_a => (FERAL_REG_EXP = $h‍_a)]],["SyntaxError", [$h‍_a => (SyntaxError = $h‍_a)]],["stringReplace", [$h‍_a => (stringReplace = $h‍_a)]],["stringSearch", [$h‍_a => (stringSearch = $h‍_a)]],["stringSlice", [$h‍_a => (stringSlice = $h‍_a)]],["stringSplit", [$h‍_a => (stringSplit = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./get-source-url.js", [["getSourceURL", [$h‍_a => (getSourceURL = $h‍_a)]]]]]);
2011
+
2016
2012
 
2017
2013
 
2018
2014
 
@@ -2083,6 +2079,7 @@ const rejectHtmlComments= (src)=>{
2083
2079
  return src;
2084
2080
  }
2085
2081
  const name= getSourceURL(src);
2082
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
2086
2083
  throw new SyntaxError(
2087
2084
  `Possible HTML comment rejected at ${name}:${lineNumber}. (SES_HTML_COMMENT_REJECTED)`);
2088
2085
 
@@ -2158,6 +2155,7 @@ const rejectImportExpressions= (src)=>{
2158
2155
  return src;
2159
2156
  }
2160
2157
  const name= getSourceURL(src);
2158
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_IMPORT_REJECTED.md
2161
2159
  throw new SyntaxError(
2162
2160
  `Possible import expression rejected at ${name}:${lineNumber}. (SES_IMPORT_REJECTED)`);
2163
2161
 
@@ -2229,6 +2227,7 @@ const rejectSomeDirectEvalExpressions= (src)=>{
2229
2227
  return src;
2230
2228
  }
2231
2229
  const name= getSourceURL(src);
2230
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_EVAL_REJECTED.md
2232
2231
  throw new SyntaxError(
2233
2232
  `Possible direct eval expression rejected at ${name}:${lineNumber}. (SES_EVAL_REJECTED)`);
2234
2233
 
@@ -2262,7 +2261,17 @@ const applyTransforms= (source, transforms)=> {
2262
2261
  source= transform(source);
2263
2262
  }
2264
2263
  return source;
2265
- };$h‍_once.applyTransforms(applyTransforms);
2264
+ };
2265
+
2266
+ // export all as a frozen object
2267
+ $h‍_once.applyTransforms(applyTransforms);const transforms=freeze({
2268
+ rejectHtmlComments: freeze(rejectHtmlComments),
2269
+ evadeHtmlCommentTest: freeze(evadeHtmlCommentTest),
2270
+ rejectImportExpressions: freeze(rejectImportExpressions),
2271
+ evadeImportExpressionTest: freeze(evadeImportExpressionTest),
2272
+ rejectSomeDirectEvalExpressions: freeze(rejectSomeDirectEvalExpressions),
2273
+ mandatoryTransforms: freeze(mandatoryTransforms),
2274
+ applyTransforms: freeze(applyTransforms)});$h‍_once.transforms(transforms);
2266
2275
  })
2267
2276
  ,
2268
2277
  // === functors[12] ===
@@ -2284,9 +2293,9 @@ const { Fail}= assert;
2284
2293
  * Build the low-level operation used by all evaluators:
2285
2294
  * eval(), Function(), Compartment.prototype.evaluate().
2286
2295
  *
2287
- * @param {Object} options
2288
- * @param {Object} options.globalObject
2289
- * @param {Object} [options.moduleLexicals]
2296
+ * @param {object} options
2297
+ * @param {object} options.globalObject
2298
+ * @param {object} [options.moduleLexicals]
2290
2299
  * @param {Array<Transform>} [options.globalTransforms]
2291
2300
  * @param {bool} [options.sloppyGlobalsMode]
2292
2301
  */
@@ -2321,7 +2330,7 @@ const makeSafeEvaluator= ({
2321
2330
 
2322
2331
  /**
2323
2332
  * @param {string} source
2324
- * @param {Object} [options]
2333
+ * @param {object} [options]
2325
2334
  * @param {Array<Transform>} [options.localTransforms]
2326
2335
  */
2327
2336
  const safeEvaluate= (source, { localTransforms= []}= {})=> {
@@ -3985,7 +3994,7 @@ const whitelist= {
3985
3994
  * But, we can install this setter to prevent a program from proceding on
3986
3995
  * this false assumption.
3987
3996
  *
3988
- * @param {Object} globalObject
3997
+ * @param {object} globalObject
3989
3998
  */
3990
3999
  const setGlobalObjectSymbolUnscopables= (globalObject)=>{
3991
4000
  defineProperty(
@@ -4011,7 +4020,7 @@ const setGlobalObjectSymbolUnscopables= (globalObject)=>{
4011
4020
  * (SetDefaultGlobalBindings). This process is split between this function and
4012
4021
  * `setGlobalObjectMutableProperties`.
4013
4022
  *
4014
- * @param {Object} globalObject
4023
+ * @param {object} globalObject
4015
4024
  */$h‍_once.setGlobalObjectSymbolUnscopables(setGlobalObjectSymbolUnscopables);
4016
4025
  const setGlobalObjectConstantProperties= (globalObject)=>{
4017
4026
  for( const [name, constant]of entries(constantProperties)) {
@@ -4031,12 +4040,12 @@ const setGlobalObjectConstantProperties= (globalObject)=>{
4031
4040
  * `newGlobalPropertyNames` should be either `initialGlobalPropertyNames` or
4032
4041
  * `sharedGlobalPropertyNames`.
4033
4042
  *
4034
- * @param {Object} globalObject
4035
- * @param {Object} param1
4036
- * @param {Object} param1.intrinsics
4037
- * @param {Object} param1.newGlobalPropertyNames
4043
+ * @param {object} globalObject
4044
+ * @param {object} param1
4045
+ * @param {object} param1.intrinsics
4046
+ * @param {object} param1.newGlobalPropertyNames
4038
4047
  * @param {Function} param1.makeCompartmentConstructor
4039
- * @param {(Object) => void} param1.markVirtualizedNativeFunction
4048
+ * @param {(object) => void} param1.markVirtualizedNativeFunction
4040
4049
  */$h‍_once.setGlobalObjectConstantProperties(setGlobalObjectConstantProperties);
4041
4050
  const setGlobalObjectMutableProperties= (
4042
4051
  globalObject,
@@ -4098,9 +4107,9 @@ const setGlobalObjectMutableProperties= (
4098
4107
  * setGlobalObjectEvaluators()
4099
4108
  * Set the eval and the Function evaluator on the global object with given evalTaming policy.
4100
4109
  *
4101
- * @param {Object} globalObject
4110
+ * @param {object} globalObject
4102
4111
  * @param {Function} evaluator
4103
- * @param {(Object) => void} markVirtualizedNativeFunction
4112
+ * @param {(object) => void} markVirtualizedNativeFunction
4104
4113
  */$h‍_once.setGlobalObjectMutableProperties(setGlobalObjectMutableProperties);
4105
4114
  const setGlobalObjectEvaluators= (
4106
4115
  globalObject,
@@ -4452,7 +4461,7 @@ const load= async(
4452
4461
 
4453
4462
  /** @type {Set<Promise<undefined>>} */
4454
4463
  const pendingJobs= new Set();
4455
- /** @type {Map<Object, Map<string, Promise<Record>>} */
4464
+ /** @type {Map<object, Map<string, Promise<Record>>} */
4456
4465
  const moduleLoads= new Map();
4457
4466
  /** @type {Array<Error>} */
4458
4467
  const errors= [];
@@ -4809,7 +4818,8 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
4809
4818
  __fixedExportMap__: fixedExportMap= {},
4810
4819
  __liveExportMap__: liveExportMap= {},
4811
4820
  __reexportMap__: reexportMap= {},
4812
- __needsImportMeta__: needsImportMeta= false}=
4821
+ __needsImportMeta__: needsImportMeta= false,
4822
+ __syncModuleFunctor__}=
4813
4823
  staticModuleRecord;
4814
4824
 
4815
4825
  const compartmentFields= weakmapGet(privateFields, compartment);
@@ -5118,11 +5128,16 @@ $h‍_once.makeThirdPartyModuleInstance(makeThirdPartyModuleInstance);const make
5118
5128
  activate();
5119
5129
  }
5120
5130
 
5121
- let optFunctor= compartmentEvaluate(compartmentFields, functorSource, {
5122
- globalObject: compartment.globalThis,
5123
- transforms: __shimTransforms__,
5124
- __moduleShimLexicals__: moduleLexicals});
5131
+ let optFunctor;
5132
+ if( __syncModuleFunctor__!== undefined) {
5133
+ optFunctor= __syncModuleFunctor__;
5134
+ }else {
5135
+ optFunctor= compartmentEvaluate(compartmentFields, functorSource, {
5136
+ globalObject: compartment.globalThis,
5137
+ transforms: __shimTransforms__,
5138
+ __moduleShimLexicals__: moduleLexicals});
5125
5139
 
5140
+ }
5126
5141
  let didThrow= false;
5127
5142
  let thrownError;
5128
5143
  function execute() {
@@ -5438,10 +5453,10 @@ const CompartmentPrototype= {
5438
5453
 
5439
5454
  /**
5440
5455
  * @param {string} source is a JavaScript program grammar construction.
5441
- * @param {Object} [options]
5456
+ * @param {object} [options]
5442
5457
  * @param {Array<Transform>} [options.transforms]
5443
5458
  * @param {boolean} [options.sloppyGlobalsMode]
5444
- * @param {Object} [options.__moduleShimLexicals__]
5459
+ * @param {object} [options.__moduleShimLexicals__]
5445
5460
  * @param {boolean} [options.__evadeHtmlCommentTest__]
5446
5461
  * @param {boolean} [options.__evadeImportExpressionTest__]
5447
5462
  * @param {boolean} [options.__rejectSomeDirectEvalExpressions__]
@@ -5522,7 +5537,7 @@ defineProperties(InertCompartment, {
5522
5537
  * @callback MakeCompartmentConstructor
5523
5538
  * @param {MakeCompartmentConstructor} targetMakeCompartmentConstructor
5524
5539
  * @param {Record<string, any>} intrinsics
5525
- * @param {(object: Object) => void} markVirtualizedNativeFunction
5540
+ * @param {(object: object) => void} markVirtualizedNativeFunction
5526
5541
  * @returns {Compartment['constructor']}
5527
5542
  */
5528
5543
 
@@ -5801,7 +5816,7 @@ const makeIntrinsicsCollector= ()=> {
5801
5816
  * If run before lockdown, the returned intrinsics record will carry the
5802
5817
  * *original* unsafe (feral, untamed) bindings of these global variables.
5803
5818
  *
5804
- * @param {Object} globalObject
5819
+ * @param {object} globalObject
5805
5820
  */$h‍_once.makeIntrinsicsCollector(makeIntrinsicsCollector);
5806
5821
  const getGlobalIntrinsics= (globalObject)=>{
5807
5822
  const { addIntrinsics, finalIntrinsics}= makeIntrinsicsCollector();
@@ -6020,7 +6035,19 @@ const severeEnablements= {
6020
6035
  * include enough of the `TypeArray` methods that here, the `severe`
6021
6036
  * enablements just enable them all.
6022
6037
  */
6023
- '%TypedArrayPrototype%': '*'};$h‍_once.severeEnablements(severeEnablements);
6038
+ '%TypedArrayPrototype%': '*',
6039
+
6040
+ /**
6041
+ * Needed to work with Immer before https://github.com/immerjs/immer/pull/914
6042
+ * is accepted.
6043
+ */
6044
+ '%MapPrototype%': '*',
6045
+
6046
+ /**
6047
+ * Needed to work with Immer before https://github.com/immerjs/immer/pull/914
6048
+ * is accepted.
6049
+ */
6050
+ '%SetPrototype%': '*'};$h‍_once.severeEnablements(severeEnablements);
6024
6051
  })
6025
6052
  ,
6026
6053
  // === functors[25] ===
@@ -6238,7 +6265,7 @@ function enablePropertyOverrides(
6238
6265
 
6239
6266
 
6240
6267
 
6241
- const { details: X, Fail, quote: q}= assert;
6268
+ const { Fail, quote: q}= assert;
6242
6269
 
6243
6270
  /**
6244
6271
  * JavaScript module semantics resists attempts to parameterize a module's
@@ -6288,7 +6315,7 @@ const { details: X, Fail, quote: q}= assert;
6288
6315
  * variables, if they are needed, and a way to catalog the names of all
6289
6316
  * the environment variables that were captured.
6290
6317
  *
6291
- * @param {Object} aGlobal
6318
+ * @param {object} aGlobal
6292
6319
  */
6293
6320
  const makeEnvironmentCaptor= (aGlobal)=>{
6294
6321
  const capturedEnvironmentOptionNames= [];
@@ -6303,19 +6330,13 @@ const makeEnvironmentCaptor= (aGlobal)=>{
6303
6330
  */
6304
6331
  const getEnvironmentOption= (optionName, defaultSetting)=> {
6305
6332
  // eslint-disable-next-line @endo/no-polymorphic-call
6306
- assert.typeof(
6307
- optionName,
6308
- 'string',
6309
- X `Environment option name ${q(optionName)} must be a string.`);
6310
-
6333
+ typeof optionName=== 'string'||
6334
+ Fail `Environment option name ${q(optionName)} must be a string.`;
6311
6335
  // eslint-disable-next-line @endo/no-polymorphic-call
6312
- assert.typeof(
6313
- defaultSetting,
6314
- 'string',
6315
- X `Environment option default setting ${q(
6336
+ typeof defaultSetting=== 'string'||
6337
+ Fail `Environment option default setting ${q(
6316
6338
  defaultSetting)
6317
- } must be a string.`);
6318
-
6339
+ } must be a string.`;
6319
6340
 
6320
6341
  /** @type {string} */
6321
6342
  let setting= defaultSetting;
@@ -6327,15 +6348,12 @@ const makeEnvironmentCaptor= (aGlobal)=>{
6327
6348
  arrayPush(capturedEnvironmentOptionNames, optionName);
6328
6349
  const optionValue= globalEnv[optionName];
6329
6350
  // eslint-disable-next-line @endo/no-polymorphic-call
6330
- assert.typeof(
6331
- optionValue,
6332
- 'string',
6333
- X `Environment option named ${q(
6351
+ typeof optionValue=== 'string'||
6352
+ Fail `Environment option named ${q(
6334
6353
  optionName)
6335
6354
  }, if present, must have a corresponding string value, got ${q(
6336
6355
  optionValue)
6337
- }`);
6338
-
6356
+ }`;
6339
6357
  setting= optionValue;
6340
6358
  }
6341
6359
  }
@@ -7626,7 +7644,7 @@ function tameErrorConstructor(
7626
7644
  * Object.getConstructorOf()
7627
7645
  * Helper function to improve readability, similar to Object.getPrototypeOf().
7628
7646
  *
7629
- * @param {Object} obj
7647
+ * @param {object} obj
7630
7648
  */
7631
7649
  function getConstructorOf(obj) {
7632
7650
  return getPrototypeOf(obj).constructor;
@@ -7644,7 +7662,7 @@ function makeArguments() {
7644
7662
  * Get the intrinsics not otherwise reachable by named own property
7645
7663
  * traversal from the global object.
7646
7664
  *
7647
- * @returns {Object}
7665
+ * @returns {object}
7648
7666
  */
7649
7667
  const getAnonymousIntrinsics= ()=> {
7650
7668
  const InertFunction= FERAL_FUNCTION.prototype.constructor;
@@ -7801,7 +7819,7 @@ const getAnonymousIntrinsics= ()=> {
7801
7819
 
7802
7820
 
7803
7821
  /**
7804
- * @typedef {import('../index.js').Harden} Harden
7822
+ * @typedef {import('../types.js').Harden} Harden
7805
7823
  */
7806
7824
 
7807
7825
  // Obtain the string tag accessor of of TypedArray so we can indirectly use the
@@ -8135,6 +8153,7 @@ function tameDomains(domainTaming= 'safe') {
8135
8153
  if( domainDescriptor!== undefined&& domainDescriptor.get!== undefined) {
8136
8154
  // The domain descriptor on Node.js initially has value: null, which
8137
8155
  // becomes a get, set pair after domains initialize.
8156
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_DOMAINS.md
8138
8157
  throw new TypeError(
8139
8158
  `SES failed to lockdown, Node.js domains have been initialized (SES_NO_DOMAINS)`);
8140
8159
 
@@ -8367,14 +8386,14 @@ const localePattern= /^(\w*[a-z])Locale([A-Z]\w*)$/;
8367
8386
  // behavior or `.prototype` property.
8368
8387
  const tamedMethods= {
8369
8388
  // See https://tc39.es/ecma262/#sec-string.prototype.localecompare
8370
- localeCompare(that) {
8389
+ localeCompare(arg) {
8371
8390
  if( this=== null|| this=== undefined) {
8372
8391
  throw new TypeError(
8373
8392
  'Cannot localeCompare with null or undefined "this" value');
8374
8393
 
8375
8394
  }
8376
8395
  const s= `${this}`;
8377
- that= `${that}`;
8396
+ const that= `${arg}`;
8378
8397
  if( s< that) {
8379
8398
  return -1;
8380
8399
  }
@@ -8583,8 +8602,8 @@ function tameRegExpConstructor(regExpTaming= 'safe') {
8583
8602
  * Removes all non-allowed properties found by recursively and
8584
8603
  * reflectively walking own property chains.
8585
8604
  *
8586
- * @param {Object} intrinsics
8587
- * @param {(Object) => void} markVirtualizedNativeFunction
8605
+ * @param {object} intrinsics
8606
+ * @param {(object) => void} markVirtualizedNativeFunction
8588
8607
  */
8589
8608
  function whitelistIntrinsics(
8590
8609
  intrinsics,
@@ -8885,7 +8904,7 @@ function whitelistIntrinsics(
8885
8904
 
8886
8905
 
8887
8906
 
8888
- /** @typedef {import('../index.js').LockdownOptions} LockdownOptions */
8907
+ /** @typedef {import('../types.js').LockdownOptions} LockdownOptions */
8889
8908
 
8890
8909
  const { Fail, details: d, quote: q}= assert;
8891
8910
 
@@ -8909,9 +8928,9 @@ const harden= makeHardener();
8909
8928
 
8910
8929
  /**
8911
8930
  * @callback CompartmentConstructor
8912
- * @param {Object} endowments
8913
- * @param {Object} moduleMap
8914
- * @param {Object} [options]
8931
+ * @param {object} endowments
8932
+ * @param {object} moduleMap
8933
+ * @param {object} [options]
8915
8934
  * @param {Array<Transform>} [options.transforms]
8916
8935
  * @param {Array<Transform>} [options.__shimTransforms__]
8917
8936
  */
@@ -8947,6 +8966,7 @@ const assertDirectEvalAvailable= ()=> {
8947
8966
  allowed= true;
8948
8967
  }
8949
8968
  if( !allowed) {
8969
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_DIRECT_EVAL.md
8950
8970
  throw new TypeError(
8951
8971
  `SES cannot initialize unless 'eval' is the original intrinsic 'eval', suitable for direct-eval (dynamically scoped eval) (SES_DIRECT_EVAL)`);
8952
8972
 
@@ -9038,6 +9058,7 @@ const repairIntrinsics= (options= {})=> {
9038
9058
  d `Already locked down at ${priorLockdown} (SES_ALREADY_LOCKED_DOWN)`,
9039
9059
  TypeError);
9040
9060
 
9061
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_ALREADY_LOCKED_DOWN.md
9041
9062
  priorLockdown= new TypeError('Prior lockdown (SES_ALREADY_LOCKED_DOWN)');
9042
9063
  // Tease V8 to generate the stack string and release the closures the stack
9043
9064
  // trace retained:
@@ -9079,6 +9100,7 @@ const repairIntrinsics= (options= {})=> {
9079
9100
  };
9080
9101
 
9081
9102
  if( seemsToBeLockedDown()) {
9103
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_MULTIPLE_INSTANCES.md
9082
9104
  throw new TypeError(
9083
9105
  `Already locked down but not by this SES instance (SES_MULTIPLE_INSTANCES)`);
9084
9106
 
@@ -9263,6 +9285,7 @@ function getThis() {
9263
9285
  }
9264
9286
 
9265
9287
  if( getThis()) {
9288
+ // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_SLOPPY.md
9266
9289
  throw new TypeError( `SES failed to initialize, sloppy mode (SES_NO_SLOPPY)`);
9267
9290
  }
9268
9291
 
@@ -9478,6 +9501,7 @@ assign(globalThis, {
9478
9501
  rejectSomeDirectEvalExpressions: cell("rejectSomeDirectEvalExpressions"),
9479
9502
  mandatoryTransforms: cell("mandatoryTransforms"),
9480
9503
  applyTransforms: cell("applyTransforms"),
9504
+ transforms: cell("transforms"),
9481
9505
  },
9482
9506
  {
9483
9507
  makeSafeEvaluator: cell("makeSafeEvaluator"),
@@ -9910,6 +9934,7 @@ function observeImports(map, importName, importIndex) {
9910
9934
  rejectSomeDirectEvalExpressions: cells[11].rejectSomeDirectEvalExpressions.set,
9911
9935
  mandatoryTransforms: cells[11].mandatoryTransforms.set,
9912
9936
  applyTransforms: cells[11].applyTransforms.set,
9937
+ transforms: cells[11].transforms.set,
9913
9938
  },
9914
9939
  importMeta: {},
9915
9940
  });