MCPcopy
hub / github.com/tinyhttp/tinyhttp / getcookie

Function getcookie

packages/session/src/index.ts:566–587  ·  view source on GitHub ↗
(req: IncomingMessage, name: string, secrets: string[])

Source from the content-addressed store, hash-verified

564}
565
566function getcookie(req: IncomingMessage, name: string, secrets: string[]) {
567 const header = req.headers.cookie
568 let raw: string
569 let val: string | boolean
570
571 // read from cookie header
572 if (header) {
573 const cookies = cookie.parse(header)
574
575 raw = cookies[name]
576
577 if (raw) {
578 if (raw.substr(0, 2) === 's:') {
579 val = unsignCookie(raw.slice(2), secrets)
580
581 if (val === false) val = undefined
582 }
583 }
584 }
585
586 return val
587}
588
589/**
590 * Store in memory. Don't use it in production!

Callers 1

SessionManagerFunction · 0.85

Calls 1

unsignCookieFunction · 0.85

Tested by

no test coverage detected