@endo/compartment-mapper 1.3.1 → 1.4.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/README.md +50 -27
- package/archive-lite.d.ts +1 -0
- package/archive-lite.js +3 -0
- package/archive-parsers.d.ts +1 -0
- package/archive-parsers.js +3 -0
- package/archive.d.ts +1 -0
- package/archive.js +3 -0
- package/bundle.d.ts +1 -0
- package/bundle.js +3 -0
- package/capture-lite.d.ts +1 -0
- package/capture-lite.js +3 -0
- package/import-archive-lite.d.ts +1 -0
- package/import-archive-lite.js +3 -0
- package/import-archive-parsers.d.ts +1 -0
- package/import-archive-parsers.js +3 -0
- package/import-archive.d.ts +1 -0
- package/import-archive.js +3 -0
- package/import-lite.d.ts +1 -0
- package/import-lite.js +3 -0
- package/import-parsers.d.ts +1 -0
- package/import-parsers.js +3 -0
- package/import.d.ts +1 -0
- package/import.js +3 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/node-modules.d.ts +1 -0
- package/node-modules.js +3 -0
- package/node-powers.d.ts +1 -0
- package/node-powers.js +3 -0
- package/package.json +10 -14
- package/src/archive-lite.d.ts +6 -6
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +35 -33
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +132 -28
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +54 -14
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +21 -17
- package/src/compartment-map.d.ts +2 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +11 -3
- package/src/extension.d.ts.map +1 -1
- package/src/extension.js +1 -3
- package/src/import-archive-lite.d.ts +3 -19
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +43 -57
- package/src/import-archive-parsers.d.ts.map +1 -1
- package/src/import-archive-parsers.js +1 -0
- package/src/import-archive.d.ts +2 -2
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +15 -12
- package/src/import-hook.d.ts +2 -1
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +87 -76
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +23 -23
- package/src/import.d.ts.map +1 -1
- package/src/import.js +47 -23
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +2 -3
- package/src/json.d.ts.map +1 -1
- package/src/json.js +1 -2
- package/src/link.d.ts.map +1 -1
- package/src/link.js +12 -29
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +21 -16
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +2 -3
- package/src/node-modules.d.ts +9 -7
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +176 -87
- package/src/node-powers.d.ts +8 -8
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +29 -24
- package/src/parse-archive-cjs.d.ts +3 -2
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +5 -4
- package/src/parse-archive-mjs.d.ts +3 -2
- package/src/parse-archive-mjs.d.ts.map +1 -1
- package/src/parse-archive-mjs.js +7 -5
- package/src/parse-bytes.d.ts +3 -2
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +7 -5
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +7 -6
- package/src/parse-cjs.d.ts +3 -2
- package/src/parse-cjs.d.ts.map +1 -1
- package/src/parse-cjs.js +14 -5
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-json.js +6 -6
- package/src/parse-mjs.d.ts +3 -2
- package/src/parse-mjs.d.ts.map +1 -1
- package/src/parse-mjs.js +3 -3
- package/src/parse-pre-cjs.d.ts +3 -2
- package/src/parse-pre-cjs.d.ts.map +1 -1
- package/src/parse-pre-cjs.js +14 -4
- package/src/parse-pre-mjs.d.ts +3 -2
- package/src/parse-pre-mjs.d.ts.map +1 -1
- package/src/parse-pre-mjs.js +4 -3
- package/src/parse-text.d.ts +3 -2
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +6 -5
- package/src/policy-format.d.ts +1 -1
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +5 -7
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +15 -10
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +15 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +10 -7
- package/src/types/compartment-map-schema.d.ts +98 -0
- package/src/types/compartment-map-schema.d.ts.map +1 -0
- package/src/types/compartment-map-schema.ts +116 -0
- package/src/types/external.d.ts +256 -0
- package/src/types/external.d.ts.map +1 -0
- package/src/types/external.ts +379 -0
- package/src/types/internal.d.ts +161 -0
- package/src/types/internal.d.ts.map +1 -0
- package/src/types/internal.ts +216 -0
- package/src/types/node-powers.d.ts +46 -0
- package/src/types/node-powers.d.ts.map +1 -0
- package/src/types/node-powers.ts +52 -0
- package/src/types/policy-schema.d.ts +81 -0
- package/src/types/policy-schema.d.ts.map +1 -0
- package/src/types/policy-schema.ts +131 -0
- package/src/types/policy.d.ts +20 -0
- package/src/types/policy.d.ts.map +1 -0
- package/src/types/policy.ts +42 -0
- package/src/types/powers.d.ts +83 -0
- package/src/types/powers.d.ts.map +1 -0
- package/src/types/powers.ts +120 -0
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -0
- package/src/types/typescript.ts +41 -0
- package/src/types-external.d.ts +14 -0
- package/src/types-external.js +2 -0
- package/src/types.d.ts +9 -787
- package/src/url.d.ts.map +1 -1
- package/src/url.js +2 -3
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -995
- package/types.d.ts +0 -19
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Internal types of the compartment mapper that need not be visible to
|
|
3
|
+
* consumers.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-use-before-define */
|
|
7
|
+
|
|
8
|
+
import type { ImportHook, ImportNowHook } from 'ses';
|
|
9
|
+
import type {
|
|
10
|
+
CompartmentDescriptor,
|
|
11
|
+
Language,
|
|
12
|
+
LanguageForExtension,
|
|
13
|
+
LanguageForModuleSpecifier,
|
|
14
|
+
ModuleDescriptor,
|
|
15
|
+
} from './compartment-map-schema.js';
|
|
16
|
+
import type {
|
|
17
|
+
HashFn,
|
|
18
|
+
MaybeReadFn,
|
|
19
|
+
MaybeReadNowFn,
|
|
20
|
+
ReadFn,
|
|
21
|
+
ReadPowers,
|
|
22
|
+
} from './powers.js';
|
|
23
|
+
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
24
|
+
import type {
|
|
25
|
+
AsyncParseFn,
|
|
26
|
+
CompartmentSources,
|
|
27
|
+
ExecuteOptions,
|
|
28
|
+
ExitModuleImportNowHook,
|
|
29
|
+
ModuleTransforms,
|
|
30
|
+
ParseFn,
|
|
31
|
+
ParserForLanguage,
|
|
32
|
+
SearchSuffixesOption,
|
|
33
|
+
SourceMapHook,
|
|
34
|
+
SourceMapHookOption,
|
|
35
|
+
Sources,
|
|
36
|
+
SyncModuleTransforms,
|
|
37
|
+
} from './external.js';
|
|
38
|
+
|
|
39
|
+
export type LinkOptions = {
|
|
40
|
+
resolve?: ResolveHook;
|
|
41
|
+
makeImportHook: ImportHookMaker;
|
|
42
|
+
makeImportNowHook?: ImportNowHookMaker;
|
|
43
|
+
parserForLanguage?: ParserForLanguage;
|
|
44
|
+
moduleTransforms?: ModuleTransforms;
|
|
45
|
+
syncModuleTransforms?: SyncModuleTransforms;
|
|
46
|
+
archiveOnly?: boolean;
|
|
47
|
+
} & ExecuteOptions;
|
|
48
|
+
|
|
49
|
+
export type LinkResult = {
|
|
50
|
+
compartment: Compartment;
|
|
51
|
+
compartments: Record<string, Compartment>;
|
|
52
|
+
attenuatorsCompartment: Compartment;
|
|
53
|
+
pendingJobsPromise: Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type ResolveHook = (
|
|
57
|
+
importSpecifier: string,
|
|
58
|
+
referrerSpecifier: string,
|
|
59
|
+
) => string;
|
|
60
|
+
|
|
61
|
+
export type ShouldDeferError = (language: Language | undefined) => boolean;
|
|
62
|
+
|
|
63
|
+
export type MakeImportNowHookMakerOptions = Partial<{
|
|
64
|
+
sources: Sources;
|
|
65
|
+
compartmentDescriptors: Record<string, CompartmentDescriptor>;
|
|
66
|
+
computeSha512: HashFn;
|
|
67
|
+
exitModuleImportNowHook: ExitModuleImportNowHook;
|
|
68
|
+
}> &
|
|
69
|
+
SearchSuffixesOption &
|
|
70
|
+
SourceMapHookOption;
|
|
71
|
+
|
|
72
|
+
export type ImportHookMaker = (params: {
|
|
73
|
+
packageLocation: string;
|
|
74
|
+
packageName: string;
|
|
75
|
+
attenuators: DeferredAttenuatorsProvider;
|
|
76
|
+
parse: ParseFn | AsyncParseFn;
|
|
77
|
+
shouldDeferError: ShouldDeferError;
|
|
78
|
+
compartments: Record<string, Compartment>;
|
|
79
|
+
}) => ImportHook;
|
|
80
|
+
|
|
81
|
+
export type ImportNowHookMaker = (params: {
|
|
82
|
+
packageLocation: string;
|
|
83
|
+
packageName: string;
|
|
84
|
+
parse: ParseFn | AsyncParseFn;
|
|
85
|
+
compartments: Record<string, Compartment>;
|
|
86
|
+
// Unlike analogous prameters of ImportHookMaker, the Compartment Mapper
|
|
87
|
+
// ignores these two parameters, so they are expressly disallowed to avoid
|
|
88
|
+
// confusion about whether they would be respected.
|
|
89
|
+
attenuators?: never;
|
|
90
|
+
shouldDeferError?: never;
|
|
91
|
+
}) => ImportNowHook;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The value returned by `makeMapParsers()`
|
|
95
|
+
*/
|
|
96
|
+
export type MapParsersFn<ParseT = AsyncParseFn | ParseFn> = (
|
|
97
|
+
/** Mapping from file extension to Language (like `js` to `mjs`). */
|
|
98
|
+
languageForExtension: LanguageForExtension,
|
|
99
|
+
/** Mapping from module specifier to Language. */
|
|
100
|
+
languageForModuleSpecifier: LanguageForModuleSpecifier,
|
|
101
|
+
) => ParseT;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* As used in `import-hook.js`
|
|
105
|
+
*/
|
|
106
|
+
export type ChooseModuleDescriptorParams = {
|
|
107
|
+
/** Module specifiers with each search suffix appended */
|
|
108
|
+
candidates: string[];
|
|
109
|
+
moduleSpecifier: string;
|
|
110
|
+
packageLocation: string;
|
|
111
|
+
/** Compartment descriptor from the compartment map */
|
|
112
|
+
compartmentDescriptor: CompartmentDescriptor;
|
|
113
|
+
/** All compartment descriptors from the compartment map */
|
|
114
|
+
compartmentDescriptors: Record<string, CompartmentDescriptor>;
|
|
115
|
+
/** All module descriptors in same compartment */
|
|
116
|
+
moduleDescriptors: Record<string, ModuleDescriptor>;
|
|
117
|
+
/** All compartments */
|
|
118
|
+
compartments: Record<string, Compartment>;
|
|
119
|
+
packageSources: CompartmentSources;
|
|
120
|
+
/** Function to compute SHA-512 hash */
|
|
121
|
+
computeSha512?: HashFn;
|
|
122
|
+
readPowers: ReadPowers | ReadFn;
|
|
123
|
+
sourceMapHook?: SourceMapHook;
|
|
124
|
+
/**
|
|
125
|
+
* Function returning a set of module names (scoped to the compartment) whose
|
|
126
|
+
* parser is not using heuristics to determine imports.
|
|
127
|
+
*/
|
|
128
|
+
strictlyRequiredForCompartment: (compartmentName: string) => Set<string>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type SyncChooseModuleDescriptorOperators = {
|
|
132
|
+
/**
|
|
133
|
+
* A function that reads a file, returning its binary contents _or_
|
|
134
|
+
* `undefined` if the file is not found
|
|
135
|
+
*/
|
|
136
|
+
maybeRead: MaybeReadNowFn;
|
|
137
|
+
/**
|
|
138
|
+
* A function that parses the (defined) binary contents from `maybeRad` into
|
|
139
|
+
* a `ParseResult`
|
|
140
|
+
*/
|
|
141
|
+
parse: ParseFn;
|
|
142
|
+
/** Should be omitted */
|
|
143
|
+
shouldDeferError?: never;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Operators for `chooseModuleDescriptor` representing asynchronous operation.
|
|
148
|
+
*/
|
|
149
|
+
export type AsyncChooseModuleDescriptorOperators = {
|
|
150
|
+
/**
|
|
151
|
+
* A function that reads a file, resolving with its binary contents _or_
|
|
152
|
+
* `undefined` if the file is not found
|
|
153
|
+
*/
|
|
154
|
+
maybeRead: MaybeReadFn;
|
|
155
|
+
/**
|
|
156
|
+
* A function that parses the (defined) binary contents from `maybeRead` into
|
|
157
|
+
* a `ParseResult`
|
|
158
|
+
*/
|
|
159
|
+
parse: AsyncParseFn | ParseFn;
|
|
160
|
+
/**
|
|
161
|
+
* A function that returns `true` if the language returned by `parse` should
|
|
162
|
+
* defer errors.
|
|
163
|
+
*/
|
|
164
|
+
shouldDeferError: (language: Language) => boolean;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Either synchronous or asynchronous operators for `chooseModuleDescriptor`.
|
|
169
|
+
*/
|
|
170
|
+
export type ChooseModuleDescriptorOperators =
|
|
171
|
+
| AsyncChooseModuleDescriptorOperators
|
|
172
|
+
| SyncChooseModuleDescriptorOperators;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The agglomeration of things that the `chooseModuleDescriptor` generator can
|
|
176
|
+
* yield.
|
|
177
|
+
*
|
|
178
|
+
* The generator does not necessarily yield _all_ of these; it depends on
|
|
179
|
+
* whether the operators are {@link AsyncChooseModuleDescriptorOperators} or
|
|
180
|
+
* {@link SyncChooseModuleDescriptorOperators}.
|
|
181
|
+
*/
|
|
182
|
+
export type ChooseModuleDescriptorYieldables =
|
|
183
|
+
| ReturnType<ChooseModuleDescriptorOperators['maybeRead']>
|
|
184
|
+
| ReturnType<ChooseModuleDescriptorOperators['parse']>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Parameters for `findRedirect()`.
|
|
188
|
+
*/
|
|
189
|
+
export type FindRedirectParams = {
|
|
190
|
+
compartmentDescriptor: CompartmentDescriptor;
|
|
191
|
+
compartmentDescriptors: Record<string, CompartmentDescriptor>;
|
|
192
|
+
compartments: Record<string, Compartment>;
|
|
193
|
+
/* A module specifier which is an absolute path. NOT a `file://` URL. */
|
|
194
|
+
absoluteModuleSpecifier: string;
|
|
195
|
+
/** Location of the compartment descriptor's package. */
|
|
196
|
+
packageLocation: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Options for `makeMapParsers()`
|
|
201
|
+
*/
|
|
202
|
+
export type MakeMapParsersOptions = {
|
|
203
|
+
/** Mapping of language to `ParserImplementation` */
|
|
204
|
+
parserForLanguage: ParserForLanguage;
|
|
205
|
+
/**
|
|
206
|
+
* Async or sync module transforms.
|
|
207
|
+
* If non-empty, synchronous import (specifically dynamic `require` in
|
|
208
|
+
* CommonJS or `compartment.importNow`) are unsupported.
|
|
209
|
+
*/
|
|
210
|
+
moduleTransforms?: ModuleTransforms;
|
|
211
|
+
/**
|
|
212
|
+
* Sync module transforms.
|
|
213
|
+
* Always supported.
|
|
214
|
+
*/
|
|
215
|
+
syncModuleTransforms?: SyncModuleTransforms;
|
|
216
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module These interfaces describe the powers needed in `node-powers.js` to
|
|
3
|
+
* adapt host capabilities for the compartment mapper.
|
|
4
|
+
*/
|
|
5
|
+
/** For creating `ReadPowers` */
|
|
6
|
+
export type FsInterface = {
|
|
7
|
+
promises: {
|
|
8
|
+
realpath: (filepath: string) => Promise<string>;
|
|
9
|
+
writeFile: (location: string, bytes: Uint8Array) => Promise<void>;
|
|
10
|
+
readFile: (location: string) => Promise<Uint8Array>;
|
|
11
|
+
};
|
|
12
|
+
readFileSync: (location: string) => Uint8Array;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The portion of the "node:url" module needed to normalize paths to fully
|
|
16
|
+
* qualified file URLs, as used by the compartment mapper internally.
|
|
17
|
+
*/
|
|
18
|
+
export type UrlInterface = {
|
|
19
|
+
fileURLToPath: (location: string | URL) => string;
|
|
20
|
+
pathToFileURL: (location: string) => URL;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The portion of the "node:path" module needed to support dynamic-require for
|
|
24
|
+
* a module specifier that is an absolute path.
|
|
25
|
+
*/
|
|
26
|
+
export type PathInterface = {
|
|
27
|
+
isAbsolute: (location: string) => boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The portion of the "node:crypto" module needed for generating and verifying
|
|
31
|
+
* integrity hashes, optionally consumed to make "read powers".
|
|
32
|
+
*/
|
|
33
|
+
export type CryptoInterface = {
|
|
34
|
+
createHash: (algorithm: 'sha512') => Hash;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Object returned by function in `CryptoInterface`
|
|
38
|
+
*/
|
|
39
|
+
type Hash = {
|
|
40
|
+
update: (data: Uint8Array | string) => Hash;
|
|
41
|
+
digest: () => {
|
|
42
|
+
toString: (radix: 'hex') => string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=node-powers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-powers.d.ts","sourceRoot":"","sources":["node-powers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,gCAAgC;AAChC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;KACrD,CAAC;IACF,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,UAAU,CAAC;CAChD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,KAAK,MAAM,CAAC;IAClD,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,CAAC,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,MAAM,EAAE,MAAM;QAEZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;KACpC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module These interfaces describe the powers needed in `node-powers.js` to
|
|
3
|
+
* adapt host capabilities for the compartment mapper.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-use-before-define */
|
|
7
|
+
|
|
8
|
+
/** For creating `ReadPowers` */
|
|
9
|
+
export type FsInterface = {
|
|
10
|
+
promises: {
|
|
11
|
+
realpath: (filepath: string) => Promise<string>;
|
|
12
|
+
writeFile: (location: string, bytes: Uint8Array) => Promise<void>;
|
|
13
|
+
readFile: (location: string) => Promise<Uint8Array>;
|
|
14
|
+
};
|
|
15
|
+
readFileSync: (location: string) => Uint8Array;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The portion of the "node:url" module needed to normalize paths to fully
|
|
20
|
+
* qualified file URLs, as used by the compartment mapper internally.
|
|
21
|
+
*/
|
|
22
|
+
export type UrlInterface = {
|
|
23
|
+
fileURLToPath: (location: string | URL) => string;
|
|
24
|
+
pathToFileURL: (location: string) => URL;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The portion of the "node:path" module needed to support dynamic-require for
|
|
29
|
+
* a module specifier that is an absolute path.
|
|
30
|
+
*/
|
|
31
|
+
export type PathInterface = {
|
|
32
|
+
isAbsolute: (location: string) => boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The portion of the "node:crypto" module needed for generating and verifying
|
|
37
|
+
* integrity hashes, optionally consumed to make "read powers".
|
|
38
|
+
*/
|
|
39
|
+
export type CryptoInterface = {
|
|
40
|
+
createHash: (algorithm: 'sha512') => Hash;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Object returned by function in `CryptoInterface`
|
|
45
|
+
*/
|
|
46
|
+
type Hash = {
|
|
47
|
+
update: (data: Uint8Array | string) => Hash;
|
|
48
|
+
digest: () => {
|
|
49
|
+
// This is the exact subset of Node.js Buffer that we need.
|
|
50
|
+
toString: (radix: 'hex') => string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Describes the portion of a compartment map dedicated to narrowing
|
|
3
|
+
* or attenuating the powers available to each compartment.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* An object representing a full attenuation definition.
|
|
7
|
+
*/
|
|
8
|
+
export type FullAttenuationDefinition = {
|
|
9
|
+
/** The type of attenuation. */
|
|
10
|
+
attenuate: string;
|
|
11
|
+
/** The parameters for the attenuation. */
|
|
12
|
+
params: ImplicitAttenuationDefinition;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* An array of any type representing an implicit attenuation definition.
|
|
16
|
+
*/
|
|
17
|
+
export type ImplicitAttenuationDefinition = [any, ...any[]];
|
|
18
|
+
/**
|
|
19
|
+
* A type representing an attenuation definition, which can be either a full or
|
|
20
|
+
* implicit definition.
|
|
21
|
+
*/
|
|
22
|
+
export type AttenuationDefinition = FullAttenuationDefinition | ImplicitAttenuationDefinition;
|
|
23
|
+
export type UnifiedAttenuationDefinition = {
|
|
24
|
+
displayName: string;
|
|
25
|
+
specifier: string | null;
|
|
26
|
+
params?: any[] | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A type representing a wildcard policy, which can be 'any'.
|
|
30
|
+
*/
|
|
31
|
+
export type WildcardPolicy = 'any';
|
|
32
|
+
/**
|
|
33
|
+
* A type representing a property policy, which is a record of string keys and
|
|
34
|
+
* boolean values
|
|
35
|
+
*/
|
|
36
|
+
export type PropertyPolicy = Record<string, boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* A type representing a policy item, which can be a {@link WildcardPolicy
|
|
39
|
+
* wildcard policy}, a property policy, `undefined`, or defined by an
|
|
40
|
+
* attenuator
|
|
41
|
+
*/
|
|
42
|
+
export type PolicyItem<T = void> = WildcardPolicy | PropertyPolicy | T;
|
|
43
|
+
/**
|
|
44
|
+
* An object representing a nested attenuation definition.
|
|
45
|
+
*/
|
|
46
|
+
export type NestedAttenuationDefinition = Record<string, AttenuationDefinition | boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* An object representing a base package policy.
|
|
49
|
+
*/
|
|
50
|
+
export type PackagePolicy<PackagePolicyItem = void, GlobalsPolicyItem = void, BuiltinsPolicyItem = void, ExtraOptions = unknown> = {
|
|
51
|
+
/** The default attenuator. */
|
|
52
|
+
defaultAttenuator?: string | undefined;
|
|
53
|
+
/** The policy item for packages. */
|
|
54
|
+
packages?: PolicyItem<PackagePolicyItem> | undefined;
|
|
55
|
+
/** The policy item or full attenuation definition for globals. */
|
|
56
|
+
globals?: AttenuationDefinition | PolicyItem<GlobalsPolicyItem> | undefined;
|
|
57
|
+
/** The policy item or nested attenuation definition for builtins. */
|
|
58
|
+
builtins?: NestedAttenuationDefinition | PolicyItem<BuiltinsPolicyItem> | undefined;
|
|
59
|
+
/** Whether to disable global freeze. */
|
|
60
|
+
noGlobalFreeze?: boolean | undefined;
|
|
61
|
+
/** Whether to allow dynamic imports */
|
|
62
|
+
dynamic?: boolean | undefined;
|
|
63
|
+
/** Any additional user-defined options can be added to the policy here */
|
|
64
|
+
options?: ExtraOptions | undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* An object representing a base policy.
|
|
68
|
+
*/
|
|
69
|
+
export type Policy<PackagePolicyItem = void, GlobalsPolicyItem = void, BuiltinsPolicyItem = void, ExtraOptions = unknown> = {
|
|
70
|
+
/** The package policies for the resources. */
|
|
71
|
+
resources: Record<string, PackagePolicy<PackagePolicyItem, GlobalsPolicyItem, BuiltinsPolicyItem, ExtraOptions>>;
|
|
72
|
+
/** The default attenuator. */
|
|
73
|
+
defaultAttenuator?: string | undefined;
|
|
74
|
+
/** The package policy for the entry. */
|
|
75
|
+
entry?: PackagePolicy<PackagePolicyItem, GlobalsPolicyItem, BuiltinsPolicyItem, ExtraOptions> | undefined;
|
|
76
|
+
};
|
|
77
|
+
/** Any {@link Policy} */
|
|
78
|
+
export type SomePolicy = Policy<any, any, any, any>;
|
|
79
|
+
/** Any {@link PackagePolicy} */
|
|
80
|
+
export type SomePackagePolicy = PackagePolicy<PolicyItem, PolicyItem, PolicyItem, unknown>;
|
|
81
|
+
//# sourceMappingURL=policy-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-schema.d.ts","sourceRoot":"","sources":["policy-schema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,MAAM,EAAE,6BAA6B,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,yBAAyB,GACzB,6BAA6B,CAAC;AAClC,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,IAAI,IAAI,cAAc,GAAG,cAAc,GAAG,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN,qBAAqB,GAAG,OAAO,CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,CACvB,iBAAiB,GAAG,IAAI,EACxB,iBAAiB,GAAG,IAAI,EACxB,kBAAkB,GAAG,IAAI,EACzB,YAAY,GAAG,OAAO,IACpB;IACF,8BAA8B;IAC9B,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;IACrD,kEAAkE;IAClE,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;IAC5E,qEAAqE;IACrE,QAAQ,CAAC,EACL,2BAA2B,GAC3B,UAAU,CAAC,kBAAkB,CAAC,GAC9B,SAAS,CAAC;IACd,wCAAwC;IACxC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,CAChB,iBAAiB,GAAG,IAAI,EACxB,iBAAiB,GAAG,IAAI,EACxB,kBAAkB,GAAG,IAAI,EACzB,YAAY,GAAG,OAAO,IACpB;IACF,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CACf,MAAM,EACN,aAAa,CACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,CACb,CACF,CAAC;IACF,8BAA8B;IAC9B,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,wCAAwC;IACxC,KAAK,CAAC,EACF,aAAa,CACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,CACb,GACD,SAAS,CAAC;CACf,CAAC;AAEF,yBAAyB;AACzB,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpD,gCAAgC;AAChC,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAC3C,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,CACR,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Describes the portion of a compartment map dedicated to narrowing
|
|
3
|
+
* or attenuating the powers available to each compartment.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-use-before-define */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An object representing a full attenuation definition.
|
|
10
|
+
*/
|
|
11
|
+
export type FullAttenuationDefinition = {
|
|
12
|
+
/** The type of attenuation. */
|
|
13
|
+
attenuate: string;
|
|
14
|
+
/** The parameters for the attenuation. */
|
|
15
|
+
params: ImplicitAttenuationDefinition;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An array of any type representing an implicit attenuation definition.
|
|
20
|
+
*/
|
|
21
|
+
export type ImplicitAttenuationDefinition = [any, ...any[]];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A type representing an attenuation definition, which can be either a full or
|
|
25
|
+
* implicit definition.
|
|
26
|
+
*/
|
|
27
|
+
export type AttenuationDefinition =
|
|
28
|
+
| FullAttenuationDefinition
|
|
29
|
+
| ImplicitAttenuationDefinition;
|
|
30
|
+
export type UnifiedAttenuationDefinition = {
|
|
31
|
+
displayName: string;
|
|
32
|
+
specifier: string | null;
|
|
33
|
+
params?: any[] | undefined;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A type representing a wildcard policy, which can be 'any'.
|
|
38
|
+
*/
|
|
39
|
+
export type WildcardPolicy = 'any';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A type representing a property policy, which is a record of string keys and
|
|
43
|
+
* boolean values
|
|
44
|
+
*/
|
|
45
|
+
export type PropertyPolicy = Record<string, boolean>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A type representing a policy item, which can be a {@link WildcardPolicy
|
|
49
|
+
* wildcard policy}, a property policy, `undefined`, or defined by an
|
|
50
|
+
* attenuator
|
|
51
|
+
*/
|
|
52
|
+
export type PolicyItem<T = void> = WildcardPolicy | PropertyPolicy | T;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* An object representing a nested attenuation definition.
|
|
56
|
+
*/
|
|
57
|
+
export type NestedAttenuationDefinition = Record<
|
|
58
|
+
string,
|
|
59
|
+
AttenuationDefinition | boolean
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* An object representing a base package policy.
|
|
64
|
+
*/
|
|
65
|
+
export type PackagePolicy<
|
|
66
|
+
PackagePolicyItem = void,
|
|
67
|
+
GlobalsPolicyItem = void,
|
|
68
|
+
BuiltinsPolicyItem = void,
|
|
69
|
+
ExtraOptions = unknown,
|
|
70
|
+
> = {
|
|
71
|
+
/** The default attenuator. */
|
|
72
|
+
defaultAttenuator?: string | undefined;
|
|
73
|
+
/** The policy item for packages. */
|
|
74
|
+
packages?: PolicyItem<PackagePolicyItem> | undefined;
|
|
75
|
+
/** The policy item or full attenuation definition for globals. */
|
|
76
|
+
globals?: AttenuationDefinition | PolicyItem<GlobalsPolicyItem> | undefined;
|
|
77
|
+
/** The policy item or nested attenuation definition for builtins. */
|
|
78
|
+
builtins?:
|
|
79
|
+
| NestedAttenuationDefinition
|
|
80
|
+
| PolicyItem<BuiltinsPolicyItem>
|
|
81
|
+
| undefined;
|
|
82
|
+
/** Whether to disable global freeze. */
|
|
83
|
+
noGlobalFreeze?: boolean | undefined;
|
|
84
|
+
/** Whether to allow dynamic imports */
|
|
85
|
+
dynamic?: boolean | undefined;
|
|
86
|
+
/** Any additional user-defined options can be added to the policy here */
|
|
87
|
+
options?: ExtraOptions | undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* An object representing a base policy.
|
|
92
|
+
*/
|
|
93
|
+
export type Policy<
|
|
94
|
+
PackagePolicyItem = void,
|
|
95
|
+
GlobalsPolicyItem = void,
|
|
96
|
+
BuiltinsPolicyItem = void,
|
|
97
|
+
ExtraOptions = unknown,
|
|
98
|
+
> = {
|
|
99
|
+
/** The package policies for the resources. */
|
|
100
|
+
resources: Record<
|
|
101
|
+
string,
|
|
102
|
+
PackagePolicy<
|
|
103
|
+
PackagePolicyItem,
|
|
104
|
+
GlobalsPolicyItem,
|
|
105
|
+
BuiltinsPolicyItem,
|
|
106
|
+
ExtraOptions
|
|
107
|
+
>
|
|
108
|
+
>;
|
|
109
|
+
/** The default attenuator. */
|
|
110
|
+
defaultAttenuator?: string | undefined;
|
|
111
|
+
/** The package policy for the entry. */
|
|
112
|
+
entry?:
|
|
113
|
+
| PackagePolicy<
|
|
114
|
+
PackagePolicyItem,
|
|
115
|
+
GlobalsPolicyItem,
|
|
116
|
+
BuiltinsPolicyItem,
|
|
117
|
+
ExtraOptions
|
|
118
|
+
>
|
|
119
|
+
| undefined;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** Any {@link Policy} */
|
|
123
|
+
export type SomePolicy = Policy<any, any, any, any>;
|
|
124
|
+
|
|
125
|
+
/** Any {@link PackagePolicy} */
|
|
126
|
+
export type SomePackagePolicy = PackagePolicy<
|
|
127
|
+
PolicyItem,
|
|
128
|
+
PolicyItem,
|
|
129
|
+
PolicyItem,
|
|
130
|
+
unknown
|
|
131
|
+
>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Types required for policy enforcement.
|
|
3
|
+
*/
|
|
4
|
+
import type { SomeObject } from './typescript.js';
|
|
5
|
+
export type PackageNamingKit = {
|
|
6
|
+
/** true if location is the entry compartment */
|
|
7
|
+
isEntry?: boolean | undefined;
|
|
8
|
+
name: string;
|
|
9
|
+
path: Array<string>;
|
|
10
|
+
};
|
|
11
|
+
export type Attenuator<GlobalParams extends [any, ...any[]] = [any, ...any[]], ModuleParams extends [any, ...any[]] = [any, ...any[]]> = {
|
|
12
|
+
attenuateGlobals?: GlobalAttenuatorFn<GlobalParams> | undefined;
|
|
13
|
+
attenuateModule?: ModuleAttenuatorFn<ModuleParams, SomeObject, SomeObject> | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type GlobalAttenuatorFn<Params extends [any, ...any[]] = [any, ...any[]]> = (params: Params, originalObject: Record<PropertyKey, any>, globalThis: Record<PropertyKey, any>) => void;
|
|
16
|
+
export type ModuleAttenuatorFn<Params extends [any, ...any[]] = [any, ...any[]], T = SomeObject, U = T> = (params: Params, ns: T) => U;
|
|
17
|
+
export type DeferredAttenuatorsProvider = {
|
|
18
|
+
import: (attenuatorSpecifier: string | null) => Promise<Attenuator>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Types required for policy enforcement.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable no-use-before-define */
|
|
6
|
+
|
|
7
|
+
import type { SomeObject } from './typescript.js';
|
|
8
|
+
|
|
9
|
+
export type PackageNamingKit = {
|
|
10
|
+
/** true if location is the entry compartment */
|
|
11
|
+
isEntry?: boolean | undefined;
|
|
12
|
+
name: string;
|
|
13
|
+
path: Array<string>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type Attenuator<
|
|
17
|
+
GlobalParams extends [any, ...any[]] = [any, ...any[]],
|
|
18
|
+
ModuleParams extends [any, ...any[]] = [any, ...any[]],
|
|
19
|
+
> = {
|
|
20
|
+
attenuateGlobals?: GlobalAttenuatorFn<GlobalParams> | undefined;
|
|
21
|
+
attenuateModule?:
|
|
22
|
+
| ModuleAttenuatorFn<ModuleParams, SomeObject, SomeObject>
|
|
23
|
+
| undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type GlobalAttenuatorFn<
|
|
27
|
+
Params extends [any, ...any[]] = [any, ...any[]],
|
|
28
|
+
> = (
|
|
29
|
+
params: Params,
|
|
30
|
+
originalObject: Record<PropertyKey, any>,
|
|
31
|
+
globalThis: Record<PropertyKey, any>,
|
|
32
|
+
) => void;
|
|
33
|
+
|
|
34
|
+
export type ModuleAttenuatorFn<
|
|
35
|
+
Params extends [any, ...any[]] = [any, ...any[]],
|
|
36
|
+
T = SomeObject,
|
|
37
|
+
U = T,
|
|
38
|
+
> = (params: Params, ns: T) => U;
|
|
39
|
+
|
|
40
|
+
export type DeferredAttenuatorsProvider = {
|
|
41
|
+
import: (attenuatorSpecifier: string | null) => Promise<Attenuator>;
|
|
42
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module The compartment mapper requires certain host capabilities.
|
|
3
|
+
* These are the platform-neutral types for those capabilities.
|
|
4
|
+
* For example, {@file node-powers.js} adapts Node.js how modules
|
|
5
|
+
* to various subsets of these capabilities.
|
|
6
|
+
*/
|
|
7
|
+
import type { SomeObject } from './typescript.js';
|
|
8
|
+
export type ReadPowers = {
|
|
9
|
+
canonical: CanonicalFn;
|
|
10
|
+
read: ReadFn;
|
|
11
|
+
maybeRead?: MaybeReadFn;
|
|
12
|
+
readNow?: ReadNowFn;
|
|
13
|
+
maybeReadNow?: MaybeReadNowFn;
|
|
14
|
+
computeSha512?: HashFn;
|
|
15
|
+
fileURLToPath?: FileURLToPathFn;
|
|
16
|
+
pathToFileURL?: PathToFileURLFn;
|
|
17
|
+
requireResolve?: RequireResolveFn;
|
|
18
|
+
isAbsolute?: IsAbsoluteFn;
|
|
19
|
+
};
|
|
20
|
+
export type MaybeReadPowers = ReadPowers & {
|
|
21
|
+
maybeRead: MaybeReadFn;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The extension of {@link ReadPowers} necessary for dynamic require support
|
|
25
|
+
*
|
|
26
|
+
* For a `ReadPowers` to be a `ReadNowPowers`:
|
|
27
|
+
*
|
|
28
|
+
* 1. It must be an object (not a {@link ReadFn})
|
|
29
|
+
* 2. Prop `maybeReadNow` is a function
|
|
30
|
+
* 3. Prop `fileURLToPath` is a function
|
|
31
|
+
* 4. Prop `isAbsolute` is a function
|
|
32
|
+
*/
|
|
33
|
+
export type ReadNowPowers = Omit<ReadPowers, ReadNowPowersProp> & Required<Pick<ReadPowers, ReadNowPowersProp>>;
|
|
34
|
+
/**
|
|
35
|
+
* These properties are necessary for dynamic require support
|
|
36
|
+
*/
|
|
37
|
+
export type ReadNowPowersProp = 'fileURLToPath' | 'isAbsolute' | 'maybeReadNow';
|
|
38
|
+
/**
|
|
39
|
+
* Returns a canonical URL for a given URL, following redirects or symbolic
|
|
40
|
+
* links if any exist along the path.
|
|
41
|
+
* Must return the given logical location if the real location does not exist.
|
|
42
|
+
*/
|
|
43
|
+
export type CanonicalFn = (location: string) => Promise<string>;
|
|
44
|
+
export type ReadFn = (location: string) => Promise<Uint8Array>;
|
|
45
|
+
/**
|
|
46
|
+
* A resolution of `undefined` indicates `ENOENT` or the equivalent.
|
|
47
|
+
*/
|
|
48
|
+
export type MaybeReadFn = (location: string) => Promise<Uint8Array | undefined>;
|
|
49
|
+
export type ReadNowFn = (location: string) => Uint8Array;
|
|
50
|
+
/**
|
|
51
|
+
* A resolution of `undefined` indicates `ENOENT` or the equivalent.
|
|
52
|
+
*/
|
|
53
|
+
export type MaybeReadNowFn = (location: string) => Uint8Array | undefined;
|
|
54
|
+
export type HashFn = (bytes: Uint8Array) => string;
|
|
55
|
+
export type FileURLToPathFn = (location: string | URL) => string;
|
|
56
|
+
export type PathToFileURLFn = (location: string) => URL;
|
|
57
|
+
export type RequireResolveFn = (fromLocation: string, specifier: string, options?: {
|
|
58
|
+
paths?: string[];
|
|
59
|
+
} | undefined) => any;
|
|
60
|
+
export type IsAbsoluteFn = (location: string) => boolean;
|
|
61
|
+
export type ArchiveReader = {
|
|
62
|
+
read: ReadFn;
|
|
63
|
+
};
|
|
64
|
+
export type HashPowers = {
|
|
65
|
+
read: ReadFn;
|
|
66
|
+
canonical: CanonicalFn;
|
|
67
|
+
computeSha512: HashFn;
|
|
68
|
+
};
|
|
69
|
+
export type WritePowers = {
|
|
70
|
+
write: WriteFn;
|
|
71
|
+
};
|
|
72
|
+
export type WriteFn = (location: string, bytes: Uint8Array) => Promise<void>;
|
|
73
|
+
export type ArchiveWriter = {
|
|
74
|
+
write: WriteFn;
|
|
75
|
+
snapshot: SnapshotFn;
|
|
76
|
+
};
|
|
77
|
+
export type SnapshotFn = () => Promise<Uint8Array>;
|
|
78
|
+
export type Application = {
|
|
79
|
+
import: ExecuteFn;
|
|
80
|
+
sha512?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
export type ExecuteFn = (options?: any) => Promise<SomeObject>;
|
|
83
|
+
//# sourceMappingURL=powers.d.ts.map
|