Files
codexbar-mobile/lib/claudeCredentials.ts
T
space 2c31be11c4
CodexBar Mobile Build / build-android (push) Successful in 21m9s
CodexBar Mobile Build / release (push) Successful in 11s
by codex: feat. General Improvements
2026-06-25 14:27:58 +02:00

20 lines
630 B
TypeScript

const CLAUDE_SESSION_KEY_PATTERN = /^sk-ant-[A-Za-z0-9_-]+$/;
export function validateClaudeSessionKey(value: string): string | null {
const key = value.trim();
if (!key.startsWith("sk-ant-")) {
return "Session key must start with sk-ant-";
}
if (key.length <= 40) {
return "Session key looks too short. Paste the complete cookie value.";
}
if (!CLAUDE_SESSION_KEY_PATTERN.test(key)) {
return "Session key contains unexpected characters. Check the pasted value.";
}
return null;
}
export function isClaudeSessionKeyValid(value: string): boolean {
return validateClaudeSessionKey(value) === null;
}