everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
44 lines (42 loc) • 1.66 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_config_slots = require('../config-slots.cjs');
let node_crypto = require("node:crypto");
//#region src/services/registry/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 = [];
require_config_slots.walkConfigSlots(config, ({ slot, entry, isPluginRef }) => {
if (isPluginRef) {
parts.push(`${slot}:${entry}`);
return;
}
const s = entry;
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(`${slot}:${pinPart}:${directPart}`);
});
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 = {};
require_config_slots.walkConfigSlots(config, ({ slot, entry, isPluginRef }) => {
if (isPluginRef) return;
const s = entry;
if (!s) return;
const manifest = s.pin?.manifest;
if (typeof manifest === "string") pins[slot] = manifest;
});
return pins;
}
//#endregion
exports.pointerFingerprint = pointerFingerprint;
exports.slotPins = slotPins;
//# sourceMappingURL=fingerprint.cjs.map