ses 0.15.17 → 0.15.20

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/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.15.20](https://github.com/endojs/endo/compare/ses@0.15.19...ses@0.15.20) (2022-08-26)
7
+
8
+ **Note:** Version bump only for package ses
9
+
10
+
11
+
12
+
13
+
14
+ ### [0.15.19](https://github.com/endojs/endo/compare/ses@0.15.18...ses@0.15.19) (2022-08-25)
15
+
16
+ **Note:** Version bump only for package ses
17
+
18
+
19
+
20
+
21
+
22
+ ### [0.15.18](https://github.com/endojs/endo/compare/ses@0.15.17...ses@0.15.18) (2022-08-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * more hardens ([#1241](https://github.com/endojs/endo/issues/1241)) ([b6ff811](https://github.com/endojs/endo/commit/b6ff8118a92fd72c5309b2bb285fac08d0531d92))
28
+ * remove __allowUnsafeMonkeyPatching__ ([fe9c784](https://github.com/endojs/endo/commit/fe9c78414eab5d1bce73cdb16e1455c1c4307e98))
29
+ * remove dead environment-options module ([#1243](https://github.com/endojs/endo/issues/1243)) ([c43c939](https://github.com/endojs/endo/commit/c43c9396976ad6b0af5d99caed033b1abf448165))
30
+ * **ses:** avoid leaks through CallSite structures ([69f69fa](https://github.com/endojs/endo/commit/69f69fac84154401a5bea72a533ba07f1ff2c191))
31
+
32
+
33
+
6
34
  ### [0.15.17](https://github.com/endojs/endo/compare/ses@0.15.16...ses@0.15.17) (2022-06-28)
7
35
 
8
36
 
package/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  User-visible changes in SES:
2
2
 
3
+ # v0.15.18 (2022-08-23)
4
+
5
+ - Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
6
+ should indicate, this was always an unsafe temporary kludge. Its only known
7
+ use was in agoric-sdk, now gone at
8
+ https://github.com/Agoric/agoric-sdk/pull/5922 . Without this option, a
9
+ successful `lockdown` will now always harden the primordials.
10
+
3
11
  # v0.15.8 (2022-02-18)
4
12
 
5
13
  - Harden now gives special treatment to typed arrays.
@@ -66,7 +74,7 @@ User-visible changes in SES:
66
74
  for cases that do not require special global lexicals, by sharing a single
67
75
  per-compartment evaluator.
68
76
 
69
- # 0.14.3 (2021-09-18)
77
+ # 0.14.3 (2021-09-18)
70
78
 
71
79
  - Due to a peculiar bit of error handling code in Node 14, as explained at
72
80
  [Hardened JavaScript interferes with Node.js 14 Error
package/dist/lockdown.cjs CHANGED
@@ -6083,7 +6083,7 @@ function enablePropertyOverrides(
6083
6083
  })
6084
6084
  ,
6085
6085
  // === functors[24] ===
6086
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,arraySlice,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6086
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6087
6087
 
6088
6088
 
6089
6089
 
@@ -6201,11 +6201,11 @@ const makeEnvironmentCaptor= (aGlobal)=>{
6201
6201
  freeze(getEnvironmentOption);
6202
6202
 
6203
6203
  const getCapturedEnvironmentOptionNames= ()=> {
6204
- return freeze(arraySlice(capturedEnvironmentOptionNames));
6204
+ return freeze([...capturedEnvironmentOptionNames]);
6205
6205
  };
6206
6206
  freeze(getCapturedEnvironmentOptionNames);
6207
6207
 
6208
- return { getEnvironmentOption, getCapturedEnvironmentOptionNames};
6208
+ return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames});
6209
6209
  };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
6210
6210
  freeze(makeEnvironmentCaptor);
6211
6211
  })
@@ -6865,8 +6865,7 @@ const tameConsole= (
6865
6865
  })
6866
6866
  ,
6867
6867
  // === functors[28] ===
6868
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapHas,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6869
-
6868
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6870
6869
 
6871
6870
 
6872
6871
 
@@ -7032,6 +7031,9 @@ const tameV8ErrorConstructor= (
7032
7031
  errorTaming,
7033
7032
  stackFiltering)=>
7034
7033
  {
7034
+ // TODO: Proper CallSite types
7035
+ /** @typedef {{}} CallSite */
7036
+
7035
7037
  const originalCaptureStackTrace= OriginalError.captureStackTrace;
7036
7038
 
7037
7039
  // const callSiteFilter = _callSite => true;
@@ -7057,9 +7059,23 @@ const tameV8ErrorConstructor= (
7057
7059
  '');
7058
7060
 
7059
7061
 
7060
- // Mapping from error instance to the structured stack trace capturing the
7061
- // stack for that instance.
7062
- const ssts= new WeakMap();
7062
+ /**
7063
+ * @typedef {object} StructuredStackInfo
7064
+ * @property {CallSite[]} callSites
7065
+ * @property {undefined} [stackString]
7066
+ */
7067
+
7068
+ /**
7069
+ * @typedef {object} ParsedStackInfo
7070
+ * @property {undefined} [callSites]
7071
+ * @property {string} stackString
7072
+ */
7073
+
7074
+ // Mapping from error instance to the stack for that instance.
7075
+ // The stack info is either the structured stack trace
7076
+ // or the generated tamed stack string
7077
+ /** @type {WeakMap<Error, ParsedStackInfo | StructuredStackInfo} */
7078
+ const stackInfos= new WeakMap();
7063
7079
 
7064
7080
  // Use concise methods to obtain named functions without constructors.
7065
7081
  const tamedMethods= {
@@ -7081,23 +7097,41 @@ const tameV8ErrorConstructor= (
7081
7097
  // string associated with an error.
7082
7098
  // See https://tc39.es/proposal-error-stacks/
7083
7099
  getStackString(error) {
7084
- if( !weakmapHas(ssts, error)) {
7100
+ let stackInfo= weakmapGet(stackInfos, error);
7101
+
7102
+ if( stackInfo=== undefined) {
7103
+ // The following will call `prepareStackTrace()` synchronously
7104
+ // which will populate stackInfos
7085
7105
  // eslint-disable-next-line no-void
7086
7106
  void error.stack;
7107
+ stackInfo= weakmapGet(stackInfos, error);
7108
+ if( !stackInfo) {
7109
+ stackInfo= { stackString: ''};
7110
+ weakmapSet(stackInfos, error, stackInfo);
7111
+ }
7087
7112
  }
7088
- const sst= weakmapGet(ssts, error);
7089
- if( !sst) {
7090
- return '';
7113
+
7114
+ // prepareStackTrace() may generate the stackString
7115
+ // if errorTaming === 'unsafe'
7116
+
7117
+ if( stackInfo.stackString!== undefined) {
7118
+ return stackInfo.stackString;
7091
7119
  }
7092
- return stackStringFromSST(error, sst);
7120
+
7121
+ const stackString= stackStringFromSST(error, stackInfo.callSites);
7122
+ weakmapSet(stackInfos, error, { stackString});
7123
+
7124
+ return stackString;
7093
7125
  },
7094
7126
  prepareStackTrace(error, sst) {
7095
- weakmapSet(ssts, error, sst);
7096
7127
  if( errorTaming=== 'unsafe') {
7097
7128
  const stackString= stackStringFromSST(error, sst);
7129
+ weakmapSet(stackInfos, error, { stackString});
7098
7130
  return `${error}${stackString}`;
7131
+ }else {
7132
+ weakmapSet(stackInfos, error, { callSites: sst});
7133
+ return '';
7099
7134
  }
7100
- return '';
7101
7135
  }};
7102
7136
 
7103
7137
 
@@ -7132,7 +7166,7 @@ const tameV8ErrorConstructor= (
7132
7166
  // Use concise methods to obtain named functions without constructors.
7133
7167
  const systemMethods= {
7134
7168
  prepareStackTrace(error, sst) {
7135
- weakmapSet(ssts, error, sst);
7169
+ weakmapSet(stackInfos, error, { callSites: sst});
7136
7170
  return inputPrepareFn(error, safeV8SST(sst));
7137
7171
  }};
7138
7172
 
@@ -7980,7 +8014,7 @@ function tameFunctionConstructors() {
7980
8014
  FERAL_FUNCTION.prototype.constructor('return 1');
7981
8015
  }catch( ignore) {
7982
8016
  // Throws, no need to patch.
7983
- return {};
8017
+ return harden({});
7984
8018
  }
7985
8019
 
7986
8020
  const newIntrinsics= {};
@@ -8785,10 +8819,6 @@ const repairIntrinsics= (options= {})=> {
8785
8819
  /** @param {string} debugName */
8786
8820
  (debugName)=>debugName!== ''),
8787
8821
 
8788
- __allowUnsafeMonkeyPatching__= getenv(
8789
- '__LOCKDOWN_ALLOW_UNSAFE_MONKEY_PATCHING__',
8790
- 'safe'),
8791
-
8792
8822
  dateTaming= 'safe', // deprecated
8793
8823
  mathTaming= 'safe', // deprecated
8794
8824
  ...extraOptions}=
@@ -8995,11 +9025,9 @@ const repairIntrinsics= (options= {})=> {
8995
9025
  // @ts-ignore enablePropertyOverrides does its own input validation
8996
9026
  enablePropertyOverrides(intrinsics, overrideTaming, overrideDebug);
8997
9027
 
8998
- if( __allowUnsafeMonkeyPatching__!== 'unsafe') {
8999
- // Finally register and optionally freeze all the intrinsics. This
9000
- // must be the operation that modifies the intrinsics.
9001
- harden(intrinsics);
9002
- }
9028
+ // Finally register and optionally freeze all the intrinsics. This
9029
+ // must be the operation that modifies the intrinsics.
9030
+ harden(intrinsics);
9003
9031
 
9004
9032
  // Reveal harden after lockdown.
9005
9033
  // Harden is dangerous before lockdown because hardening just
package/dist/lockdown.mjs CHANGED
@@ -6083,7 +6083,7 @@ function enablePropertyOverrides(
6083
6083
  })
6084
6084
  ,
6085
6085
  // === functors[24] ===
6086
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,arraySlice,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6086
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6087
6087
 
6088
6088
 
6089
6089
 
@@ -6201,11 +6201,11 @@ const makeEnvironmentCaptor= (aGlobal)=>{
6201
6201
  freeze(getEnvironmentOption);
6202
6202
 
6203
6203
  const getCapturedEnvironmentOptionNames= ()=> {
6204
- return freeze(arraySlice(capturedEnvironmentOptionNames));
6204
+ return freeze([...capturedEnvironmentOptionNames]);
6205
6205
  };
6206
6206
  freeze(getCapturedEnvironmentOptionNames);
6207
6207
 
6208
- return { getEnvironmentOption, getCapturedEnvironmentOptionNames};
6208
+ return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames});
6209
6209
  };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
6210
6210
  freeze(makeEnvironmentCaptor);
6211
6211
  })
@@ -6865,8 +6865,7 @@ const tameConsole= (
6865
6865
  })
6866
6866
  ,
6867
6867
  // === functors[28] ===
6868
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapHas,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6869
-
6868
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6870
6869
 
6871
6870
 
6872
6871
 
@@ -7032,6 +7031,9 @@ const tameV8ErrorConstructor= (
7032
7031
  errorTaming,
7033
7032
  stackFiltering)=>
7034
7033
  {
7034
+ // TODO: Proper CallSite types
7035
+ /** @typedef {{}} CallSite */
7036
+
7035
7037
  const originalCaptureStackTrace= OriginalError.captureStackTrace;
7036
7038
 
7037
7039
  // const callSiteFilter = _callSite => true;
@@ -7057,9 +7059,23 @@ const tameV8ErrorConstructor= (
7057
7059
  '');
7058
7060
 
7059
7061
 
7060
- // Mapping from error instance to the structured stack trace capturing the
7061
- // stack for that instance.
7062
- const ssts= new WeakMap();
7062
+ /**
7063
+ * @typedef {object} StructuredStackInfo
7064
+ * @property {CallSite[]} callSites
7065
+ * @property {undefined} [stackString]
7066
+ */
7067
+
7068
+ /**
7069
+ * @typedef {object} ParsedStackInfo
7070
+ * @property {undefined} [callSites]
7071
+ * @property {string} stackString
7072
+ */
7073
+
7074
+ // Mapping from error instance to the stack for that instance.
7075
+ // The stack info is either the structured stack trace
7076
+ // or the generated tamed stack string
7077
+ /** @type {WeakMap<Error, ParsedStackInfo | StructuredStackInfo} */
7078
+ const stackInfos= new WeakMap();
7063
7079
 
7064
7080
  // Use concise methods to obtain named functions without constructors.
7065
7081
  const tamedMethods= {
@@ -7081,23 +7097,41 @@ const tameV8ErrorConstructor= (
7081
7097
  // string associated with an error.
7082
7098
  // See https://tc39.es/proposal-error-stacks/
7083
7099
  getStackString(error) {
7084
- if( !weakmapHas(ssts, error)) {
7100
+ let stackInfo= weakmapGet(stackInfos, error);
7101
+
7102
+ if( stackInfo=== undefined) {
7103
+ // The following will call `prepareStackTrace()` synchronously
7104
+ // which will populate stackInfos
7085
7105
  // eslint-disable-next-line no-void
7086
7106
  void error.stack;
7107
+ stackInfo= weakmapGet(stackInfos, error);
7108
+ if( !stackInfo) {
7109
+ stackInfo= { stackString: ''};
7110
+ weakmapSet(stackInfos, error, stackInfo);
7111
+ }
7087
7112
  }
7088
- const sst= weakmapGet(ssts, error);
7089
- if( !sst) {
7090
- return '';
7113
+
7114
+ // prepareStackTrace() may generate the stackString
7115
+ // if errorTaming === 'unsafe'
7116
+
7117
+ if( stackInfo.stackString!== undefined) {
7118
+ return stackInfo.stackString;
7091
7119
  }
7092
- return stackStringFromSST(error, sst);
7120
+
7121
+ const stackString= stackStringFromSST(error, stackInfo.callSites);
7122
+ weakmapSet(stackInfos, error, { stackString});
7123
+
7124
+ return stackString;
7093
7125
  },
7094
7126
  prepareStackTrace(error, sst) {
7095
- weakmapSet(ssts, error, sst);
7096
7127
  if( errorTaming=== 'unsafe') {
7097
7128
  const stackString= stackStringFromSST(error, sst);
7129
+ weakmapSet(stackInfos, error, { stackString});
7098
7130
  return `${error}${stackString}`;
7131
+ }else {
7132
+ weakmapSet(stackInfos, error, { callSites: sst});
7133
+ return '';
7099
7134
  }
7100
- return '';
7101
7135
  }};
7102
7136
 
7103
7137
 
@@ -7132,7 +7166,7 @@ const tameV8ErrorConstructor= (
7132
7166
  // Use concise methods to obtain named functions without constructors.
7133
7167
  const systemMethods= {
7134
7168
  prepareStackTrace(error, sst) {
7135
- weakmapSet(ssts, error, sst);
7169
+ weakmapSet(stackInfos, error, { callSites: sst});
7136
7170
  return inputPrepareFn(error, safeV8SST(sst));
7137
7171
  }};
7138
7172
 
@@ -7980,7 +8014,7 @@ function tameFunctionConstructors() {
7980
8014
  FERAL_FUNCTION.prototype.constructor('return 1');
7981
8015
  }catch( ignore) {
7982
8016
  // Throws, no need to patch.
7983
- return {};
8017
+ return harden({});
7984
8018
  }
7985
8019
 
7986
8020
  const newIntrinsics= {};
@@ -8785,10 +8819,6 @@ const repairIntrinsics= (options= {})=> {
8785
8819
  /** @param {string} debugName */
8786
8820
  (debugName)=>debugName!== ''),
8787
8821
 
8788
- __allowUnsafeMonkeyPatching__= getenv(
8789
- '__LOCKDOWN_ALLOW_UNSAFE_MONKEY_PATCHING__',
8790
- 'safe'),
8791
-
8792
8822
  dateTaming= 'safe', // deprecated
8793
8823
  mathTaming= 'safe', // deprecated
8794
8824
  ...extraOptions}=
@@ -8995,11 +9025,9 @@ const repairIntrinsics= (options= {})=> {
8995
9025
  // @ts-ignore enablePropertyOverrides does its own input validation
8996
9026
  enablePropertyOverrides(intrinsics, overrideTaming, overrideDebug);
8997
9027
 
8998
- if( __allowUnsafeMonkeyPatching__!== 'unsafe') {
8999
- // Finally register and optionally freeze all the intrinsics. This
9000
- // must be the operation that modifies the intrinsics.
9001
- harden(intrinsics);
9002
- }
9028
+ // Finally register and optionally freeze all the intrinsics. This
9029
+ // must be the operation that modifies the intrinsics.
9030
+ harden(intrinsics);
9003
9031
 
9004
9032
  // Reveal harden after lockdown.
9005
9033
  // Harden is dangerous before lockdown because hardening just
@@ -6083,7 +6083,7 @@ function enablePropertyOverrides(
6083
6083
  })
6084
6084
  ,
6085
6085
  // === functors[24] ===
6086
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,arraySlice,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6086
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let arrayPush,freeze,assert;$h‍_imports([["./commons.js", [["arrayPush", [$h‍_a => (arrayPush = $h‍_a)]],["freeze", [$h‍_a => (freeze = $h‍_a)]]]],["./error/assert.js", [["assert", [$h‍_a => (assert = $h‍_a)]]]]]);
6087
6087
 
6088
6088
 
6089
6089
 
@@ -6201,11 +6201,11 @@ const makeEnvironmentCaptor= (aGlobal)=>{
6201
6201
  freeze(getEnvironmentOption);
6202
6202
 
6203
6203
  const getCapturedEnvironmentOptionNames= ()=> {
6204
- return freeze(arraySlice(capturedEnvironmentOptionNames));
6204
+ return freeze([...capturedEnvironmentOptionNames]);
6205
6205
  };
6206
6206
  freeze(getCapturedEnvironmentOptionNames);
6207
6207
 
6208
- return { getEnvironmentOption, getCapturedEnvironmentOptionNames};
6208
+ return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames});
6209
6209
  };$h‍_once.makeEnvironmentCaptor(makeEnvironmentCaptor);
6210
6210
  freeze(makeEnvironmentCaptor);
6211
6211
  })
@@ -6865,8 +6865,7 @@ const tameConsole= (
6865
6865
  })
