refactor(oidc-auth): enable isolated declarations (#1202)

pull/1206/head
Jonathan Haines 2025-06-09 19:35:28 +10:00 committed by GitHub
parent 641fd4c3de
commit aaf90c39e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/oidc-auth': patch
---
Add explicit `MiddlewareHandler` return type

View File

@ -2,7 +2,7 @@
* OpenID Connect authentication middleware for hono * OpenID Connect authentication middleware for hono
*/ */
import type { Context, MiddlewareHandler, OidcAuthClaims } from 'hono' import type { Context, MiddlewareHandler, OidcAuthClaims, TypedResponse } from 'hono'
import { env } from 'hono/adapter' import { env } from 'hono/adapter'
import { deleteCookie, getCookie, setCookie } from 'hono/cookie' import { deleteCookie, getCookie, setCookie } from 'hono/cookie'
import { createMiddleware } from 'hono/factory' import { createMiddleware } from 'hono/factory'
@ -66,7 +66,7 @@ export type OidcAuthEnv = {
* If used, should be called before any other OIDC middleware or functions for the Hono context. * If used, should be called before any other OIDC middleware or functions for the Hono context.
* Unconfigured values will fallback to environment variables. * Unconfigured values will fallback to environment variables.
*/ */
export const initOidcAuthMiddleware = (config: Partial<OidcAuthEnv>) => { export const initOidcAuthMiddleware = (config: Partial<OidcAuthEnv>): MiddlewareHandler => {
return createMiddleware(async (c, next) => { return createMiddleware(async (c, next) => {
setOidcAuthEnv(c, config) setOidcAuthEnv(c, config)
await next() await next()
@ -356,7 +356,9 @@ const generateAuthorizationRequestUrl = async (
/** /**
* Processes the OAuth2 callback request. * Processes the OAuth2 callback request.
*/ */
export const processOAuthCallback = async (c: Context) => { export const processOAuthCallback = async (
c: Context
): Promise<Response & TypedResponse<undefined, 302, 'redirect'>> => {
const env = getOidcAuthEnv(c) const env = getOidcAuthEnv(c)
const as = await getAuthorizationServer(c) const as = await getAuthorizationServer(c)
const client = getClient(c) const client = getClient(c)

View File

@ -4,7 +4,8 @@
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo", "tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": false "emitDeclarationOnly": false,
"isolatedDeclarations": true
}, },
"include": ["src/**/*.ts"], "include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"], "exclude": ["**/*.test.ts"],