ses 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/lockdown.js CHANGED
@@ -183,7 +183,7 @@ export const repairIntrinsics = (options = {}) => {
183
183
  ),
184
184
  stackFiltering = getenv('LOCKDOWN_STACK_FILTERING', 'concise'),
185
185
  domainTaming = getenv('LOCKDOWN_DOMAIN_TAMING', 'safe'),
186
- evalTaming = getenv('LOCKDOWN_EVAL_TAMING', 'safeEval'),
186
+ evalTaming = getenv('LOCKDOWN_EVAL_TAMING', 'safe-eval'),
187
187
  overrideDebug = arrayFilter(
188
188
  stringSplit(getenv('LOCKDOWN_OVERRIDE_DEBUG', ''), ','),
189
189
  /** @param {string} debugName */
@@ -194,8 +194,8 @@ export const repairIntrinsics = (options = {}) => {
194
194
  'safe',
195
195
  ),
196
196
  __hardenTaming__ = getenv('LOCKDOWN_HARDEN_TAMING', 'safe'),
197
- dateTaming = 'safe', // deprecated
198
- mathTaming = 'safe', // deprecated
197
+ dateTaming, // deprecated
198
+ mathTaming, // deprecated
199
199
  ...extraOptions
200
200
  } = options;
201
201
 
@@ -203,9 +203,12 @@ export const repairIntrinsics = (options = {}) => {
203
203
  legacyRegeneratorRuntimeTaming === 'unsafe-ignore' ||
204
204
  Fail`lockdown(): non supported option legacyRegeneratorRuntimeTaming: ${q(legacyRegeneratorRuntimeTaming)}`;
205
205
 
206
- evalTaming === 'unsafeEval' ||
207
- evalTaming === 'safeEval' ||
208
- evalTaming === 'noEval' ||
206
+ evalTaming === 'unsafe-eval' ||
207
+ evalTaming === 'unsafeEval' || // deprecated
208
+ evalTaming === 'safe-eval' ||
209
+ evalTaming === 'safeEval' || // deprecated
210
+ evalTaming === 'no-eval' ||
211
+ evalTaming === 'noEval' || // deprecated
209
212
  Fail`lockdown(): non supported option evalTaming: ${q(evalTaming)}`;
210
213
 
211
214
  // Assert that only supported options were passed.
@@ -215,6 +218,20 @@ export const repairIntrinsics = (options = {}) => {
215
218
  Fail`lockdown(): non supported option ${q(extraOptionsNames)}`;
216
219
 
217
220
  const reporter = chooseReporter(reporting);
221
+ const { warn } = reporter;
222
+
223
+ if (dateTaming !== undefined) {
224
+ // eslint-disable-next-line no-console
225
+ warn(
226
+ `SES The 'dateTaming' option is deprecated and does nothing. In the future specifying it will be an error.`,
227
+ );
228
+ }
229
+ if (mathTaming !== undefined) {
230
+ // eslint-disable-next-line no-console
231
+ warn(
232
+ `SES The 'mathTaming' option is deprecated and does nothing. In the future specifying it will be an error.`,
233
+ );
234
+ }
218
235
 
219
236
  priorRepairIntrinsics === undefined ||
220
237
  // eslint-disable-next-line @endo/no-polymorphic-call
@@ -289,9 +306,9 @@ export const repairIntrinsics = (options = {}) => {
289
306
 
290
307
  addIntrinsics(tameFunctionConstructors());
291
308
 
292
- addIntrinsics(tameDateConstructor(dateTaming));
309
+ addIntrinsics(tameDateConstructor());
293
310
  addIntrinsics(tameErrorConstructor(errorTaming, stackFiltering));
294
- addIntrinsics(tameMathObject(mathTaming));
311
+ addIntrinsics(tameMathObject());
295
312
  addIntrinsics(tameRegExpConstructor(regExpTaming));
296
313
  addIntrinsics(tameSymbolConstructor());
297
314
  addIntrinsics(shimArrayBufferTransfer());
@@ -394,23 +411,36 @@ export const repairIntrinsics = (options = {}) => {
394
411
  markVirtualizedNativeFunction,
395
412
  });
396
413
 
397
- if (evalTaming === 'noEval') {
414
+ if (
415
+ evalTaming === 'no-eval' ||
416
+ // deprecated
417
+ evalTaming === 'noEval'
418
+ ) {
398
419
  setGlobalObjectEvaluators(
399
420
  globalThis,
400
421
  noEvalEvaluate,
401
422
  markVirtualizedNativeFunction,
402
423
  );
403
- } else if (evalTaming === 'safeEval') {
424
+ } else if (
425
+ evalTaming === 'safe-eval' ||
426
+ // deprecated
427
+ evalTaming === 'safeEval'
428
+ ) {
404
429
  const { safeEvaluate } = makeSafeEvaluator({ globalObject: globalThis });
405
430
  setGlobalObjectEvaluators(
406
431
  globalThis,
407
432
  safeEvaluate,
408
433
  markVirtualizedNativeFunction,
409
434
  );
410
- } else if (evalTaming === 'unsafeEval') {
411
- // Leave eval function and Function constructor of the initial compartment in-tact.
412
- // Other compartments will not have access to these evaluators unless a guest program
413
- // escapes containment.
435
+ } else if (
436
+ evalTaming === 'unsafe-eval' ||
437
+ // deprecated
438
+ evalTaming === 'unsafeEval'
439
+ ) {
440
+ // Leave eval function and Function constructor of the initial
441
+ // compartment intact.
442
+ // Other compartments will not have access to these evaluators unless a
443
+ // guest program escapes containment.
414
444
  }
415
445
 
416
446
  /**
@@ -1,7 +1,7 @@
1
1
  // Portions adapted from V8 - Copyright 2016 the V8 project authors.
2
2
  // https://github.com/v8/v8/blob/master/src/builtins/builtins-function.cc
3
3
 
4
- import { apply, freeze } from './commons.js';
4
+ import { apply, arrayFlatMap, freeze, identity } from './commons.js';
5
5
  import { strictScopeTerminator } from './strict-scope-terminator.js';
6
6
  import { createSloppyGlobalsScopeTerminator } from './sloppy-globals-scope-terminator.js';
7
7
  import { makeEvalScopeKit } from './eval-scope.js';
@@ -62,11 +62,13 @@ export const makeSafeEvaluator = ({
62
62
 
63
63
  // Execute the mandatory transforms last to ensure that any rewritten code
64
64
  // meets those mandatory requirements.
65
- source = applyTransforms(source, [
66
- ...localTransforms,
67
- ...globalTransforms,
68
- mandatoryTransforms,
69
- ]);
65
+ source = applyTransforms(
66
+ source,
67
+ arrayFlatMap(
68
+ [localTransforms, globalTransforms, [mandatoryTransforms]],
69
+ identity,
70
+ ),
71
+ );
70
72
 
71
73
  let err;
72
74
  try {
@@ -1,3 +1,5 @@
1
+ /** @import {ModuleExportsNamespace} from '../types.js' */
2
+
1
3
  import { assert } from './error/assert.js';
2
4
  import { getDeferredExports } from './module-proxy.js';
3
5
  import {
@@ -131,13 +133,15 @@ export const makeModuleInstance = (
131
133
  __fixedExportMap__: fixedExportMap = {},
132
134
  __liveExportMap__: liveExportMap = {},
133
135
  __reexportMap__: reexportMap = {},
136
+ __needsImport__: needsImport = false,
134
137
  __needsImportMeta__: needsImportMeta = false,
135
138
  __syncModuleFunctor__,
136
139
  } = moduleSource;
137
140
 
138
141
  const compartmentFields = weakmapGet(privateFields, compartment);
139
142
 
140
- const { __shimTransforms__, importMetaHook } = compartmentFields;
143
+ const { __shimTransforms__, resolveHook, importMetaHook, compartmentImport } =
144
+ compartmentFields;
141
145
 
142
146
  const { exportsProxy, exportsTarget, activate } = getDeferredExports(
143
147
  compartment,
@@ -171,6 +175,14 @@ export const makeModuleInstance = (
171
175
  importMetaHook(moduleSpecifier, importMeta);
172
176
  }
173
177
 
178
+ /** @type {(fullSpecifier: string) => Promise<ModuleExportsNamespace>} */
179
+ let dynamicImport;
180
+ if (needsImport) {
181
+ /** @param {string} importSpecifier */
182
+ dynamicImport = async importSpecifier =>
183
+ compartmentImport(resolveHook(importSpecifier, moduleSpecifier));
184
+ }
185
+
174
186
  // {_localName_: [{get, set, notify}]} used to merge all the export updaters.
175
187
  const localGetNotify = create(null);
176
188
 
@@ -462,6 +474,7 @@ export const makeModuleInstance = (
462
474
  imports: freeze(imports),
463
475
  onceVar: freeze(onceVar),
464
476
  liveVar: freeze(liveVar),
477
+ import: dynamicImport,
465
478
  importMeta,
466
479
  }),
467
480
  );
package/src/permits.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-restricted-globals */
2
2
  /* eslint max-lines: 0 */
3
3
 
4
- import { arrayPush } from './commons.js';
4
+ import { arrayPush, arrayForEach } from './commons.js';
5
5
 
6
6
  /** @import {GenericErrorConstructor} from '../types.js' */
7
7
 
@@ -89,6 +89,15 @@ export const universalPropertyNames = {
89
89
  // https://github.com/endojs/endo/issues/550
90
90
  AggregateError: 'AggregateError',
91
91
 
92
+ // https://github.com/tc39/proposal-explicit-resource-management
93
+ // TODO DisposableStack, AsyncDisposableStack
94
+ // DisposableStack: 'DisposableStack',
95
+ // AsyncDisposableStack: 'AsyncDisposableStack',
96
+
97
+ // https://tc39.es/proposal-shadowrealm/
98
+ // TODO ShadowRealm
99
+ // ShadowRealm: 'ShadowRealm',
100
+
92
101
  // *** Other Properties of the Global Object
93
102
 
94
103
  JSON: 'JSON',
@@ -143,6 +152,10 @@ export const initialGlobalPropertyNames = {
143
152
  // TODO https://github.com/Agoric/SES-shim/issues/551
144
153
  // Need initial WeakRef and FinalizationGroup in
145
154
  // start compartment only.
155
+
156
+ // TODO Temporal
157
+ // https://github.com/tc39/proposal-temporal
158
+ // Temporal: '%InitialTemporal%' // with Temporal.Now
146
159
  };
147
160
 
148
161
  /**
@@ -162,6 +175,10 @@ export const sharedGlobalPropertyNames = {
162
175
  // *** Other Properties of the Global Object
163
176
 
164
177
  Math: '%SharedMath%',
178
+
179
+ // TODO Temporal
180
+ // https://github.com/tc39/proposal-temporal
181
+ // Temporal: '%SharedTemporal%' // without Temporal.Now
165
182
  };
166
183
 
167
184
  /**
@@ -299,6 +316,24 @@ const accessor = {
299
316
  set: fn,
300
317
  };
301
318
 
319
+ // eslint-disable-next-line func-names
320
+ const strict = function () {
321
+ 'use strict';
322
+ };
323
+
324
+ // TODO Remove this once we no longer support the Hermes that needed this.
325
+ arrayForEach(['caller', 'arguments'], prop => {
326
+ try {
327
+ strict[prop];
328
+ } catch (e) {
329
+ // https://github.com/facebook/hermes/blob/main/test/hermes/function-non-strict.js
330
+ if (e.message === 'Restricted in strict mode') {
331
+ // Fixed in Static Hermes: https://github.com/facebook/hermes/issues/1582
332
+ FunctionInstance[prop] = accessor;
333
+ }
334
+ }
335
+ });
336
+
302
337
  export const isAccessorPermit = permit => {
303
338
  return permit === getter || permit === accessor;
304
339
  };
@@ -393,6 +428,11 @@ const CommonMath = {
393
428
  tan: fn,
394
429
  tanh: fn,
395
430
  trunc: fn,
431
+ // https://github.com/tc39/proposal-float16array
432
+ f16round: fn,
433
+ // https://github.com/tc39/proposal-math-sum
434
+ sumPrecise: fn,
435
+
396
436
  // See https://github.com/Moddable-OpenSource/moddable/issues/523
397
437
  idiv: false,
398
438
  // See https://github.com/Moddable-OpenSource/moddable/issues/523
@@ -455,7 +495,6 @@ export const permitted = {
455
495
  getOwnPropertyNames: fn,
456
496
  getOwnPropertySymbols: fn,
457
497
  getPrototypeOf: fn,
458
- hasOwn: fn,
459
498
  is: fn,
460
499
  isExtensible: fn,
461
500
  isFrozen: fn,
@@ -466,6 +505,8 @@ export const permitted = {
466
505
  seal: fn,
467
506
  setPrototypeOf: fn,
468
507
  values: fn,
508
+ // https://github.com/tc39/proposal-accessible-object-hasownproperty
509
+ hasOwn: fn,
469
510
  // https://github.com/tc39/proposal-array-grouping
470
511
  groupBy: fn,
471
512
  // Seen on QuickJS
@@ -537,9 +578,7 @@ export const permitted = {
537
578
  '%SharedSymbol%': {
538
579
  // Properties of the Symbol Constructor
539
580
  '[[Proto]]': '%FunctionPrototype%',
540
- asyncDispose: 'symbol',
541
581
  asyncIterator: 'symbol',
542
- dispose: 'symbol',
543
582
  for: fn,
544
583
  hasInstance: 'symbol',
545
584
  isConcatSpreadable: 'symbol',
@@ -555,6 +594,10 @@ export const permitted = {
555
594
  toPrimitive: 'symbol',
556
595
  toStringTag: 'symbol',
557
596
  unscopables: 'symbol',
597
+ // https://github.com/tc39/proposal-explicit-resource-management
598
+ asyncDispose: 'symbol',
599
+ // https://github.com/tc39/proposal-explicit-resource-management
600
+ dispose: 'symbol',
558
601
  // Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
559
602
  useSimple: false,
560
603
  // Seen at core-js https://github.com/zloirock/core-js#ecmascript-symbol
@@ -583,6 +626,8 @@ export const permitted = {
583
626
  stackTraceLimit: accessor,
584
627
  // Non standard, v8 only, used by several, tamed to accessor
585
628
  prepareStackTrace: accessor,
629
+ // https://github.com/tc39/proposal-is-error
630
+ isError: fn,
586
631
  },
587
632
 
588
633
  '%SharedError%': {
@@ -595,6 +640,8 @@ export const permitted = {
595
640
  stackTraceLimit: accessor,
596
641
  // Non standard, v8 only, used by several, tamed to accessor
597
642
  prepareStackTrace: accessor,
643
+ // https://github.com/tc39/proposal-is-error
644
+ isError: fn,
598
645
  },
599
646
 
600
647
  '%ErrorPrototype%': {
@@ -623,6 +670,10 @@ export const permitted = {
623
670
  // https://github.com/endojs/endo/issues/550
624
671
  AggregateError: NativeError('%AggregateErrorPrototype%'),
625
672
 
673
+ // TODO SuppressedError
674
+ // https://github.com/tc39/proposal-explicit-resource-management
675
+ // SuppressedError: NativeError('%SuppressedErrorPrototype%'),
676
+
626
677
  '%EvalErrorPrototype%': NativeErrorPrototype('EvalError'),
627
678
  '%RangeErrorPrototype%': NativeErrorPrototype('RangeError'),
628
679
  '%ReferenceErrorPrototype%': NativeErrorPrototype('ReferenceError'),
@@ -631,6 +682,13 @@ export const permitted = {
631
682
  '%URIErrorPrototype%': NativeErrorPrototype('URIError'),
632
683
  // https://github.com/endojs/endo/issues/550
633
684
  '%AggregateErrorPrototype%': NativeErrorPrototype('AggregateError'),
685
+ // TODO AggregateError .errors
686
+
687
+ // TODO SuppressedError
688
+ // https://github.com/tc39/proposal-explicit-resource-management
689
+ // '%SuppressedErrorPrototype%': NativeErrorPrototype('SuppressedError'),
690
+ // TODO SuppressedError .error
691
+ // TODO SuppressedError .suppressed
634
692
 
635
693
  // *** Numbers and Dates
636
694
 
@@ -809,7 +867,6 @@ export const permitted = {
809
867
  '%StringPrototype%': {
810
868
  // Properties of the String Prototype Object
811
869
  length: 'number',
812
- at: fn,
813
870
  charAt: fn,
814
871
  charCodeAt: fn,
815
872
  codePointAt: fn,
@@ -843,6 +900,13 @@ export const permitted = {
843
900
  trimStart: fn,
844
901
  valueOf: fn,
845
902
  '@@iterator': fn,
903
+ // Failed tc39 proposal
904
+ // https://github.com/tc39/proposal-relative-indexing-method
905
+ at: fn,
906
+ // https://github.com/tc39/proposal-is-usv-string
907
+ isWellFormed: fn,
908
+ toWellFormed: fn,
909
+ unicodeSets: fn,
846
910
 
847
911
  // Annex B: Additional Properties of the String.prototype Object
848
912
  substr: fn,
@@ -863,10 +927,6 @@ export const permitted = {
863
927
  trimRight: fn,
864
928
  // See https://github.com/Moddable-OpenSource/moddable/issues/523
865
929
  compare: false,
866
- // https://github.com/tc39/proposal-is-usv-string
867
- isWellFormed: fn,
868
- toWellFormed: fn,
869
- unicodeSets: fn,
870
930
  // Seen on QuickJS
871
931
  __quote: false,
872
932
  },
@@ -882,6 +942,8 @@ export const permitted = {
882
942
  '[[Proto]]': '%FunctionPrototype%',
883
943
  prototype: '%RegExpPrototype%',
884
944
  '@@species': getter,
945
+ // https://github.com/tc39/proposal-regex-escaping
946
+ escape: fn,
885
947
 
886
948
  // The https://github.com/tc39/proposal-regexp-legacy-features
887
949
  // are all optional, unsafe, and omitted
@@ -911,6 +973,8 @@ export const permitted = {
911
973
  '[[Proto]]': '%FunctionPrototype%',
912
974
  prototype: '%RegExpPrototype%',
913
975
  '@@species': getter,
976
+ // https://github.com/tc39/proposal-regex-escaping
977
+ escape: fn,
914
978
  },
915
979
 
916
980
  '%RegExpPrototype%': {
@@ -957,7 +1021,7 @@ export const permitted = {
957
1021
  prototype: '%ArrayPrototype%',
958
1022
  '@@species': getter,
959
1023
 
960
- // Stage 3:
1024
+ // Failed tc39 proposal
961
1025
  // https://tc39.es/proposal-relative-indexing-method/
962
1026
  at: fn,
963
1027
  // https://tc39.es/proposal-array-from-async/
@@ -966,7 +1030,6 @@ export const permitted = {
966
1030
 
967
1031
  '%ArrayPrototype%': {
968
1032
  // Properties of the Array Prototype Object
969
- at: fn,
970
1033
  length: 'number',
971
1034
  concat: fn,
972
1035
  constructor: 'Array',
@@ -1014,6 +1077,7 @@ export const permitted = {
1014
1077
  keys: 'boolean',
1015
1078
  values: 'boolean',
1016
1079
  // Failed tc39 proposal
1080
+ // https://tc39.es/proposal-relative-indexing-method/
1017
1081
  // Seen on FF Nightly 88.0a1
1018
1082
  at: 'boolean',
1019
1083
  // See https://github.com/tc39/proposal-array-find-from-last
@@ -1041,6 +1105,9 @@ export const permitted = {
1041
1105
  group: fn, // Not in proposal? Where?
1042
1106
  groupToMap: fn, // Not in proposal? Where?
1043
1107
  groupBy: fn,
1108
+ // Failed tc39 proposal
1109
+ // https://tc39.es/proposal-relative-indexing-method/
1110
+ at: fn,
1044
1111
  },
1045
1112
 
1046
1113
  '%ArrayIteratorPrototype%': {
@@ -1062,7 +1129,6 @@ export const permitted = {
1062
1129
  },
1063
1130
 
1064
1131
  '%TypedArrayPrototype%': {
1065
- at: fn,
1066
1132
  buffer: getter,
1067
1133
  byteLength: getter,
1068
1134
  byteOffset: getter,
@@ -1095,6 +1161,9 @@ export const permitted = {
1095
1161
  values: fn,
1096
1162
  '@@iterator': fn,
1097
1163
  '@@toStringTag': getter,
1164
+ // Failed tc39 proposal
1165
+ // https://tc39.es/proposal-relative-indexing-method/
1166
+ at: fn,
1098
1167
  // See https://github.com/tc39/proposal-array-find-from-last
1099
1168
  findLast: fn,
1100
1169
  findLastIndex: fn,
@@ -1352,6 +1421,11 @@ export const permitted = {
1352
1421
  '[[Proto]]': '%FunctionPrototype%',
1353
1422
  prototype: '%IteratorPrototype%',
1354
1423
  from: fn,
1424
+ // https://github.com/tc39/proposal-joint-iteration
1425
+ zip: fn,
1426
+ zipKeyed: fn,
1427
+ // https://github.com/tc39/proposal-iterator-sequencing
1428
+ concat: fn,
1355
1429
  },
1356
1430
 
1357
1431
  '%IteratorPrototype%': {
@@ -1373,6 +1447,7 @@ export const permitted = {
1373
1447
  '@@toStringTag': 'string',
1374
1448
  // https://github.com/tc39/proposal-async-iterator-helpers
1375
1449
  toAsync: fn,
1450
+ // https://github.com/tc39/proposal-explicit-resource-management
1376
1451
  // See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505
1377
1452
  '@@dispose': false,
1378
1453
  },
@@ -1417,6 +1492,7 @@ export const permitted = {
1417
1492
  every: fn,
1418
1493
  find: fn,
1419
1494
  '@@toStringTag': 'string',
1495
+ // https://github.com/tc39/proposal-explicit-resource-management
1420
1496
  // See https://github.com/Moddable-OpenSource/moddable/issues/523#issuecomment-1942904505
1421
1497
  '@@asyncDispose': false,
1422
1498
  },
@@ -1524,6 +1600,10 @@ export const permitted = {
1524
1600
  bindings: getter,
1525
1601
  needsImport: getter,
1526
1602
  needsImportMeta: getter,
1603
+ // @endo/module-source provides a legacy interface
1604
+ imports: getter,
1605
+ exports: getter,
1606
+ reexports: getter,
1527
1607
  },
1528
1608
 
1529
1609
  '%AbstractModuleSource%': {
@@ -6,8 +6,8 @@ export type Reporter = {
6
6
  };
7
7
 
8
8
  export type GroupReporter = Reporter & {
9
- groupCollapsed: (label: string) => void;
10
- groupEnd: () => void;
9
+ groupCollapsed?: (label: string) => void;
10
+ groupEnd?: () => void;
11
11
  };
12
12
 
13
13
  // Console implements GroupReporter
package/src/reporting.js CHANGED
@@ -80,18 +80,19 @@ export const chooseReporter = reporting => {
80
80
  */
81
81
  export const reportInGroup = (groupLabel, console, callback) => {
82
82
  const { warn, error, groupCollapsed, groupEnd } = console;
83
+ const grouping = groupCollapsed && groupEnd;
83
84
  let groupStarted = false;
84
85
  try {
85
86
  return callback({
86
87
  warn(...args) {
87
- if (!groupStarted) {
88
+ if (grouping && !groupStarted) {
88
89
  groupCollapsed(groupLabel);
89
90
  groupStarted = true;
90
91
  }
91
92
  warn(...args);
92
93
  },
93
94
  error(...args) {
94
- if (!groupStarted) {
95
+ if (grouping && !groupStarted) {
95
96
  groupCollapsed(groupLabel);
96
97
  groupStarted = true;
97
98
  }
@@ -99,8 +100,9 @@ export const reportInGroup = (groupLabel, console, callback) => {
99
100
  },
100
101
  });
101
102
  } finally {
102
- if (groupStarted) {
103
+ if (grouping && groupStarted) {
103
104
  groupEnd();
105
+ groupStarted = false;
104
106
  }
105
107
  }
106
108
  };
@@ -3,7 +3,6 @@ import {
3
3
  create,
4
4
  freeze,
5
5
  getOwnPropertyDescriptors,
6
- immutableObject,
7
6
  reflectSet,
8
7
  } from './commons.js';
9
8
  import {
@@ -11,6 +10,14 @@ import {
11
10
  alwaysThrowHandler,
12
11
  } from './strict-scope-terminator.js';
13
12
 
13
+ /**
14
+ * `freeze` but not `harden` the proxy target so it remains trapping.
15
+ * Thus, it should not be shared outside this module.
16
+ *
17
+ * @see https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md
18
+ */
19
+ const objTarget = freeze({ __proto__: null });
20
+
14
21
  /*
15
22
  * createSloppyGlobalsScopeTerminator()
16
23
  * strictScopeTerminatorHandler manages a scopeTerminator Proxy which serves as
@@ -45,7 +52,7 @@ export const createSloppyGlobalsScopeTerminator = globalObject => {
45
52
  );
46
53
 
47
54
  const sloppyGlobalsScopeTerminator = new Proxy(
48
- immutableObject,
55
+ objTarget,
49
56
  sloppyGlobalsScopeTerminatorHandler,
50
57
  );
51
58
 
@@ -6,13 +6,19 @@ import {
6
6
  create,
7
7
  freeze,
8
8
  getOwnPropertyDescriptors,
9
- globalThis,
10
- immutableObject,
11
9
  } from './commons.js';
12
10
  import { assert } from './error/assert.js';
13
11
 
14
12
  const { Fail, quote: q } = assert;
15
13
 
14
+ /**
15
+ * `freeze` but not `harden` the proxy target so it remains trapping.
16
+ * Thus, it should not be shared outside this module.
17
+ *
18
+ * @see https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md
19
+ */
20
+ const objTarget = freeze({ __proto__: null });
21
+
16
22
  /**
17
23
  * alwaysThrowHandler
18
24
  * This is an object that throws if any property is called. It's used as
@@ -21,7 +27,7 @@ const { Fail, quote: q } = assert;
21
27
  * create one and share it between all Proxy handlers.
22
28
  */
23
29
  export const alwaysThrowHandler = new Proxy(
24
- immutableObject,
30
+ objTarget,
25
31
  freeze({
26
32
  get(_shadow, prop) {
27
33
  Fail`Please report unexpected scope handler trap: ${q(String(prop))}`;
@@ -48,7 +54,7 @@ const scopeProxyHandlerProperties = {
48
54
 
49
55
  has(_shadow, prop) {
50
56
  // we must at least return true for all properties on the realm globalThis
51
- return prop in globalThis;
57
+ return true;
52
58
  },
53
59
 
54
60
  // note: this is likely a bug of safari
@@ -88,6 +94,6 @@ export const strictScopeTerminatorHandler = freeze(
88
94
  );
89
95
 
90
96
  export const strictScopeTerminator = new Proxy(
91
- immutableObject,
97
+ objTarget,
92
98
  strictScopeTerminatorHandler,
93
99
  );
@@ -8,10 +8,7 @@ import {
8
8
  defineProperties,
9
9
  } from './commons.js';
10
10
 
11
- export default function tameDateConstructor(dateTaming = 'safe') {
12
- if (dateTaming !== 'safe' && dateTaming !== 'unsafe') {
13
- throw TypeError(`unrecognized dateTaming ${dateTaming}`);
14
- }
11
+ export default function tameDateConstructor() {
15
12
  const OriginalDate = Date;
16
13
  const DatePrototype = OriginalDate.prototype;
17
14
 
@@ -6,6 +6,7 @@ import {
6
6
  getPrototypeOf,
7
7
  setPrototypeOf,
8
8
  freeze,
9
+ AsyncGeneratorFunctionInstance,
9
10
  } from './commons.js';
10
11
 
11
12
  // This module replaces the original `Function` constructor, and the original
@@ -126,11 +127,14 @@ export default function tameFunctionConstructors() {
126
127
  '%InertAsyncFunction%',
127
128
  '(async function(){})',
128
129
  );
129
- repairFunction(
130
- 'AsyncGeneratorFunction',
131
- '%InertAsyncGeneratorFunction%',
132
- '(async function*(){})',
133
- );
130
+
131
+ if (AsyncGeneratorFunctionInstance !== undefined) {
132
+ repairFunction(
133
+ 'AsyncGeneratorFunction',
134
+ '%InertAsyncGeneratorFunction%',
135
+ '(async function*(){})',
136
+ );
137
+ }
134
138
 
135
139
  return newIntrinsics;
136
140
  }
@@ -6,10 +6,7 @@ import {
6
6
  objectPrototype,
7
7
  } from './commons.js';
8
8
 
9
- export default function tameMathObject(mathTaming = 'safe') {
10
- if (mathTaming !== 'safe' && mathTaming !== 'unsafe') {
11
- throw TypeError(`unrecognized mathTaming ${mathTaming}`);
12
- }
9
+ export default function tameMathObject() {
13
10
  const originalMath = Math;
14
11
  const initialMath = originalMath; // to follow the naming pattern
15
12
 
package/src/transforms.js CHANGED
@@ -248,7 +248,8 @@ export const mandatoryTransforms = source => {
248
248
  * @returns {string}
249
249
  */
250
250
  export const applyTransforms = (source, transforms) => {
251
- for (const transform of transforms) {
251
+ for (let i = 0, l = transforms.length; i < l; i += 1) {
252
+ const transform = transforms[i];
252
253
  source = transform(source);
253
254
  }
254
255
  return source;