passwords-sqnfa-web
Version:
This library implements the recommendations that apply to client-side password handling from NIST and OWASP. The purpose of this library is to provide an easy pluggable client-side password preprocessor.
119 lines (118 loc) • 6.35 kB
TypeScript
import { BcryptConfiguration } from './handlers/bcrypt-handler';
import { BlackListConfiguration } from './handlers/blacklist-handler';
import { EmailBlackListConfiguration } from './handlers/email-blacklist-handler';
import { HaveibeenpwnedConfiguration } from './handlers/haveibeenpwned-handler';
import { LengthConfiguration } from './handlers/length-handler';
import { RegexConfiguration } from './handlers/regex-handler';
import { Result } from './result';
import { Handler, HandlerSync } from './types/sqnfa';
/**
* Passwords are still essential for most applications. This also includes web applications.
* This library implements the recommendations that apply to client-side password handling
* from the National Institute of Standards and Technology (NIST) and the Open Web Application
* Security Project (OWASP). The purpose of this library is to provide an easy pluggable
* client-side password preprocessor. It is not a substitute for the proper handling of passwords
* in the backend and should only be considered an extra layer.
*
* @license passwords-sqnfa-web Copyright 2022 Martin Storgaard Dieu <martin@storgaarddieu.com>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/sqnfa/passwords-sqnfa-web/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare class PasswordsSqnfaWeb implements Handler {
readonly name = "PasswordsSqnfaWeb";
/**
* A key-value property that contains the name of handlers that has been
* run as key and their total running time statistics in milliseconds as
* value.
*/
statistics: {
[key: string]: number;
};
private handlers;
private failures;
handle(password: string): Promise<Result>;
/**
* Bring your own handler. Any instance that implements the HandlerSync interface can be added.
* Please bear in mind that high password complexity requriements does not always yield
* highly secure passwords chosen by the user.
*
* @param handler A syncronous implementaion of the handler interface.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useSync(handler: HandlerSync, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* Bring your own handler. Any instance that implements the Handler interface can be added.
* Please bear in mind that high password complexity requriements does not always yield
* highly secure passwords chosen by the user.
*
* @param handler An asyncronous implementaion of the handler interface.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
use(handler: Handler, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see LengthHandler for details.
*
* @param config @see LengthConfiguration for details.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useLengthHandler(config?: LengthConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see BlackListHandler for details.
*
* @param config @see BlacklistConfiguration for details.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useBlackListHandler(config: BlackListConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see RegexHandler for details.
*
* @param config @see RegexConfiguration for details.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useRegexHandler(config: RegexConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see EmailBlackListHandler for details.
*
* @param config @see EmailBlackListConfiguration for details
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useEmailBlackListHandler(config: EmailBlackListConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see HaveibeenpwnedHandler for details.
*
* @param config @see HaveibeenpwnedConfiguration for details.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useHaveibeenpwnedHandler(config: HaveibeenpwnedConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see Sha512Handler for details.
*
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useSha512Handler(stopOnFailure?: boolean): PasswordsSqnfaWeb;
/**
* @see BcryptHandler for details.
*
* @param config @see BcryptConfiguration for details.
* @param stopOnFailure If true, the execution will stop, if any failures has happened to this point.
* @returns The current instance of PasswordsSqnfaWeb which allows chaining of the use* methods.
*/
useBcryptHandler(config: BcryptConfiguration, stopOnFailure?: boolean): PasswordsSqnfaWeb;
}