2026-03-16 20:38:05 +00:00
|
|
|
const toHttpUrl = (url: string) =>
|
|
|
|
|
url
|
|
|
|
|
.replace(/^wss:\/\//, "https://")
|
|
|
|
|
.replace(/^ws:\/\//, "http://")
|
|
|
|
|
.replace(/\/$/, "")
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
const livekitEndpoint = (url: string, roomId?: string) => {
|
2026-03-16 20:38:05 +00:00
|
|
|
const base = `${toHttpUrl(url)}/.well-known/nip29/livekit`
|
2026-07-28 16:16:26 +00:00
|
|
|
return roomId ? `${base}/${roomId}` : base
|
2026-03-16 20:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const checkRelayHasLivekit = async (url: string): Promise<boolean> => {
|
|
|
|
|
const endpoint = livekitEndpoint(url)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(endpoint)
|
|
|
|
|
return response.status === 204
|
|
|
|
|
} catch {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
export const getLivekitEndpoint = (url: string, roomId: string) => livekitEndpoint(url, roomId)
|