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

Function parseEncodedSession

packages/ci-proxy-worker/src/index.ts:266–285  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

264}
265
266function parseEncodedSession(value: string): EncodedSession {
267 const decoded = base64UrlDecode(value);
268 const trimmed = decoded.trim();
269 if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
270 const url = new URL(trimmed);
271 const token = url.searchParams.get("simdeckToken") ?? undefined;
272 const device = url.searchParams.get("device") ?? undefined;
273 url.searchParams.delete("simdeckToken");
274 url.searchParams.delete("device");
275 return normalizeSession({
276 v: 1,
277 upstream: `${url.origin}${url.pathname === "/" ? "" : url.pathname}`,
278 token,
279 device,
280 });
281 }
282
283 const parsed = JSON.parse(trimmed) as EncodedSession;
284 return normalizeSession(parsed);
285}
286
287function normalizeSession(session: EncodedSession): EncodedSession {
288 if (session.v !== 1) {

Callers 2

handleRequestFunction · 0.85
authenticateSessionFunction · 0.85

Calls 5

base64UrlDecodeFunction · 0.85
normalizeSessionFunction · 0.85
getMethod · 0.65
deleteMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected