{"version":3,"file":"fingerprint.cjs","names":["createHash"],"sources":["../../../src/services/registry/fingerprint.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { BosConfig, RuntimeConfig } from \"../../types\";\nimport { walkRemotes } from \"../remotes\";\n\n/**\n * The registry's fingerprint module — every identity hash lives here so the\n * planes can't drift apart:\n *\n * - `pointerFingerprint` — THE composition identity: a hash over every\n *   remote's pin coordinates (digest manifest + integrity, or the direct\n *   entry integrity). It is the lockfile's fingerprint (ADR 0042), the\n *   watch's change-detection hash, and what deployment records name.\n * - `deploymentFingerprint` — the serving-generation payload hash\n *   (atomic-deploys 10): entryUrl + entry integrity (+ SSR integrity) per\n *   remote, stamped into the client config as the soft-refresh signal and\n *   used by the host's adopt comparison for derived generations. Derived\n *   from the same remotes AFTER entry resolution, so it changes whenever\n *   the composition changes — plus when only resolved entry coordinates\n *   change. Semantic merge of the two hashes is a recorded future seam:\n *   both sides of every existing comparison must move together.\n */\n\n/**\n * The published pointer's version identity (atomic-deploys 08/12): a hash\n * over every remote's `digest` — cheap to compute (no version-manifest\n * fetch), and stable exactly when the deployed set is. Shared so the CLI and\n * the host compute the same identity for the same pointer.\n */\nexport function pointerFingerprint(config: BosConfig): string {\n  const parts: Array<string> = [];\n  walkRemotes(config as unknown as Record<string, unknown>, ({ remote, entry, isPluginRef }) => {\n    if (isPluginRef) {\n      parts.push(`${remote}:${entry as string}`);\n      return;\n    }\n    const s = entry as { digest?: unknown; integrity?: unknown } | undefined;\n    if (!s) return;\n    const digest = s.digest as { manifest?: unknown; integrity?: unknown } | undefined;\n    const digestPart =\n      digest && typeof digest.manifest === \"string\" && typeof digest.integrity === \"string\"\n        ? `${digest.manifest}:${digest.integrity}`\n        : \"\";\n    const directPart = typeof s.integrity === \"string\" ? s.integrity : \"\";\n    parts.push(`${remote}:${digestPart}:${directPart}`);\n  });\n  return createHash(\"sha256\").update(parts.join(\"|\")).digest(\"hex\").slice(0, 16);\n}\n\n/** Per-remote digest ids for display (remote → versioned manifest filename). */\nexport function remoteDigests(config: BosConfig): Record<string, string> {\n  const digests: Record<string, string> = {};\n  walkRemotes(config as unknown as Record<string, unknown>, ({ remote, entry, isPluginRef }) => {\n    if (isPluginRef) return;\n    const s = entry as { digest?: unknown } | undefined;\n    if (!s) return;\n    const manifest = (s.digest as { manifest?: unknown } | undefined)?.manifest;\n    if (typeof manifest === \"string\") digests[remote] = manifest;\n  });\n  return digests;\n}\n\n/**\n * The serving-generation payload hash — see the module docstring for its\n * identity contract versus `pointerFingerprint`.\n */\nexport function deploymentFingerprint(config: RuntimeConfig): string {\n  const parts: Array<string> = [];\n  const remote = (\n    prefix: string,\n    s: { entryUrl?: string; integrity?: string; ssrIntegrity?: string } | undefined,\n  ) => {\n    if (!s) return;\n    parts.push(`${prefix}:${s.entryUrl ?? \"\"}:${s.integrity ?? \"\"}:${s.ssrIntegrity ?? \"\"}`);\n  };\n  remote(\"ui\", config.ui);\n  remote(\"api\", config.api);\n  remote(\"auth\", config.auth);\n  for (const [key, plugin] of Object.entries(config.plugins ?? {})) {\n    remote(`plugin.${key}`, plugin);\n    remote(`plugin.${key}.ui`, plugin.ui);\n  }\n  return createHash(\"sha256\").update(parts.join(\"|\")).digest(\"hex\").slice(0, 16);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,mBAAmB,QAA2B;CAC5D,MAAM,QAAuB,CAAC;CAC9B,4BAAY,SAA+C,EAAE,QAAQ,OAAO,kBAAkB;EAC5F,IAAI,aAAa;GACf,MAAM,KAAK,GAAG,OAAO,GAAG,OAAiB;GACzC;EACF;EACA,MAAM,IAAI;EACV,IAAI,CAAC,GAAG;EACR,MAAM,SAAS,EAAE;EACjB,MAAM,aACJ,UAAU,OAAO,OAAO,aAAa,YAAY,OAAO,OAAO,cAAc,WACzE,GAAG,OAAO,SAAS,GAAG,OAAO,cAC7B;EACN,MAAM,aAAa,OAAO,EAAE,cAAc,WAAW,EAAE,YAAY;EACnE,MAAM,KA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