ses 1.14.0 → 1.15.1

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.14.0
1
+ // ses@1.15.1
2
2
  (functors => options => {
3
3
  'use strict';
4
4
 
@@ -95,11 +95,11 @@
95
95
  setPrototypeOf: cell("setPrototypeOf"),
96
96
  values: cell("values"),
97
97
  fromEntries: cell("fromEntries"),
98
- hasOwn: cell("hasOwn"),
99
98
  speciesSymbol: cell("speciesSymbol"),
100
99
  toStringTagSymbol: cell("toStringTagSymbol"),
101
100
  iteratorSymbol: cell("iteratorSymbol"),
102
101
  matchAllSymbol: cell("matchAllSymbol"),
102
+ replaceSymbol: cell("replaceSymbol"),
103
103
  unscopablesSymbol: cell("unscopablesSymbol"),
104
104
  symbolKeyFor: cell("symbolKeyFor"),
105
105
  symbolFor: cell("symbolFor"),
@@ -131,7 +131,7 @@
131
131
  iteratorPrototype: cell("iteratorPrototype"),
132
132
  typedArrayPrototype: cell("typedArrayPrototype"),
133
133
  uncurryThis: cell("uncurryThis"),
134
- objectHasOwnProperty: cell("objectHasOwnProperty"),
134
+ hasOwn: cell("hasOwn"),
135
135
  arrayFilter: cell("arrayFilter"),
136
136
  arrayForEach: cell("arrayForEach"),
137
137
  arrayIncludes: cell("arrayIncludes"),
@@ -158,16 +158,14 @@
158
158
  setForEach: cell("setForEach"),
159
159
  setHas: cell("setHas"),
160
160
  iterateSet: cell("iterateSet"),
161
- regexpTest: cell("regexpTest"),
162
161
  regexpExec: cell("regexpExec"),
162
+ regexpReplace: cell("regexpReplace"),
163
163
  matchAllRegExp: cell("matchAllRegExp"),
164
+ sealRegexp: cell("sealRegexp"),
164
165
  stringEndsWith: cell("stringEndsWith"),
165
166
  stringIncludes: cell("stringIncludes"),
166
167
  stringIndexOf: cell("stringIndexOf"),
167
168
  stringMatch: cell("stringMatch"),
168
- generatorNext: cell("generatorNext"),
169
- generatorThrow: cell("generatorThrow"),
170
- stringReplace: cell("stringReplace"),
171
169
  stringSearch: cell("stringSearch"),
172
170
  stringSlice: cell("stringSlice"),
173
171
  stringSplit: cell("stringSplit"),
@@ -181,12 +179,13 @@
181
179
  weaksetHas: cell("weaksetHas"),
182
180
  functionToString: cell("functionToString"),
183
181
  functionBind: cell("functionBind"),
182
+ generatorNext: cell("generatorNext"),
183
+ generatorThrow: cell("generatorThrow"),
184
184
  promiseAll: cell("promiseAll"),
185
185
  promiseCatch: cell("promiseCatch"),
186
186
  promiseThen: cell("promiseThen"),
187
187
  finalizationRegistryRegister: cell("finalizationRegistryRegister"),
188
188
  finalizationRegistryUnregister: cell("finalizationRegistryUnregister"),
189
- getConstructorOf: cell("getConstructorOf"),
190
189
  isPrimitive: cell("isPrimitive"),
191
190
  isError: cell("isError"),
192
191
  identity: cell("identity"),
@@ -242,10 +241,10 @@
242
241
  makeError: cell("makeError"),
243
242
  annotateError: cell("annotateError"),
244
243
  loggedErrorHandler: cell("loggedErrorHandler"),
245
- makeAssert: cell("makeAssert"),
246
244
  assert: cell("assert"),
247
245
  assertEqual: cell("assertEqual"),
248
246
  sanitizeError: cell("sanitizeError"),
247
+ makeAssert: cell("makeAssert"),
249
248
  },
250
249
  {
251
250
  isTypedArray: cell("isTypedArray"),
@@ -524,11 +523,11 @@ function observeImports(map, importName, importIndex) {
524
523
  setPrototypeOf: cells[0].setPrototypeOf.set,
525
524
  values: cells[0].values.set,
526
525
  fromEntries: cells[0].fromEntries.set,
527
- hasOwn: cells[0].hasOwn.set,
528
526
  speciesSymbol: cells[0].speciesSymbol.set,
529
527
  toStringTagSymbol: cells[0].toStringTagSymbol.set,
530
528
  iteratorSymbol: cells[0].iteratorSymbol.set,
531
529
  matchAllSymbol: cells[0].matchAllSymbol.set,
530
+ replaceSymbol: cells[0].replaceSymbol.set,
532
531
  unscopablesSymbol: cells[0].unscopablesSymbol.set,
533
532
  symbolKeyFor: cells[0].symbolKeyFor.set,
534
533
  symbolFor: cells[0].symbolFor.set,
@@ -560,7 +559,7 @@ function observeImports(map, importName, importIndex) {
560
559
  iteratorPrototype: cells[0].iteratorPrototype.set,
561
560
  typedArrayPrototype: cells[0].typedArrayPrototype.set,
562
561
  uncurryThis: cells[0].uncurryThis.set,
563
- objectHasOwnProperty: cells[0].objectHasOwnProperty.set,
562
+ hasOwn: cells[0].hasOwn.set,
564
563
  arrayFilter: cells[0].arrayFilter.set,
565
564
  arrayForEach: cells[0].arrayForEach.set,
566
565
  arrayIncludes: cells[0].arrayIncludes.set,
@@ -587,16 +586,14 @@ function observeImports(map, importName, importIndex) {
587
586
  setForEach: cells[0].setForEach.set,
588
587
  setHas: cells[0].setHas.set,
589
588
  iterateSet: cells[0].iterateSet.set,
590
- regexpTest: cells[0].regexpTest.set,
591
589
  regexpExec: cells[0].regexpExec.set,
590
+ regexpReplace: cells[0].regexpReplace.set,
592
591
  matchAllRegExp: cells[0].matchAllRegExp.set,
592
+ sealRegexp: cells[0].sealRegexp.set,
593
593
  stringEndsWith: cells[0].stringEndsWith.set,
594
594
  stringIncludes: cells[0].stringIncludes.set,
595
595
  stringIndexOf: cells[0].stringIndexOf.set,
596
596
  stringMatch: cells[0].stringMatch.set,
597
- generatorNext: cells[0].generatorNext.set,
598
- generatorThrow: cells[0].generatorThrow.set,
599
- stringReplace: cells[0].stringReplace.set,
600
597
  stringSearch: cells[0].stringSearch.set,
601
598
  stringSlice: cells[0].stringSlice.set,
602
599
  stringSplit: cells[0].stringSplit.set,
@@ -610,12 +607,13 @@ function observeImports(map, importName, importIndex) {
610
607
  weaksetHas: cells[0].weaksetHas.set,
611
608
  functionToString: cells[0].functionToString.set,
612
609
  functionBind: cells[0].functionBind.set,
610
+ generatorNext: cells[0].generatorNext.set,
611
+ generatorThrow: cells[0].generatorThrow.set,
613
612
  promiseAll: cells[0].promiseAll.set,
614
613
  promiseCatch: cells[0].promiseCatch.set,
615
614
  promiseThen: cells[0].promiseThen.set,
616
615
  finalizationRegistryRegister: cells[0].finalizationRegistryRegister.set,
617
616
  finalizationRegistryUnregister: cells[0].finalizationRegistryUnregister.set,
618
- getConstructorOf: cells[0].getConstructorOf.set,
619
617
  isPrimitive: cells[0].isPrimitive.set,
620
618
  isError: cells[0].isError.set,
621
619
  identity: cells[0].identity.set,
@@ -786,10 +784,10 @@ function observeImports(map, importName, importIndex) {
786
784
  makeError: cells[13].makeError.set,
787
785
  note: cells[13].annotateError.set,
788
786
  loggedErrorHandler: cells[13].loggedErrorHandler.set,
789
- makeAssert: cells[13].makeAssert.set,
790
787
  assert: cells[13].assert.set,
791
788
  assertEqual: cells[13].assertEqual.set,
792
789
  sanitizeError: cells[13].sanitizeError.set,
790
+ makeAssert: cells[13].makeAssert.set,
793
791
  },
794
792
  importMeta: {},
795
793
  });
@@ -1603,18 +1601,18 @@ const universalThis = globalThis;$h͏_once.universalThis(universalThis);
1603
1601
  setPrototypeOf,
1604
1602
  values,
1605
1603
  fromEntries,
1606
- hasOwn,
1607
- } = Object;$h͏_once.assign(assign);$h͏_once.create(create);$h͏_once.defineProperties(defineProperties);$h͏_once.entries(entries);$h͏_once.freeze(freeze);$h͏_once.getOwnPropertyDescriptor(getOwnPropertyDescriptor);$h͏_once.getOwnPropertyDescriptors(getOwnPropertyDescriptors);$h͏_once.getOwnPropertyNames(getOwnPropertyNames);$h͏_once.getPrototypeOf(getPrototypeOf);$h͏_once.is(is);$h͏_once.isFrozen(isFrozen);$h͏_once.isSealed(isSealed);$h͏_once.isExtensible(isExtensible);$h͏_once.keys(keys);$h͏_once.objectPrototype(objectPrototype);$h͏_once.seal(seal);$h͏_once.preventExtensions(preventExtensions);$h͏_once.setPrototypeOf(setPrototypeOf);$h͏_once.values(values);$h͏_once.fromEntries(fromEntries);$h͏_once.hasOwn(hasOwn);
1604
+ } = Object;$h͏_once.assign(assign);$h͏_once.create(create);$h͏_once.defineProperties(defineProperties);$h͏_once.entries(entries);$h͏_once.freeze(freeze);$h͏_once.getOwnPropertyDescriptor(getOwnPropertyDescriptor);$h͏_once.getOwnPropertyDescriptors(getOwnPropertyDescriptors);$h͏_once.getOwnPropertyNames(getOwnPropertyNames);$h͏_once.getPrototypeOf(getPrototypeOf);$h͏_once.is(is);$h͏_once.isFrozen(isFrozen);$h͏_once.isSealed(isSealed);$h͏_once.isExtensible(isExtensible);$h͏_once.keys(keys);$h͏_once.objectPrototype(objectPrototype);$h͏_once.seal(seal);$h͏_once.preventExtensions(preventExtensions);$h͏_once.setPrototypeOf(setPrototypeOf);$h͏_once.values(values);$h͏_once.fromEntries(fromEntries);
1608
1605
 
1609
1606
  const {
1610
1607
  species: speciesSymbol,
1611
1608
  toStringTag: toStringTagSymbol,
1612
1609
  iterator: iteratorSymbol,
1613
1610
  matchAll: matchAllSymbol,
1611
+ replace: replaceSymbol,
1614
1612
  unscopables: unscopablesSymbol,
1615
1613
  keyFor: symbolKeyFor,
1616
1614
  for: symbolFor,
1617
- } = Symbol;$h͏_once.speciesSymbol(speciesSymbol);$h͏_once.toStringTagSymbol(toStringTagSymbol);$h͏_once.iteratorSymbol(iteratorSymbol);$h͏_once.matchAllSymbol(matchAllSymbol);$h͏_once.unscopablesSymbol(unscopablesSymbol);$h͏_once.symbolKeyFor(symbolKeyFor);$h͏_once.symbolFor(symbolFor);
1615
+ } = Symbol;$h͏_once.speciesSymbol(speciesSymbol);$h͏_once.toStringTagSymbol(toStringTagSymbol);$h͏_once.iteratorSymbol(iteratorSymbol);$h͏_once.matchAllSymbol(matchAllSymbol);$h͏_once.replaceSymbol(replaceSymbol);$h͏_once.unscopablesSymbol(unscopablesSymbol);$h͏_once.symbolKeyFor(symbolKeyFor);$h͏_once.symbolFor(symbolFor);
1618
1616
 
1619
1617
  const { isInteger } = Number;$h͏_once.isInteger(isInteger);
1620
1618
 
@@ -1693,12 +1691,29 @@ const { bind } = functionPrototype;
1693
1691
  */
1694
1692
  const uncurryThis = bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
1695
1693
 
1696
- /**
1697
- * @deprecated Use `hasOwn` instead
1698
- */$h͏_once.uncurryThis(uncurryThis);
1699
- const objectHasOwnProperty = hasOwn;
1694
+ // See https://github.com/endojs/endo/issues/2930
1695
+ $h͏_once.uncurryThis(uncurryThis);if(!('hasOwn'in Object)){
1696
+ const ObjectPrototypeHasOwnProperty = objectPrototype.hasOwnProperty;
1697
+ const hasOwnShim = (obj, key) => {
1698
+ if (obj === undefined || obj === null) {
1699
+ // We need to add this extra test because of differences in
1700
+ // the order in which `hasOwn` vs `hasOwnProperty` validates
1701
+ // arguments.
1702
+ throw TypeError('Cannot convert undefined or null to object');
1703
+ }
1704
+ return apply(ObjectPrototypeHasOwnProperty, obj, [key]);
1705
+ };
1706
+ defineProperty(Object, 'hasOwn', {
1707
+ value: hasOwnShim,
1708
+ writable: true,
1709
+ enumerable: false,
1710
+ configurable: true,
1711
+ });
1712
+ }
1713
+
1714
+ const { hasOwn } = Object;
1700
1715
  //
1701
- $h͏_once.objectHasOwnProperty(objectHasOwnProperty);const arrayFilter=uncurryThis(arrayPrototype.filter);$h͏_once.arrayFilter(arrayFilter);
1716
+ $h͏_once.hasOwn(hasOwn);const arrayFilter=uncurryThis(arrayPrototype.filter);$h͏_once.arrayFilter(arrayFilter);
1702
1717
  const arrayForEach = uncurryThis(arrayPrototype.forEach);$h͏_once.arrayForEach(arrayForEach);
1703
1718
  const arrayIncludes = uncurryThis(arrayPrototype.includes);$h͏_once.arrayIncludes(arrayIncludes);
1704
1719
  const arrayJoin = uncurryThis(arrayPrototype.join);
@@ -1737,32 +1752,53 @@ $h͏_once.iterateMap(iterateMap);const setAdd=uncurryThis(setPrototype.add);$h͏
1737
1752
  const setHas = uncurryThis(setPrototype.has);$h͏_once.setHas(setHas);
1738
1753
  const iterateSet = uncurryThis(setPrototype[iteratorSymbol]);
1739
1754
  //
1740
- $h͏_once.iterateSet(iterateSet);const regexpTest=uncurryThis(regexpPrototype.test);$h͏_once.regexpTest(regexpTest);
1741
- const regexpExec = uncurryThis(regexpPrototype.exec);$h͏_once.regexpExec(regexpExec);
1742
- const matchAllRegExp = uncurryThis(regexpPrototype[matchAllSymbol]);
1743
- //
1744
- $h͏_once.matchAllRegExp(matchAllRegExp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h͏_once.stringEndsWith(stringEndsWith);
1745
- const stringIncludes = uncurryThis(stringPrototype.includes);$h͏_once.stringIncludes(stringIncludes);
1746
- const stringIndexOf = uncurryThis(stringPrototype.indexOf);$h͏_once.stringIndexOf(stringIndexOf);
1747
- const stringMatch = uncurryThis(stringPrototype.match);$h͏_once.stringMatch(stringMatch);
1748
- const generatorNext = uncurryThis(generatorPrototype.next);$h͏_once.generatorNext(generatorNext);
1749
- const generatorThrow = uncurryThis(generatorPrototype.throw);
1750
-
1755
+ /**
1756
+ * `regexpExec` is provided in exclusion of `regexpTest`, which would be
1757
+ * vulnerable to RegExp.prototype poisoning.
1758
+ */$h͏_once.iterateSet(iterateSet);
1759
+ const regexpExec = uncurryThis(regexpPrototype.exec);
1751
1760
  /**
1752
1761
  * @type { &
1753
- * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) &
1754
- * ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string)
1762
+ * ((thisArg: RegExp, string: string, replaceValue: string) => string) &
1763
+ * ((thisArg: RegExp, string: string, replacer: (substring: string, ...args: any[]) => string) => string)
1755
1764
  * }
1756
- */$h͏_once.generatorThrow(generatorThrow);
1757
- const stringReplace = /** @type {any} */ (
1758
- uncurryThis(stringPrototype.replace)
1759
- );$h͏_once.stringReplace(stringReplace);
1760
- const stringSearch = uncurryThis(stringPrototype.search);$h͏_once.stringSearch(stringSearch);
1761
- const stringSlice = uncurryThis(stringPrototype.slice);$h͏_once.stringSlice(stringSlice);
1762
- const stringSplit =
1763
- /** @type {(thisArg: string, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[]} */ (
1764
- uncurryThis(stringPrototype.split)
1765
- );$h͏_once.stringSplit(stringSplit);
1765
+ */$h͏_once.regexpExec(regexpExec);
1766
+ const regexpReplace = /** @type {any} */ (
1767
+ uncurryThis(regexpPrototype[replaceSymbol])
1768
+ );$h͏_once.regexpReplace(regexpReplace);
1769
+ const matchAllRegExp = uncurryThis(regexpPrototype[matchAllSymbol]);$h͏_once.matchAllRegExp(matchAllRegExp);
1770
+ const { _regexpConstructor, ...regexpDescriptors } =
1771
+ getOwnPropertyDescriptors(regexpPrototype);
1772
+ arrayForEach(ownKeys(regexpDescriptors), key => {
1773
+ const desc = regexpDescriptors[/** @type {any} */ (key)];
1774
+ desc.configurable = false;
1775
+ if (desc.writable) desc.writable = false;
1776
+ });
1777
+ /**
1778
+ * Protect a RegExp instance against RegExp.prototype poisoning ("exec",
1779
+ * "flags", Symbol.replace, etc.).
1780
+ * @type {<T extends RegExp>(regexp: T) => T}
1781
+ */
1782
+ const sealRegexp = regexp =>
1783
+ seal(defineProperties(regexp, regexpDescriptors));
1784
+ //
1785
+ $h͏_once.sealRegexp(sealRegexp);const stringEndsWith=uncurryThis(stringPrototype.endsWith);$h͏_once.stringEndsWith(stringEndsWith);
1786
+ const stringIncludes = uncurryThis(stringPrototype.includes);$h͏_once.stringIncludes(stringIncludes);
1787
+ const stringIndexOf = uncurryThis(stringPrototype.indexOf);$h͏_once.stringIndexOf(stringIndexOf);
1788
+ const stringMatch = uncurryThis(stringPrototype.match);
1789
+ // `stringReplace` is intentionally omitted because it would be vulnerable to
1790
+ // RegExp.prototype poisoning; use `regexpReplace(re, str, replacer)` instead
1791
+ // (and `sealRegexp` on its regular expressions).
1792
+ $h͏_once.stringMatch(stringMatch);const stringSearch=uncurryThis(stringPrototype.search);$h͏_once.stringSearch(stringSearch);
1793
+ const stringSlice = uncurryThis(stringPrototype.slice);
1794
+ /**
1795
+ * `stringSplit` should only be used with a string separator; regular
1796
+ * expressions are vulnerable to RegExp.prototype poisoning.
1797
+ * @type {(thisArg: string, separator: string, limit?: number) => string[]}
1798
+ */$h͏_once.stringSlice(stringSlice);
1799
+ const stringSplit = /** @type {any} */ (
1800
+ uncurryThis(stringPrototype.split)
1801
+ );$h͏_once.stringSplit(stringSplit);
1766
1802
  const stringStartsWith = uncurryThis(stringPrototype.startsWith);$h͏_once.stringStartsWith(stringStartsWith);
1767
1803
  const iterateString = uncurryThis(stringPrototype[iteratorSymbol]);
1768
1804
  //
@@ -1778,7 +1814,10 @@ $h͏_once.weakmapSet(weakmapSet);const weaksetAdd=uncurryThis(weaksetPrototype.a
1778
1814
  $h͏_once.weaksetHas(weaksetHas);const functionToString=uncurryThis(functionPrototype.toString);$h͏_once.functionToString(functionToString);
1779
1815
  const functionBind = uncurryThis(bind);
1780
1816
  //
1781
- $h͏_once.functionBind(functionBind);const{all}=Promise;
1817
+ $h͏_once.functionBind(functionBind);const generatorNext=uncurryThis(generatorPrototype.next);$h͏_once.generatorNext(generatorNext);
1818
+ const generatorThrow = uncurryThis(generatorPrototype.throw);
1819
+ //
1820
+ $h͏_once.generatorThrow(generatorThrow);const{all}=Promise;
1782
1821
  const promiseAll = promises => apply(all, Promise, [promises]);$h͏_once.promiseAll(promiseAll);
1783
1822
  const promiseCatch = uncurryThis(promisePrototype.catch);
1784
1823
  /** @type {<T, TResult1 = T, TResult2 = never>(thisArg: T, onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null) => Promise<TResult1 | TResult2>} */$h͏_once.promiseCatch(promiseCatch);
@@ -1792,15 +1831,6 @@ $h͏_once.promiseThen(promiseThen);const finalizationRegistryRegister=
1792
1831
  FinalizationRegistry &&
1793
1832
  uncurryThis(FinalizationRegistry.prototype.unregister);
1794
1833
 
1795
- /**
1796
- * getConstructorOf()
1797
- * Return the constructor from an instance.
1798
- *
1799
- * @param {Function} fn
1800
- */$h͏_once.finalizationRegistryUnregister(finalizationRegistryUnregister);
1801
- const getConstructorOf = fn =>
1802
- reflectGet(getPrototypeOf(fn), 'constructor');
1803
-
1804
1834
  /**
1805
1835
  * TODO Consolidate with `isPrimitive` that's currently in `@endo/pass-style`.
1806
1836
  * Layering constraints make this tricky, which is why we haven't yet figured
@@ -1813,7 +1843,7 @@ $h͏_once.promiseThen(promiseThen);const finalizationRegistryRegister=
1813
1843
  * | bigint
1814
1844
  * | string
1815
1845
  * | symbol)}
1816
- */$h͏_once.getConstructorOf(getConstructorOf);
1846
+ */$h͏_once.finalizationRegistryUnregister(finalizationRegistryUnregister);
1817
1847
  const isPrimitive = val =>
1818
1848
  !val || (typeof val !== 'object' && typeof val !== 'function');
1819
1849
 
@@ -1853,13 +1883,40 @@ $h͏_once.FERAL_EVAL(FERAL_EVAL);const FERAL_FUNCTION=Function;$h͏_once.FERAL_F
1853
1883
  };
1854
1884
 
1855
1885
  // ////////////////// FERAL_STACK_GETTER FERAL_STACK_SETTER ////////////////////
1856
- $h͏_once.noEvalEvaluate(noEvalEvaluate);
1857
- const er1StackDesc = getOwnPropertyDescriptor(Error('er1'), 'stack');
1858
- const er2StackDesc = getOwnPropertyDescriptor(TypeError('er2'), 'stack');
1886
+
1887
+ // The error repair mechanism is very similar to code in
1888
+ // pass-style/src/error.js and these implementations should be kept in sync.
1889
+
1890
+ /**
1891
+ * We gratuitiously construct a TypeError instance using syntax in order to
1892
+ * obviate the possibility that code that ran before SES (for which we are
1893
+ * irreducable vulnerable) may have replaced the global TypeError constructor.
1894
+ * We treat the nature of this error instance as the source of truth for the
1895
+ * nature of runtime constructed errors on the platform, particularly whether
1896
+ * such errors will have an own "stack" property with getters and setters.
1897
+ * At time of writing (2025) we know of no comparable mechanism for obtaining a
1898
+ * host-generated base Error instance, but we corroborate the nature of the
1899
+ * global Error constructor's instances and refuse to initialize SES in an
1900
+ * environment where the syntactic TypeError and global Error produce
1901
+ * inconsistent "stack" properties.
1902
+ * @returns {TypeError}
1903
+ */$h͏_once.noEvalEvaluate(noEvalEvaluate);
1904
+ const makeTypeError = () => {
1905
+ try {
1906
+ // @ts-expect-error deliberate TypeError
1907
+ null.null;
1908
+ throw TypeError('obligatory'); // To convince the type flow inferrence.
1909
+ } catch (error) {
1910
+ return error;
1911
+ }
1912
+ };
1913
+
1914
+ const errorStackDesc = getOwnPropertyDescriptor(Error('obligatory'), 'stack');
1915
+ const typeErrorStackDesc = getOwnPropertyDescriptor(makeTypeError(), 'stack');
1859
1916
 
1860
1917
  let feralStackGetter;
1861
1918
  let feralStackSetter;
1862
- if (er1StackDesc && er2StackDesc && er1StackDesc.get) {
1919
+ if (typeErrorStackDesc && typeErrorStackDesc.get) {
1863
1920
  // We should only encounter this case on v8 because of its problematic
1864
1921
  // error own stack accessor behavior.
1865
1922
  // Note that FF/SpiderMonkey, Moddable/XS, and the error stack proposal
@@ -1870,16 +1927,17 @@ if (er1StackDesc && er2StackDesc && er1StackDesc.get) {
1870
1927
  // accessor property, but within the same realm, all these accessor
1871
1928
  // properties have the same getter and have the same setter.
1872
1929
  // This is therefore the case that we repair.
1873
- typeof er1StackDesc.get === 'function' &&
1874
- er1StackDesc.get === er2StackDesc.get &&
1875
- typeof er1StackDesc.set === 'function' &&
1876
- er1StackDesc.set === er2StackDesc.set
1930
+ errorStackDesc &&
1931
+ typeof typeErrorStackDesc.get === 'function' &&
1932
+ typeErrorStackDesc.get === errorStackDesc.get &&
1933
+ typeof typeErrorStackDesc.set === 'function' &&
1934
+ typeErrorStackDesc.set === errorStackDesc.set
1877
1935
  ) {
1878
1936
  // Otherwise, we have own stack accessor properties that are outside
1879
1937
  // our expectations, that therefore need to be understood better
1880
1938
  // before we know how to repair them.
1881
- feralStackGetter = freeze(er1StackDesc.get);
1882
- feralStackSetter = freeze(er1StackDesc.set);
1939
+ feralStackGetter = freeze(typeErrorStackDesc.get);
1940
+ feralStackSetter = freeze(typeErrorStackDesc.set);
1883
1941
  } else {
1884
1942
  // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_UNEXPECTED_ERROR_OWN_STACK_ACCESSOR.md
1885
1943
  throw TypeError(
@@ -2428,11 +2486,11 @@ const arrayBufferMethods = {
2428
2486
  ...(optTransferBufferToImmutable
2429
2487
  ? {
2430
2488
  /**
2431
- * Transfer the contents to a new Immutable ArrayBuffer
2489
+ * Transfer the contents to a new immutable ArrayBuffer
2432
2490
  *
2433
2491
  * @this {ArrayBuffer} buffer The original buffer.
2434
2492
  * @param {number} [newLength] The start index.
2435
- * @returns {ArrayBuffer} The sliced immutable ArrayBuffer.
2493
+ * @returns {ArrayBuffer} The new immutable ArrayBuffer.
2436
2494
  */
2437
2495
  transferToImmutable(newLength = undefined) {
2438
2496
  return optTransferBufferToImmutable(this, newLength);
@@ -2505,12 +2563,12 @@ defineProperties(
2505
2563
 
2506
2564
 
2507
2565
 
2508
- /** @import {StringablePayload} from '../../types.js' */
2566
+ /** @import {Stringable} from '../../types.js' */
2509
2567
 
2510
2568
  /**
2511
2569
  * Joins English terms with commas and an optional conjunction.
2512
2570
  *
2513
- * @param {(string | StringablePayload)[]} terms
2571
+ * @param {(string | Stringable)[]} terms
2514
2572
  * @param {"and" | "or"} conjunction
2515
2573
  */
2516
2574
  const enJoin = (terms, conjunction) => {
@@ -2681,7 +2739,7 @@ freeze(bestEffortStringify);
2681
2739
  // === 8. ses ./src/error/types.js ===
2682
2740
  ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';$h͏_imports([]);// @ts-check
2683
2741
 
2684
- /** @import {GenericErrorConstructor, AssertMakeErrorOptions, DetailsToken, StringablePayload} from '../../types.js' */
2742
+ /** @import {GenericErrorConstructor, AssertMakeErrorOptions, DetailsToken, Stringable} from '../../types.js' */
2685
2743
 
2686
2744
  /**
2687
2745
  * @typedef {object} VirtualConsole
@@ -3246,7 +3304,8 @@ freeze(makeNoteLogArgsArrayKit);
3246
3304
  })()
3247
3305
  ,
3248
3306
  // === 13. ses ./src/error/assert.js ===
3249
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,defineProperty,globalThis,is,isError,regexpTest,stringIndexOf,stringReplace,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,AggregateError,getOwnPropertyDescriptors,ownKeys,create,objectPrototype,hasOwn,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h͏_imports([["../commons.js", [["RangeError",[$h͏_a => (RangeError = $h͏_a)]],["TypeError",[$h͏_a => (TypeError = $h͏_a)]],["WeakMap",[$h͏_a => (WeakMap = $h͏_a)]],["arrayJoin",[$h͏_a => (arrayJoin = $h͏_a)]],["arrayMap",[$h͏_a => (arrayMap = $h͏_a)]],["arrayPop",[$h͏_a => (arrayPop = $h͏_a)]],["arrayPush",[$h͏_a => (arrayPush = $h͏_a)]],["assign",[$h͏_a => (assign = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]],["defineProperty",[$h͏_a => (defineProperty = $h͏_a)]],["globalThis",[$h͏_a => (globalThis = $h͏_a)]],["is",[$h͏_a => (is = $h͏_a)]],["isError",[$h͏_a => (isError = $h͏_a)]],["regexpTest",[$h͏_a => (regexpTest = $h͏_a)]],["stringIndexOf",[$h͏_a => (stringIndexOf = $h͏_a)]],["stringReplace",[$h͏_a => (stringReplace = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringStartsWith",[$h͏_a => (stringStartsWith = $h͏_a)]],["weakmapDelete",[$h͏_a => (weakmapDelete = $h͏_a)]],["weakmapGet",[$h͏_a => (weakmapGet = $h͏_a)]],["weakmapHas",[$h͏_a => (weakmapHas = $h͏_a)]],["weakmapSet",[$h͏_a => (weakmapSet = $h͏_a)]],["AggregateError",[$h͏_a => (AggregateError = $h͏_a)]],["getOwnPropertyDescriptors",[$h͏_a => (getOwnPropertyDescriptors = $h͏_a)]],["ownKeys",[$h͏_a => (ownKeys = $h͏_a)]],["create",[$h͏_a => (create = $h͏_a)]],["objectPrototype",[$h͏_a => (objectPrototype = $h͏_a)]],["hasOwn",[$h͏_a => (hasOwn = $h͏_a)]]]],["./stringify-utils.js", [["an",[$h͏_a => (an = $h͏_a)]],["bestEffortStringify",[$h͏_a => (bestEffortStringify = $h͏_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit",[$h͏_a => (makeNoteLogArgsArrayKit = $h͏_a)]]]]]);
3307
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let RangeError,TypeError,WeakMap,arrayJoin,arrayMap,arrayPop,arrayPush,assign,freeze,defineProperty,globalThis,is,isError,regexpExec,regexpReplace,sealRegexp,stringIndexOf,stringSlice,stringStartsWith,weakmapDelete,weakmapGet,weakmapHas,weakmapSet,AggregateError,getOwnPropertyDescriptors,ownKeys,create,objectPrototype,hasOwn,an,bestEffortStringify,makeNoteLogArgsArrayKit;$h͏_imports([["../commons.js", [["RangeError",[$h͏_a => (RangeError = $h͏_a)]],["TypeError",[$h͏_a => (TypeError = $h͏_a)]],["WeakMap",[$h͏_a => (WeakMap = $h͏_a)]],["arrayJoin",[$h͏_a => (arrayJoin = $h͏_a)]],["arrayMap",[$h͏_a => (arrayMap = $h͏_a)]],["arrayPop",[$h͏_a => (arrayPop = $h͏_a)]],["arrayPush",[$h͏_a => (arrayPush = $h͏_a)]],["assign",[$h͏_a => (assign = $h͏_a)]],["freeze",[$h͏_a => (freeze = $h͏_a)]],["defineProperty",[$h͏_a => (defineProperty = $h͏_a)]],["globalThis",[$h͏_a => (globalThis = $h͏_a)]],["is",[$h͏_a => (is = $h͏_a)]],["isError",[$h͏_a => (isError = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $h͏_a)]],["stringIndexOf",[$h͏_a => (stringIndexOf = $h͏_a)]],["stringSlice",[$h͏_a => (stringSlice = $h͏_a)]],["stringStartsWith",[$h͏_a => (stringStartsWith = $h͏_a)]],["weakmapDelete",[$h͏_a => (weakmapDelete = $h͏_a)]],["weakmapGet",[$h͏_a => (weakmapGet = $h͏_a)]],["weakmapHas",[$h͏_a => (weakmapHas = $h͏_a)]],["weakmapSet",[$h͏_a => (weakmapSet = $h͏_a)]],["AggregateError",[$h͏_a => (AggregateError = $h͏_a)]],["getOwnPropertyDescriptors",[$h͏_a => (getOwnPropertyDescriptors = $h͏_a)]],["ownKeys",[$h͏_a => (ownKeys = $h͏_a)]],["create",[$h͏_a => (create = $h͏_a)]],["objectPrototype",[$h͏_a => (objectPrototype = $h͏_a)]],["hasOwn",[$h͏_a => (hasOwn = $h͏_a)]]]],["./stringify-utils.js", [["an",[$h͏_a => (an = $h͏_a)]],["bestEffortStringify",[$h͏_a => (bestEffortStringify = $h͏_a)]]]],["./types.js", []],["./internal-types.js", []],["./note-log-args.js", [["makeNoteLogArgsArrayKit",[$h͏_a => (makeNoteLogArgsArrayKit = $h͏_a)]]]]]);
3308
+
3250
3309
 
3251
3310
 
3252
3311
 
@@ -3295,24 +3354,28 @@ freeze(makeNoteLogArgsArrayKit);
3295
3354
 
3296
3355
 
3297
3356
  /**
3298
- * @import {BaseAssert, Assert, AssertionFunctions, AssertionUtilities, StringablePayload, DetailsToken, MakeAssert} from '../../types.js'
3299
- * @import {LogArgs, NoteCallback, LoggedErrorHandler} from "./internal-types.js";
3357
+ * @import {BaseAssert, Assert, AssertionFunctions, AssertionUtilities, DeprecatedAssertionUtilities, Stringable, DetailsToken, MakeAssert} from '../../types.js';
3358
+ * @import {LogArgs, NoteCallback, LoggedErrorHandler} from './internal-types.js';
3300
3359
  */
3301
3360
 
3302
- // For our internal debugging purposes, uncomment
3361
+ // For internal debugging purposes, uncomment
3303
3362
  // const internalDebugConsole = console;
3304
3363
 
3305
3364
  // /////////////////////////////////////////////////////////////////////////////
3306
3365
 
3307
- /** @type {WeakMap<StringablePayload, any>} */
3366
+ /**
3367
+ * Maps the result of a `quote` or `bare` call back to its input value.
3368
+ *
3369
+ * @type {WeakMap<Stringable, any>}
3370
+ */
3308
3371
  const declassifiers = new WeakMap();
3309
3372
 
3310
3373
  /** @type {AssertionUtilities['quote']} */
3311
- const quote = (payload, spaces = undefined) => {
3374
+ const quote = (value, spaces = undefined) => {
3312
3375
  const result = freeze({
3313
- toString: freeze(() => bestEffortStringify(payload, spaces)),
3376
+ toString: freeze(() => bestEffortStringify(value, spaces)),
3314
3377
  });
3315
- weakmapSet(declassifiers, result, payload);
3378
+ weakmapSet(declassifiers, result, value);
3316
3379
  return result;
3317
3380
  };$h͏_once.quote(quote);
3318
3381
  freeze(quote);
@@ -3322,14 +3385,14 @@ const canBeBare = freeze(/^[\w:-]( ?[\w:-])*$/);
3322
3385
  /**
3323
3386
  * @type {AssertionUtilities['bare']}
3324
3387
  */
3325
- const bare = (payload, spaces = undefined) => {
3326
- if (typeof payload !== 'string' || !regexpTest(canBeBare, payload)) {
3327
- return quote(payload, spaces);
3388
+ const bare = (text, spaces = undefined) => {
3389
+ if (typeof text !== 'string' || !regexpExec(canBeBare, text)) {
3390
+ return quote(text, spaces);
3328
3391
  }
3329
3392
  const result = freeze({
3330
- toString: freeze(() => payload),
3393
+ toString: freeze(() => text),
3331
3394
  });
3332
- weakmapSet(declassifiers, result, payload);
3395
+ weakmapSet(declassifiers, result, text);
3333
3396
  return result;
3334
3397
  };$h͏_once.bare(bare);
3335
3398
  freeze(bare);
@@ -3337,24 +3400,28 @@ freeze(bare);
3337
3400
  // /////////////////////////////////////////////////////////////////////////////
3338
3401
 
3339
3402
  /**
3340
- * @typedef {object} HiddenDetails
3403
+ * @typedef {{ template: TemplateStringsArray | string[], args: any[] }} DetailsParts
3341
3404
  *
3342
- * Captures the arguments passed to the `details` template string tag.
3405
+ * The contents of a `details` template literal tag: literal strings (always at
3406
+ * least one) and arbitrary substitution values from in between them.
3343
3407
  *
3344
- * @property {TemplateStringsArray | string[]} template
3345
- * @property {any[]} args
3408
+ * Unquoted substitution values are sensitive (and are redacted in error
3409
+ * `message` strings), so a DetailsPart must not leak outside of this file.
3346
3410
  */
3347
3411
 
3348
3412
  /**
3349
- * @type {WeakMap<DetailsToken, HiddenDetails>}
3413
+ * Maps the result of a `details` tagged template literal back to a record of
3414
+ * that template literal's contents.
3350
3415
  *
3351
- * Maps from a details token which a `details` template literal returned
3352
- * to a record of the contents of that template literal expression.
3416
+ * @type {WeakMap<DetailsToken, DetailsParts>}
3353
3417
  */
3354
3418
  const hiddenDetailsMap = new WeakMap();
3355
3419
 
3356
3420
  /**
3357
- * @param {HiddenDetails} hiddenDetails
3421
+ * Construct an error message string from `details` template literal contents,
3422
+ * replacing unquoted substitution values with redactions.
3423
+ *
3424
+ * @param {DetailsParts} hiddenDetails
3358
3425
  * @returns {string}
3359
3426
  */
3360
3427
  const getMessageString = ({ template, args }) => {
@@ -3375,16 +3442,14 @@ const getMessageString = ({ template, args }) => {
3375
3442
  };
3376
3443
 
3377
3444
  /**
3378
- * Give detailsTokens a toString behavior. To minimize the overhead of
3379
- * creating new detailsTokens, we do this with an
3380
- * inherited `this` sensitive `toString` method, even though we normally
3381
- * avoid `this` sensitivity. To protect the method from inappropriate
3382
- * `this` application, it does something interesting only for objects
3383
- * registered in `redactedDetails`, which should be exactly the detailsTokens.
3445
+ * Define `toString` behavior for DetailsToken. To minimize the overhead of
3446
+ * creating new instances, we do this with an inherited `this`-sensitive method,
3447
+ * even though we normally avoid such sensitivity. To protect the method from
3448
+ * inappropriate application, it verifies that `this` is registered in
3449
+ * `redactedDetails` before doing interesting work.
3384
3450
  *
3385
- * The printing behavior must not reveal anything redacted, so we just use
3386
- * the same `getMessageString` we use to construct the redacted message
3387
- * string for a thrown assertion error.
3451
+ * The behavior must not reveal anything redacted, so we use `getMessageString`
3452
+ * to return the same value as the message for a thrown assertion-failure error.
3388
3453
  */
3389
3454
  const DetailsTokenProto = freeze({
3390
3455
  toString() {
@@ -3404,16 +3469,15 @@ freeze(DetailsTokenProto.toString);
3404
3469
  * given to `lockdown`, then `unredactedDetails` is used instead.
3405
3470
  *
3406
3471
  * There are some unconditional uses of `redactedDetails` in this module. All
3407
- * of them should be uses where the template literal has no redacted
3408
- * substitution values. In those cases, the two are equivalent.
3472
+ * of them should be uses where the template literal has no redacted (unquoted)
3473
+ * substitution values. In those cases, `redactedDetails` is equivalent to
3474
+ * `unredactedDetails`.
3409
3475
  *
3410
3476
  * @type {AssertionUtilities['details']}
3411
3477
  */
3412
3478
  const redactedDetails = (template, ...args) => {
3413
- // Keep in mind that the vast majority of calls to `details` creates
3414
- // a details token that is never used, so this path must remain as fast as
3415
- // possible. Hence we store what we've got with little processing, postponing
3416
- // all the work to happen only if needed, for example, if an assertion fails.
3479
+ // In case the result of this call is never used, perform as little processing
3480
+ // as possible here to keep things fast.
3417
3481
  const detailsToken = freeze({ __proto__: DetailsTokenProto });
3418
3482
  weakmapSet(hiddenDetailsMap, detailsToken, { template, args });
3419
3483
  return /** @type {DetailsToken} */ (/** @type {unknown} */ (detailsToken));
@@ -3443,8 +3507,15 @@ const unredactedDetails = (template, ...args) => {
3443
3507
  freeze(unredactedDetails);
3444
3508
 
3445
3509
 
3510
+ const leadingSpacePattern = sealRegexp(/^ /);
3511
+ const trailingSpacePattern = sealRegexp(/ $/);
3512
+
3446
3513
  /**
3447
- * @param {HiddenDetails} hiddenDetails
3514
+ * Get arguments suitable for a console logger function (e.g., `console.error`)
3515
+ * from `details` template literal contents, unquoting quoted substitution
3516
+ * values.
3517
+ *
3518
+ * @param {DetailsParts} hiddenDetails
3448
3519
  * @returns {LogArgs}
3449
3520
  */
3450
3521
  const getLogArgs = ({ template, args }) => {
@@ -3454,14 +3525,22 @@ const getLogArgs = ({ template, args }) => {
3454
3525
  if (weakmapHas(declassifiers, arg)) {
3455
3526
  arg = weakmapGet(declassifiers, arg);
3456
3527
  }
3457
- // Remove the extra spaces (since console.error puts them
3458
- // between each cause).
3459
- const priorWithoutSpace = stringReplace(arrayPop(logArgs) || '', / $/, '');
3460
- if (priorWithoutSpace !== '') {
3461
- arrayPush(logArgs, priorWithoutSpace);
3528
+ // Remove substitution-adjacent spaces from template fixed-string parts
3529
+ // (since console logging inserts its own argument-separating spaces).
3530
+ const prevLiteralPart = regexpReplace(
3531
+ trailingSpacePattern,
3532
+ arrayPop(logArgs) || '',
3533
+ '',
3534
+ );
3535
+ if (prevLiteralPart !== '') {
3536
+ arrayPush(logArgs, prevLiteralPart);
3462
3537
  }
3463
- const nextWithoutSpace = stringReplace(template[i + 1], /^ /, '');
3464
- arrayPush(logArgs, arg, nextWithoutSpace);
3538
+ const nextLiteralPart = regexpReplace(
3539
+ leadingSpacePattern,
3540
+ template[i + 1],
3541
+ '',
3542
+ );
3543
+ arrayPush(logArgs, arg, nextLiteralPart);
3465
3544
  }
3466
3545
  if (logArgs[logArgs.length - 1] === '') {
3467
3546
  arrayPop(logArgs);
@@ -3470,11 +3549,11 @@ const getLogArgs = ({ template, args }) => {
3470
3549
  };
3471
3550
 
3472
3551
  /**
3473
- * @type {WeakMap<Error, LogArgs>}
3552
+ * Maps from an error object to arguments suitable for a privileged console
3553
+ * logger function such as `console.error`, including values that may be
3554
+ * redacted in the error's `message`.
3474
3555
  *
3475
- * Maps from an error object to the log args that are a more informative
3476
- * alternative message for that error. When logging the error, these
3477
- * log args should be preferred to `error.message`.
3556
+ * @type {WeakMap<Error, LogArgs>}
3478
3557
  */
3479
3558
  const hiddenMessageLogArgs = new WeakMap();
3480
3559
 
@@ -3545,27 +3624,24 @@ const tagError = (err, optErrorName = err.name) => {
3545
3624
  for (const name of restNames) {
3546
3625
  delete error[name];
3547
3626
  }
3548
- const droppedNote = create(objectPrototype, restDescs);
3627
+ const dropped = create(objectPrototype, restDescs);
3628
+ const droppedDetails = redactedDetails`originally with properties ${quote(dropped)}`;
3549
3629
  // eslint-disable-next-line no-use-before-define
3550
- note(
3551
- error,
3552
- redactedDetails`originally with properties ${quote(droppedNote)}`,
3553
- );
3630
+ note(error, droppedDetails);
3554
3631
  }
3555
3632
  for (const name of ownKeys(error)) {
3556
- // @ts-expect-error TS still confused by symbols as property names
3633
+ // @ts-expect-error TypeScript is still confused by symbols as property keys
3557
3634
  const desc = descs[name];
3558
3635
  if (desc && hasOwn(desc, 'get')) {
3559
- defineProperty(error, name, {
3560
- value: error[name] // invoke the getter to convert to data property
3561
- });
3636
+ const value = error[name]; // invokes the getter
3637
+ defineProperty(error, name, { value });
3562
3638
  }
3563
3639
  }
3564
3640
  freeze(error);
3565
3641
  };
3566
3642
 
3567
3643
  /**
3568
- * @type {AssertionUtilities['error']}
3644
+ * @type {AssertionUtilities['makeError']}
3569
3645
  */$h͏_once.sanitizeError(sanitizeError);
3570
3646
  const makeError = (
3571
3647
  optDetails = redactedDetails`Assert failed`,
@@ -3577,9 +3653,9 @@ const makeError = (
3577
3653
  sanitize = true,
3578
3654
  } = {},
3579
3655
  ) => {
3656
+ // Promote string-valued `optDetails` into a minimal DetailsParts
3657
+ // consisting of that string as the sole literal part with no substitutions.
3580
3658
  if (typeof optDetails === 'string') {
3581
- // If it is a string, use it as the literal part of the template so
3582
- // it doesn't get quoted.
3583
3659
  optDetails = redactedDetails([optDetails]);
3584
3660
  }
3585
3661
  const hiddenDetails = weakmapGet(hiddenDetailsMap, optDetails);
@@ -3595,13 +3671,11 @@ const makeError = (
3595
3671
  ) {
3596
3672
  error = AggregateError(errors || [], messageString, opts);
3597
3673
  } else {
3598
- error = /** @type {ErrorConstructor} */ (errConstructor)(
3599
- messageString,
3600
- opts,
3601
- );
3674
+ const ErrorCtor = /** @type {ErrorConstructor} */ (errConstructor);
3675
+ error = ErrorCtor(messageString, opts);
3676
+ // Since we need to tolerate `errors` on an AggregateError, we may as well
3677
+ // tolerate it on all errors.
3602
3678
  if (errors !== undefined) {
3603
- // Since we need to tolerate `errors` on an AggregateError, may as
3604
- // well tolerate it on all errors.
3605
3679
  defineProperty(error, 'errors', {
3606
3680
  value: errors,
3607
3681
  writable: true,
@@ -3624,11 +3698,10 @@ freeze(makeError);
3624
3698
 
3625
3699
  // /////////////////////////////////////////////////////////////////////////////
3626
3700
 
3627
- const { addLogArgs, takeLogArgsArray } = makeNoteLogArgsArrayKit();
3701
+ const { addLogArgs: addNoteLogArgs, takeLogArgsArray: takeAllNoteLogArgs } =
3702
+ makeNoteLogArgsArrayKit();
3628
3703
 
3629
3704
  /**
3630
- * @type {WeakMap<Error, NoteCallback[]>}
3631
- *
3632
3705
  * An augmented console will normally only take the hidden noteArgs array once,
3633
3706
  * when it logs the error being annotated. Once that happens, further
3634
3707
  * annotations of that error should go to the console immediately. We arrange
@@ -3637,14 +3710,16 @@ const { addLogArgs, takeLogArgsArray } = makeNoteLogArgsArrayKit();
3637
3710
  * callback per error, but that depends on console behavior which we should not
3638
3711
  * assume. We make this an array of callbacks so multiple registrations
3639
3712
  * are independent.
3713
+ *
3714
+ * @type {WeakMap<Error, NoteCallback[]>}
3640
3715
  */
3641
- const hiddenNoteCallbackArrays = new WeakMap();
3716
+ const hiddenNoteCallbacks = new WeakMap();
3642
3717
 
3643
3718
  /** @type {AssertionUtilities['note']} */
3644
3719
  const note = (error, detailsNote) => {
3720
+ // Promote string-valued `detailsNote` into a minimal DetailsParts consisting
3721
+ // of that string as the sole literal part with no substitutions.
3645
3722
  if (typeof detailsNote === 'string') {
3646
- // If it is a string, use it as the literal part of the template so
3647
- // it doesn't get quoted.
3648
3723
  detailsNote = redactedDetails([detailsNote]);
3649
3724
  }
3650
3725
  const hiddenDetails = weakmapGet(hiddenDetailsMap, detailsNote);
@@ -3652,13 +3727,13 @@ const note = (error, detailsNote) => {
3652
3727
  throw TypeError(`unrecognized details ${quote(detailsNote)}`);
3653
3728
  }
3654
3729
  const logArgs = getLogArgs(hiddenDetails);
3655
- const callbacks = weakmapGet(hiddenNoteCallbackArrays, error);
3730
+ const callbacks = weakmapGet(hiddenNoteCallbacks, error);
3656
3731
  if (callbacks !== undefined) {
3657
3732
  for (const callback of callbacks) {
3658
3733
  callback(error, logArgs);
3659
3734
  }
3660
3735
  } else {
3661
- addLogArgs(error, logArgs);
3736
+ addNoteLogArgs(error, logArgs);
3662
3737
  }
3663
3738
  };$h͏_once.note(note);
3664
3739
  freeze(note);
@@ -3692,21 +3767,21 @@ const loggedErrorHandler = {
3692
3767
  },
3693
3768
  getMessageLogArgs: error => weakmapGet(hiddenMessageLogArgs, error),
3694
3769
  takeMessageLogArgs: error => {
3695
- const result = weakmapGet(hiddenMessageLogArgs, error);
3770
+ const logArgs = weakmapGet(hiddenMessageLogArgs, error);
3696
3771
  weakmapDelete(hiddenMessageLogArgs, error);
3697
- return result;
3772
+ return logArgs;
3698
3773
  },
3699
3774
  takeNoteLogArgsArray: (error, callback) => {
3700
- const result = takeLogArgsArray(error);
3775
+ const logArgsArray = takeAllNoteLogArgs(error);
3701
3776
  if (callback !== undefined) {
3702
- const callbacks = weakmapGet(hiddenNoteCallbackArrays, error);
3777
+ const callbacks = weakmapGet(hiddenNoteCallbacks, error);
3703
3778
  if (callbacks) {
3704
3779
  arrayPush(callbacks, callback);
3705
3780
  } else {
3706
- weakmapSet(hiddenNoteCallbackArrays, error, [callback]);
3781
+ weakmapSet(hiddenNoteCallbacks, error, [callback]);
3707
3782
  }
3708
3783
  }
3709
- return result || [];
3784
+ return logArgsArray || [];
3710
3785
  },
3711
3786
  };$h͏_once.loggedErrorHandler(loggedErrorHandler);
3712
3787
  freeze(loggedErrorHandler);
@@ -3717,7 +3792,7 @@ freeze(loggedErrorHandler);
3717
3792
  /**
3718
3793
  * @type {MakeAssert}
3719
3794
  */
3720
- const makeAssert = (optRaise = undefined, unredacted = false) => {
3795
+ const makeAssert = (optRaise = undefined, unredacted = false) => {
3721
3796
  const details = unredacted ? unredactedDetails : redactedDetails;
3722
3797
  const assertFailedDetails = details`Check failed`;
3723
3798
 
@@ -3729,7 +3804,6 @@ const makeAssert = (optRaise = undefined, unredacted = false) => {
3729
3804
  ) => {
3730
3805
  const reason = makeError(optDetails, errConstructor, options);
3731
3806
  if (optRaise !== undefined) {
3732
- // @ts-ignore returns `never` doesn't mean it isn't callable
3733
3807
  optRaise(reason);
3734
3808
  }
3735
3809
  throw reason;
@@ -3739,18 +3813,16 @@ const makeAssert = (optRaise = undefined, unredacted = false) => {
3739
3813
  /** @type {AssertionUtilities['Fail']} */
3740
3814
  const Fail = (template, ...args) => fail(details(template, ...args));
3741
3815
 
3742
- // Don't freeze or export `baseAssert` until we add methods.
3743
- // TODO If I change this from a `function` function to an arrow
3744
- // function, I seem to get type errors from TypeScript. Why?
3816
+ // Don't freeze or export `assert` until we add methods.
3745
3817
  /** @type {BaseAssert} */
3746
- function baseAssert(
3747
- flag,
3818
+ const assert = (
3819
+ condition,
3748
3820
  optDetails = undefined,
3749
3821
  errConstructor = undefined,
3750
3822
  options = undefined,
3751
- ) {
3752
- flag || fail(optDetails, errConstructor, options);
3753
- }
3823
+ ) => {
3824
+ condition || fail(optDetails, errConstructor, options);
3825
+ };
3754
3826
 
3755
3827
  /** @type {AssertionFunctions['equal']} */
3756
3828
  const equal = (
@@ -3792,26 +3864,37 @@ const makeAssert = (optRaise = undefined, unredacted = false) => {
3792
3864
  const assertString = (specimen, optDetails = undefined) =>
3793
3865
  assertTypeof(specimen, 'string', optDetails);
3794
3866
 
3795
- // Note that "assert === baseAssert"
3796
- /** @type {Assert} */
3797
- const assert = assign(baseAssert, {
3798
- error: makeError,
3799
- fail,
3867
+ /** @type {Pick<AssertionFunctions, keyof AssertionFunctions>} */
3868
+ const assertionFunctions = {
3800
3869
  equal,
3801
3870
  typeof: assertTypeof,
3802
3871
  string: assertString,
3872
+ fail,
3873
+ };
3874
+
3875
+ /** @type {AssertionUtilities} */
3876
+ const assertionUtilities = {
3877
+ makeError,
3803
3878
  note,
3804
3879
  details,
3805
3880
  Fail,
3806
3881
  quote,
3807
3882
  bare,
3808
- makeAssert,
3883
+ };
3884
+
3885
+ /** @type {DeprecatedAssertionUtilities} */
3886
+ const deprecated = { error: makeError, makeAssert };
3887
+
3888
+ /** @type {Assert} */
3889
+ const finishedAssert = assign(assert, {
3890
+ ...assertionFunctions,
3891
+ ...assertionUtilities,
3892
+ ...deprecated,
3809
3893
  });
3810
- return freeze(assert);
3894
+ return freeze(finishedAssert);
3811
3895
  };$h͏_once.makeAssert(makeAssert);
3812
3896
  freeze(makeAssert);
3813
3897
 
3814
-
3815
3898
  /** @type {Assert} */
3816
3899
  const assert = makeAssert();$h͏_once.assert(assert);
3817
3900
 
@@ -4683,6 +4766,11 @@ const CommonMath = {
4683
4766
  seal: fn,
4684
4767
  setPrototypeOf: fn,
4685
4768
  values: fn,
4769
+ 'RegisteredSymbol(harden)': {
4770
+ ...fn,
4771
+ // Installed with hardenTaming: 'unsafe'
4772
+ isFake: 'boolean',
4773
+ },
4686
4774
  // https://github.com/tc39/proposal-accessible-object-hasownproperty
4687
4775
  hasOwn: fn,
4688
4776
  // https://github.com/tc39/proposal-array-grouping
@@ -6892,6 +6980,7 @@ function sampleGlobals(globalObject, newPropertyNames) {
6892
6980
  '%ErrorPrototype%': {
6893
6981
  name: true // set by "precond", "ava", "node-fetch"
6894
6982
  },
6983
+
6895
6984
  '%IteratorPrototype%': {
6896
6985
  toString: true,
6897
6986
  // https://github.com/tc39/proposal-iterator-helpers
@@ -6905,6 +6994,8 @@ function sampleGlobals(globalObject, newPropertyNames) {
6905
6994
  * Moderate enablements are usually good enough for legacy compat.
6906
6995
  */$h͏_once.minEnablements(minEnablements);
6907
6996
  const moderateEnablements = {
6997
+ ...minEnablements,
6998
+
6908
6999
  '%ObjectPrototype%': {
6909
7000
  toString: true,
6910
7001
  valueOf: true,
@@ -6917,6 +7008,10 @@ function sampleGlobals(globalObject, newPropertyNames) {
6917
7008
  [iteratorSymbol]: true // set by mobx generated code (old TS compiler?)
6918
7009
  },
6919
7010
 
7011
+ '%IteratorPrototype%': {
7012
+ [iteratorSymbol]: true // is sometimes used in custom iterators and generators implementations eg. @rive-app/canvas
7013
+ },
7014
+
6920
7015
  // Function.prototype has no 'prototype' property to enable.
6921
7016
  // Function instances have their own 'name' and 'length' properties
6922
7017
  // which are configurable and non-writable. Thus, they are already
@@ -6982,14 +7077,6 @@ function sampleGlobals(globalObject, newPropertyNames) {
6982
7077
  name: true,
6983
7078
  toString: true,
6984
7079
  },
6985
-
6986
- '%IteratorPrototype%': {
6987
- toString: true,
6988
- // https://github.com/tc39/proposal-iterator-helpers
6989
- constructor: true,
6990
- // https://github.com/tc39/proposal-iterator-helpers
6991
- [toStringTagSymbol]: true,
6992
- },
6993
7080
  };
6994
7081
 
6995
7082
  /**
@@ -7956,7 +8043,9 @@ const sourceMetaEntriesRegExp = new FERAL_REG_EXP(
7956
8043
  })()
7957
8044
  ,
7958
8045
  // === 33. ses ./src/transforms.js ===
7959
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';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)]]]]]);
8046
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let FERAL_REG_EXP,SyntaxError,regexpExec,regexpReplace,sealRegexp,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)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpReplace",[$h͏_a => (regexpReplace = $h͏_a)]],["sealRegexp",[$h͏_a => (sealRegexp = $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)]]]]]);
8047
+
8048
+
7960
8049
 
7961
8050
 
7962
8051
 
@@ -7993,7 +8082,9 @@ function getLineNumber(src, pattern) {
7993
8082
 
7994
8083
  // /////////////////////////////////////////////////////////////////////////////
7995
8084
 
7996
- const htmlCommentPattern = new FERAL_REG_EXP(`(?:${'<'}!--|--${'>'})`, 'g');
8085
+ const htmlCommentPattern = sealRegexp(
8086
+ new FERAL_REG_EXP(`(?:${'<'}!--|--${'>'})`, 'g'),
8087
+ );
7997
8088
 
7998
8089
  /**
7999
8090
  * Conservatively reject the source text if it may contain text that some
@@ -8058,16 +8149,85 @@ const htmlCommentPattern = new FERAL_REG_EXP(`(?:${'<'}!--|--${'>'})`, 'g');
8058
8149
  */$h͏_once.rejectHtmlComments(rejectHtmlComments);
8059
8150
  const evadeHtmlCommentTest = src => {
8060
8151
  const replaceFn = match => (match[0] === '<' ? '< ! --' : '-- >');
8061
- return stringReplace(src, htmlCommentPattern, replaceFn);
8152
+ return regexpReplace(htmlCommentPattern, src, replaceFn);
8062
8153
  };
8063
8154
 
8064
8155
  // /////////////////////////////////////////////////////////////////////////////
8065
8156
  $h͏_once.evadeHtmlCommentTest(evadeHtmlCommentTest);
8066
- const importPattern = new FERAL_REG_EXP(
8067
- '(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
8068
- 'g',
8157
+ const importPattern = sealRegexp(
8158
+ new FERAL_REG_EXP('(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|\\.|/[/*]))', 'g'),
8069
8159
  );
8070
8160
 
8161
+ /**
8162
+ * Matches one line of a run of `//# sourceURL=` and `//# sourceMappingURL=`
8163
+ * comments at the very end of the source (`sourceMetaTrailerStart` finds
8164
+ * the run), as module-source, compartment-mapper and
8165
+ * bundlers append to evaluated code (a module's location may well contain
8166
+ * `import.`, as in `conditional-import.js`).
8167
+ *
8168
+ * Each line must begin at a line start and its value must hold no whitespace
8169
+ * and none of `*`, backtick, `$`, quotes or backslash. Such a line is inert
8170
+ * wherever it stands: outside any literal it is a line comment; a regular
8171
+ * expression literal cannot span lines; and inside a block comment, a string
8172
+ * continued from the line before or a template literal, the line can neither
8173
+ * close that context (no `*`, quote or backtick) nor open a substitution (no
8174
+ * `$`). Since nothing but whitespace follows the run, an unclosed context
8175
+ * there is a SyntaxError. So `rejectImportExpressions` need not scan it.
8176
+ *
8177
+ * A `/*# sourceMappingURL=` block comment is not skipped but scanned like
8178
+ * any other code, which can only make the check stricter.
8179
+ */
8180
+ const sourceMetaLinePattern = sealRegexp(
8181
+ new FERAL_REG_EXP('^//# source(?:Mapping)?URL=[^\\s*`$\'"\\\\]*$'),
8182
+ );
8183
+
8184
+ const whitespacePattern = sealRegexp(new FERAL_REG_EXP('^\\s$'));
8185
+
8186
+ const lineTerminatorPattern = sealRegexp(
8187
+ new FERAL_REG_EXP('^[\\n\\r\\u2028\\u2029]$'),
8188
+ );
8189
+
8190
+ /**
8191
+ * Returns the index at which the trailing run of source meta comments
8192
+ * begins, at its leading line terminator if it has one, or the length of
8193
+ * the source if there is no such run. It reads the source backward, one
8194
+ * line at a time, and tests each line with `sourceMetaLinePattern` alone,
8195
+ * so it takes time linear in the length of the source. A single regular
8196
+ * expression for the whole run, `(?:(?:^|[\n\r\u2028\u2029])<line>)+\s*$`,
8197
+ * finds the same run, but a search retries it at every line terminator,
8198
+ * which takes time quadratic in the number of lines of the run.
8199
+ *
8200
+ * @param {string} src
8201
+ * @returns {number}
8202
+ */
8203
+ const sourceMetaTrailerStart = src => {
8204
+ let end = src.length;
8205
+ while (end > 0 && regexpExec(whitespacePattern, src[end - 1]) !== null) {
8206
+ end -= 1;
8207
+ }
8208
+ let start = src.length;
8209
+ for (;;) {
8210
+ let lineStart = end;
8211
+ while (
8212
+ lineStart > 0 &&
8213
+ regexpExec(lineTerminatorPattern, src[lineStart - 1]) === null
8214
+ ) {
8215
+ lineStart -= 1;
8216
+ }
8217
+ if (
8218
+ regexpExec(sourceMetaLinePattern, stringSlice(src, lineStart, end)) ===
8219
+ null
8220
+ ) {
8221
+ return start;
8222
+ }
8223
+ if (lineStart === 0) {
8224
+ return 0;
8225
+ }
8226
+ start = lineStart - 1;
8227
+ end = lineStart - 1;
8228
+ }
8229
+ };
8230
+
8071
8231
  /**
8072
8232
  * Conservatively reject the source text if it may contain a dynamic
8073
8233
  * import expression. To reject without parsing, `rejectImportExpressions` will
@@ -8083,10 +8243,23 @@ const importPattern = new FERAL_REG_EXP(
8083
8243
  * apparent import expressions in literal strings or comments.
8084
8244
  *
8085
8245
  * The current conservative rule looks for the identifier "import"
8086
- * followed by either an open paren or something that looks like the
8087
- * beginning of a comment. We assume that we do not need to worry
8088
- * about html comment syntax because that was already rejected by
8089
- * rejectHtmlComments.
8246
+ * followed by either an open paren, a dot, or something that looks like
8247
+ * the beginning of a comment. The dot case rejects not just a
8248
+ * phase-qualified call such as `import.source(...)` or `import.defer(...)`,
8249
+ * but any property access under `import` at all, including `import.meta`,
8250
+ * regardless of whether the property is then called. This is broader than
8251
+ * strictly necessary: the substring "import." can occur incidentally, for
8252
+ * example in a module path or a comment, and such source text is rejected
8253
+ * too. That tradeoff is intentional: covering every `import.<name>` form,
8254
+ * called or not, without naming specific property names, is judged simpler
8255
+ * and safer than narrowing the match to the shape of a call. We assume that
8256
+ * we do not need to worry about html comment syntax because that was
8257
+ * already rejected by rejectHtmlComments.
8258
+ *
8259
+ * The scan stops short of a trailing run of `//# sourceURL=` or
8260
+ * `//# sourceMappingURL=` comments whose values could not end a comment,
8261
+ * string or template (see `sourceMetaTrailerStart`), so that a module
8262
+ * whose location contains `import.` still loads.
8090
8263
  *
8091
8264
  * this \s *must* match all kinds of syntax-defined whitespace. If e.g.
8092
8265
  * U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) is treated as
@@ -8099,7 +8272,8 @@ const importPattern = new FERAL_REG_EXP(
8099
8272
  * @returns {string}
8100
8273
  */
8101
8274
  const rejectImportExpressions = src => {
8102
- const lineNumber = getLineNumber(src, importPattern);
8275
+ const scanned = stringSlice(src, 0, sourceMetaTrailerStart(src));
8276
+ const lineNumber = getLineNumber(scanned, importPattern);
8103
8277
  if (lineNumber < 0) {
8104
8278
  return src;
8105
8279
  }
@@ -8128,7 +8302,7 @@ const importPattern = new FERAL_REG_EXP(
8128
8302
  */$h͏_once.rejectImportExpressions(rejectImportExpressions);
8129
8303
  const evadeImportExpressionTest = src => {
8130
8304
  const replaceFn = (_, p1, p2) => `${p1}__import__${p2}`;
8131
- return stringReplace(src, importPattern, replaceFn);
8305
+ return regexpReplace(importPattern, src, replaceFn);
8132
8306
  };
8133
8307
 
8134
8308
  // /////////////////////////////////////////////////////////////////////////////
@@ -8226,7 +8400,9 @@ $h͏_once.applyTransforms(applyTransforms);const transforms=freeze({
8226
8400
  })()
8227
8401
  ,
8228
8402
  // === 34. ses ./src/scope-constants.js ===
8229
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,hasOwn,regexpTest;$h͏_imports([["./commons.js", [["arrayFilter",[$h͏_a => (arrayFilter = $h͏_a)]],["arrayIncludes",[$h͏_a => (arrayIncludes = $h͏_a)]],["getOwnPropertyDescriptor",[$h͏_a => (getOwnPropertyDescriptor = $h͏_a)]],["getOwnPropertyNames",[$h͏_a => (getOwnPropertyNames = $h͏_a)]],["hasOwn",[$h͏_a => (hasOwn = $h͏_a)]],["regexpTest",[$h͏_a => (regexpTest = $h͏_a)]]]]]);
8403
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let arrayFilter,arrayIncludes,getOwnPropertyDescriptor,getOwnPropertyNames,hasOwn,regexpExec,Set,setHas;$h͏_imports([["./commons.js", [["arrayFilter",[$h͏_a => (arrayFilter = $h͏_a)]],["arrayIncludes",[$h͏_a => (arrayIncludes = $h͏_a)]],["getOwnPropertyDescriptor",[$h͏_a => (getOwnPropertyDescriptor = $h͏_a)]],["getOwnPropertyNames",[$h͏_a => (getOwnPropertyNames = $h͏_a)]],["hasOwn",[$h͏_a => (hasOwn = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["Set",[$h͏_a => (Set = $h͏_a)]],["setHas",[$h͏_a => (setHas = $h͏_a)]]]]]);
8404
+
8405
+
8230
8406
 
8231
8407
 
8232
8408
 
@@ -8236,11 +8412,12 @@ $h͏_once.applyTransforms(applyTransforms);const transforms=freeze({
8236
8412
 
8237
8413
 
8238
8414
  /**
8239
- * keywords
8240
- * In JavaScript you cannot use these reserved words as variables.
8241
- * See 11.6.1 Identifier Names
8415
+ * reservedNames
8416
+ * In JavaScript you cannot use reserved words as variable names (except for
8417
+ * "eval", which is specially reserved to prevent shadowing).
8418
+ * https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-identifier-names
8242
8419
  */
8243
- const keywords = [
8420
+ const reservedNames = new Set([
8244
8421
  // 11.6.2.1 Keywords
8245
8422
  'await',
8246
8423
  'break',
@@ -8301,7 +8478,10 @@ const keywords = [
8301
8478
 
8302
8479
  'this',
8303
8480
  'arguments',
8304
- ];
8481
+
8482
+ // Reserved by us
8483
+ 'eval',
8484
+ ]);
8305
8485
 
8306
8486
  /**
8307
8487
  * identifierPattern
@@ -8317,24 +8497,12 @@ const identifierPattern = /^[a-zA-Z_$][\w$]*$/;
8317
8497
 
8318
8498
  /**
8319
8499
  * isValidIdentifierName()
8320
- * What variable names might it bring into scope? These include all
8321
- * property names which can be variable names, including the names
8322
- * of inherited properties. It excludes symbols and names which are
8323
- * keywords. We drop symbols safely. Currently, this shim refuses
8324
- * service if any of the names are keywords or keyword-like. This is
8325
- * safe and only prevent performance optimization.
8500
+ * Is a value allowed as an arbitrary identifier name?
8326
8501
  *
8327
8502
  * @param {string} name
8328
8503
  */
8329
- const isValidIdentifierName = name => {
8330
- // Ensure we have a valid identifier. We use regexpTest rather than
8331
- // /../.test() to guard against the case where RegExp has been poisoned.
8332
- return (
8333
- name !== 'eval' &&
8334
- !arrayIncludes(keywords, name) &&
8335
- regexpTest(identifierPattern, name)
8336
- );
8337
- };
8504
+ const isValidIdentifierName = name =>
8505
+ !setHas(reservedNames, name) && !!regexpExec(identifierPattern, name);
8338
8506
 
8339
8507
  /*
8340
8508
  * isImmutableDataProperty
@@ -8365,12 +8533,12 @@ function isImmutableDataProperty(obj, name) {
8365
8533
 
8366
8534
  /**
8367
8535
  * getScopeConstants()
8368
- * What variable names might it bring into scope? These include all
8536
+ * What variable names might be brought into scope? These include all
8369
8537
  * property names which can be variable names, including the names
8370
8538
  * of inherited properties. It excludes symbols and names which are
8371
8539
  * keywords. We drop symbols safely. Currently, this shim refuses
8372
8540
  * service if any of the names are keywords or keyword-like. This is
8373
- * safe and only prevent performance optimization.
8541
+ * safe and only affects performance optimization.
8374
8542
  *
8375
8543
  * @param {object} globalObject
8376
8544
  * @param {object} moduleLexicals
@@ -9657,8 +9825,7 @@ const wrapLogger = (logger, thisArg) =>
9657
9825
  })()
9658
9826
  ,
9659
9827
  // === 43. ses ./src/error/tame-v8-error-constructor.js ===
9660
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas,TypeError;$h͏_imports([["../commons.js", [["WeakMap",[$h͏_a => (WeakMap = $h͏_a)]],["WeakSet",[$h͏_a => (WeakSet = $h͏_a)]],["apply",[$h͏_a => (apply = $h͏_a)]],["arrayFilter",[$h͏_a => (arrayFilter = $h͏_a)]],["arrayJoin",[$h͏_a => (arrayJoin = $h͏_a)]],["arrayMap",[$h͏_a => (arrayMap = $h͏_a)]],["arraySlice",[$h͏_a => (arraySlice = $h͏_a)]],["create",[$h͏_a => (create = $h͏_a)]],["defineProperties",[$h͏_a => (defineProperties = $h͏_a)]],["fromEntries",[$h͏_a => (fromEntries = $h͏_a)]],["reflectSet",[$h͏_a => (reflectSet = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["regexpTest",[$h͏_a => (regexpTest = $h͏_a)]],["weakmapGet",[$h͏_a => (weakmapGet = $h͏_a)]],["weakmapSet",[$h͏_a => (weakmapSet = $h͏_a)]],["weaksetAdd",[$h͏_a => (weaksetAdd = $h͏_a)]],["weaksetHas",[$h͏_a => (weaksetHas = $h͏_a)]],["TypeError",[$h͏_a => (TypeError = $h͏_a)]]]]]);
9661
-
9828
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,weakmapGet,weakmapSet,weaksetAdd,weaksetHas,TypeError;$h͏_imports([["../commons.js", [["WeakMap",[$h͏_a => (WeakMap = $h͏_a)]],["WeakSet",[$h͏_a => (WeakSet = $h͏_a)]],["apply",[$h͏_a => (apply = $h͏_a)]],["arrayFilter",[$h͏_a => (arrayFilter = $h͏_a)]],["arrayJoin",[$h͏_a => (arrayJoin = $h͏_a)]],["arrayMap",[$h͏_a => (arrayMap = $h͏_a)]],["arraySlice",[$h͏_a => (arraySlice = $h͏_a)]],["create",[$h͏_a => (create = $h͏_a)]],["defineProperties",[$h͏_a => (defineProperties = $h͏_a)]],["fromEntries",[$h͏_a => (fromEntries = $h͏_a)]],["reflectSet",[$h͏_a => (reflectSet = $h͏_a)]],["regexpExec",[$h͏_a => (regexpExec = $h͏_a)]],["weakmapGet",[$h͏_a => (weakmapGet = $h͏_a)]],["weakmapSet",[$h͏_a => (weakmapSet = $h͏_a)]],["weaksetAdd",[$h͏_a => (weaksetAdd = $h͏_a)]],["weaksetHas",[$h͏_a => (weaksetHas = $h͏_a)]],["TypeError",[$h͏_a => (TypeError = $h͏_a)]]]]]);
9662
9829
 
9663
9830
 
9664
9831
 
@@ -9761,12 +9928,12 @@ const FILENAME_CENSORS = [
9761
9928
  // Exported only so it can be unit tested.
9762
9929
  // TODO Move so that it applies not just to v8.
9763
9930
  const filterFileName = fileName => {
9764
- if (!fileName) {
9765
- // Stack frames with no fileName should appear in concise stack traces.
9766
- return true;
9931
+ if (fileName === null) {
9932
+ // Seems to suppress builtins like `Array.every (<anonymous>)`
9933
+ return false;
9767
9934
  }
9768
9935
  for (const filter of FILENAME_CENSORS) {
9769
- if (regexpTest(filter, fileName)) {
9936
+ if (regexpExec(filter, fileName)) {
9770
9937
  return false;
9771
9938
  }
9772
9939
  }
@@ -9777,9 +9944,9 @@ const FILENAME_CENSORS = [
9777
9944
  // likely url-path prefix, ending in a `/.../` should get dropped.
9778
9945
  // Anything to the left of the likely path text is kept.
9779
9946
  // Everything to the right of `/.../` is kept. Thus
9780
- // `'Object.bar (/vat-v1/.../eventual-send/test/deep-send.test.js:13:21)'`
9947
+ // `'Object.bar (/vat-v1/.../errors/test/deep-send.test.js:13:21)'`
9781
9948
  // simplifies to
9782
- // `'Object.bar (eventual-send/test/deep-send.test.js:13:21)'`.
9949
+ // `'Object.bar (errors/test/deep-send.test.js:13:21)'`.
9783
9950
  //
9784
9951
  // See thread starting at
9785
9952
  // https://github.com/Agoric/agoric-sdk/issues/2326#issuecomment-773020389
@@ -9789,9 +9956,9 @@ $h͏_once.filterFileName(filterFileName);const CALLSITE_ELLIPSIS_PATTERN1=/^((?:
9789
9956
  // likely url-path prefix consisting of `.../` should get dropped.
9790
9957
  // Anything to the left of the likely path text is kept.
9791
9958
  // Everything to the right of `.../` is kept. Thus
9792
- // `'Object.bar (.../eventual-send/test/deep-send.test.js:13:21)'`
9959
+ // `'Object.bar (.../errors/test/deep-send.test.js:13:21)'`
9793
9960
  // simplifies to
9794
- // `'Object.bar (eventual-send/test/deep-send.test.js:13:21)'`.
9961
+ // `'Object.bar (errors/test/deep-send.test.js:13:21)'`.
9795
9962
  //
9796
9963
  // See thread starting at
9797
9964
  // https://github.com/Agoric/agoric-sdk/issues/2326#issuecomment-773020389
@@ -9802,9 +9969,9 @@ const CALLSITE_ELLIPSIS_PATTERN2 = /^((?:.*[( ])?)\.\.\.\/(.+)$/;
9802
9969
  // dropped.
9803
9970
  // Anything to the left of the likely path prefix text is kept. `package/` and
9804
9971
  // everything to its right is kept. Thus
9805
- // `'Object.bar (/Users/markmiller/src/ongithub/agoric/agoric-sdk/packages/eventual-send/test/deep-send.test.js:13:21)'`
9972
+ // `'Object.bar (/Users/markmiller/src/ongithub/agoric/agoric-sdk/packages/errors/test/deep-send.test.js:13:21)'`
9806
9973
  // simplifies to
9807
- // `'Object.bar (packages/eventual-send/test/deep-send.test.js:13:21)'`.
9974
+ // `'Object.bar (packages/errors/test/deep-send.test.js:13:21)'`.
9808
9975
  // Note that `/packages/` is a convention for monorepos encouraged by
9809
9976
  // lerna.
9810
9977
  const CALLSITE_PACKAGES_PATTERN = /^((?:.*[( ])?)[:/\w_-]*\/(packages\/.+)$/;
@@ -9814,7 +9981,7 @@ const CALLSITE_PACKAGES_PATTERN = /^((?:.*[( ])?)[:/\w_-]*\/(packages\/.+)$/;
9814
9981
  // dropped.
9815
9982
  // Anything to the left of the likely path prefix text is kept. Everything to
9816
9983
  // the right of `file://` is kept. Thus
9817
- // `'Object.bar (file:///Users/markmiller/src/ongithub/endojs/endo/packages/eventual-send/test/deep-send.test.js:13:21)'` is unchanged but
9984
+ // `'Object.bar (file:///Users/markmiller/src/ongithub/endojs/endo/packages/errors/test/deep-send.test.js:13:21)'` is unchanged but
9818
9985
  // `'Object.bar (file://test/deep-send.test.js:13:21)'`
9819
9986
 
9820
9987
  // simplifies to
@@ -9880,6 +10047,10 @@ const CALLSITE_PATTERNS = [
9880
10047
  // const callSiteFilter = _callSite => true;
9881
10048
  const callSiteFilter = callSite => {
9882
10049
  if (omitFrames) {
10050
+ // eslint-disable-next-line @endo/no-polymorphic-call
10051
+ if (callSite.getFunctionName()?.startsWith('__HIDE_')) {
10052
+ return false;
10053
+ }
9883
10054
  // eslint-disable-next-line @endo/no-polymorphic-call
9884
10055
  return filterFileName(callSite.getFileName());
9885
10056
  }
@@ -11710,6 +11881,25 @@ $h͏_once.makeVirtualModuleInstance(makeVirtualModuleInstance);const makeModuleI
11710
11881
  };
11711
11882
  notifiers['*'] = notifyStar;
11712
11883
 
11884
+ const wireUpExportNotifier = (exportName, notify) => {
11885
+ if (!notifiers[exportName] && notify !== false) {
11886
+ notifiers[exportName] = notify;
11887
+
11888
+ // exported live binding state
11889
+ let value;
11890
+ const update = newValue => (value = newValue);
11891
+ notify(update);
11892
+ exportsProps[exportName] = {
11893
+ get() {
11894
+ return value;
11895
+ },
11896
+ set: undefined,
11897
+ enumerable: true,
11898
+ configurable: false,
11899
+ };
11900
+ }
11901
+ };
11902
+
11713
11903
  // Per the calling convention for the moduleFunctor generated from
11714
11904
  // an ESM, the `imports` function gets called once up front
11715
11905
  // to populate or arrange the population of imports and reexports.
@@ -11763,30 +11953,15 @@ $h͏_once.makeVirtualModuleInstance(makeVirtualModuleInstance);const makeModuleI
11763
11953
  }
11764
11954
  }
11765
11955
  if (reexportMap[specifier]) {
11766
- // Make named reexports candidates too.
11956
+ // Set up reexport notifiers instantly so they are available in cycles.
11767
11957
  for (const [localName, exportedName] of reexportMap[specifier]) {
11768
- candidateAll[exportedName] = importNotifiers[localName];
11958
+ wireUpExportNotifier(exportedName, importNotifiers[localName]);
11769
11959
  }
11770
11960
  }
11771
11961
  }
11772
11962
 
11773
11963
  for (const [exportName, notify] of entries(candidateAll)) {
11774
- if (!notifiers[exportName] && notify !== false) {
11775
- notifiers[exportName] = notify;
11776
-
11777
- // exported live binding state
11778
- let value;
11779
- const update = newValue => (value = newValue);
11780
- notify(update);
11781
- exportsProps[exportName] = {
11782
- get() {
11783
- return value;
11784
- },
11785
- set: undefined,
11786
- enumerable: true,
11787
- configurable: false,
11788
- };
11789
- }
11964
+ wireUpExportNotifier(exportName, notify);
11790
11965
  }
11791
11966
 
11792
11967
  // Sort the module exports namespace as per spec.
@@ -12666,7 +12841,6 @@ function makeArguments() {
12666
12841
  }
12667
12842
 
12668
12843
  const ab = new ArrayBuffer(0);
12669
- // @ts-expect-error TODO How do I add sliceToImmutable to ArrayBuffer type?
12670
12844
  // eslint-disable-next-line @endo/no-polymorphic-call
12671
12845
  const iab = ab.sliceToImmutable();
12672
12846
  const iabProto = getPrototypeOf(iab);
@@ -13112,16 +13286,48 @@ const throws = thunk => {
13112
13286
  })()
13113
13287
  ,
13114
13288
  // === 57. ses ./src/reporting.js ===
13115
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let functionBind,globalThis,assert;$h͏_imports([["./commons.js", [["functionBind",[$h͏_a => (functionBind = $h͏_a)]],["globalThis",[$h͏_a => (globalThis = $h͏_a)]]]],["./error/assert.js", [["assert",[$h͏_a => (assert = $h͏_a)]]]]]);
13289
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let globalThis,assert;$h͏_imports([["./commons.js", [["globalThis",[$h͏_a => (globalThis = $h͏_a)]]]],["./error/assert.js", [["assert",[$h͏_a => (assert = $h͏_a)]]]]]);
13116
13290
 
13117
13291
 
13118
13292
  /**
13119
13293
  * @import {Reporter, GroupReporter} from './reporting-types.js'
13120
13294
  */
13121
13295
 
13296
+ /* eslint-disable @endo/no-polymorphic-call */
13297
+ /**
13298
+ * To address https://github.com/endojs/endo/issues/2908,
13299
+ * the `consoleReporter` uses the current `console` rather
13300
+ * than the original one.
13301
+ *
13302
+ * @type {GroupReporter}
13303
+ */
13304
+ const consoleReporter = {
13305
+ warn(...args) {
13306
+ globalThis.console.warn(...args);
13307
+ },
13308
+ error(...args) {
13309
+ globalThis.console.error(...args);
13310
+ },
13311
+ ...(globalThis.console?.groupCollapsed
13312
+ ? {
13313
+ groupCollapsed(...args) {
13314
+ globalThis.console.groupCollapsed(...args);
13315
+ },
13316
+ }
13317
+ : undefined),
13318
+ ...(globalThis.console?.groupEnd
13319
+ ? {
13320
+ groupEnd() {
13321
+ globalThis.console.groupEnd();
13322
+ },
13323
+ }
13324
+ : undefined),
13325
+ };
13326
+ /* eslint-enable @endo/no-polymorphic-call */
13327
+
13122
13328
  /**
13123
13329
  * Creates a suitable reporter for internal errors and warnings out of the
13124
- * Node.js console.error to ensure all messages to go stderr, including the
13330
+ * Node.js console.error to ensure all messages go to stderr, including the
13125
13331
  * group label.
13126
13332
  * Accounts for the extra space introduced by console.error as a delimiter
13127
13333
  * between the indent and subsequent arguments.
@@ -13165,18 +13371,22 @@ const mute = () => {};
13165
13371
  if (reporting === 'none') {
13166
13372
  return makeReportPrinter(mute);
13167
13373
  }
13168
- if (
13169
- reporting === 'console' ||
13170
- globalThis.window === globalThis ||
13171
- globalThis.importScripts !== undefined
13172
- ) {
13173
- return console;
13174
- }
13175
13374
  if (globalThis.console !== undefined) {
13375
+ if (
13376
+ reporting === 'console' || // asks for console explicitly
13377
+ globalThis.window === globalThis || // likely on browser
13378
+ globalThis.importScripts !== undefined // likely on worker
13379
+ ) {
13380
+ // reporter just delegates directly to the current console
13381
+ return consoleReporter;
13382
+ }
13383
+ assert(reporting === 'platform');
13176
13384
  // On Node.js, we send all feedback to stderr, regardless of purported level.
13177
- const console = globalThis.console;
13178
- const error = functionBind(console.error, console);
13179
- return makeReportPrinter(error);
13385
+ // This uses `consoleReporter.error` instead of `console.error` because we
13386
+ // want the constructed reporter to use the `console.error` of the current
13387
+ // `console`, not the `console` that was installed when the reporter
13388
+ // was created.
13389
+ return makeReportPrinter(consoleReporter.error);
13180
13390
  }
13181
13391
  if (globalThis.print !== undefined) {
13182
13392
  return makeReportPrinter(globalThis.print);
@@ -13220,7 +13430,8 @@ const mute = () => {};
13220
13430
  })()
13221
13431
  ,
13222
13432
  // === 58. ses ./src/lockdown.js ===
13223
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,removeUnpermittedIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameModuleSource,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties,tameRegeneratorRuntime,shimArrayBufferTransfer,reportInGroup,chooseReporter;$h͏_imports([["@endo/env-options", [["getEnvironmentOption",[$h͏_a => (getenv = $h͏_a)]]]],["@endo/immutable-arraybuffer/shim.js", []],["./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 => (removeUnpermittedIntrinsics = $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)]]]],["./tame-module-source.js", [["tameModuleSource",[$h͏_a => (tameModuleSource = $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)]]]],["./tame-regenerator-runtime.js", [["tameRegeneratorRuntime",[$h͏_a => (tameRegeneratorRuntime = $h͏_a)]]]],["./shim-arraybuffer-transfer.js", [["shimArrayBufferTransfer",[$h͏_a => (shimArrayBufferTransfer = $h͏_a)]]]],["./reporting.js", [["reportInGroup",[$h͏_a => (reportInGroup = $h͏_a)]],["chooseReporter",[$h͏_a => (chooseReporter = $h͏_a)]]]]]);
13433
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let getenv,FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,globalThis,is,ownKeys,stringSplit,symbolFor,noEvalEvaluate,getOwnPropertyNames,getPrototypeOf,makeHardener,makeIntrinsicsCollector,removeUnpermittedIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,setGlobalObjectEvaluators,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameModuleSource,tameConsole,tameErrorConstructor,assert,makeAssert,getAnonymousIntrinsics,makeCompartmentConstructor,tameHarden,tameSymbolConstructor,tameFauxDataProperties,tameRegeneratorRuntime,shimArrayBufferTransfer,reportInGroup,chooseReporter;$h͏_imports([["@endo/env-options", [["getEnvironmentOption",[$h͏_a => (getenv = $h͏_a)]]]],["@endo/immutable-arraybuffer/shim.js", []],["./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)]],["symbolFor",[$h͏_a => (symbolFor = $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 => (removeUnpermittedIntrinsics = $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)]]]],["./tame-module-source.js", [["tameModuleSource",[$h͏_a => (tameModuleSource = $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)]]]],["./tame-regenerator-runtime.js", [["tameRegeneratorRuntime",[$h͏_a => (tameRegeneratorRuntime = $h͏_a)]]]],["./shim-arraybuffer-transfer.js", [["shimArrayBufferTransfer",[$h͏_a => (shimArrayBufferTransfer = $h͏_a)]]]],["./reporting.js", [["reportInGroup",[$h͏_a => (reportInGroup = $h͏_a)]],["chooseReporter",[$h͏_a => (chooseReporter = $h͏_a)]]]]]);
13434
+
13224
13435
 
13225
13436
 
13226
13437
 
@@ -13585,6 +13796,30 @@ const probeHostEvaluators = () => {
13585
13796
 
13586
13797
  const intrinsics = finalIntrinsics();
13587
13798
 
13799
+ // Install Object[@harden] or abort.
13800
+ const symbolForHarden = symbolFor('harden');
13801
+ const priorHarden = intrinsics.Object[symbolForHarden];
13802
+ if (priorHarden) {
13803
+ // By convention, if a module like @endo/harden gets used before lockdown,
13804
+ // it will install itself as a non-configurable, non-writable property over
13805
+ // Object[@harden] so that versions of SES predating the introduction of
13806
+ // Object[@harden] will fail to lockdown because they cannot remove an
13807
+ // unknown intrinsic.
13808
+ // All newer versions explicitly check for Object[@harden] (here).
13809
+ // The @endo/harden implementation additionally captures a stack trace
13810
+ // where harden was first used to assist developers in tracking down the
13811
+ // hardened module that was initialized before lockdown.
13812
+ if (priorHarden.lockdownError) {
13813
+ throw priorHarden.lockdownError;
13814
+ }
13815
+ // And in the event a library installs Object[@harden] without leaving a
13816
+ // hint, we fall back to a generic lockdown error.
13817
+ throw new TypeError(
13818
+ 'Cannot lockdown (repairIntrinsics) if a prior harden implementation has been used and installed. Check for libraries using @endo/harden before lockdown.',
13819
+ );
13820
+ }
13821
+ intrinsics.Object[symbolForHarden] = tamedHarden;
13822
+
13588
13823
  const hostIntrinsics = { __proto__: null };
13589
13824
 
13590
13825
  // The Node.js Buffer is a derived class of Uint8Array, and as such is often
@@ -13626,19 +13861,16 @@ const probeHostEvaluators = () => {
13626
13861
  );
13627
13862
  }
13628
13863
 
13864
+ // The default `assert` installed by `assert-shim.js` does not redact errors,
13865
+ // leaving `lockdown` or `repairIntrinsics` with the obligation to replace it
13866
+ // with a redacting version, unless the caller opts-out with errorTaming set
13867
+ // to `unsafe` or `unsafe-debug`.
13868
+ // The inverse was true through version 1.13.0, except the configuration
13869
+ // was disregarded and the redacting `assert` left in place if lexical
13870
+ // `assert` differed from `globalThis.assert`.
13629
13871
  // @ts-ignore assert is absent on globalThis type def.
13630
- if (
13631
- (errorTaming === 'unsafe' || errorTaming === 'unsafe-debug') &&
13632
- globalThis.assert === assert
13633
- ) {
13634
- // If errorTaming is 'unsafe' or 'unsafe-debug' we replace the
13635
- // global assert with
13636
- // one whose `details` template literal tag does not redact
13637
- // unmarked substitution values. IOW, it blabs information that
13638
- // was supposed to be secret from callers, as an aid to debugging
13639
- // at a further cost in safety.
13640
- // @ts-ignore assert is absent on globalThis type def.
13641
- globalThis.assert = makeAssert(undefined, true);
13872
+ if (errorTaming !== 'unsafe' && errorTaming !== 'unsafe-debug') {
13873
+ globalThis.assert = makeAssert();
13642
13874
  }
13643
13875
 
13644
13876
  // Replace *Locale* methods with their non-locale equivalents
@@ -13846,10 +14078,10 @@ globalThis.Compartment = makeCompartmentConstructor(
13846
14078
  })()
13847
14079
  ,
13848
14080
  // === 61. ses ./src/assert-shim.js ===
13849
- ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let globalThis,assert;$h͏_imports([["./commons.js", [["globalThis",[$h͏_a => (globalThis = $h͏_a)]]]],["./error/assert.js", [["assert",[$h͏_a => (assert = $h͏_a)]]]]]);
14081
+ ({imports:$h͏_imports,liveVar:$h͏_live,onceVar:$h͏_once,import:$h͏_import,importMeta:$h͏____meta})=>(function(){'use strict';let globalThis,makeAssert;$h͏_imports([["./commons.js", [["globalThis",[$h͏_a => (globalThis = $h͏_a)]]]],["./error/assert.js", [["makeAssert",[$h͏_a => (makeAssert = $h͏_a)]]]]]);
13850
14082
 
13851
14083
 
13852
- globalThis.assert = assert;
14084
+ globalThis.assert = makeAssert(undefined, true);
13853
14085
  })()
13854
14086
  ,
13855
14087
  // === 62. ses ./src/console-shim.js ===