UNPKG

saget-auth-midleware

Version:

SSO Middleware untuk validasi authentifikasi domain malinau.go.id dan semua subdomain pada aplikasi Next.js 14 & 15

67 lines (62 loc) 1.97 kB
// index.d.ts import { NextRequest, NextResponse } from 'next/server'; export interface SSOPayload { exp?: number; user?: { id: string; phone: string; email: string; type: string; identity: string; status: string; lastLogin: string; createdAt: string; updatedAt: string; profile?: { id: string; userId: string; name: string; [key: string]: any; }; applications: { id: string; applicationKey: string; role: string; subrole: string; [key: string]: any; }[]; application?: { id: string; applicationKey: string; role: string; subrole: string; [key: string]: any; }; }; [key: string]: any; } export interface UserFromRequest { user?: any; role?: string; subrole?: string; userId?: string | null; userRole?: string | null; appKey?: string | null; domain?: string | null; subdomain?: string | null; } export declare class SSOMiddleware { constructor(); withSSOValidation(handler: (req: NextRequest) => Promise<Response | NextResponse>): (req: NextRequest) => Promise<Response | NextResponse>; getPayload(req: NextRequest): Promise<SSOPayload | null>; getPayloadFromHeaders(headers: Headers | Record<string, string | string[] | undefined>): Promise<any | null>; getUserFromRequest(req: NextRequest): UserFromRequest | null; setAuthCookies(response: NextResponse, accessToken: string, refreshToken: string): NextResponse; clearAuthCookies(response: NextResponse): NextResponse; getCookieOptions(): object; getSubdomain(hostname: string): string; redirectToSSO(currentUrl: URL, payload?: any): NextResponse; } declare const _default: SSOMiddleware; export default _default; export { SSOMiddleware };