diff --git a/patches/@endo+compartment-mapper+1.1.0.patch b/patches/@endo+compartment-mapper+1.1.0.patch new file mode 100644 index 0000000000..709d8aefde --- /dev/null +++ b/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} + */ +-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} 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,