@@ -48,26 +48,35 @@ export interface Event {
4848}
4949
5050export interface Stats {
51+ total_active : number
5152 total_mitigations : number
52- active_mitigations : number
53- events_24h : number
5453 total_events : number
55- pops : string [ ]
54+ pops : PopInfo [ ]
55+ }
56+
57+ export interface PopInfo {
58+ pop : string
59+ active_mitigations : number
60+ last_seen : string
5661}
5762
5863export interface HealthResponse {
5964 status : string
60- version : string
61- pop : string
62- uptime_seconds : number
63- bgp_session_up : boolean
65+ bgp_sessions : Record < string , string >
66+ active_mitigations : number
67+ database : string
68+ gobgp : {
69+ status : string
70+ error ?: string
71+ }
6472}
6573
6674export interface SafelistEntry {
6775 prefix : string
68- reason : string
76+ reason : string | null
6977 added_by : string
7078 added_at : string
79+ expires_at : string | null
7180}
7281
7382async function fetchApi < T > ( endpoint : string , options ?: RequestInit ) : Promise < T > {
@@ -102,7 +111,10 @@ async function fetchApi<T>(endpoint: string, options?: RequestInit): Promise<T>
102111}
103112
104113async function doFetch < T > ( url : string , options : RequestInit ) : Promise < T > {
105- const res = await fetch ( url , options )
114+ const res = await fetch ( url , {
115+ ...options ,
116+ credentials : "include" , // Send session cookies for hybrid auth
117+ } )
106118
107119 if ( ! res . ok ) {
108120 const error = await res . text ( )
@@ -128,16 +140,18 @@ export async function getMitigations(params?: {
128140 offset ?: number
129141} ) : Promise < Mitigation [ ] > {
130142 const searchParams = new URLSearchParams ( )
131- if ( params ?. status ) {
132- params . status . forEach ( ( s ) => searchParams . append ( "status" , s ) )
143+ if ( params ?. status && params . status . length > 0 ) {
144+ // Backend expects comma-separated status values
145+ searchParams . set ( "status" , params . status . join ( "," ) )
133146 }
134147 if ( params ?. customer_id ) searchParams . set ( "customer_id" , params . customer_id )
135148 if ( params ?. pop ) searchParams . set ( "pop" , params . pop )
136149 if ( params ?. limit ) searchParams . set ( "limit" , params . limit . toString ( ) )
137150 if ( params ?. offset ) searchParams . set ( "offset" , params . offset . toString ( ) )
138151
139152 const query = searchParams . toString ( )
140- return fetchApi < Mitigation [ ] > ( `/v1/mitigations${ query ? `?${ query } ` : "" } ` )
153+ const response = await fetchApi < { mitigations : Mitigation [ ] ; count : number } > ( `/v1/mitigations${ query ? `?${ query } ` : "" } ` )
154+ return response . mitigations
141155}
142156
143157export async function getMitigation ( id : string ) : Promise < Mitigation > {
@@ -164,7 +178,8 @@ export async function getEvents(params?: {
164178 if ( params ?. offset ) searchParams . set ( "offset" , params . offset . toString ( ) )
165179
166180 const query = searchParams . toString ( )
167- return fetchApi < Event [ ] > ( `/v1/events${ query ? `?${ query } ` : "" } ` )
181+ const response = await fetchApi < { events : Event [ ] ; count : number } > ( `/v1/events${ query ? `?${ query } ` : "" } ` )
182+ return response . events
168183}
169184
170185export interface AuditEntry {
@@ -212,8 +227,8 @@ export async function removeSafelist(prefix: string): Promise<void> {
212227 } )
213228}
214229
215- export async function getPops ( ) : Promise < string [ ] > {
216- return fetchApi < string [ ] > ( "/v1/pops" )
230+ export async function getPops ( ) : Promise < PopInfo [ ] > {
231+ return fetchApi < PopInfo [ ] > ( "/v1/pops" )
217232}
218233
219234export async function reloadConfig ( ) : Promise < void > {
0 commit comments