feat: bootstrap commercial AI drama platform

This commit is contained in:
xz
2026-08-24 10:24:34 +08:00
commit ffb27d845b
100 changed files with 35314 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { createHash, randomBytes } from "node:crypto";
const KEY_PREFIX = "local-";
export function hashApiClientKey(value) {
return createHash("sha256").update(String(value || "")).digest("hex");
}
export function issueApiClientKey() {
const secret = `${KEY_PREFIX}${randomBytes(24).toString("base64url")}`;
return {
secret,
hash: hashApiClientKey(secret),
prefix: secret.slice(0, 12)
};
}
export function apiClientStorageMarker(hash) {
return `hash:${String(hash || "")}`;
}
export function apiClientPreview(prefix) {
const value = String(prefix || "");
return value ? `${value}****` : "仅创建或轮换时显示一次";
}