ses 0.15.4 → 0.15.5
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 +8 -0
- package/dist/lockdown.cjs +7 -1
- package/dist/lockdown.mjs +7 -1
- package/dist/lockdown.umd.js +7 -1
- package/dist/ses.cjs +7 -1
- package/dist/ses.mjs +7 -1
- package/dist/ses.umd.js +7 -1
- package/index.d.ts +116 -41
- package/package.json +6 -6
- package/src/lockdown-shim.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.15.5](https://github.com/endojs/endo/compare/ses@0.15.4...ses@0.15.5) (2022-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package ses
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
### [0.15.4](https://github.com/endojs/endo/compare/ses@0.15.3...ses@0.15.4) (2022-01-23)
|
|
7
15
|
|
|
8
16
|
|
package/dist/lockdown.cjs
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/dist/lockdown.mjs
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/dist/lockdown.umd.js
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/dist/ses.cjs
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/dist/ses.mjs
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/dist/ses.umd.js
CHANGED
|
@@ -8394,11 +8394,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8394
8394
|
const seemsToBeLockedDown = () => {
|
|
8395
8395
|
return (
|
|
8396
8396
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
8397
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
8397
8398
|
typeof globalThis.harden === 'function' &&
|
|
8399
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
8398
8400
|
typeof globalThis.lockdown === 'function' &&
|
|
8399
8401
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
8400
8402
|
typeof globalThis.Date.now === 'function' &&
|
|
8401
|
-
// @ts-ignore
|
|
8403
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
8404
|
+
// Function.
|
|
8402
8405
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
8403
8406
|
is(globalThis.Date.prototype.constructor.now(), NaN));
|
|
8404
8407
|
|
|
@@ -8454,12 +8457,14 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8454
8457
|
|
|
8455
8458
|
globalThis.console = /** @type {Console} */consoleRecord.console;
|
|
8456
8459
|
|
|
8460
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8457
8461
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
8458
8462
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
8459
8463
|
// one whose `details` template literal tag does not redact
|
|
8460
8464
|
// unmarked substitution values. IOW, it blabs information that
|
|
8461
8465
|
// was supposed to be secret from callers, as an aid to debugging
|
|
8462
8466
|
// at a further cost in safety.
|
|
8467
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
8463
8468
|
globalThis.assert = makeAssert(undefined, true);
|
|
8464
8469
|
}
|
|
8465
8470
|
|
|
@@ -8524,6 +8529,7 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8524
8529
|
// that is portable between JS and SES), the existence of harden in global
|
|
8525
8530
|
// scope signals whether such code should attempt to use harden in the
|
|
8526
8531
|
// defense of its own API.
|
|
8532
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
8527
8533
|
globalThis.harden = harden;
|
|
8528
8534
|
|
|
8529
8535
|
// Returning `true` indicates that this is a JS to SES transition.
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-globals */
|
|
1
2
|
|
|
2
3
|
// It's academically tempting to define a hardened type, but TypeScript doesn't
|
|
3
4
|
// strike a good balance in distinguishing "readonly" in the sense that you
|
|
@@ -31,8 +32,8 @@ export interface LockdownOptions {
|
|
|
31
32
|
|
|
32
33
|
export type Lockdown = (options?: LockdownOptions) => void;
|
|
33
34
|
|
|
34
|
-
export type __LiveExportsMap__ = Record<string, [string, boolean]
|
|
35
|
-
export type __FixedExportsMap__ = Record<string, [string]
|
|
35
|
+
export type __LiveExportsMap__ = Record<string, [string, boolean]>;
|
|
36
|
+
export type __FixedExportsMap__ = Record<string, [string]>;
|
|
36
37
|
|
|
37
38
|
export interface PrecompiledStaticModuleInterface {
|
|
38
39
|
imports: Array<string>;
|
|
@@ -46,33 +47,46 @@ export interface PrecompiledStaticModuleInterface {
|
|
|
46
47
|
export interface ThirdPartyStaticModuleInterface {
|
|
47
48
|
imports: Array<string>;
|
|
48
49
|
exports: Array<string>;
|
|
49
|
-
execute(
|
|
50
|
+
execute(
|
|
51
|
+
proxiedExports: Object,
|
|
52
|
+
compartment: Compartment,
|
|
53
|
+
resolvedImports: Record<string, string>,
|
|
54
|
+
): void;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
export type FinalStaticModuleType =
|
|
57
|
+
export type FinalStaticModuleType =
|
|
58
|
+
| PrecompiledStaticModuleInterface
|
|
59
|
+
| ThirdPartyStaticModuleInterface;
|
|
53
60
|
|
|
54
61
|
export interface RedirectStaticModuleInterface {
|
|
55
|
-
record: FinalStaticModuleType
|
|
56
|
-
specifier: string
|
|
62
|
+
record: FinalStaticModuleType;
|
|
63
|
+
specifier: string;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
export type StaticModuleType =
|
|
66
|
+
export type StaticModuleType =
|
|
67
|
+
| RedirectStaticModuleInterface
|
|
68
|
+
| FinalStaticModuleType;
|
|
60
69
|
|
|
61
|
-
export type ModuleExportsNamespace = Record<string, any
|
|
70
|
+
export type ModuleExportsNamespace = Record<string, any>;
|
|
62
71
|
|
|
63
72
|
export type Transform = (source: string) => string;
|
|
64
|
-
export type ResolveHook = (
|
|
73
|
+
export type ResolveHook = (
|
|
74
|
+
importSpecifier: string,
|
|
75
|
+
referrerSpecifier: string,
|
|
76
|
+
) => string;
|
|
65
77
|
export type ModuleMap = Record<string, string | ModuleExportsNamespace>;
|
|
66
|
-
export type ModuleMapHook = (
|
|
78
|
+
export type ModuleMapHook = (
|
|
79
|
+
moduleSpecifier: string,
|
|
80
|
+
) => string | ModuleExportsNamespace | void;
|
|
67
81
|
export type ImportHook = (moduleSpecifier: string) => Promise<StaticModuleType>;
|
|
68
82
|
|
|
69
83
|
export interface CompartmentOptions {
|
|
70
84
|
name?: string;
|
|
71
85
|
transforms?: Array<Transform>;
|
|
72
86
|
globalLexicals?: Record<string, any>;
|
|
73
|
-
moduleMapHook?: ModuleMapHook
|
|
74
|
-
importHook?: ImportHook
|
|
75
|
-
resolveHook?: ResolveHook
|
|
87
|
+
moduleMapHook?: ModuleMapHook;
|
|
88
|
+
importHook?: ImportHook;
|
|
89
|
+
resolveHook?: ResolveHook;
|
|
76
90
|
__shimTransforms__?: Array<Transform>;
|
|
77
91
|
}
|
|
78
92
|
|
|
@@ -85,21 +99,53 @@ export interface EvaluateOptions {
|
|
|
85
99
|
}
|
|
86
100
|
|
|
87
101
|
// The DetailsToken is an empty object literal.
|
|
88
|
-
export type DetailsToken = Record<any, never
|
|
89
|
-
export type Details = string | DetailsToken
|
|
102
|
+
export type DetailsToken = Record<any, never>;
|
|
103
|
+
export type Details = string | DetailsToken;
|
|
90
104
|
|
|
91
105
|
export interface AssertMakeErrorOptions {
|
|
92
|
-
errorName?: string
|
|
106
|
+
errorName?: string;
|
|
93
107
|
}
|
|
94
108
|
|
|
95
|
-
type AssertTypeofBigint = (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
type
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
type AssertTypeofBigint = (
|
|
110
|
+
specimen: any,
|
|
111
|
+
typeName: 'bigint',
|
|
112
|
+
details?: Details,
|
|
113
|
+
) => asserts specimen is bigint;
|
|
114
|
+
type AssertTypeofBoolean = (
|
|
115
|
+
specimen: any,
|
|
116
|
+
typeName: 'boolean',
|
|
117
|
+
details?: Details,
|
|
118
|
+
) => asserts specimen is boolean;
|
|
119
|
+
type AssertTypeofFunction = (
|
|
120
|
+
specimen: any,
|
|
121
|
+
typeName: 'function',
|
|
122
|
+
details?: Details,
|
|
123
|
+
) => asserts specimen is Function;
|
|
124
|
+
type AssertTypeofNumber = (
|
|
125
|
+
specimen: any,
|
|
126
|
+
typeName: 'number',
|
|
127
|
+
details?: Details,
|
|
128
|
+
) => asserts specimen is number;
|
|
129
|
+
type AssertTypeofObject = (
|
|
130
|
+
specimen: any,
|
|
131
|
+
typeName: 'object',
|
|
132
|
+
details?: Details,
|
|
133
|
+
) => asserts specimen is Record<any, any> | null;
|
|
134
|
+
type AssertTypeofString = (
|
|
135
|
+
specimen: any,
|
|
136
|
+
typeName: 'string',
|
|
137
|
+
details?: Details,
|
|
138
|
+
) => asserts specimen is string;
|
|
139
|
+
type AssertTypeofSymbol = (
|
|
140
|
+
specimen: any,
|
|
141
|
+
typeName: 'symbol',
|
|
142
|
+
details?: Details,
|
|
143
|
+
) => asserts specimen is symbol;
|
|
144
|
+
type AssertTypeofUndefined = (
|
|
145
|
+
specimen: any,
|
|
146
|
+
typeName: 'undefined',
|
|
147
|
+
details?: Details,
|
|
148
|
+
) => asserts specimen is undefined;
|
|
103
149
|
|
|
104
150
|
export type AssertTypeof = AssertTypeofBigint &
|
|
105
151
|
AssertTypeofBoolean &
|
|
@@ -110,45 +156,74 @@ export type AssertTypeof = AssertTypeofBigint &
|
|
|
110
156
|
AssertTypeofSymbol &
|
|
111
157
|
AssertTypeofUndefined;
|
|
112
158
|
|
|
113
|
-
export type Raise = (reason: Error) => void;
|
|
114
|
-
export type MakeAssert = (raise?: Raise, unredacted?: boolean) => Assert;
|
|
115
|
-
|
|
116
159
|
interface ToStringable {
|
|
117
|
-
toString(): string
|
|
160
|
+
toString(): string;
|
|
118
161
|
}
|
|
119
162
|
|
|
163
|
+
export type Raise = (reason: Error) => void;
|
|
164
|
+
// Behold: recursion.
|
|
165
|
+
// eslint-disable-next-line no-use-before-define
|
|
166
|
+
export type MakeAssert = (raise?: Raise, unredacted?: boolean) => Assert;
|
|
167
|
+
|
|
120
168
|
export interface Assert {
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
169
|
+
(
|
|
170
|
+
value: any,
|
|
171
|
+
details?: Details,
|
|
172
|
+
errorConstructor?: ErrorConstructor,
|
|
173
|
+
): asserts value;
|
|
174
|
+
typeof: AssertTypeof;
|
|
175
|
+
error(
|
|
176
|
+
details?: Details,
|
|
177
|
+
errorConstructor?: ErrorConstructor,
|
|
178
|
+
options?: AssertMakeErrorOptions,
|
|
179
|
+
): Error;
|
|
180
|
+
fail(details?: Details, errorConstructor?: ErrorConstructor): never;
|
|
181
|
+
equal(
|
|
182
|
+
left: any,
|
|
183
|
+
right: any,
|
|
184
|
+
details?: Details,
|
|
185
|
+
errorConstructor?: ErrorConstructor,
|
|
186
|
+
): void;
|
|
126
187
|
string(specimen: any, details?: Details): asserts specimen is string;
|
|
127
188
|
note(error: Error, details: Details): void;
|
|
128
|
-
details(
|
|
129
|
-
|
|
130
|
-
|
|
189
|
+
details(
|
|
190
|
+
template: TemplateStringsArray | string[],
|
|
191
|
+
...args: any
|
|
192
|
+
): DetailsToken;
|
|
193
|
+
quote(payload: any, spaces?: string | number): ToStringable;
|
|
194
|
+
makeAssert: MakeAssert;
|
|
131
195
|
}
|
|
132
196
|
|
|
133
197
|
declare global {
|
|
134
|
-
|
|
198
|
+
const harden: Harden;
|
|
135
199
|
|
|
136
|
-
|
|
200
|
+
const lockdown: Lockdown;
|
|
137
201
|
|
|
138
|
-
|
|
202
|
+
const assert: Assert;
|
|
139
203
|
|
|
140
204
|
/**
|
|
141
205
|
* Each Compartment constructor is a global. A host that wants to execute
|
|
142
206
|
* code in a context bound to a new global creates a new compartment.
|
|
143
207
|
*/
|
|
144
208
|
export class Compartment {
|
|
145
|
-
constructor(
|
|
209
|
+
constructor(
|
|
210
|
+
globals?: Object,
|
|
211
|
+
moduleMap?: ModuleMap,
|
|
212
|
+
options?: CompartmentOptions,
|
|
213
|
+
);
|
|
214
|
+
|
|
146
215
|
get globalThis(): Record<string, any>;
|
|
216
|
+
|
|
147
217
|
get name(): string;
|
|
218
|
+
|
|
148
219
|
evaluate(code: string): any;
|
|
149
|
-
|
|
220
|
+
|
|
221
|
+
import(specifier: string): Promise<{ namespace: ModuleExportsNamespace }>;
|
|
222
|
+
|
|
150
223
|
load(specifier: string): Promise<void>;
|
|
224
|
+
|
|
151
225
|
importNow(specifier: string): ModuleExportsNamespace;
|
|
226
|
+
|
|
152
227
|
module(specifier: string): ModuleExportsNamespace;
|
|
153
228
|
}
|
|
154
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"test:platform-compatability": "node test/package/test.cjs"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@endo/compartment-mapper": "^0.6.
|
|
63
|
-
"@endo/eslint-config": "^0.
|
|
64
|
-
"@endo/static-module-record": "^0.6.
|
|
65
|
-
"@endo/test262-runner": "^0.1.
|
|
62
|
+
"@endo/compartment-mapper": "^0.6.3",
|
|
63
|
+
"@endo/eslint-config": "^0.4.0",
|
|
64
|
+
"@endo/static-module-record": "^0.6.10",
|
|
65
|
+
"@endo/test262-runner": "^0.1.16",
|
|
66
66
|
"ava": "^3.12.1",
|
|
67
67
|
"babel-eslint": "^10.0.3",
|
|
68
68
|
"c8": "^7.7.3",
|
|
@@ -178,5 +178,5 @@
|
|
|
178
178
|
],
|
|
179
179
|
"timeout": "2m"
|
|
180
180
|
},
|
|
181
|
-
"gitHead": "
|
|
181
|
+
"gitHead": "c46f8d5d40f71014a099c53d26c75b149ea56d09"
|
|
182
182
|
}
|
package/src/lockdown-shim.js
CHANGED
|
@@ -229,11 +229,14 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
229
229
|
const seemsToBeLockedDown = () => {
|
|
230
230
|
return (
|
|
231
231
|
globalThis.Function.prototype.constructor !== globalThis.Function &&
|
|
232
|
+
// @ts-ignore harden is absent on globalThis type def.
|
|
232
233
|
typeof globalThis.harden === 'function' &&
|
|
234
|
+
// @ts-ignore lockdown is absent on globalThis type def.
|
|
233
235
|
typeof globalThis.lockdown === 'function' &&
|
|
234
236
|
globalThis.Date.prototype.constructor !== globalThis.Date &&
|
|
235
237
|
typeof globalThis.Date.now === 'function' &&
|
|
236
|
-
// @ts-ignore
|
|
238
|
+
// @ts-ignore does not recognize that Date constructor is a special
|
|
239
|
+
// Function.
|
|
237
240
|
// eslint-disable-next-line @endo/no-polymorphic-call
|
|
238
241
|
is(globalThis.Date.prototype.constructor.now(), NaN)
|
|
239
242
|
);
|
|
@@ -289,12 +292,14 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
289
292
|
);
|
|
290
293
|
globalThis.console = /** @type {Console} */ (consoleRecord.console);
|
|
291
294
|
|
|
295
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
292
296
|
if (errorTaming === 'unsafe' && globalThis.assert === assert) {
|
|
293
297
|
// If errorTaming is 'unsafe' we replace the global assert with
|
|
294
298
|
// one whose `details` template literal tag does not redact
|
|
295
299
|
// unmarked substitution values. IOW, it blabs information that
|
|
296
300
|
// was supposed to be secret from callers, as an aid to debugging
|
|
297
301
|
// at a further cost in safety.
|
|
302
|
+
// @ts-ignore assert is absent on globalThis type def.
|
|
298
303
|
globalThis.assert = makeAssert(undefined, true);
|
|
299
304
|
}
|
|
300
305
|
|
|
@@ -359,6 +364,7 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
359
364
|
// that is portable between JS and SES), the existence of harden in global
|
|
360
365
|
// scope signals whether such code should attempt to use harden in the
|
|
361
366
|
// defense of its own API.
|
|
367
|
+
// @ts-ignore harden not yet recognized on globalThis.
|
|
362
368
|
globalThis.harden = harden;
|
|
363
369
|
|
|
364
370
|
// Returning `true` indicates that this is a JS to SES transition.
|