diff --git a/packages/daemon/src/daemon.js b/packages/daemon/src/daemon.js index a06c313490..96bdd71e18 100644 --- a/packages/daemon/src/daemon.js +++ b/packages/daemon/src/daemon.js @@ -584,15 +584,6 @@ const makeDaemonCore = async ( }); }; - /** - * @param {import('./types.js').Formula} formula - * @param {string} formulaType - */ - const provideValueForFormula = async (formula, formulaType) => { - const formulaNumber = await randomHex512(); - return provideValueForNumberedFormula(formulaType, formulaNumber, formula); - }; - /** @type {import('./types.js').ProvideControllerForFormulaIdentifier} */ const provideControllerForFormulaIdentifier = formulaIdentifier => { const { type: formulaType, number: formulaNumber } = @@ -873,6 +864,25 @@ const makeDaemonCore = async ( return provideValueForNumberedFormula(formula.type, formulaNumber, formula); }; + /** + * @param {string} powersFormulaIdentifier + * @param {string} bundleFormulaIdentifier + * @returns {Promise<{ formulaIdentifier: string, value: unknown }>} + */ + const incarnateWebBundle = async ( + powersFormulaIdentifier, + bundleFormulaIdentifier, + ) => { + const formulaNumber = await randomHex512(); + /** @type {import('./types.js').WebBundleFormula} */ + const formula = { + type: 'web-bundle', + powers: powersFormulaIdentifier, + bundle: bundleFormulaIdentifier, + }; + return provideValueForNumberedFormula(formula.type, formulaNumber, formula); + }; + /** * @param {string} [specifiedFormulaNumber] * @returns {Promise<{ formulaIdentifier: string, value: import('./types').EndoBootstrap }>} @@ -916,18 +926,16 @@ const makeDaemonCore = async ( const makeIdentifiedHost = makeHostMaker({ provideValueForFormulaIdentifier, - provideValueForFormula, - provideValueForNumberedFormula, provideControllerForFormulaIdentifier, incarnateHost, incarnateGuest, incarnateEval, incarnateUnconfined, incarnateBundle, + incarnateWebBundle, incarnateHandle, storeReaderRef, randomHex512, - makeSha512, makeMailbox, }); diff --git a/packages/daemon/src/host.js b/packages/daemon/src/host.js index 641e43daa6..e72b58107e 100644 --- a/packages/daemon/src/host.js +++ b/packages/daemon/src/host.js @@ -7,17 +7,15 @@ const { quote: q } = assert; export const makeHostMaker = ({ provideValueForFormulaIdentifier, - provideValueForFormula, - provideValueForNumberedFormula, provideControllerForFormulaIdentifier, incarnateHost, incarnateGuest, incarnateEval, incarnateUnconfined, incarnateBundle, + incarnateWebBundle, incarnateHandle, storeReaderRef, - makeSha512, randomHex512, makeMailbox, }) => { @@ -452,24 +450,10 @@ export const makeHostMaker = ({ powersName, ); - const digester = makeSha512(); - digester.updateText( - `${bundleFormulaIdentifier},${powersFormulaIdentifier}`, - ); - const formulaNumber = digester.digestHex().slice(32, 64); - - const formula = { - type: 'web-bundle', - bundle: bundleFormulaIdentifier, - powers: powersFormulaIdentifier, - }; - // Behold, recursion: - // eslint-disable-next-line no-use-before-define - const { value, formulaIdentifier } = await provideValueForNumberedFormula( - 'web-bundle', - formulaNumber, - formula, + const { value, formulaIdentifier } = await incarnateWebBundle( + powersFormulaIdentifier, + bundleFormulaIdentifier, ); if (webPageName !== undefined) {