claude-code-best/packages/remote-control-server/src/auth/api-key.ts
claude-code-best 2da6514095
feat: 支持自托管的 remote-control-server (#214)
* feat: 支持自托管的 remote-control-server (#214)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-04-09 17:40:50 +08:00

13 lines
372 B
TypeScript

import { createHash } from "node:crypto";
import { config } from "../config";
/** Validate a raw API key token string */
export function validateApiKey(token: string | undefined): boolean {
if (!token) return false;
return config.apiKeys.includes(token);
}
export function hashApiKey(key: string): string {
return createHash("sha256").update(key).digest("hex");
}