Skip to content

Commit

Permalink
chore(endomoat): just add a patch for now
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Feb 6, 2024
1 parent 77d9d25 commit 73ce1d0
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions patches/@endo+compartment-mapper+1.1.0.patch
@@ -0,0 +1,105 @@
diff --git a/node_modules/@endo/compartment-mapper/index.js b/node_modules/@endo/compartment-mapper/index.js
index acccf2c..8b0333e 100644
--- a/node_modules/@endo/compartment-mapper/index.js
+++ b/node_modules/@endo/compartment-mapper/index.js
@@ -6,6 +6,8 @@ export {
writeArchive,
mapLocation,
hashLocation,
+ loadCompartmentForArchive,
+ makeArchiveCompartmentMap,
} from './src/archive.js';
export {
parseArchive,
diff --git a/node_modules/@endo/compartment-mapper/src/archive.js b/node_modules/@endo/compartment-mapper/src/archive.js
index 17f10f7..686fc95 100644
--- a/node_modules/@endo/compartment-mapper/src/archive.js
+++ b/node_modules/@endo/compartment-mapper/src/archive.js
@@ -289,15 +289,18 @@ export const makeArchiveCompartmentMap = (compartmentMap, sources) => {
* @param {ReadFn | ReadPowers} powers
* @param {string} moduleLocation
* @param {ArchiveOptions} [options]
- * @returns {Promise<{sources: Sources, compartmentMapBytes: Uint8Array, sha512?: string}>}
+ * @returns {Promise<import('./types.js').LoadCompartmentForArchiveResult>}
*/
-const digestLocation = async (powers, moduleLocation, options) => {
+export const loadCompartmentForArchive = async (
+ powers,
+ moduleLocation,
+ options,
+) => {
const {
moduleTransforms,
modules: exitModules = {},
dev = false,
tags = new Set(),
- captureSourceLocation = undefined,
searchSuffixes = undefined,
commonDependencies = undefined,
importHook: exitModuleImportHook = undefined,
@@ -334,6 +337,8 @@ const digestLocation = async (powers, moduleLocation, options) => {
entry: { module: entryModuleSpecifier, compartment: entryCompartmentName },
} = compartmentMap;

+ // compartment map contains no source code
+
/** @type {Sources} */
const sources = Object.create(null);

@@ -361,7 +366,25 @@ const digestLocation = async (powers, moduleLocation, options) => {
parserForLanguage,
archiveOnly: true,
});
+
await compartment.load(entryModuleSpecifier);
+
+ return { attenuatorsCompartment, compartmentMap, sources, computeSha512 };
+};
+
+/**
+ * @param {ReadFn | ReadPowers} powers
+ * @param {string} moduleLocation
+ * @param {ArchiveOptions} [options]
+ * @returns {Promise<{sources: Sources, compartmentMapBytes: Uint8Array, sha512?: string}>}
+ */
+const digestLocation = async (powers, moduleLocation, options) => {
+ const { captureSourceLocation = undefined, policy = undefined } =
+ options || {};
+
+ const { attenuatorsCompartment, compartmentMap, sources, computeSha512 } =
+ await loadCompartmentForArchive(powers, moduleLocation, options);
+
if (policy) {
// retain all attenuators.
await Promise.all(
diff --git a/node_modules/@endo/compartment-mapper/src/types.js b/node_modules/@endo/compartment-mapper/src/types.js
index 9e8f605..f760124 100644
--- a/node_modules/@endo/compartment-mapper/src/types.js
+++ b/node_modules/@endo/compartment-mapper/src/types.js
@@ -504,3 +504,13 @@ export {};
* Any object. All objects. Not `null`, though.
* @typedef {Record<PropertyKey, any>} SomeObject
*/
+
+/**
+ * Return value of `loadCompartmentForArchive`.
+ *
+ * @typedef LoadCompartmentForArchiveResult
+ * @property {CompartmentMapDescriptor} compartmentMap
+ * @property {Sources} sources
+ * @property {Compartment} attenuatorsCompartment
+ * @property {(bytes: Uint8Array) => string} [computeSha512]
+ */
diff --git a/node_modules/@endo/compartment-mapper/types.d.ts b/node_modules/@endo/compartment-mapper/types.d.ts
index e480609..9b011ae 100644
--- a/node_modules/@endo/compartment-mapper/types.d.ts
+++ b/node_modules/@endo/compartment-mapper/types.d.ts
@@ -5,6 +5,8 @@ export {
writeArchive,
mapLocation,
hashLocation,
+ loadCompartmentForArchive,
+ makeArchiveCompartmentMap,
} from './src/archive.js';
export {
parseArchive,

0 comments on commit 73ce1d0

Please sign in to comment.