@@ -18,6 +18,7 @@ describe("Authentication Client", async () => {
1818 clientSecret : "client-secret" ,
1919 appBaseUrl : "https://example.com" ,
2020 sid : "auth0-sid" ,
21+ idToken : "idt_123" ,
2122 accessToken : "at_123" ,
2223 refreshToken : "rt_123" ,
2324 sub : "user_123" ,
@@ -1827,6 +1828,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
18271828 const session : SessionData = {
18281829 user : { sub : DEFAULT . sub } ,
18291830 tokenSet : {
1831+ idToken : DEFAULT . idToken ,
18301832 accessToken : DEFAULT . accessToken ,
18311833 refreshToken : DEFAULT . refreshToken ,
18321834 expiresAt : 123456
@@ -1864,6 +1866,9 @@ ca/T0LLtgmbMmxSv/MmzIg==
18641866 expect ( authorizationUrl . searchParams . get ( "logout_hint" ) ) . toEqual (
18651867 DEFAULT . sid
18661868 ) ;
1869+ expect ( authorizationUrl . searchParams . get ( "id_token_hint" ) ) . toEqual (
1870+ DEFAULT . idToken
1871+ ) ;
18671872
18681873 // session cookie is cleared
18691874 const cookie = response . cookies . get ( "__session" ) ;
@@ -1941,6 +1946,43 @@ ca/T0LLtgmbMmxSv/MmzIg==
19411946 expect ( cookie ?. expires ) . toEqual ( new Date ( "1970-01-01T00:00:00.000Z" ) ) ;
19421947 } ) ;
19431948
1949+ it ( "should not include the id_token_hint parameter if a session does not exist" , async ( ) => {
1950+ const secret = await generateSecret ( 32 ) ;
1951+ const transactionStore = new TransactionStore ( {
1952+ secret
1953+ } ) ;
1954+ const sessionStore = new StatelessSessionStore ( {
1955+ secret
1956+ } ) ;
1957+ const authClient = new AuthClient ( {
1958+ transactionStore,
1959+ sessionStore,
1960+
1961+ domain : DEFAULT . domain ,
1962+ clientId : DEFAULT . clientId ,
1963+ clientSecret : DEFAULT . clientSecret ,
1964+
1965+ secret,
1966+ appBaseUrl : DEFAULT . appBaseUrl ,
1967+
1968+ fetch : getMockAuthorizationServer ( )
1969+ } ) ;
1970+
1971+ const request = new NextRequest (
1972+ new URL ( "/auth/logout" , DEFAULT . appBaseUrl ) ,
1973+ {
1974+ method : "GET"
1975+ }
1976+ ) ;
1977+
1978+ const response = await authClient . handleLogout ( request ) ;
1979+ expect ( response . status ) . toEqual ( 307 ) ;
1980+ expect ( response . headers . get ( "Location" ) ) . not . toBeNull ( ) ;
1981+
1982+ const authorizationUrl = new URL ( response . headers . get ( "Location" ) ! ) ;
1983+ expect ( authorizationUrl . searchParams . get ( "id_token_hint" ) ) . toBeNull ( ) ;
1984+ } ) ;
1985+
19441986 it ( "should not include the logout_hint parameter if a session does not exist" , async ( ) => {
19451987 const secret = await generateSecret ( 32 ) ;
19461988 const transactionStore = new TransactionStore ( {
0 commit comments