6866
6866
  ,
6867
6867
  // === functors[28] ===
6868
- (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapHas,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapHas", [$h‍_a => (weakmapHas = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6869
-
6868
+ (({ imports: $h‍_imports, liveVar: $h‍_live, onceVar: $h‍_once, importMeta: $h‍____meta, }) => { let WeakMap,WeakSet,apply,arrayFilter,arrayJoin,arrayMap,arraySlice,create,defineProperties,fromEntries,reflectSet,regexpExec,regexpTest,weakmapGet,weakmapSet,weaksetAdd,weaksetHas;$h‍_imports([["../commons.js", [["WeakMap", [$h‍_a => (WeakMap = $h‍_a)]],["WeakSet", [$h‍_a => (WeakSet = $h‍_a)]],["apply", [$h‍_a => (apply = $h‍_a)]],["arrayFilter", [$h‍_a => (arrayFilter = $h‍_a)]],["arrayJoin", [$h‍_a => (arrayJoin = $h‍_a)]],["arrayMap", [$h‍_a => (arrayMap = $h‍_a)]],["arraySlice", [$h‍_a => (arraySlice = $h‍_a)]],["create", [$h‍_a => (create = $h‍_a)]],["defineProperties", [$h‍_a => (defineProperties = $h‍_a)]],["fromEntries", [$h‍_a => (fromEntries = $h‍_a)]],["reflectSet", [$h‍_a => (reflectSet = $h‍_a)]],["regexpExec", [$h‍_a => (regexpExec = $h‍_a)]],["regexpTest", [$h‍_a => (regexpTest = $h‍_a)]],["weakmapGet", [$h‍_a => (weakmapGet = $h‍_a)]],["weakmapSet", [$h‍_a => (weakmapSet = $h‍_a)]],["weaksetAdd", [$h‍_a => (weaksetAdd = $h‍_a)]],["weaksetHas", [$h‍_a => (weaksetHas = $h‍_a)]]]]]);
6870
6869
 
6871
6870
 
6872
6871
 
@@ -7032,6 +7031,9 @@ const tameV8ErrorConstructor= (
7032
7031
  errorTaming,
7033
7032
  stackFiltering)=>
7034
7033
  {
7034
+ // TODO: Proper CallSite types
7035
+ /** @typedef {{}} CallSite */
7036
+
7035
7037
  const originalCaptureStackTrace= OriginalError.captureStackTrace;
7036
7038
 
7037
7039
  // const callSiteFilter = _callSite => true;
@@ -7057,9 +7059,23 @@ const tameV8ErrorConstructor= (
7057
7059
  '');
7058
7060
 
7059
7061
 
7060
- // Mapping from error instance to the structured stack trace capturing the
7061
- // stack for that instance.
7062
- const ssts= new WeakMap();
7062
+ /**
7063
+ * @typedef {object} StructuredStackInfo
7064
+ * @property {CallSite[]} callSites
7065
+ * @property {undefined} [stackString]
7066
+ */
7067
+
7068
+ /**
7069
+ * @typedef {object} ParsedStackInfo
7070
+ * @property {undefined} [callSites]
7071
+ * @property {string} stackString
7072
+ */
7073
+
7074
+ // Mapping from error instance to the stack for that instance.
7075
+ // The stack info is either the structured stack trace
7076
+ // or the generated tamed stack string
7077
+ /** @type {WeakMap<Error, ParsedStackInfo | StructuredStackInfo} */
7078
+ const stackInfos= new WeakMap();
7063
7079
 
7064
7080
  // Use concise methods to obtain named functions without constructors.
7065
7081
  const tamedMethods= {
@@ -7081,23 +7097,41 @@ const tameV8ErrorConstructor= (
7081
7097
  // string associated with an error.
7082
7098
  // See https://tc39.es/proposal-error-stacks/
7083
7099
  getStackString(error) {
7084
- if( !weakmapHas(ssts, error)) {
7100
+ let stackInfo= weakmapGet(stackInfos, error);
7101
+
7102
+ if( stackInfo=== undefined) {
7103
+ // The following will call `prepareStackTrace()` synchronously
7104
+ // which will populate stackInfos
7085
7105
  // eslint-disable-next-line no-void
7086
7106
  void error.stack;
7107
+ stackInfo= weakmapGet(stackInfos, error);
7108
+ if( !stackInfo) {
7109
+ stackInfo= { stackString: ''};
7110
+ weakmapSet(stackInfos, error, stackInfo);
7111
+ }
7087
7112
  }
7088
- const sst= weakmapGet(ssts, error);
7089
- if( !sst) {
7090
- return '';
7113
+
7114
+ // prepareStackTrace() may generate the stackString
7115
+ // if errorTaming === 'unsafe'
7116
+
7117
+ if( stackInfo.stackString!== undefined) {
7118
+ return stackInfo.stackString;
7091
7119
  }
7092
- return stackStringFromSST(error, sst);
7120
+
7121
+ const stackString= stackStringFromSST(error, stackInfo.callSites);
7122
+ weakmapSet(stackInfos, error, { stackString});
7123
+
7124
+ return stackString;
7093
7125
  },
7094
7126
  prepareStackTrace(error, sst) {
7095
- weakmapSet(ssts, error, sst);
7096
7127
  if( errorTaming=== 'unsafe') {
7097
7128
  const stackString= stackStringFromSST(error, sst);
7129
+ weakmapSet(stackInfos, error, { stackString});
7098
7130
  return `${error}${stackString}`;
7131
+ }else {
7132
+ weakmapSet(stackInfos, error, { callSites: sst});
7133
+ return '';
7099
7134
  }
7100
- return '';
7101
7135
  }};
7102
7136
 
7103
7137
 
@@ -7132,7 +7166,7 @@ const tameV8ErrorConstructor= (
7132
7166
  // Use concise methods to obtain named functions without constructors.
7133
7167
  const systemMethods= {
7134
7168
  prepareStackTrace(error, sst) {
7135
- weakmapSet(ssts, error, sst);
7169
+ weakmapSet(stackInfos, error, { callSites: sst});
7136
7170
  return inputPrepareFn(error, safeV8SST(sst));
7137
7171
  }};
7138
7172
 
@@ -7980,7 +8014,7 @@ function tameFunctionConstructors() {
7980
8014
  FERAL_FUNCTION.prototype.constructor('return 1');
7981
8015
  }catch( ignore) {
7982
8016
  // Throws, no need to patch.
7983
- return {};
8017
+ return harden({});
7984
8018
  }
7985
8019
 
7986
8020
  const newIntrinsics= {};
@@ -8785,10 +8819,6 @@ const repairIntrinsics= (options= {})=> {
8785
8819
  /** @param {string} debugName */
8786
8820
  (debugName)=>debugName!== ''),
8787
8821
 
8788
- __allowUnsafeMonkeyPatching__= getenv(
8789
- '__LOCKDOWN_ALLOW_UNSAFE_MONKEY_PATCHING__',
8790
- 'safe'),
8791
-
8792
8822
  dateTaming= 'safe', // deprecated
8793
8823
  mathTaming= 'safe', // deprecated
8794
8824
  ...extraOptions}=
@@ -8995,11 +9025,9 @@ const repairIntrinsics= (options= {})=> {
8995
9025
  // @ts-ignore enablePropertyOverrides does its own input validation
8996
9026
  enablePropertyOverrides(intrinsics, overrideTaming, overrideDebug);
8997
9027
 
8998
- if( __allowUnsafeMonkeyPatching__!== 'unsafe') {
8999
- // Finally register and optionally freeze all the intrinsics. This
9000
- // must be the operation that modifies the intrinsics.
9001
- harden(intrinsics);
9002
- }
9028
+ // Finally register and optionally freeze all the intrinsics. This
9029
+ // must be the operation that modifies the intrinsics.
9030
+ harden(intrinsics);
9003
9031
 
9004
9032
  // Reveal harden after lockdown.
9005
9033
  // Harden is dangerous before lockdown because hardening just