Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension/js/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class Settings {
userInputs: PgpPwd.weakWords(),
},
};
zxcvbnts.core.zxcvbnOptions.setOptions(options);
const guesses = zxcvbnts.core.zxcvbn(passphrase).guesses;
const zxcvbn = new zxcvbnts.core.ZxcvbnFactory(options);
const guesses = zxcvbn.check(passphrase).guesses;
return PgpPwd.estimateStrength(guesses, type);
}

Expand Down
49 changes: 12 additions & 37 deletions extension/types/zxcvbn.d.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
// the shape of the result returned by zxcvbn
interface ZxcvbnFeedback {
warning: string;
suggestions: string[];
}

type Score = 0 | 1 | 2 | 3 | 4;
interface ZxcvbnResult {
score: Score;
password: string;
guesses: number;
guessesLog10: number;
calcTime: number;
}

// options for customizing zxcvbn
interface ZxcvbnOptions {
translations: Record<string, string>;
graphs: Record<string, string>;
dictionary: Record<string, string[]>;
}
import type { OptionsType, ZxcvbnFactory as ZxcvbnFactoryInstance } from '@zxcvbn-ts/core';
import type * as ZxcvbnCommonPackage from '@zxcvbn-ts/language-common';
import type * as ZxcvbnEnPackage from '@zxcvbn-ts/language-en';

declare var zxcvbnts: {
core: {
// the main function
zxcvbn(password: string, userInputs?: string[]): ZxcvbnResult;
zxcvbnOptions: {
setOptions(opts: ZxcvbnOptions): void;
declare global {
var zxcvbnts: {
core: {
ZxcvbnFactory: new (opts?: OptionsType) => ZxcvbnFactoryInstance;
};
'language-common': typeof ZxcvbnCommonPackage;
'language-en': typeof ZxcvbnEnPackage;
};
'language-common': {
translations: Record<string, string>;
adjacencyGraphs: Record<string, string>;
dictionary: Record<string, string[]>;
};
'language-en': {
translations: Record<string, string>;
dictionary: Record<string, string[]>;
};
};
}

export {};
Loading
Loading