ses 0.15.21 → 0.15.23
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 +25 -0
- package/NEWS.md +26 -20
- package/dist/lockdown.cjs +72 -26
- package/dist/lockdown.mjs +72 -26
- package/dist/lockdown.umd.js +72 -26
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +72 -26
- package/dist/ses.mjs +72 -26
- package/dist/ses.umd.js +72 -26
- package/dist/ses.umd.min.js +1 -1
- package/package.json +4 -4
- package/src/commons.js +14 -9
- package/src/compartment-shim.js +5 -2
- package/src/environment-options.js +8 -4
- package/src/error/README.md +1 -1
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.23",
|
|
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",
|
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
],
|
|
180
180
|
"timeout": "2m"
|
|
181
181
|
},
|
|
182
|
-
"gitHead": "
|
|
182
|
+
"gitHead": "2d3f1a5c472aaef102e8919cbf8d0c53238d155f"
|
|
183
183
|
}
|
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
|
|
|
@@ -107,10 +107,14 @@ export const makeEnvironmentCaptor = aGlobal => {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
setting === undefined ||
|
|
111
|
+
typeof setting === 'string' ||
|
|
112
|
+
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
113
|
+
assert.fail(
|
|
114
|
+
X`Environment option value ${q(
|
|
115
|
+
setting,
|
|
116
|
+
)}, if present, must be a string.`,
|
|
117
|
+
);
|
|
114
118
|
return setting;
|
|
115
119
|
};
|
|
116
120
|
freeze(getEnvironmentOption);
|
package/src/error/README.md
CHANGED
|
@@ -75,7 +75,7 @@ However, the above description violates one of our constraints: The automatic lo
|
|
|
75
75
|
This section explains our *plans* to build a logging experience on top of this system that supports local and distributed asynchrony. Also tracked at [Support deep stacks for local asynchronous log-based debugging #1862](https://github.com/Agoric/agoric-sdk/issues/1862) and [Support distributed deep stacks for log-based debugging #1864](https://github.com/Agoric/agoric-sdk/issues/1864).
|
|
76
76
|
|
|
77
77
|
JavaScript itself is not a dustributed language, but it is a highly asynchronous language. Our distributed computational model—communicating event loops—pushes much of our code into making heavy use of this asynchrony. For such code, individual synchronous call stacks are often short and uninformative. [Causeway](https://github.com/Agoric/agoric-sdk/issues/1318#issuecomment-662127549) shows that the asynchronous and distributed analog of synchronous stack traces is a directed acyclic graph of prior causal events, each with their local synchronous stack at their moment of causation. To capture this well requires instrumenting the promise system in ways impossible for user code. However, the most important causal paths are
|
|
78
|
-
* the [eventual-send](https://github.com/tc39/proposal-eventual-send) operations by [handled promise](
|
|
78
|
+
* the [eventual-send](https://github.com/tc39/proposal-eventual-send) operations by [handled promise](../../../eventual-send/README.md), whether expressed by `E()` or `~.`.
|
|
79
79
|
* the `.then` operation. However, we replace the builtin `Promise.prototype.then` at our peril. Many built in operations implicitly invoke the original binding of `Promise.prototype.then` in ways we cannot override. However, our same eventual-send package already provides a safer alternative `E.when` operation.
|
|
80
80
|
|
|
81
81
|
Restricting the instrumentation to these two operations gives predictability and preserves platform independence, but at the loss of some useful diagnostic information. This loss may encourage programmers to shift from their current habits to eventual-send and `E.when`, which would be a good thing anyway.
|
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);
|