openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
33 lines (32 loc) • 1.04 kB
JavaScript
import { t as stableStringify } from "./stable-stringify-vqde_3tT.mjs";
import { n as sha256Hex } from "./node-crypto-B6yuTjmm.mjs";
import fs from "node:fs";
import { safeStatSync } from "@openclaw/fs-safe/path";
//#region src/plugins/installed-plugin-index-hash.ts
/** Hashes JSON-serializable data with SHA-256. */
function hashJson(e) {
return sha256Hex(JSON.stringify(e));
}
/** Hashes JSON-like data independently of object property insertion order. */
function hashStableJson(e) {
return sha256Hex(stableStringify(e));
}
/** Hashes a file, returning undefined when it cannot be read. */
function safeHashFile(e) {
try {
return sha256Hex(fs.readFileSync(e));
} catch {
return;
}
}
/** Reads a safe file signature for installed plugin index freshness checks. */
function safeFileSignature(e) {
const t = safeStatSync(e);
return t?.isFile() ? {
size: t.size,
mtimeMs: t.mtimeMs,
ctimeMs: t.ctimeMs
} : void 0;
}
//#endregion
export { safeHashFile as i, hashStableJson as n, safeFileSignature as r, hashJson as t };