diff --git a/src/next/api.ts b/src/next/api.ts index 29d0daac..60357425 100644 --- a/src/next/api.ts +++ b/src/next/api.ts @@ -3,7 +3,7 @@ import {NextApiRequest, NextApiResponse} from 'next'; import {CustomTokens, VerifiedTokens} from '../auth/custom-token/index.js'; import {getFirebaseAuth} from '../auth/index.js'; import {AuthCookies} from './cookies/AuthCookies.js'; -import {SetAuthCookiesOptions} from './cookies/index.js'; +import {CookiesObject, SetAuthCookiesOptions} from './cookies/index.js'; import {ObjectCookiesProvider} from './cookies/parser/ObjectCookiesProvider.js'; import {getCookiesTokens} from './tokens.js'; @@ -23,9 +23,7 @@ export async function refreshApiResponseCookies( } export async function appendAuthCookiesApi( - cookies: Partial<{ - [key: string]: string; - }>, + cookies: CookiesObject, response: NextApiResponse, tokens: CustomTokens, options: SetAuthCookiesOptions @@ -39,9 +37,7 @@ export async function appendAuthCookiesApi( } export async function refreshApiCookies( - cookies: Partial<{ - [key: string]: string; - }>, + cookies: CookiesObject, headers: IncomingHttpHeaders, options: SetAuthCookiesOptions ): Promise { diff --git a/src/next/cookies/index.ts b/src/next/cookies/index.ts index a62c10d2..100fd1be 100644 --- a/src/next/cookies/index.ts +++ b/src/next/cookies/index.ts @@ -178,9 +178,7 @@ export function removeAuthCookies( } export async function verifyApiCookies( - cookies: Partial<{ - [key: string]: string; - }>, + cookies: CookiesObject, headers: IncomingHttpHeaders, options: SetAuthCookiesOptions ): Promise { diff --git a/src/next/cookies/parser/CookieParserFactory.ts b/src/next/cookies/parser/CookieParserFactory.ts index 909f832c..4649594f 100644 --- a/src/next/cookies/parser/CookieParserFactory.ts +++ b/src/next/cookies/parser/CookieParserFactory.ts @@ -3,6 +3,7 @@ import type {RequestCookies} from 'next/dist/server/web/spec-extension/cookies'; import {InvalidTokenError, InvalidTokenReason} from '../../../auth/error.js'; import {debug} from '../../../debug/index.js'; import {GetCookiesTokensOptions} from '../../tokens.js'; +import {CookiesObject} from '../index.js'; import {CookiesProvider} from './CookiesProvider.js'; import {MultipleCookiesParser} from './MultipleCookiesParser.js'; import {ObjectCookiesProvider} from './ObjectCookiesProvider.js'; @@ -105,10 +106,7 @@ export class CookieParserFactory { return CookieParserFactory.fromProvider(provider, options); } - static fromObject( - cookies: Partial<{[K in string]: string}>, - options: GetCookiesTokensOptions - ) { + static fromObject(cookies: CookiesObject, options: GetCookiesTokensOptions) { const provider = new ObjectCookiesProvider(cookies); return CookieParserFactory.fromProvider(provider, options); diff --git a/src/next/cookies/parser/ObjectCookiesProvider.ts b/src/next/cookies/parser/ObjectCookiesProvider.ts index fa76f714..6182f34c 100644 --- a/src/next/cookies/parser/ObjectCookiesProvider.ts +++ b/src/next/cookies/parser/ObjectCookiesProvider.ts @@ -1,5 +1,7 @@ +import {CookiesObject} from '../index.js'; + export class ObjectCookiesProvider { - constructor(private cookies: Partial<{[K in string]: string}>) {} + constructor(private cookies: CookiesObject) {} get(key: string) { return this.cookies[key]; diff --git a/src/next/tokens.ts b/src/next/tokens.ts index def62dd3..d7ca23c2 100644 --- a/src/next/tokens.ts +++ b/src/next/tokens.ts @@ -167,7 +167,7 @@ export async function getTokens( } export async function getCookiesTokens( - cookies: Partial<{[K in string]: string}>, + cookies: CookiesObject, options: GetCookiesTokensOptions ): Promise { const parser = CookieParserFactory.fromObject(cookies, options);