Skip to content

Commit

Permalink
fix(oidc-auth): Fixed type error (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
hnw authored Jan 17, 2025
1 parent 1e0f0a0 commit be34f69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-trains-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/oidc-auth': patch
---

Fix type error
12 changes: 6 additions & 6 deletions packages/oidc-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ export const getClient = (c: Context): oauth2.Client => {
*/
export const getAuth = async (c: Context): Promise<OidcAuth | null> => {
const env = getOidcAuthEnv(c)
let auth: Partial<OidcAuth> | null = c.get('oidcAuth')
let auth = c.get('oidcAuth')
if (auth === undefined) {
const session_jwt = getCookie(c, env.OIDC_COOKIE_NAME)
if (session_jwt === undefined) {
return null
}
try {
auth = await verify(session_jwt, env.OIDC_AUTH_SECRET)
auth = await verify(session_jwt, env.OIDC_AUTH_SECRET) as OidcAuth
} catch (e) {
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
return null
Expand Down Expand Up @@ -178,11 +178,11 @@ export const getAuth = async (c: Context): Promise<OidcAuth | null> => {
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
return null
}
auth = await updateAuth(c, auth as OidcAuth, result)
auth = await updateAuth(c, auth, result)
}
c.set('oidcAuth', auth as OidcAuth)
c.set('oidcAuth', auth)
}
return auth as OidcAuth
return auth
}

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

0 comments on commit be34f69

Please sign in to comment.