ses 0.17.0 → 0.18.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/CHANGELOG.md +19 -0
- package/NEWS.md +10 -0
- package/README.md +3 -6
- package/dist/lockdown.cjs +159 -165
- package/dist/lockdown.mjs +159 -165
- package/dist/lockdown.umd.js +159 -165
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +159 -165
- package/dist/ses.mjs +159 -165
- package/dist/ses.umd.js +159 -165
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +1 -1
- package/package.json +6 -6
- package/src/compartment-evaluate.js +5 -7
- package/src/compartment-shim.js +0 -30
- package/src/environment-options.js +4 -7
- package/src/error/assert.js +4 -0
- package/src/error/types.js +59 -0
- package/src/eval-scope.js +2 -5
- package/src/lockdown-shim.js +13 -18
- package/src/make-evaluate.js +10 -10
- package/src/make-function-constructor.js +6 -8
- package/src/make-safe-evaluator.js +5 -6
- package/src/module-instance.js +6 -6
- package/src/module-link.js +22 -36
- package/src/module-load.js +4 -7
- package/src/scope-constants.js +8 -8
- package/src/strict-scope-terminator.js +2 -5
- package/src/tame-locale-methods.js +6 -10
package/src/scope-constants.js
CHANGED
|
@@ -144,20 +144,20 @@ function isImmutableDataProperty(obj, name) {
|
|
|
144
144
|
* safe and only prevent performance optimization.
|
|
145
145
|
*
|
|
146
146
|
* @param {Object} globalObject
|
|
147
|
-
* @param {Object}
|
|
147
|
+
* @param {Object} moduleLexicals
|
|
148
148
|
*/
|
|
149
|
-
export const getScopeConstants = (globalObject,
|
|
149
|
+
export const getScopeConstants = (globalObject, moduleLexicals = {}) => {
|
|
150
150
|
// getOwnPropertyNames() does ignore Symbols so we don't need to
|
|
151
151
|
// filter them out.
|
|
152
152
|
const globalObjectNames = getOwnPropertyNames(globalObject);
|
|
153
|
-
const
|
|
153
|
+
const moduleLexicalNames = getOwnPropertyNames(moduleLexicals);
|
|
154
154
|
|
|
155
155
|
// Collect all valid & immutable identifiers from the endowments.
|
|
156
|
-
const
|
|
157
|
-
|
|
156
|
+
const moduleLexicalConstants = arrayFilter(
|
|
157
|
+
moduleLexicalNames,
|
|
158
158
|
name =>
|
|
159
159
|
isValidIdentifierName(name) &&
|
|
160
|
-
isImmutableDataProperty(
|
|
160
|
+
isImmutableDataProperty(moduleLexicals, name),
|
|
161
161
|
);
|
|
162
162
|
|
|
163
163
|
// Collect all valid & immutable identifiers from the global that
|
|
@@ -167,13 +167,13 @@ export const getScopeConstants = (globalObject, globalLexicals = {}) => {
|
|
|
167
167
|
name =>
|
|
168
168
|
// Can't define a constant: it would prevent a
|
|
169
169
|
// lookup on the endowments.
|
|
170
|
-
!arrayIncludes(
|
|
170
|
+
!arrayIncludes(moduleLexicalNames, name) &&
|
|
171
171
|
isValidIdentifierName(name) &&
|
|
172
172
|
isImmutableDataProperty(globalObject, name),
|
|
173
173
|
);
|
|
174
174
|
|
|
175
175
|
return {
|
|
176
176
|
globalObjectConstants,
|
|
177
|
-
|
|
177
|
+
moduleLexicalConstants,
|
|
178
178
|
};
|
|
179
179
|
};
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from './commons.js';
|
|
12
12
|
import { assert } from './error/assert.js';
|
|
13
13
|
|
|
14
|
-
const {
|
|
14
|
+
const { Fail, quote: q } = assert;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* alwaysThrowHandler
|
|
@@ -24,10 +24,7 @@ export const alwaysThrowHandler = new Proxy(
|
|
|
24
24
|
immutableObject,
|
|
25
25
|
freeze({
|
|
26
26
|
get(_shadow, prop) {
|
|
27
|
-
|
|
28
|
-
assert.fail(
|
|
29
|
-
d`Please report unexpected scope handler trap: ${q(String(prop))}`,
|
|
30
|
-
);
|
|
27
|
+
Fail`Please report unexpected scope handler trap: ${q(String(prop))}`;
|
|
31
28
|
},
|
|
32
29
|
}),
|
|
33
30
|
);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from './commons.js';
|
|
10
10
|
import { assert } from './error/assert.js';
|
|
11
11
|
|
|
12
|
-
const {
|
|
12
|
+
const { Fail, quote: q } = assert;
|
|
13
13
|
|
|
14
14
|
const localePattern = /^(\w*[a-z])Locale([A-Z]\w*)$/;
|
|
15
15
|
|
|
@@ -31,7 +31,7 @@ const tamedMethods = {
|
|
|
31
31
|
if (s > that) {
|
|
32
32
|
return 1;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
s === that || Fail`expected ${q(s)} and ${q(that)} to compare`;
|
|
35
35
|
return 0;
|
|
36
36
|
},
|
|
37
37
|
|
|
@@ -61,16 +61,12 @@ export default function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
|
61
61
|
for (const methodName of getOwnPropertyNames(intrinsic)) {
|
|
62
62
|
const match = regexpExec(localePattern, methodName);
|
|
63
63
|
if (match) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
d`expected ${q(methodName)} to be a function`,
|
|
67
|
-
);
|
|
64
|
+
typeof intrinsic[methodName] === 'function' ||
|
|
65
|
+
Fail`expected ${q(methodName)} to be a function`;
|
|
68
66
|
const nonLocaleMethodName = `${match[1]}${match[2]}`;
|
|
69
67
|
const method = intrinsic[nonLocaleMethodName];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
d`function ${q(nonLocaleMethodName)} not found`,
|
|
73
|
-
);
|
|
68
|
+
typeof method === 'function' ||
|
|
69
|
+
Fail`function ${q(nonLocaleMethodName)} not found`;
|
|
74
70
|
defineProperty(intrinsic, methodName, { value: method });
|
|
75
71
|
}
|
|
76
72
|
}
|