@a-type/auth
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -35,5 +35,6 @@ import { AuthError } from './error.js'; | ||
} | ||
session.headers.set('location', url.toString()); | ||
return new Response(null, { | ||
status: 302, | ||
headers: Object.assign({ location: url.toString() }, session.headers), | ||
headers: session.headers, | ||
}); | ||
@@ -348,2 +349,3 @@ } | ||
const { headers } = await sessions.refreshSession(accessToken, refreshToken); | ||
headers.append('content-type', 'application/json'); | ||
return new Response(JSON.stringify({ | ||
@@ -353,3 +355,3 @@ ok: true, | ||
status: 200, | ||
headers: Object.assign(Object.assign({}, headers), { 'content-type': 'application/json' }), | ||
headers, | ||
}); | ||
@@ -360,2 +362,4 @@ } | ||
if (err instanceof AuthError && err.statusCode === 401) { | ||
const { headers } = sessions.clearSession(); | ||
headers.append('content-type', 'application/json'); | ||
return new Response(JSON.stringify({ | ||
@@ -365,3 +369,3 @@ ok: false, | ||
status: 401, | ||
headers: Object.assign(Object.assign({}, sessions.clearSession().headers), { 'content-type': 'application/json' }), | ||
headers, | ||
}); | ||
@@ -368,0 +372,0 @@ } |
@@ -52,9 +52,9 @@ export interface Session { | ||
refreshSession: (accessToken: string, refreshToken: string) => Promise<{ | ||
headers: HeadersInit; | ||
headers: Headers; | ||
}>; | ||
updateSession: (session: Session) => Promise<{ | ||
headers: HeadersInit; | ||
headers: Headers; | ||
}>; | ||
clearSession: () => { | ||
headers: HeadersInit; | ||
headers: Headers; | ||
}; | ||
@@ -61,0 +61,0 @@ private getAccessTokenBuilder; |
{ | ||
"name": "@a-type/auth", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "My personal auth request handlers", | ||
@@ -5,0 +5,0 @@ "module": "dist/esm/index.js", |
@@ -73,3 +73,3 @@ import { AuthDB } from './db.js'; | ||
session: { | ||
headers: HeadersInit; | ||
headers: Headers; | ||
searchParams?: URLSearchParams; | ||
@@ -98,8 +98,7 @@ }, | ||
session.headers.set('location', url.toString()); | ||
return new Response(null, { | ||
status: 302, | ||
headers: { | ||
location: url.toString(), | ||
...session.headers, | ||
}, | ||
headers: session.headers, | ||
}); | ||
@@ -459,2 +458,3 @@ } | ||
); | ||
headers.append('content-type', 'application/json'); | ||
@@ -467,6 +467,3 @@ return new Response( | ||
status: 200, | ||
headers: { | ||
...headers, | ||
'content-type': 'application/json', | ||
}, | ||
headers, | ||
}, | ||
@@ -477,2 +474,5 @@ ); | ||
if (err instanceof AuthError && err.statusCode === 401) { | ||
const { headers } = sessions.clearSession(); | ||
headers.append('content-type', 'application/json'); | ||
return new Response( | ||
@@ -484,6 +484,3 @@ JSON.stringify({ | ||
status: 401, | ||
headers: { | ||
...sessions.clearSession().headers, | ||
'content-type': 'application/json', | ||
}, | ||
headers, | ||
}, | ||
@@ -490,0 +487,0 @@ ); |
@@ -164,5 +164,3 @@ import { parse, serialize } from 'cookie'; | ||
updateSession = async ( | ||
session: Session, | ||
): Promise<{ headers: HeadersInit }> => { | ||
updateSession = async (session: Session): Promise<{ headers: Headers }> => { | ||
const headers = new Headers(); | ||
@@ -208,3 +206,3 @@ | ||
clearSession = (): { headers: HeadersInit } => { | ||
clearSession = (): { headers: Headers } => { | ||
const headers = new Headers(); | ||
@@ -211,0 +209,0 @@ const cookie = serialize(this.options.cookieName, '', { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
126301
2527