298a7fa9de
Audit D2/D3/D4/D5: all four ApiTab buttons were handler-less and the fields were hardcoded. Adds api/apiKeys.ts + api/webhooks.ts modules and rewires ApiTab: loads the api-key prefix + webhook settings on mount; Copy -> clipboard + snackbar; Regenerate -> confirm dialog -> POST regenerate (full key shown once); Save Webhook -> PUT webhook-settings; Test Webhook -> POST test with the result in a snackbar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
911 B
TypeScript
33 lines
911 B
TypeScript
import { apiClient, ensureCsrfCookie } from './client';
|
|
|
|
/**
|
|
* API-ключи тенанта (audit D2/D3). Backend: ApiKeyController.
|
|
* Полный ключ доступен только в ответе regenerateApiKey().
|
|
*/
|
|
export interface ApiKeyInfo {
|
|
id: number;
|
|
name: string;
|
|
key_prefix: string;
|
|
last_used_at: string | null;
|
|
expires_at: string | null;
|
|
created_at: string | null;
|
|
}
|
|
|
|
export interface RegeneratedApiKey {
|
|
id: number;
|
|
name: string;
|
|
key: string;
|
|
key_prefix: string;
|
|
}
|
|
|
|
export async function listApiKeys(): Promise<ApiKeyInfo[]> {
|
|
const { data } = await apiClient.get<{ data: ApiKeyInfo[] }>('/api/api-keys');
|
|
return data.data;
|
|
}
|
|
|
|
export async function regenerateApiKey(): Promise<RegeneratedApiKey> {
|
|
await ensureCsrfCookie();
|
|
const { data } = await apiClient.post<RegeneratedApiKey>('/api/api-keys/regenerate');
|
|
return data;
|
|
}
|