fix(api-keys): validate api key charset

This commit is contained in:
Supra4E8C
2026-01-03 15:51:32 +08:00
parent fae4fb0fed
commit f5c1ef36ce
4 changed files with 15 additions and 0 deletions

View File

@@ -35,6 +35,14 @@ export function isValidApiKey(key: string): boolean {
return !/\s/.test(key);
}
/**
* 验证 API Key 字符集(仅允许 ASCII 可见字符)
*/
export function isValidApiKeyCharset(key: string): boolean {
if (!key) return false;
return /^[\x21-\x7E]+$/.test(key);
}
/**
* 验证 JSON 格式
*/