kaven-utils
Version:
Utils for Node.js.
51 lines (50 loc) • 2.1 kB
TypeScript
/********************************************************************
* @author: Kaven
* @email: kaven@wuwenkai.com
* @website: http://blog.kaven.xyz
* @file: [Kaven-Utils] /src/net/authentication/KavenAuthentication.ts
* @create: 2019-03-26 14:16:54.029
* @modify: 2025-10-14 22:58:04.874
* @version: 6.1.0
* @times: 38
* @lines: 123
* @copyright: Copyright © 2019-2025 Kaven. All Rights Reserved.
* @description: [description]
* @license: [license]
********************************************************************/
import { HttpStatusCode, ILoggingAgent } from "kaven-basic";
import { IHttpAuthorizationInfo } from "../../base/Interfaces.js";
import { HttpResponseMessage } from "../http/HttpResponseMessage.js";
import { KavenAuthorizationRecords } from "./KavenAuthorizationRecords.js";
export declare abstract class KavenAuthentication {
UserName: string;
Password: string;
/**
* A string to be displayed to users so they know which username and
* password to use.
*
* This string should contain at least the name of
* the host performing the authentication and might additionally
* indicate the collection of users who might have access.
*/
Realm: string;
/**
* WWW-Authenticate or Proxy-Authenticate
*/
ResponseHeaderName: string;
abstract Name: string;
/**
* @since 4.3.6
* @version 2022-09-20
*/
Records: KavenAuthorizationRecords | undefined;
Logger?: ILoggingAgent;
constructor(userName: string, password: string);
get StatusCode(): HttpStatusCode.Unauthorized | HttpStatusCode.ProxyAuthenticationRequired;
get RequestHeaderName(): "Proxy-Authorization" | "Authorization";
abstract Authenticate(req: IHttpAuthorizationInfo): Promise<boolean>;
abstract Update(response: HttpResponseMessage): HttpResponseMessage;
CanAuthenticate(key: string): boolean;
AddRecord(key: string, success: boolean): void;
GetResponse(message?: string, statusCode?: HttpStatusCode): HttpResponseMessage;
}