MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / establishSession

Function establishSession

packages/ci-proxy-worker/src/index.ts:182–211  ·  view source on GitHub ↗
(session: EncodedSession, token: string)

Source from the content-addressed store, hash-verified

180}
181
182function establishSession(session: EncodedSession, token: string): Response {
183 if (sessionExpired(session.expiresAt)) {
184 return passwordShellResponse(
185 "Session expired",
186 "<p>This SimDeck CI session has expired. Re-run the workflow to create a new link.</p>",
187 410,
188 );
189 }
190
191 const cookie: SessionCookie = {
192 upstream: session.upstream,
193 token,
194 device: session.device,
195 expiresAt: session.expiresAt,
196 };
197 const target = new URL("https://simdeck.local/");
198 if (session.device) {
199 target.searchParams.set("device", session.device);
200 }
201 target.searchParams.set("remoteStream", "1");
202
203 return new Response(null, {
204 status: 303,
205 headers: {
206 Location: `${target.pathname}${target.search}`,
207 "Set-Cookie": sessionCookie(cookie),
208 "Cache-Control": "no-store",
209 },
210 });
211}
212
213async function proxyToSimDeck(
214 request: Request,

Callers 2

handleRequestFunction · 0.85
authenticateSessionFunction · 0.85

Calls 4

sessionExpiredFunction · 0.85
passwordShellResponseFunction · 0.85
sessionCookieFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected