ses 1.9.1 → 1.11.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.
@@ -7,12 +7,19 @@ import {
7
7
  freeze,
8
8
  getOwnPropertyDescriptors,
9
9
  globalThis,
10
- immutableObject,
11
10
  } from './commons.js';
12
11
  import { assert } from './error/assert.js';
13
12
 
14
13
  const { Fail, quote: q } = assert;
15
14
 
15
+ /**
16
+ * `freeze` but not `harden` the proxy target so it remains trapping.
17
+ * Thus, it should not be shared outside this module.
18
+ *
19
+ * @see https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md
20
+ */
21
+ const objTarget = freeze({ __proto__: null });
22
+
16
23
  /**
17
24
  * alwaysThrowHandler
18
25
  * This is an object that throws if any property is called. It's used as
@@ -21,7 +28,7 @@ const { Fail, quote: q } = assert;
21
28
  * create one and share it between all Proxy handlers.
22
29
  */
23
30
  export const alwaysThrowHandler = new Proxy(
24
- immutableObject,
31
+ objTarget,
25
32
  freeze({
26
33
  get(_shadow, prop) {
27
34
  Fail`Please report unexpected scope handler trap: ${q(String(prop))}`;
@@ -88,6 +95,6 @@ export const strictScopeTerminatorHandler = freeze(
88
95
  );
89
96
 
90
97
  export const strictScopeTerminator = new Proxy(
91
- immutableObject,
98
+ objTarget,
92
99
  strictScopeTerminatorHandler,
93
100
  );
@@ -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,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
 
@@ -16,8 +16,8 @@ import {
16
16
  * `Symbol` constructor on constructed compartments.
17
17
  *
18
18
  * Starting these properties as configurable assumes two succeeding phases of
19
- * processing: A whitelisting phase, that
20
- * removes all properties not on the whitelist (which requires them to be
19
+ * processing: A permit enforcement phase, that
20
+ * removes all properties not on the permits (which requires them to be
21
21
  * configurable) and a global hardening step that freezes all primordials,
22
22
  * returning these properties to their expected non-configurable status.
23
23
  *
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;
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file Types of the SES environment
2
+ * @module Types of the SES environment
3
3
  */
4
4
 
5
5
  /* eslint-disable no-restricted-globals, vars-on-top, no-var */
@@ -24,10 +24,17 @@ export interface RepairOptions {
24
24
  localeTaming?: 'safe' | 'unsafe';
25
25
  consoleTaming?: 'safe' | 'unsafe';
26
26
  errorTrapping?: 'platform' | 'exit' | 'abort' | 'report' | 'none';
27
+ reporting?: 'platform' | 'console' | 'none';
27
28
  unhandledRejectionTrapping?: 'report' | 'none';
28
29
  errorTaming?: 'safe' | 'unsafe' | 'unsafe-debug';
29
- dateTaming?: 'safe' | 'unsafe'; // deprecated
30
- mathTaming?: 'safe' | 'unsafe'; // deprecated
30
+ /**
31
+ * @deprecated Deprecated and does nothing. In the future specifying it will be an error.
32
+ */
33
+ dateTaming?: 'safe' | 'unsafe';
34
+ /**
35
+ * @deprecated Deprecated and does nothing. In the future specifying it will be an error.
36
+ */
37
+ mathTaming?: 'safe' | 'unsafe';
31
38
  evalTaming?: 'safeEval' | 'unsafeEval' | 'noEval';
32
39
  stackFiltering?: 'concise' | 'verbose';
33
40
  overrideTaming?: 'moderate' | 'min' | 'severe';
@@ -551,12 +558,12 @@ declare global {
551
558
 
552
559
  // Deprecated:
553
560
  constructor(
554
- globals?: Record<string, any> | undefined,
561
+ globals?: Record<PropertyKey, any> | undefined,
555
562
  modules?: Record<string, ModuleDescriptor>,
556
563
  options?: CompartmentOptions,
557
564
  );
558
565
 
559
- get globalThis(): Record<string, any>;
566
+ get globalThis(): Record<PropertyKey, any>;
560
567
 
561
568
  get name(): string;
562
569