@@ -2,9 +2,10 @@ import { RequestCookies, ResponseCookies } from "@edge-runtime/cookies";
22import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
33
44import { Auth0Client } from "./client.js" ;
5- import { deleteChunkedCookie , deleteCookie } from "./cookies.js" ;
5+ import { deleteChunkedCookie } from "./cookies.js" ;
66import { StatelessSessionStore } from "./session/stateless-session-store.js" ;
77import { TransactionStore } from "./transaction-store.js" ;
8+ import { Auth0RequestCookies , Auth0ResponseCookies } from "./http/index.js" ;
89
910describe ( "Base path and cookie configuration tests" , ( ) => {
1011 let originalEnv : NodeJS . ProcessEnv ;
@@ -55,7 +56,7 @@ describe("Base path and cookie configuration tests", () => {
5556 mockReqCookies . getAll = ( ) => [ ] ;
5657
5758 // Call delete method (this would be called during logout)
58- await sessionStore . delete ( mockReqCookies , mockResCookies ) ;
59+ await sessionStore . delete ( new Auth0RequestCookies ( mockReqCookies ) , new Auth0ResponseCookies ( mockResCookies ) ) ;
5960
6061 // Verify that the cookie deletion header includes the correct path
6162 const cookieHeader = mockResCookies . toString ( ) ;
@@ -90,7 +91,7 @@ describe("Base path and cookie configuration tests", () => {
9091 mockReqCookies . get = ( ) => ( { value : "mock-session-value" } ) ;
9192 mockReqCookies . getAll = ( ) => [ ] ;
9293
93- await sessionStore . delete ( mockReqCookies , mockResCookies ) ;
94+ await sessionStore . delete ( new Auth0RequestCookies ( mockReqCookies ) , new Auth0ResponseCookies ( mockResCookies ) ) ;
9495
9596 const cookieHeader = mockResCookies . toString ( ) ;
9697
@@ -132,7 +133,8 @@ describe("Base path and cookie configuration tests", () => {
132133 } ) ;
133134
134135 it ( "should delete cookie with default path when no path is specified" , ( ) => {
135- deleteCookie ( mockResCookies , "test-cookie" ) ;
136+ const auth0ResCookies = new Auth0ResponseCookies ( mockResCookies ) ;
137+ auth0ResCookies . delete ( "test-cookie" ) ;
136138
137139 const cookieHeader = mockResCookies . toString ( ) ;
138140 expect ( cookieHeader ) . toContain ( "test-cookie=" ) ;
@@ -141,7 +143,11 @@ describe("Base path and cookie configuration tests", () => {
141143 } ) ;
142144
143145 it ( "should delete cookie with specified path" , ( ) => {
144- deleteCookie ( mockResCookies , "test-cookie" , { path : "/dashboard" } ) ;
146+ const auth0ResCookies = new Auth0ResponseCookies ( mockResCookies ) ;
147+ auth0ResCookies . delete ( {
148+ name : "test-cookie" ,
149+ path : "/dashboard"
150+ } ) ;
145151
146152 const cookieHeader = mockResCookies . toString ( ) ;
147153 expect ( cookieHeader ) . toContain ( "test-cookie=" ) ;
@@ -150,7 +156,11 @@ describe("Base path and cookie configuration tests", () => {
150156 } ) ;
151157
152158 it ( "should delete cookie with root path explicitly" , ( ) => {
153- deleteCookie ( mockResCookies , "test-cookie" , { path : "/" } ) ;
159+ const auth0ResCookies = new Auth0ResponseCookies ( mockResCookies ) ;
160+ auth0ResCookies . delete ( {
161+ name : "test-cookie" ,
162+ path : "/"
163+ } ) ;
154164
155165 const cookieHeader = mockResCookies . toString ( ) ;
156166 expect ( cookieHeader ) . toContain ( "test-cookie=" ) ;
@@ -168,8 +178,8 @@ describe("Base path and cookie configuration tests", () => {
168178
169179 deleteChunkedCookie (
170180 "test-cookie" ,
171- mockReqCookies ,
172- mockResCookies ,
181+ new Auth0RequestCookies ( mockReqCookies ) ,
182+ new Auth0ResponseCookies ( mockResCookies ) ,
173183 false ,
174184 { path : "/dashboard" }
175185 ) ;
@@ -284,7 +294,7 @@ describe("Base path and cookie configuration tests", () => {
284294 }
285295 } ) ;
286296
287- await sessionStore . delete ( mockReqCookies , mockResCookies ) ;
297+ await sessionStore . delete ( new Auth0RequestCookies ( mockReqCookies ) , new Auth0ResponseCookies ( mockResCookies ) ) ;
288298
289299 const cookieHeader = mockResCookies . toString ( ) ;
290300 expect ( cookieHeader ) . toContain ( "__session=" ) ;
@@ -304,7 +314,7 @@ describe("Base path and cookie configuration tests", () => {
304314 }
305315 } ) ;
306316
307- await transactionStore . delete ( mockResCookies , "test-state" ) ;
317+ await transactionStore . delete ( new Auth0ResponseCookies ( mockResCookies ) , "test-state" ) ;
308318
309319 const cookieHeader = mockResCookies . toString ( ) ;
310320 expect ( cookieHeader ) . toContain ( "__txn_test-state=" ) ;
@@ -330,7 +340,7 @@ describe("Base path and cookie configuration tests", () => {
330340 }
331341 } ) ;
332342
333- await transactionStore . deleteAll ( mockReqCookies , mockResCookies ) ;
343+ await transactionStore . deleteAll ( new Auth0RequestCookies ( mockReqCookies ) , new Auth0ResponseCookies ( mockResCookies ) ) ;
334344
335345 const cookieHeader = mockResCookies . toString ( ) ;
336346 expect ( cookieHeader ) . toContain ( "__txn_state1=" ) ;
@@ -373,7 +383,9 @@ describe("Base path and cookie configuration tests", () => {
373383 } ) ;
374384
375385 it ( "should handle empty path correctly" , ( ) => {
376- deleteCookie ( new ResponseCookies ( new Headers ( ) ) , "test-cookie" , {
386+ const auth0ResponseCookies = new Auth0ResponseCookies ( new ResponseCookies ( new Headers ( ) ) ) ;
387+ auth0ResponseCookies . delete ( {
388+ name : "test-cookie" ,
377389 path : ""
378390 } ) ;
379391
0 commit comments