Split V5 dashboard behavior into domain controllers and policies, add agent token rotation/revocation, status reconciliation jobs, ingress firewall syncing, and canvas connection APIs. Add migrations for V5 status tracking, server capabilities, resource connection aliases, and revoked agent tokens.
24 lines
780 B
TypeScript
24 lines
780 B
TypeScript
import { csrfToken } from '@/lib/csrf';
|
|
|
|
type CanvasRequestOptions = {
|
|
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
body?: unknown;
|
|
};
|
|
|
|
/**
|
|
* Shared JSON fetch for the canvas endpoints: same-origin credentials,
|
|
* CSRF header, and a 30 second timeout on every request.
|
|
*/
|
|
export function canvasRequest(url: string, { method, body }: CanvasRequestOptions): Promise<Response> {
|
|
return fetch(url, {
|
|
method,
|
|
credentials: 'same-origin',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
|
'X-CSRF-TOKEN': csrfToken(),
|
|
},
|
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
signal: AbortSignal.timeout(30_000),
|
|
});
|
|
}
|