Added multi-key support

This commit is contained in:
2026-01-17 16:12:41 -05:00
parent 3eb9863c3e
commit 3bb350f3cf
6 changed files with 244 additions and 25 deletions

View File

@@ -15,6 +15,8 @@ const DEFAULT_TASKS = [
const DEFAULT_SETTINGS = {
apiKey: "",
apiKeys: [],
activeApiKeyId: "",
apiBaseUrl: "https://api.openai.com/v1",
apiKeyHeader: "Authorization",
apiKeyPrefix: "Bearer ",
@@ -80,6 +82,17 @@ chrome.runtime.onInstalled.addListener(async () => {
if (missing) updates[key] = value;
}
const hasApiKeys =
Array.isArray(stored.apiKeys) && stored.apiKeys.length > 0;
if (!hasApiKeys && stored.apiKey) {
const id = crypto?.randomUUID
? crypto.randomUUID()
: `key-${Date.now()}-${Math.random().toString(16).slice(2, 8)}`;
updates.apiKeys = [{ id, name: "Default", key: stored.apiKey }];
updates.activeApiKeyId = id;
}
if (Object.keys(updates).length) {
await chrome.storage.local.set(updates);
}