UNPKG

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.

70 lines (69 loc) 2.65 kB
import { Result } from '../result'; import { HandlerSync } from '../types/sqnfa'; export declare class EmailBlackListConfiguration { /** * The information contained within the e-mail will be added to the black list. */ readonly email: string; /** * The size of the sliding window used when tokenizing the email. */ readonly slidingWindow: number; /** * A safe-gaurd to ensure that shorter tokens are not added, i.e. ensure that * the handler is not too restrictive. */ readonly minTokenLength: number; constructor( /** * The information contained within the e-mail will be added to the black list. */ email: string, /** * The size of the sliding window used when tokenizing the email. */ slidingWindow: number, /** * A safe-gaurd to ensure that shorter tokens are not added, i.e. ensure that * the handler is not too restrictive. */ minTokenLength: number); } export declare class EmailBlackListHandler implements HandlerSync { readonly name: string; private emailTokens; /** * NIST 800-63B: * Password complexity: Users’ password choices are very predictable, * so attackers are likely to guess passwords that have been successful * in the past. For this reason, it is recommended that passwords chosen * by users be compared against a “black list” of unacceptable passwords. * This list should include pecific words (such as the name of the service * itself) that users are likely to choose. * * This handler black lists passwords containing parts of the user's e-mail * address. The e-mail is tokenized and each token is added to the black list. */ constructor(config: EmailBlackListConfiguration); handleSync(password: string): Result; /** * Adds information about the e-mail. The e-mail is tokenized and each token * is added to the black list. * * Example: john.doe@example.com * * Tokens: john, example * (Note that doe is below minTokenLength) * * Sliding windows 4: * * Tokens: john, example, ohn., hn.d, n.do, .doe, exam, xamp, ampl, mple * * @param email The e-mail that should be black listed. * @param slidingWindowSize If positive non-zero: Adds words of the size provided sliding accross the e-mail. * @param minTokenLength A safe-gaurd to not let the black list be too restricted. */ addEmailInformation(email: string, slidingWindowSize: number, minTokenLength: number): void; private addSlidingWindowWords; private addToken; }