@endo/compartment-mapper 1.6.3 → 2.0.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/package.json +12 -16
- package/src/archive-lite.d.ts +7 -7
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +78 -27
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +7 -0
- package/src/bundle-lite.d.ts +3 -3
- package/src/bundle-lite.d.ts.map +1 -1
- package/src/bundle-lite.js +19 -24
- package/src/bundle.d.ts +3 -3
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +19 -24
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +217 -25
- package/src/compartment-map.d.ts +9 -2
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +737 -254
- package/src/digest.d.ts +22 -2
- package/src/digest.d.ts.map +1 -1
- package/src/digest.js +179 -56
- package/src/generic-graph.d.ts.map +1 -1
- package/src/generic-graph.js +8 -3
- package/src/guards.d.ts +18 -0
- package/src/guards.d.ts.map +1 -0
- package/src/guards.js +109 -0
- package/src/hooks.md +124 -0
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +15 -11
- package/src/import-archive.d.ts +5 -19
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +7 -27
- package/src/import-hook.d.ts +4 -3
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +138 -69
- package/src/import-lite.d.ts +6 -6
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +8 -5
- package/src/import.d.ts +3 -3
- package/src/import.d.ts.map +1 -1
- package/src/import.js +16 -6
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +16 -6
- package/src/link.d.ts +4 -3
- package/src/link.d.ts.map +1 -1
- package/src/link.js +70 -58
- package/src/node-modules.d.ts +4 -3
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +482 -114
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +3 -1
- package/src/policy-format.d.ts +22 -5
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +342 -108
- package/src/policy.d.ts +13 -28
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +161 -106
- package/src/types/canonical-name.d.ts +97 -0
- package/src/types/canonical-name.d.ts.map +1 -0
- package/src/types/canonical-name.ts +151 -0
- package/src/types/compartment-map-schema.d.ts +114 -35
- package/src/types/compartment-map-schema.d.ts.map +1 -1
- package/src/types/compartment-map-schema.ts +202 -37
- package/src/types/external.d.ts +168 -28
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +215 -26
- package/src/types/internal.d.ts +23 -42
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +51 -50
- package/src/types/node-modules.d.ts +71 -10
- package/src/types/node-modules.d.ts.map +1 -1
- package/src/types/node-modules.ts +107 -9
- package/src/types/policy-schema.d.ts +26 -11
- package/src/types/policy-schema.d.ts.map +1 -1
- package/src/types/policy-schema.ts +29 -16
- package/src/types/policy.d.ts +6 -2
- package/src/types/policy.d.ts.map +1 -1
- package/src/types/policy.ts +7 -2
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -1
- package/src/types/typescript.ts +37 -1
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { WILDCARD_POLICY_VALUE } from '../policy-format.js';
|
|
9
|
+
|
|
8
10
|
/* eslint-disable no-use-before-define */
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -14,7 +16,7 @@ export type FullAttenuationDefinition = {
|
|
|
14
16
|
/** The type of attenuation. */
|
|
15
17
|
attenuate: string;
|
|
16
18
|
/** The parameters for the attenuation. */
|
|
17
|
-
params
|
|
19
|
+
params?: ImplicitAttenuationDefinition;
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -38,7 +40,7 @@ export type UnifiedAttenuationDefinition = {
|
|
|
38
40
|
/**
|
|
39
41
|
* A type representing a wildcard policy, which can be 'any'.
|
|
40
42
|
*/
|
|
41
|
-
export type WildcardPolicy =
|
|
43
|
+
export type WildcardPolicy = typeof WILDCARD_POLICY_VALUE;
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
46
|
* A type representing a property policy, which is a record of string keys and
|
|
@@ -51,7 +53,9 @@ export type PropertyPolicy = Record<string, boolean>;
|
|
|
51
53
|
* wildcard policy}, a property policy, `undefined`, or defined by an
|
|
52
54
|
* attenuator
|
|
53
55
|
*/
|
|
54
|
-
export type PolicyItem<T = void> =
|
|
56
|
+
export type PolicyItem<T = void> = [T] extends [void]
|
|
57
|
+
? WildcardPolicy | PropertyPolicy
|
|
58
|
+
: WildcardPolicy | PropertyPolicy | T;
|
|
55
59
|
|
|
56
60
|
/**
|
|
57
61
|
* An object representing a nested attenuation definition.
|
|
@@ -70,22 +74,36 @@ export type PackagePolicy<
|
|
|
70
74
|
BuiltinsPolicyItem = void,
|
|
71
75
|
ExtraOptions = unknown,
|
|
72
76
|
> = {
|
|
73
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* The default attenuator, if any.
|
|
79
|
+
*/
|
|
74
80
|
defaultAttenuator?: string | undefined;
|
|
75
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* The policy item for packages.
|
|
83
|
+
*/
|
|
76
84
|
packages?: PolicyItem<PackagePolicyItem> | undefined;
|
|
77
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* The policy item or full attenuation definition for globals.
|
|
87
|
+
*/
|
|
78
88
|
globals?: AttenuationDefinition | PolicyItem<GlobalsPolicyItem> | undefined;
|
|
79
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* The policy item or nested attenuation definition for builtins.
|
|
91
|
+
*/
|
|
80
92
|
builtins?:
|
|
81
93
|
| NestedAttenuationDefinition
|
|
82
94
|
| PolicyItem<BuiltinsPolicyItem>
|
|
83
95
|
| undefined;
|
|
84
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Whether to disable global freeze.
|
|
98
|
+
*/
|
|
85
99
|
noGlobalFreeze?: boolean | undefined;
|
|
86
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Whether to allow dynamic imports
|
|
102
|
+
*/
|
|
87
103
|
dynamic?: boolean | undefined;
|
|
88
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Any additional user-defined options can be added to the policy here
|
|
106
|
+
*/
|
|
89
107
|
options?: ExtraOptions | undefined;
|
|
90
108
|
};
|
|
91
109
|
|
|
@@ -125,9 +143,4 @@ export type Policy<
|
|
|
125
143
|
export type SomePolicy = Policy<any, any, any, any>;
|
|
126
144
|
|
|
127
145
|
/** Any {@link PackagePolicy} */
|
|
128
|
-
export type SomePackagePolicy = PackagePolicy<
|
|
129
|
-
PolicyItem,
|
|
130
|
-
PolicyItem,
|
|
131
|
-
PolicyItem,
|
|
132
|
-
unknown
|
|
133
|
-
>;
|
|
146
|
+
export type SomePackagePolicy = PackagePolicy<void, void, void, unknown>;
|
package/src/types/policy.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { SomeObject } from './typescript.js';
|
|
6
|
+
import type { LiteralUnion, SomeObject } from './typescript.js';
|
|
7
7
|
export type PackageNamingKit = {
|
|
8
8
|
/** true if location is the entry compartment */
|
|
9
9
|
isEntry?: boolean | undefined;
|
|
10
|
-
name
|
|
10
|
+
name?: LiteralUnion<'<ATTENUATORS>', string>;
|
|
11
11
|
path: Array<string>;
|
|
12
12
|
};
|
|
13
13
|
export type Attenuator<GlobalParams extends [any, ...any[]] = [any, ...any[]], ModuleParams extends [any, ...any[]] = [any, ...any[]]> = {
|
|
@@ -19,4 +19,8 @@ export type ModuleAttenuatorFn<Params extends [any, ...any[]] = [any, ...any[]],
|
|
|
19
19
|
export type DeferredAttenuatorsProvider = {
|
|
20
20
|
import: (attenuatorSpecifier: string | null) => Promise<Attenuator>;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* A fieldname of `PackagePolicy`; used with `policyLookupHelper()`
|
|
24
|
+
*/
|
|
25
|
+
export type PolicyEnforcementField = 'builtins' | 'globals' | 'packages';
|
|
22
26
|
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,UAAU,CACpB,YAAY,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EACtD,YAAY,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,IACpD;IACF,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAChE,eAAe,CAAC,EACZ,kBAAkB,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC,GACxD,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAC5B,MAAM,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,IAC9C,CACF,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EACxC,UAAU,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,KACjC,IAAI,CAAC;AAEV,MAAM,MAAM,kBAAkB,CAC5B,MAAM,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EAChD,CAAC,GAAG,UAAU,EACd,CAAC,GAAG,CAAC,IACH,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAEjC,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACrE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC"}
|
package/src/types/policy.ts
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
/* eslint-disable no-use-before-define */
|
|
8
8
|
|
|
9
|
-
import type { SomeObject } from './typescript.js';
|
|
9
|
+
import type { LiteralUnion, SomeObject } from './typescript.js';
|
|
10
10
|
|
|
11
11
|
export type PackageNamingKit = {
|
|
12
12
|
/** true if location is the entry compartment */
|
|
13
13
|
isEntry?: boolean | undefined;
|
|
14
|
-
name
|
|
14
|
+
name?: LiteralUnion<'<ATTENUATORS>', string>;
|
|
15
15
|
path: Array<string>;
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -42,3 +42,8 @@ export type ModuleAttenuatorFn<
|
|
|
42
42
|
export type DeferredAttenuatorsProvider = {
|
|
43
43
|
import: (attenuatorSpecifier: string | null) => Promise<Attenuator>;
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A fieldname of `PackagePolicy`; used with `policyLookupHelper()`
|
|
48
|
+
*/
|
|
49
|
+
export type PolicyEnforcementField = 'builtins' | 'globals' | 'packages';
|
|
@@ -25,6 +25,34 @@ export type Primitive = null | undefined | string | number | boolean | symbol |
|
|
|
25
25
|
* https://github.com/Microsoft/TypeScript/issues/29729
|
|
26
26
|
* Microsoft/TypeScript#29729}. It will be removed as soon as it's not needed
|
|
27
27
|
* anymore.
|
|
28
|
+
* @see {@link https://www.npmjs.com/package/type-fest}
|
|
28
29
|
*/
|
|
29
30
|
export type LiteralUnion<LiteralType, PrimitiveType extends Primitive> = LiteralType | (PrimitiveType & Record<never, never>);
|
|
31
|
+
/**
|
|
32
|
+
* Generic type guard function that checks if a value of type `T` is also of type `U`.
|
|
33
|
+
* @template T The type of the value to check.
|
|
34
|
+
* @template U The type that the value should be checked against.
|
|
35
|
+
*/
|
|
36
|
+
export type TypeGuard<T, U extends T> = (value: T) => value is U;
|
|
37
|
+
/**
|
|
38
|
+
* Helper type for a generic type guard used in an "extends" clause
|
|
39
|
+
*/
|
|
40
|
+
export type SomeTypeGuard = TypeGuard<any, any>;
|
|
41
|
+
/**
|
|
42
|
+
* Infers the type that a type guard function checks for.
|
|
43
|
+
*
|
|
44
|
+
* @template T The type guard function type itself
|
|
45
|
+
* @returns The type that the guard checks for
|
|
46
|
+
*/
|
|
47
|
+
export type GuardedType<T> = T extends (value: any) => value is infer U ? U : never;
|
|
48
|
+
/**
|
|
49
|
+
* Converts a union type to an intersection type
|
|
50
|
+
*/
|
|
51
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
52
|
+
/**
|
|
53
|
+
* Makes a nicer tooltip for `T` in IDEs (most of the time).
|
|
54
|
+
*/
|
|
55
|
+
export type Simplify<T> = {
|
|
56
|
+
[K in keyof T]: T[K];
|
|
57
|
+
} & {};
|
|
30
58
|
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AAEX
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,YAAY,CAAC,WAAW,EAAE,aAAa,SAAS,SAAS,IACjE,WAAW,GACX,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE3C;;;;GAIG;AAEH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,KAAK,IAAI,MAAM,CAAC,GACnE,CAAC,GACD,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACnC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CACvC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GAC1B,CAAC,GACD,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC"}
|
package/src/types/typescript.ts
CHANGED
|
@@ -35,9 +35,45 @@ export type Primitive =
|
|
|
35
35
|
* https://github.com/Microsoft/TypeScript/issues/29729
|
|
36
36
|
* Microsoft/TypeScript#29729}. It will be removed as soon as it's not needed
|
|
37
37
|
* anymore.
|
|
38
|
+
* @see {@link https://www.npmjs.com/package/type-fest}
|
|
38
39
|
*/
|
|
39
40
|
export type LiteralUnion<LiteralType, PrimitiveType extends Primitive> =
|
|
40
41
|
| LiteralType
|
|
41
42
|
| (PrimitiveType & Record<never, never>);
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Generic type guard function that checks if a value of type `T` is also of type `U`.
|
|
46
|
+
* @template T The type of the value to check.
|
|
47
|
+
* @template U The type that the value should be checked against.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export type TypeGuard<T, U extends T> = (value: T) => value is U;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Helper type for a generic type guard used in an "extends" clause
|
|
54
|
+
*/
|
|
55
|
+
export type SomeTypeGuard = TypeGuard<any, any>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Infers the type that a type guard function checks for.
|
|
59
|
+
*
|
|
60
|
+
* @template T The type guard function type itself
|
|
61
|
+
* @returns The type that the guard checks for
|
|
62
|
+
*/
|
|
63
|
+
export type GuardedType<T> = T extends (value: any) => value is infer U
|
|
64
|
+
? U
|
|
65
|
+
: never;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Converts a union type to an intersection type
|
|
69
|
+
*/
|
|
70
|
+
export type UnionToIntersection<U> = (
|
|
71
|
+
U extends any ? (k: U) => void : never
|
|
72
|
+
) extends (k: infer I) => void
|
|
73
|
+
? I
|
|
74
|
+
: never;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Makes a nicer tooltip for `T` in IDEs (most of the time).
|
|
78
|
+
*/
|
|
79
|
+
export type Simplify<T> = { [K in keyof T]: T[K] } & {};
|