ses 0.15.22 → 0.15.24
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/NEWS.md +34 -20
- package/dist/lockdown.cjs +66 -24
- package/dist/lockdown.mjs +66 -24
- package/dist/lockdown.umd.js +66 -24
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +66 -24
- package/dist/ses.mjs +66 -24
- package/dist/ses.umd.js +66 -24
- package/dist/ses.umd.min.js +1 -1
- package/package.json +4 -5
- package/src/commons.js +14 -9
- package/src/compartment-shim.js +5 -2
- package/src/error/console.js +1 -1
- package/src/error/stringify-utils.js +1 -1
- package/src/error/tame-error-constructor.js +34 -0
- package/src/error/unhandled-rejection.js +1 -1
- package/src/transforms.js +1 -1
- package/CHANGELOG.md +0 -507
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.24",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"test:platform-compatability": "node test/package/test.cjs"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@endo/compartment-mapper": "^0.7.
|
|
62
|
+
"@endo/compartment-mapper": "^0.7.13",
|
|
63
63
|
"@endo/eslint-config": "^0.5.1",
|
|
64
|
-
"@endo/static-module-record": "^0.7.
|
|
64
|
+
"@endo/static-module-record": "^0.7.12",
|
|
65
65
|
"@endo/test262-runner": "^0.1.28",
|
|
66
66
|
"ava": "^3.12.1",
|
|
67
67
|
"babel-eslint": "^10.0.3",
|
|
@@ -178,6 +178,5 @@
|
|
|
178
178
|
"test/**/test-*.js"
|
|
179
179
|
],
|
|
180
180
|
"timeout": "2m"
|
|
181
|
-
}
|
|
182
|
-
"gitHead": "44b17d92334592b2da54d91dba73f28db513412a"
|
|
181
|
+
}
|
|
183
182
|
}
|
package/src/commons.js
CHANGED
|
@@ -145,24 +145,19 @@ export const { prototype: promisePrototype } = Promise;
|
|
|
145
145
|
|
|
146
146
|
export const typedArrayPrototype = getPrototypeOf(Uint8Array.prototype);
|
|
147
147
|
|
|
148
|
+
const { bind } = functionPrototype;
|
|
148
149
|
/**
|
|
149
150
|
* uncurryThis()
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* The original uncurry uses:
|
|
153
|
-
* const bind = Function.prototype.bind;
|
|
154
|
-
* const uncurryThis = bind.bind(bind.call);
|
|
151
|
+
* Equivalent of: fn => (thisArg, ...args) => apply(fn, thisArg, args)
|
|
155
152
|
*
|
|
156
153
|
* See those reference for a complete explanation:
|
|
157
154
|
* http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
158
155
|
* which only lives at
|
|
159
156
|
* http://web.archive.org/web/20160805225710/http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
|
|
160
157
|
*
|
|
161
|
-
* @
|
|
162
|
-
* @param {F} fn
|
|
163
|
-
* returns {(thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>}
|
|
158
|
+
* @type {<F extends (this: any, ...args: any[]) => any>(fn: F) => ((thisArg: ThisParameterType<F>, ...args: Parameters<F>) => ReturnType<F>)}
|
|
164
159
|
*/
|
|
165
|
-
export const uncurryThis =
|
|
160
|
+
export const uncurryThis = bind.bind(bind.call); // eslint-disable-line @endo/no-polymorphic-call
|
|
166
161
|
|
|
167
162
|
export const objectHasOwnProperty = uncurryThis(objectPrototype.hasOwnProperty);
|
|
168
163
|
//
|
|
@@ -170,8 +165,10 @@ export const arrayFilter = uncurryThis(arrayPrototype.filter);
|
|
|
170
165
|
export const arrayForEach = uncurryThis(arrayPrototype.forEach);
|
|
171
166
|
export const arrayIncludes = uncurryThis(arrayPrototype.includes);
|
|
172
167
|
export const arrayJoin = uncurryThis(arrayPrototype.join);
|
|
168
|
+
/** @type {<T, U>(thisArg: readonly T[], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]} */
|
|
173
169
|
export const arrayMap = uncurryThis(arrayPrototype.map);
|
|
174
170
|
export const arrayPop = uncurryThis(arrayPrototype.pop);
|
|
171
|
+
/** @type {<T>(thisArg: T[], ...items: T[]) => number} */
|
|
175
172
|
export const arrayPush = uncurryThis(arrayPrototype.push);
|
|
176
173
|
export const arraySlice = uncurryThis(arrayPrototype.slice);
|
|
177
174
|
export const arraySome = uncurryThis(arrayPrototype.some);
|
|
@@ -199,9 +196,16 @@ export const stringEndsWith = uncurryThis(stringPrototype.endsWith);
|
|
|
199
196
|
export const stringIncludes = uncurryThis(stringPrototype.includes);
|
|
200
197
|
export const stringIndexOf = uncurryThis(stringPrototype.indexOf);
|
|
201
198
|
export const stringMatch = uncurryThis(stringPrototype.match);
|
|
199
|
+
/**
|
|
200
|
+
* @type {
|
|
201
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string) => string) |
|
|
202
|
+
* ((thisArg: string, searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string) => string)
|
|
203
|
+
* }
|
|
204
|
+
*/
|
|
202
205
|
export const stringReplace = uncurryThis(stringPrototype.replace);
|
|
203
206
|
export const stringSearch = uncurryThis(stringPrototype.search);
|
|
204
207
|
export const stringSlice = uncurryThis(stringPrototype.slice);
|
|
208
|
+
/** @type {(thisArg: string, splitter: string | RegExp | { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number) => string[]} */
|
|
205
209
|
export const stringSplit = uncurryThis(stringPrototype.split);
|
|
206
210
|
export const stringStartsWith = uncurryThis(stringPrototype.startsWith);
|
|
207
211
|
export const iterateString = uncurryThis(stringPrototype[iteratorSymbol]);
|
|
@@ -221,6 +225,7 @@ export const functionToString = uncurryThis(functionPrototype.toString);
|
|
|
221
225
|
const { all } = Promise;
|
|
222
226
|
export const promiseAll = promises => apply(all, Promise, [promises]);
|
|
223
227
|
export const promiseCatch = uncurryThis(promisePrototype.catch);
|
|
228
|
+
/** @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>} */
|
|
224
229
|
export const promiseThen = uncurryThis(promisePrototype.then);
|
|
225
230
|
//
|
|
226
231
|
export const finalizationRegistryRegister =
|
package/src/compartment-shim.js
CHANGED
|
@@ -154,7 +154,10 @@ export const CompartmentPrototype = {
|
|
|
154
154
|
() => {
|
|
155
155
|
// The namespace box is a contentious design and likely to be a breaking
|
|
156
156
|
// change in an appropriately numbered future version.
|
|
157
|
-
const namespace = compartmentImportNow(
|
|
157
|
+
const namespace = compartmentImportNow(
|
|
158
|
+
/** @type {Compartment} */ (this),
|
|
159
|
+
specifier,
|
|
160
|
+
);
|
|
158
161
|
return { namespace };
|
|
159
162
|
},
|
|
160
163
|
);
|
|
@@ -177,7 +180,7 @@ export const CompartmentPrototype = {
|
|
|
177
180
|
|
|
178
181
|
assertModuleHooks(this);
|
|
179
182
|
|
|
180
|
-
return compartmentImportNow(this, specifier);
|
|
183
|
+
return compartmentImportNow(/** @type {Compartment} */ (this), specifier);
|
|
181
184
|
},
|
|
182
185
|
};
|
|
183
186
|
|
package/src/error/console.js
CHANGED
|
@@ -322,9 +322,9 @@ const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
|
|
|
322
322
|
const levelMethod = (...logArgs) => {
|
|
323
323
|
const subErrors = [];
|
|
324
324
|
const argTags = extractErrorArgs(logArgs, subErrors);
|
|
325
|
-
// @ts-ignore
|
|
326
325
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
327
326
|
baseConsole[level](...argTags);
|
|
327
|
+
// @ts-expect-error ConsoleProp vs LogSeverity mismatch
|
|
328
328
|
logSubErrors(level, subErrors);
|
|
329
329
|
};
|
|
330
330
|
defineProperty(levelMethod, 'name', { value: level });
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
/**
|
|
20
20
|
* Joins English terms with commas and an optional conjunction.
|
|
21
21
|
*
|
|
22
|
-
* @param {string[]} terms
|
|
22
|
+
* @param {(string | StringablePayload)[]} terms
|
|
23
23
|
* @param {"and" | "or"} conjunction
|
|
24
24
|
*/
|
|
25
25
|
export const enJoin = (terms, conjunction) => {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
defineProperties,
|
|
7
7
|
setPrototypeOf,
|
|
8
8
|
getOwnPropertyDescriptor,
|
|
9
|
+
defineProperty,
|
|
9
10
|
} from '../commons.js';
|
|
10
11
|
import { NativeErrors } from '../whitelist.js';
|
|
11
12
|
import { tameV8ErrorConstructor } from './tame-v8-error-constructor.js';
|
|
@@ -137,6 +138,39 @@ export default function tameErrorConstructor(
|
|
|
137
138
|
},
|
|
138
139
|
});
|
|
139
140
|
|
|
141
|
+
if (platform === 'v8') {
|
|
142
|
+
// `SharedError.prepareStackTrace`, if it exists, must also be
|
|
143
|
+
// powerless. However, from what we've heard, depd expects to be able to
|
|
144
|
+
// assign to it without the assignment throwing. It is normally a function
|
|
145
|
+
// that returns a stack string to be magically added to error objects.
|
|
146
|
+
// However, as long as we're adding a lenient standin, we may as well
|
|
147
|
+
// accommodate any who expect to get a function they can call and get
|
|
148
|
+
// a string back. This prepareStackTrace is a do-nothing function that
|
|
149
|
+
// always returns the empty string.
|
|
150
|
+
defineProperties(SharedError, {
|
|
151
|
+
prepareStackTrace: {
|
|
152
|
+
get() {
|
|
153
|
+
return () => '';
|
|
154
|
+
},
|
|
155
|
+
set(_prepareFn) {
|
|
156
|
+
// do nothing
|
|
157
|
+
},
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true,
|
|
160
|
+
},
|
|
161
|
+
captureStackTrace: {
|
|
162
|
+
value: (errorish, _constructorOpt) => {
|
|
163
|
+
defineProperty(errorish, 'stack', {
|
|
164
|
+
value: '',
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
writable: false,
|
|
168
|
+
enumerable: false,
|
|
169
|
+
configurable: true,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
140
174
|
let initialGetStackString = tamedMethods.getStackString;
|
|
141
175
|
if (platform === 'v8') {
|
|
142
176
|
initialGetStackString = tameV8ErrorConstructor(
|
|
@@ -63,7 +63,7 @@ export const makeRejectionHandlers = reportReason => {
|
|
|
63
63
|
* @param {ReasonId} heldReasonId
|
|
64
64
|
*/
|
|
65
65
|
const finalizeDroppedPromise = heldReasonId => {
|
|
66
|
-
if (mapHas(idToReason)) {
|
|
66
|
+
if (mapHas(idToReason, heldReasonId)) {
|
|
67
67
|
const reason = mapGet(idToReason, heldReasonId);
|
|
68
68
|
removeReasonId(heldReasonId);
|
|
69
69
|
reportReason(reason);
|
package/src/transforms.js
CHANGED
|
@@ -104,7 +104,7 @@ export const evadeHtmlCommentTest = src => {
|
|
|
104
104
|
// /////////////////////////////////////////////////////////////////////////////
|
|
105
105
|
|
|
106
106
|
const importPattern = new FERAL_REG_EXP(
|
|
107
|
-
'(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))',
|
|
107
|
+
'(^|[^.]|\\.\\.\\.)\\bimport(\\s*(?:\\(|/[/*]))',
|
|
108
108
|
'g',
|
|
109
109
|
);
|
|
110
110
|
|