(tokens: { id: string; token: string }[])
| 68 | let tokenRoundRobinIndex = 0; |
| 69 | |
| 70 | function selectTokenFromPool(tokens: { id: string; token: string }[]): string | null { |
| 71 | if (tokens.length === 0) return null; |
| 72 | const idx = tokenRoundRobinIndex % tokens.length; |
| 73 | tokenRoundRobinIndex++; |
| 74 | return tokens[idx].token; |
| 75 | } |
| 76 | |
| 77 | async function authenticate(request: Request, env: Env): Promise<string> { |
| 78 | const apiKeys = extractAPIKeys(request); |