diff --git a/.changeset/plain-rockets-grow.md b/.changeset/plain-rockets-grow.md new file mode 100644 index 00000000..f55e5d2f --- /dev/null +++ b/.changeset/plain-rockets-grow.md @@ -0,0 +1,5 @@ +--- +'@hono/oidc-auth': patch +--- + +Add explicit `MiddlewareHandler` return type diff --git a/packages/oidc-auth/src/index.ts b/packages/oidc-auth/src/index.ts index 4975a008..17f12e5c 100644 --- a/packages/oidc-auth/src/index.ts +++ b/packages/oidc-auth/src/index.ts @@ -2,7 +2,7 @@ * 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 { deleteCookie, getCookie, setCookie } from 'hono/cookie' 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. * Unconfigured values will fallback to environment variables. */ -export const initOidcAuthMiddleware = (config: Partial) => { +export const initOidcAuthMiddleware = (config: Partial): MiddlewareHandler => { return createMiddleware(async (c, next) => { setOidcAuthEnv(c, config) await next() @@ -356,7 +356,9 @@ const generateAuthorizationRequestUrl = async ( /** * Processes the OAuth2 callback request. */ -export const processOAuthCallback = async (c: Context) => { +export const processOAuthCallback = async ( + c: Context +): Promise> => { const env = getOidcAuthEnv(c) const as = await getAuthorizationServer(c) const client = getClient(c) diff --git a/packages/oidc-auth/tsconfig.build.json b/packages/oidc-auth/tsconfig.build.json index ccc2f65a..a82a1266 100644 --- a/packages/oidc-auth/tsconfig.build.json +++ b/packages/oidc-auth/tsconfig.build.json @@ -4,7 +4,8 @@ "rootDir": "src", "outDir": "dist", "tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo", - "emitDeclarationOnly": false + "emitDeclarationOnly": false, + "isolatedDeclarations": true }, "include": ["src/**/*.ts"], "exclude": ["**/*.test.ts"],