UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

57 lines (55 loc) • 2.03 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); let node_crypto = require("node:crypto"); //#region src/fingerprint.ts /** * The published pointer's version identity (atomic-deploys 08/12): a hash * over every slot's `pin` — cheap to compute (no version-manifest fetch), and * stable exactly when the deployed set is. Shared so the CLI and the host * compute the same identity for the same pointer. */ function pointerFingerprint(config) { const parts = []; const slot = (prefix, s) => { if (!s) return; const pin = s.pin; const pinPart = pin && typeof pin.manifest === "string" && typeof pin.integrity === "string" ? `${pin.manifest}:${pin.integrity}` : ""; const directPart = typeof s.integrity === "string" ? s.integrity : ""; parts.push(`${prefix}:${pinPart}:${directPart}`); }; for (const [key, entry] of Object.entries(config.app ?? {})) { slot(`app.${key}`, entry); slot(`app.${key}.ui`, entry.ui); } for (const [key, entry] of Object.entries(config.plugins ?? {})) { if (typeof entry === "string") { parts.push(`plugins.${key}:${entry}`); continue; } slot(`plugins.${key}`, entry); slot(`plugins.${key}.ui`, entry.ui); } return (0, node_crypto.createHash)("sha256").update(parts.join("|")).digest("hex").slice(0, 16); } /** Per-slot pin ids for display (slot → versioned manifest filename). */ function slotPins(config) { const pins = {}; const slot = (prefix, s) => { if (!s) return; const manifest = s.pin?.manifest; if (typeof manifest === "string") pins[prefix] = manifest; }; for (const [key, entry] of Object.entries(config.app ?? {})) { slot(`app.${key}`, entry); slot(`app.${key}.ui`, entry.ui); } for (const [key, entry] of Object.entries(config.plugins ?? {})) { if (typeof entry === "string") continue; slot(`plugins.${key}`, entry); slot(`plugins.${key}.ui`, entry.ui); } return pins; } //#endregion exports.pointerFingerprint = pointerFingerprint; exports.slotPins = slotPins; //# sourceMappingURL=fingerprint.cjs.map