favalib 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ class ExportImportManager {
50
50
  throw new ExportImportError('Invalid export format');
51
51
  }
52
52
  if (password) {
53
- await validatePasswordStrength(this.libraryLoader, password, this.passwordExtraDict);
53
+ await validatePasswordStrength(this.libraryLoader, this.passwordExtraDict, password);
54
54
  return encryptExport(this.libraryLoader.getOpenPGPLib(), exportData, password);
55
55
  }
56
56
  return exportData;
@@ -144,7 +144,7 @@ class PersistentStorageManager {
144
144
  * @throws {AuthenticationError} If the provided old password is incorrect.
145
145
  */
146
146
  async changePassword(oldPassword, newPassword) {
147
- await validatePasswordStrength(this.mediator.getComponent('libraryLoader'), newPassword, this.passwordExtraDict);
147
+ await validatePasswordStrength(this.mediator.getComponent('libraryLoader'), this.passwordExtraDict, newPassword);
148
148
  const isValid = await this.validatePassword(this.salt, oldPassword);
149
149
  if (!isValid)
150
150
  throw new AuthenticationError('Invalid old password');
@@ -10,19 +10,19 @@ import { SaveFunction } from '../interfaces/SaveFunction.mjs';
10
10
  /**
11
11
  * Evaluates the strength of a password.
12
12
  * @param libraryLoader - An instance of LibraryLoader.
13
- * @param password - The password to evaluate.
14
13
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
14
+ * @param password - The password to evaluate.
15
15
  * @returns Promise resolving to the password strength result.
16
16
  */
17
- export declare const getPasswordStrength: (libraryLoader: LibraryLoader, password: Password, passwordExtraDict: PasswordExtraDict) => Promise<ZxcvbnResult>;
17
+ export declare const getPasswordStrength: (libraryLoader: LibraryLoader, passwordExtraDict: PasswordExtraDict, password: Password) => Promise<ZxcvbnResult>;
18
18
  /**
19
19
  * Validates the strength of a password.
20
20
  * @param libraryLoader - An instance of LibraryLoader.
21
- * @param password - The password to validate.
22
21
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
22
+ * @param password - The password to validate.
23
23
  * @throws {InitializationError} If the password is too weak.
24
24
  */
25
- export declare const validatePasswordStrength: (libraryLoader: LibraryLoader, password: Password, passwordExtraDict: PasswordExtraDict) => Promise<void>;
25
+ export declare const validatePasswordStrength: (libraryLoader: LibraryLoader, passwordExtraDict: PasswordExtraDict, password: Password) => Promise<void>;
26
26
  /**
27
27
  * Returns utility functions useful in creating a new twoFaLib vault
28
28
  * @param platformProviders - The platform-specific providers containing CryptoLib and other providers.
@@ -33,7 +33,7 @@ export declare const validatePasswordStrength: (libraryLoader: LibraryLoader, pa
33
33
  * @returns An object with methods to evaluate password strength and create a new TwoFaLib vault.
34
34
  */
35
35
  export declare const getTwoFaLibVaultCreationUtils: (platformProviders: PlatformProviders, deviceType: DeviceType, passwordExtraDict: PasswordExtraDict, saveFunction?: SaveFunction, serverUrl?: string) => {
36
- getPasswordStrength: (password: Password, passwordExtraDict: PasswordExtraDict) => Promise<ZxcvbnResult>;
36
+ getPasswordStrength: (password: Password) => Promise<ZxcvbnResult>;
37
37
  createNewTwoFaLibVault: (password: Password) => Promise<{
38
38
  twoFaLib: TwoFaLib;
39
39
  publicKey: import("../interfaces/CryptoLib.mjs").PublicKey;
@@ -5,11 +5,11 @@ import LibraryLoader from '../subclasses/LibraryLoader.mjs';
5
5
  /**
6
6
  * Evaluates the strength of a password.
7
7
  * @param libraryLoader - An instance of LibraryLoader.
8
- * @param password - The password to evaluate.
9
8
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
9
+ * @param password - The password to evaluate.
10
10
  * @returns Promise resolving to the password strength result.
11
11
  */
12
- export const getPasswordStrength = async (libraryLoader, password, passwordExtraDict) => {
12
+ export const getPasswordStrength = async (libraryLoader, passwordExtraDict, password) => {
13
13
  const zxcvbn = await libraryLoader.getZxcvbn();
14
14
  return zxcvbn(password, [
15
15
  'twofactor',
@@ -40,12 +40,12 @@ export const getPasswordStrength = async (libraryLoader, password, passwordExtra
40
40
  /**
41
41
  * Validates the strength of a password.
42
42
  * @param libraryLoader - An instance of LibraryLoader.
43
- * @param password - The password to validate.
44
43
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
44
+ * @param password - The password to validate.
45
45
  * @throws {InitializationError} If the password is too weak.
46
46
  */
47
- export const validatePasswordStrength = async (libraryLoader, password, passwordExtraDict) => {
48
- const passwordStrength = await getPasswordStrength(libraryLoader, password, passwordExtraDict);
47
+ export const validatePasswordStrength = async (libraryLoader, passwordExtraDict, password) => {
48
+ const passwordStrength = await getPasswordStrength(libraryLoader, passwordExtraDict, password);
49
49
  if (passwordStrength.score < 3) {
50
50
  throw new TwoFALibError('Password is too weak');
51
51
  }
@@ -64,7 +64,7 @@ const createNewTwoFaLibVault = async (libraryLoader, deviceType, serverUrl, pass
64
64
  const cryptoLib = libraryLoader.getCryptoLib();
65
65
  const platformProviders = libraryLoader.getPlatformProviders();
66
66
  const { publicKey, privateKey, symmetricKey, encryptedPrivateKey, encryptedSymmetricKey, salt, } = await cryptoLib.createKeys(password);
67
- await validatePasswordStrength(libraryLoader, password, passwordExtraDict);
67
+ await validatePasswordStrength(libraryLoader, passwordExtraDict, password);
68
68
  const deviceId = genUuidV4();
69
69
  const twoFaLib = new TwoFaLib(deviceType, platformProviders, passwordExtraDict, privateKey, symmetricKey, encryptedPrivateKey, encryptedSymmetricKey, salt, publicKey, {
70
70
  deviceId,
@@ -128,7 +128,7 @@ const loadTwoFaLibFromLockedRepesentation = async (libraryLoader, deviceType, pa
128
128
  export const getTwoFaLibVaultCreationUtils = (platformProviders, deviceType, passwordExtraDict, saveFunction, serverUrl) => {
129
129
  const libraryLoader = new LibraryLoader(platformProviders);
130
130
  return {
131
- getPasswordStrength: getPasswordStrength.bind(null, libraryLoader),
131
+ getPasswordStrength: getPasswordStrength.bind(null, libraryLoader, passwordExtraDict),
132
132
  createNewTwoFaLibVault: createNewTwoFaLibVault.bind(null, libraryLoader, deviceType, serverUrl, passwordExtraDict, saveFunction),
133
133
  loadTwoFaLibFromLockedRepesentation: loadTwoFaLibFromLockedRepesentation.bind(null, libraryLoader, deviceType, passwordExtraDict, saveFunction),
134
134
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "favalib",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {