MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / addAccountByKey

Function addAccountByKey

src/auth.js:402–435  ·  view source on GitHub ↗
(apiKey, label = '', apiServerUrl = '')

Source from the content-addressed store, hash-verified

400 * Add account via API key.
401 */
402export function addAccountByKey(apiKey, label = '', apiServerUrl = '') {
403 const existing = accounts.find(a => a.apiKey === apiKey);
404 if (existing) {
405 if (apiServerUrl && !existing.apiServerUrl) {
406 existing.apiServerUrl = apiServerUrl;
407 saveAccounts();
408 }
409 return existing;
410 }
411
412 const account = {
413 id: randomUUID().slice(0, 8),
414 email: label || `key-${apiKey.slice(0, 8)}`,
415 apiKey,
416 apiServerUrl: apiServerUrl || '',
417 method: 'api_key',
418 status: 'active',
419 lastUsed: 0,
420 errorCount: 0,
421 refreshToken: '',
422 expiresAt: 0,
423 refreshTimer: null,
424 addedAt: Date.now(),
425 tier: 'unknown',
426 capabilities: {},
427 lastProbed: 0,
428 blockedModels: [],
429 };
430 account.credits = null;
431 accounts.push(account);
432 saveAccounts();
433 log.info(`Account added: ${safeAccountRef(account)} [api_key]`);
434 return account;
435}
436
437/**
438 * Add account via auth token.

Callers 15

mkFunction · 0.90
addTestAccountFunction · 0.90
addTestAccountFunction · 0.90
mkAccountFunction · 0.90
mkFunction · 0.90
mkFunction · 0.90
routeFunction · 0.90
processWindsurfLoginFunction · 0.90

Calls 3

safeAccountRefFunction · 0.90
saveAccountsFunction · 0.85
pushMethod · 0.80

Tested by 6

mkFunction · 0.72
addTestAccountFunction · 0.72
addTestAccountFunction · 0.72
mkAccountFunction · 0.72
mkFunction · 0.72
mkFunction · 0.72