Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/router/apiKeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export class ApiKeyManager {
* Register an API key for a provider
*/
public registerKey(provider: string, apiKey: string): void {
if (!provider || typeof provider !== 'string' || provider.trim() === '') {
if (!provider || typeof provider !== 'string' || provider.trim().length === 0) {
throw new Error('TokenFirewall: Provider must be a non-empty string');
}
if (!apiKey || typeof apiKey !== 'string' || apiKey.trim() === '') {
if (!apiKey || typeof apiKey !== 'string' || apiKey.trim().length === 0) {
throw new Error(`TokenFirewall: Invalid API key for provider "${provider}"`);
}
this.keys.set(provider.toLowerCase(), apiKey);
Expand Down
2 changes: 1 addition & 1 deletion src/router/modelRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class ModelRouter {

// Validate each fallback model name
for (const fallbackModel of fallbacks) {
if (typeof fallbackModel !== 'string' || fallbackModel.trim() === '') {
if (typeof fallbackModel !== 'string' || fallbackModel.trim().length === 0) {
throw new Error(
`TokenFirewall Router: fallbackMap for "${model}" contains invalid model name (empty or whitespace)`
);
Expand Down