import { NextMiddleware, NextRequest } from 'next/server'; import { updateSessionMiddleware, updateSession } from './session.js'; import { AuthkitMiddlewareOptions, AuthkitOptions, AuthkitResponse } from './interfaces.js'; import { WORKOS_REDIRECT_URI } from './env-variables.js'; export function authkitProxy({ debug = false, middlewareAuth = { enabled: false, unauthenticatedPaths: [] }, redirectUri = WORKOS_REDIRECT_URI, signUpPaths = [], eagerAuth = false, refreshBufferSeconds, }: AuthkitMiddlewareOptions = {}): NextMiddleware { return function (request) { return updateSessionMiddleware( request, debug, middlewareAuth, redirectUri, signUpPaths, eagerAuth, refreshBufferSeconds, ); }; } /** @deprecated Use `authkitProxy` instead. */ export const authkitMiddleware: typeof authkitProxy = authkitProxy; export async function authkit(request: NextRequest, options: AuthkitOptions = {}): Promise { return await updateSession(request, options); }