@endo/compartment-mapper 1.6.2 → 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 +84 -0
- package/src/generic-graph.d.ts.map +1 -0
- package/src/generic-graph.js +356 -0
- 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 +156 -71
- 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/json.d.ts +1 -1
- package/src/json.d.ts.map +1 -1
- package/src/json.js +10 -3
- 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 +5 -3
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +648 -245
- package/src/node-powers.d.ts +6 -5
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +11 -8
- 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 +173 -29
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +221 -27
- package/src/types/generic-graph.d.ts +17 -0
- package/src/types/generic-graph.d.ts.map +1 -0
- package/src/types/generic-graph.ts +17 -0
- package/src/types/internal.d.ts +24 -42
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +52 -50
- package/src/types/node-modules.d.ts +101 -17
- package/src/types/node-modules.d.ts.map +1 -1
- package/src/types/node-modules.ts +142 -17
- 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/powers.d.ts +38 -11
- package/src/types/powers.d.ts.map +1 -1
- package/src/types/powers.ts +50 -17
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -1
- package/src/types/typescript.ts +37 -1
package/src/node-powers.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export function makeReadNowPowers({ fs, url, crypto, path, }: {
|
|
|
3
3
|
url?: UrlInterface | undefined;
|
|
4
4
|
crypto?: CryptoInterface | undefined;
|
|
5
5
|
path?: PathInterface | undefined;
|
|
6
|
-
}):
|
|
6
|
+
}): ReadNowPowers<FileUrlString>;
|
|
7
7
|
/**
|
|
8
8
|
* The implementation of `makeReadPowers` and the deprecated
|
|
9
9
|
* `makeNodeReadPowers` handles the case when the `url` power is not provided,
|
|
@@ -14,14 +14,14 @@ export function makeReadNowPowers({ fs, url, crypto, path, }: {
|
|
|
14
14
|
* @param {UrlInterface} [args.url]
|
|
15
15
|
* @param {CryptoInterface} [args.crypto]
|
|
16
16
|
* @param {PathInterface} [args.path]
|
|
17
|
-
* @returns {MaybeReadPowers}
|
|
17
|
+
* @returns {MaybeReadPowers<FileUrlString>}
|
|
18
18
|
*/
|
|
19
19
|
export function makeReadPowers({ fs, url, crypto, path, }: {
|
|
20
20
|
fs: FsInterface;
|
|
21
21
|
url?: UrlInterface | undefined;
|
|
22
22
|
crypto?: CryptoInterface | undefined;
|
|
23
23
|
path?: PathInterface | undefined;
|
|
24
|
-
}): MaybeReadPowers
|
|
24
|
+
}): MaybeReadPowers<FileUrlString>;
|
|
25
25
|
/**
|
|
26
26
|
* The implementation of `makeWritePowers` and the deprecated
|
|
27
27
|
* `makeNodeWritePowers` handles the case when the `url` power is not provided,
|
|
@@ -37,14 +37,15 @@ export function makeWritePowers({ fs, url }: {
|
|
|
37
37
|
}): {
|
|
38
38
|
write: (location: string, data: Uint8Array) => Promise<void>;
|
|
39
39
|
};
|
|
40
|
-
export function makeNodeReadPowers(fs: FsInterface, crypto?: CryptoInterface): ReadPowers
|
|
40
|
+
export function makeNodeReadPowers(fs: FsInterface, crypto?: CryptoInterface): ReadPowers<FileUrlString>;
|
|
41
41
|
export function makeNodeWritePowers(fs: FsInterface): WritePowers;
|
|
42
42
|
import type { FsInterface } from './types/node-powers.js';
|
|
43
43
|
import type { UrlInterface } from './types/node-powers.js';
|
|
44
44
|
import type { CryptoInterface } from './types/node-powers.js';
|
|
45
45
|
import type { PathInterface } from './types/node-powers.js';
|
|
46
|
-
import type {
|
|
46
|
+
import type { FileUrlString } from './types/external.js';
|
|
47
47
|
import type { ReadNowPowers } from './types/powers.js';
|
|
48
|
+
import type { MaybeReadPowers } from './types/powers.js';
|
|
48
49
|
import type { ReadPowers } from './types/powers.js';
|
|
49
50
|
import type { WritePowers } from './types/powers.js';
|
|
50
51
|
//# sourceMappingURL=node-powers.d.ts.map
|
package/src/node-powers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-powers.d.ts","sourceRoot":"","sources":["node-powers.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-powers.d.ts","sourceRoot":"","sources":["node-powers.js"],"names":[],"mappings":"AA+LO,8DANJ;IAA0B,EAAE,EAApB,WAAW;IACS,GAAG;IACA,MAAM;IACR,IAAI;CACjC,GAAU,cAAc,aAAa,CAAC,CAoCxC;AApKD;;;;;;;;;;;GAWG;AACH,2DANG;IAA0B,EAAE,EAApB,WAAW;IACS,GAAG;IACA,MAAM;IACR,IAAI;CACjC,GAAU,gBAAgB,aAAa,CAAC,CA4G1C;AAgDD;;;;;;;;GAQG;AACH,6CAHG;IAA0B,EAAE,EAApB,WAAW;IACS,GAAG;CAAC;sBAOtB,MAAM,QACN,UAAU;EAYtB;AA2BM,uCALI,WAAW,WACX,eAAe,GACb,WAAW,aAAa,CAAC,CAKrC;AAWM,wCAJI,WAAW,GACT,WAAW,CAKvB;iCAvRS,wBAAwB;kCAAxB,wBAAwB;qCAAxB,wBAAwB;mCAAxB,wBAAwB;mCACF,qBAAqB;mCAe3C,mBAAmB;qCAAnB,mBAAmB;gCAAnB,mBAAmB;iCAAnB,mBAAmB"}
|
package/src/node-powers.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* PathInterface,
|
|
17
17
|
* UrlInterface,
|
|
18
18
|
* } from './types/node-powers.js'
|
|
19
|
+
* @import {FileUrlString} from './types/external.js'
|
|
19
20
|
* @import {
|
|
20
21
|
* CanonicalFn,
|
|
21
22
|
* FileURLToPathFn,
|
|
@@ -68,7 +69,7 @@ const fakeIsAbsolute = () => false;
|
|
|
68
69
|
* @param {UrlInterface} [args.url]
|
|
69
70
|
* @param {CryptoInterface} [args.crypto]
|
|
70
71
|
* @param {PathInterface} [args.path]
|
|
71
|
-
* @returns {MaybeReadPowers}
|
|
72
|
+
* @returns {MaybeReadPowers<FileUrlString>}
|
|
72
73
|
*/
|
|
73
74
|
const makeReadPowersSloppy = ({
|
|
74
75
|
fs,
|
|
@@ -125,9 +126,9 @@ const makeReadPowersSloppy = ({
|
|
|
125
126
|
|
|
126
127
|
/**
|
|
127
128
|
* There are two special things about the canonical function the compartment
|
|
128
|
-
* mapper needs. It needs to use URL
|
|
129
|
+
* mapper needs. It needs to use URL's instead of posix paths to avoid
|
|
129
130
|
* bundling up a bunch of cruft when we port this around. It needs to use
|
|
130
|
-
* promises. URL
|
|
131
|
+
* promises. URL's can and must logically distinguish a directory from a
|
|
131
132
|
* file, by the final slash, whereas paths must never have a final slash
|
|
132
133
|
* because that implies a blank file name within the enclosing directory. The
|
|
133
134
|
* canonical function must also return the logical path instead of the real
|
|
@@ -136,7 +137,7 @@ const makeReadPowersSloppy = ({
|
|
|
136
137
|
* non-existent directory on the next step after canonicalizing the package
|
|
137
138
|
* location.
|
|
138
139
|
*
|
|
139
|
-
* @type {CanonicalFn}
|
|
140
|
+
* @type {CanonicalFn<FileUrlString>}
|
|
140
141
|
*/
|
|
141
142
|
const canonical = async location => {
|
|
142
143
|
await null;
|
|
@@ -145,10 +146,12 @@ const makeReadPowersSloppy = ({
|
|
|
145
146
|
const realPath = await fs.promises.realpath(
|
|
146
147
|
fileURLToPath(location).replace(/\/$/, ''),
|
|
147
148
|
);
|
|
148
|
-
return
|
|
149
|
+
return /** @type {FileUrlString} */ (
|
|
150
|
+
`${pathToFileURL(realPath).href}/`
|
|
151
|
+
);
|
|
149
152
|
} else {
|
|
150
153
|
const realPath = await fs.promises.realpath(fileURLToPath(location));
|
|
151
|
-
return pathToFileURL(realPath).href;
|
|
154
|
+
return /** @type {FileUrlString} */ (pathToFileURL(realPath).href);
|
|
152
155
|
}
|
|
153
156
|
} catch {
|
|
154
157
|
return location;
|
|
@@ -184,7 +187,7 @@ const makeReadPowersSloppy = ({
|
|
|
184
187
|
* @param {UrlInterface} [args.url]
|
|
185
188
|
* @param {CryptoInterface} [args.crypto]
|
|
186
189
|
* @param {PathInterface} [args.path]
|
|
187
|
-
* @returns {
|
|
190
|
+
* @returns {ReadNowPowers<FileUrlString>}
|
|
188
191
|
*/
|
|
189
192
|
export const makeReadNowPowers = ({
|
|
190
193
|
fs,
|
|
@@ -273,7 +276,7 @@ export const makeWritePowers = makeWritePowersSloppy;
|
|
|
273
276
|
*
|
|
274
277
|
* @param {FsInterface} fs
|
|
275
278
|
* @param {CryptoInterface} [crypto]
|
|
276
|
-
* @returns {ReadPowers}
|
|
279
|
+
* @returns {ReadPowers<FileUrlString>}
|
|
277
280
|
* @deprecated
|
|
278
281
|
*/
|
|
279
282
|
export const makeNodeReadPowers = (fs, crypto = undefined) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AA0CO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,
|
|
1
|
+
{"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AA0CO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,CAiJH;gCAlOqC,YAAY;4BAAZ,YAAY"}
|
|
@@ -219,7 +219,9 @@ export const wrap = ({
|
|
|
219
219
|
}
|
|
220
220
|
} else {
|
|
221
221
|
for (const prop of redefined) {
|
|
222
|
-
|
|
222
|
+
if (prop !== 'default') {
|
|
223
|
+
moduleEnvironmentRecord[prop] = moduleEnvironmentRecord.default[prop];
|
|
224
|
+
}
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
227
|
};
|
package/src/policy-format.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Const string to identify the internal attenuators compartment
|
|
3
|
+
*/
|
|
4
|
+
export const ATTENUATORS_COMPARTMENT: "<ATTENUATORS>";
|
|
5
|
+
export const ENTRY_COMPARTMENT: "$root$";
|
|
6
|
+
export function generateCanonicalName({ isEntry, name, path }: PackageNamingKit): string;
|
|
1
7
|
export const WILDCARD_POLICY_VALUE: "any";
|
|
2
|
-
export function policyLookupHelper(packagePolicy:
|
|
3
|
-
export function isAllowingEverything(policyValue: unknown): policyValue is
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
export function policyLookupHelper(packagePolicy: PackagePolicy, field: PolicyEnforcementField, canonicalName: string): boolean | AttenuationDefinition;
|
|
9
|
+
export function isAllowingEverything(policyValue: unknown): policyValue is WildcardPolicy;
|
|
10
|
+
/**
|
|
11
|
+
* Type guard for `AttenuationDefinition`
|
|
12
|
+
*/
|
|
13
|
+
export const isAttenuationDefinition: (value: unknown) => value is FullAttenuationDefinition | ImplicitAttenuationDefinition;
|
|
14
|
+
export function getAttenuatorFromDefinition(attenuationDefinition: AttenuationDefinition): UnifiedAttenuationDefinition;
|
|
15
|
+
export function assertPackagePolicy(allegedPackagePolicy: unknown, keypath: string, url?: string): asserts allegedPackagePolicy is SomePackagePolicy | undefined;
|
|
7
16
|
export function assertPolicy(allegedPolicy: unknown): asserts allegedPolicy is (SomePolicy | undefined);
|
|
17
|
+
import type { PackageNamingKit } from './types.js';
|
|
18
|
+
import type { PackagePolicy } from './types.js';
|
|
19
|
+
import type { PolicyEnforcementField } from './types.js';
|
|
20
|
+
import type { AttenuationDefinition } from './types.js';
|
|
21
|
+
import type { WildcardPolicy } from './types.js';
|
|
22
|
+
import type { FullAttenuationDefinition } from './types.js';
|
|
23
|
+
import type { ImplicitAttenuationDefinition } from './types.js';
|
|
24
|
+
import type { UnifiedAttenuationDefinition } from './types.js';
|
|
8
25
|
import type { SomePackagePolicy } from './types.js';
|
|
9
26
|
import type { SomePolicy } from './types.js';
|
|
10
27
|
//# sourceMappingURL=policy-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-format.d.ts","sourceRoot":"","sources":["policy-format.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy-format.d.ts","sourceRoot":"","sources":["policy-format.js"],"names":[],"mappings":"AA8BA;;GAEG;AACH,sCAAuC,eAAe,CAAC;AAEvD,gCAAiC,QAAQ,CAAC;AAmBnC,+DAJI,gBAAgB,GACd,MAAM,CAWlB;AAED,oCAAqC,KAAK,CAAC;AAqEpC,kDALI,aAAa,SACb,sBAAsB,iBACtB,MAAM,GACJ,OAAO,GAAG,qBAAqB,CA2B3C;AAQM,kDAHI,OAAO,GACL,WAAW,IAAI,cAAc,CAGH;AA6EvC;;GAEG;AACH,6HAGG;AAQI,mEAHI,qBAAqB,GACnB,4BAA4B,CAwBxC;AAqGM,0DALI,OAAO,WACP,MAAM,QACN,MAAM,GACJ,QAAQ,oBAAoB,IAAI,iBAAiB,GAAC,SAAS,CA0DvE;AAUM,4CAHI,OAAO,GACL,QAAQ,aAAa,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAiC7D;sCAvcQ,YAAY;mCAAZ,YAAY;4CAAZ,YAAY;2CAAZ,YAAY;oCAAZ,YAAY;+CAAZ,YAAY;mDAAZ,YAAY;kDAAZ,YAAY;uCAAZ,YAAY;gCAAZ,YAAY"}
|