Build 2602262030: add magent settings and hardening
This commit is contained in:
@@ -23,3 +23,18 @@ export const authFetch = (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
}
|
||||
return fetch(input, { ...init, headers })
|
||||
}
|
||||
|
||||
export const getEventStreamToken = async () => {
|
||||
const baseUrl = getApiBase()
|
||||
const response = await authFetch(`${baseUrl}/auth/stream-token`)
|
||||
if (!response.ok) {
|
||||
const text = await response.text()
|
||||
throw new Error(text || `Stream token request failed: ${response.status}`)
|
||||
}
|
||||
const data = await response.json()
|
||||
const token = typeof data?.stream_token === 'string' ? data.stream_token : ''
|
||||
if (!token) {
|
||||
throw new Error('Stream token not returned')
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user