mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 22:13:59 +01:00
Reviewed and verified at 9b4acc456d.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
10 lines
656 B
TypeScript
10 lines
656 B
TypeScript
import { createHash } from "node:crypto";
|
|
import type { PaperclipPluginManifestV1 } from "@paperclipai/shared";
|
|
export interface IdlePluginCatalogEntry { pluginId: string; manifestGeneration: string }
|
|
export function pluginIdleManifestGeneration(manifest: PaperclipPluginManifestV1): string {
|
|
const ordered = (value: unknown): unknown => Array.isArray(value) ? value.map(ordered)
|
|
: value !== null && typeof value === "object"
|
|
? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, v]) => [key, ordered(v)])) : value;
|
|
return createHash("sha256").update(JSON.stringify(ordered(manifest))).digest("hex");
|
|
}
|