import { apiFetchJSON } from '@/utils/apiClient'; export interface APITokenRecord { id: string; name: string; prefix: string; suffix: string; createdAt: string; lastUsedAt?: string; scopes?: string[]; } export interface CreateAPITokenResponse { token: string; record: APITokenRecord; } export class SecurityAPI { static async listTokens(): Promise { const response = await apiFetchJSON<{ tokens: APITokenRecord[] }>('/api/security/tokens'); return response.tokens ?? []; } static async createToken(name?: string, scopes?: string[]): Promise { const payload: Record = {}; if (name) { payload.name = name; } if (scopes) { payload.scopes = scopes; } return apiFetchJSON('/api/security/tokens', { method: 'POST', body: JSON.stringify(payload), }); } static async deleteToken(id: string): Promise { await apiFetchJSON(`/api/security/tokens/${id}`, { method: 'DELETE', }); } }