From 965f84ec0eee36e430e45f0a6c1f4a8163ca9308 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Sun, 29 Dec 2024 10:20:56 +0100 Subject: [PATCH] fix(cookie): Fix regression after v1 upgrade --- packages/api/src/auth/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/api/src/auth/index.ts b/packages/api/src/auth/index.ts index 7cd9bc98ea40..cfa9183bab70 100644 --- a/packages/api/src/auth/index.ts +++ b/packages/api/src/auth/index.ts @@ -1,7 +1,7 @@ export * from './parseJWT' import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda' -import { parse as parseCookie } from 'cookie' +import * as cookie from 'cookie' import { getEventHeader } from '../event' @@ -29,26 +29,26 @@ export interface AuthorizationHeader { } export type AuthorizationCookies = { - parsedCookie: Record + parsedCookie: Record rawCookie: string - type: string + type: string | undefined } | null export const parseAuthorizationCookie = ( event: APIGatewayProxyEvent | Request, ): AuthorizationCookies => { - const cookie = getEventHeader(event, 'Cookie') + const cookieHeader = getEventHeader(event, 'Cookie') // Unauthenticated request - if (!cookie) { + if (!cookieHeader) { return null } - const parsedCookie = parseCookie(cookie) + const parsedCookie = cookie.parse(cookieHeader) return { parsedCookie, - rawCookie: cookie, + rawCookie: cookieHeader, // When not unauthenticated, this will be null/undefined // Remember that the cookie header could contain other (unrelated) values! type: parsedCookie[AUTH_PROVIDER_HEADER],