Skip to content

Commit be34f69

Browse files
authored
fix(oidc-auth): Fixed type error (#936)
1 parent 1e0f0a0 commit be34f69

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changeset/eighty-trains-peel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hono/oidc-auth': patch
3+
---
4+
5+
Fix type error

packages/oidc-auth/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ export const getClient = (c: Context): oauth2.Client => {
142142
*/
143143
export const getAuth = async (c: Context): Promise<OidcAuth | null> => {
144144
const env = getOidcAuthEnv(c)
145-
let auth: Partial<OidcAuth> | null = c.get('oidcAuth')
145+
let auth = c.get('oidcAuth')
146146
if (auth === undefined) {
147147
const session_jwt = getCookie(c, env.OIDC_COOKIE_NAME)
148148
if (session_jwt === undefined) {
149149
return null
150150
}
151151
try {
152-
auth = await verify(session_jwt, env.OIDC_AUTH_SECRET)
152+
auth = await verify(session_jwt, env.OIDC_AUTH_SECRET) as OidcAuth
153153
} catch (e) {
154154
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
155155
return null
@@ -178,11 +178,11 @@ export const getAuth = async (c: Context): Promise<OidcAuth | null> => {
178178
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
179179
return null
180180
}
181-
auth = await updateAuth(c, auth as OidcAuth, result)
181+
auth = await updateAuth(c, auth, result)
182182
}
183-
c.set('oidcAuth', auth as OidcAuth)
183+
c.set('oidcAuth', auth)
184184
}
185-
return auth as OidcAuth
185+
return auth
186186
}
187187

188188
/**
@@ -239,7 +239,7 @@ export const revokeSession = async (c: Context): Promise<void> => {
239239
const session_jwt = getCookie(c, env.OIDC_COOKIE_NAME)
240240
if (session_jwt !== undefined) {
241241
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
242-
const auth = await verify(session_jwt, env.OIDC_AUTH_SECRET)
242+
const auth = await verify(session_jwt, env.OIDC_AUTH_SECRET) as OidcAuth
243243
if (auth.rtk !== undefined && auth.rtk !== '') {
244244
// revoke refresh token
245245
const as = await getAuthorizationServer(c)

0 commit comments

Comments
 (0)