MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / fetchConnectionTicket

Function fetchConnectionTicket

packages/event-service/src/client.ts:50–64  ·  view source on GitHub ↗
(wsBase: string, token: string)

Source from the content-addressed store, hash-verified

48 } else if (url.protocol === 'https:') {
49 url.protocol = 'wss:';
50 }
51 const query = { ticket } satisfies ConnectTicketQuery;
52 url.searchParams.set('ticket', query.ticket);
53 return url.toString();
54}
55
56async function fetchConnectionTicket(wsBase: string, token: string): Promise<string> {
57 return withDeadline(CONTROL_PLANE_DEADLINE_MS, async signal => {
58 const response = await fetch(ticketEndpointFor(wsBase), {
59 method: 'POST',
60 headers: { authorization: `Bearer ${token}` },
61 signal,
62 });
63 if (response.status === 401 || response.status === 403) {
64 throw new WebSocketAuthError();
65 }
66 if (!response.ok) {
67 throw new Error('Failed to mint WebSocket connection ticket');

Callers 1

connectOnceMethod · 0.85

Calls 3

ticketEndpointForFunction · 0.85
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected