UNPKG

@j2inn/scram

Version:

TypeScript client SCRAM authentication library

78 lines (77 loc) 2.43 kB
/** * The stage in the SCRAM authentication process from the client side. */ export declare enum ScramStage { /** * Initialization where client and server agree on the specific SCRAM mechanism to use. */ Hello = "hello", /** * The client sends its username and a client-generated nonce to the server. */ FirstMessage = "firstMessage", /** * The client computes a "Client Proof" then sends this proof to the server. */ LastMessage = "lastMessage", /** * The client validates the Server Signature. */ Validation = "validation" } /** * Options to construct a {@link ScramError}. */ export interface ScramErrorOptions { /** * Response from the Fetch request. */ response?: Response; /** * SCRAM stage at which the process failed. */ stage?: ScramStage; } /** * Error returned by the SCRAM authentication process. */ export declare class ScramError extends Error implements ScramErrorOptions { #private; /** * Constructs a {@link ScramError}. * * @param message Optional message. * @param options Additional options to construct an error. */ constructor(message?: string, options?: ScramErrorOptions); get response(): Response | undefined; get stage(): ScramStage | undefined; /** * Constructs a {@link ScramError} for the Hello stage. * * @param message Optional message. * @param options Additional options to construct an error. */ static hello(message?: string, options?: ScramErrorOptions): ScramError; /** * Constructs a {@link ScramError} for the First Message stage. * * @param message Optional message. * @param options Additional options to construct an error. */ static firstMessage(message?: string, options?: ScramErrorOptions): ScramError; /** * Constructs a {@link ScramError} for the Last Message stage. * * @param message Optional message. * @param options Additional options to construct an error. */ static lastMessage(message?: string, options?: ScramErrorOptions): ScramError; /** * Constructs a {@link ScramError} for the Validation stage. * * @param message Optional message. * @param options Additional options to construct an error. */ static validation(message?: string, options?: ScramErrorOptions): ScramError; }