refactor(oidc-auth): enable isolated declarations (#1202)
parent
641fd4c3de
commit
aaf90c39e6
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/oidc-auth': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add explicit `MiddlewareHandler` return type
|
|
@ -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)
|
||||||
|
|
|
@ -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"],
|
||||||
|
|
Loading…
Reference in New Issue