favalib 0.0.14 → 0.0.15

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.
Files changed (53) hide show
  1. package/build/Command/BaseCommand.d.mts +5 -5
  2. package/build/Command/CommandQueue.d.mts +1 -1
  3. package/build/Command/CommandQueue.mjs +3 -3
  4. package/build/Command/commands/AddEntryCommand.d.mts +2 -2
  5. package/build/Command/commands/AddEntryCommand.mjs +1 -1
  6. package/build/Command/commands/AddSyncDeviceCommand.d.mts +2 -2
  7. package/build/Command/commands/AddSyncDeviceCommand.mjs +2 -2
  8. package/build/Command/commands/ChangeDeviceInfoCommand.d.mts +3 -3
  9. package/build/Command/commands/ChangeDeviceInfoCommand.mjs +2 -2
  10. package/build/Command/commands/DeleteEntryCommand.d.mts +2 -2
  11. package/build/Command/commands/DeleteEntryCommand.mjs +1 -1
  12. package/build/Command/commands/UpdateEntryCommand.d.mts +2 -2
  13. package/build/Command/commands/UpdateEntryCommand.mjs +1 -1
  14. package/build/{TwoFaLib.d.mts → FavaLib.d.mts} +5 -5
  15. package/build/{TwoFaLib.mjs → FavaLib.mjs} +14 -14
  16. package/build/{TwoFALibError.d.mts → FavaLibError.d.mts} +9 -9
  17. package/build/{TwoFALibError.mjs → FavaLibError.mjs} +13 -13
  18. package/build/{TwoFaLibEvent.d.mts → FavaLibEvent.d.mts} +1 -1
  19. package/build/FavaLibEvent.mjs +9 -0
  20. package/build/{TwoFaLibMediator.d.mts → FavaLibMediator.d.mts} +3 -3
  21. package/build/{TwoFaLibMediator.mjs → FavaLibMediator.mjs} +4 -4
  22. package/build/interfaces/Events.d.mts +10 -10
  23. package/build/interfaces/PlatformProviders.d.mts +4 -0
  24. package/build/interfaces/Vault.d.mts +2 -2
  25. package/build/main.d.mts +5 -5
  26. package/build/main.mjs +5 -5
  27. package/build/platformProviders/browser/cryptoLib.mjs +1 -1
  28. package/build/platformProviders/browser/index.mjs +2 -0
  29. package/build/platformProviders/browser/qrCodeLib.mjs +5 -5
  30. package/build/platformProviders/node/cryptoLib.mjs +1 -1
  31. package/build/platformProviders/node/index.mjs +2 -0
  32. package/build/platformProviders/node/qrCodeLib.mjs +2 -2
  33. package/build/subclasses/CommandManager.d.mts +2 -2
  34. package/build/subclasses/CommandManager.mjs +1 -1
  35. package/build/subclasses/ExportImportManager.d.mts +2 -2
  36. package/build/subclasses/ExportImportManager.mjs +1 -1
  37. package/build/subclasses/LibraryLoader.mjs +1 -1
  38. package/build/subclasses/PersistentStorageManager.d.mts +2 -2
  39. package/build/subclasses/PersistentStorageManager.mjs +3 -3
  40. package/build/subclasses/StorageOperationsManager.d.mts +2 -2
  41. package/build/subclasses/SyncManager.d.mts +2 -2
  42. package/build/subclasses/SyncManager.mjs +11 -11
  43. package/build/subclasses/VaultDataManager.d.mts +2 -2
  44. package/build/subclasses/VaultDataManager.mjs +6 -6
  45. package/build/subclasses/VaultOperationsManager.d.mts +3 -2
  46. package/build/subclasses/VaultOperationsManager.mjs +5 -3
  47. package/build/utils/creationUtils.d.mts +7 -7
  48. package/build/utils/creationUtils.mjs +16 -17
  49. package/build/utils/exportImportUtils.mjs +1 -1
  50. package/build/utils/qrUtils.mjs +2 -2
  51. package/build/utils/syncUtils.mjs +1 -1
  52. package/package.json +2 -1
  53. package/build/TwoFaLibEvent.mjs +0 -9
@@ -1,4 +1,4 @@
1
- import type TwoFaLibMediator from '../TwoFaLibMediator.mjs';
1
+ import type FavaLibMediator from '../FavaLibMediator.mjs';
2
2
  import { CommandData } from '../interfaces/CommandTypes.mjs';
3
3
  /**
4
4
  * Abstract base class for commands that interact with the vault.
@@ -23,16 +23,16 @@ declare abstract class BaseCommand<T extends CommandData = CommandData> {
23
23
  constructor(type: string, data: T, id?: string, timestamp?: number, version?: string, fromRemote?: boolean);
24
24
  /**
25
25
  * Executes the command using the provided mediator, which can be used to access the other classes.
26
- * @param VaultDataManager - The TwoFaLibMediator instance to use for execution.
26
+ * @param VaultDataManager - The FavaLibMediator instance to use for execution.
27
27
  * @returns A Promise that resolves when the execution is complete.
28
28
  */
29
- abstract execute(twoFaLibMediator: TwoFaLibMediator): Promise<void>;
29
+ abstract execute(favaLibMediator: FavaLibMediator): Promise<void>;
30
30
  /**
31
31
  * Creates an undo command that, when executed, reverses the effects of this command.
32
- * @param VaultDataManager - The TwoFaLibMediator instance to use for creating the undo command.
32
+ * @param VaultDataManager - The FavaLibMediator instance to use for creating the undo command.
33
33
  * @returns A BaseCommand instance that undoes this command or false if this command has no undo.
34
34
  */
35
- abstract createUndoCommand(TwoFaLibMediator: TwoFaLibMediator): BaseCommand | false;
35
+ abstract createUndoCommand(FavaLibMediator: FavaLibMediator): BaseCommand | false;
36
36
  /**
37
37
  * Creates a new instance of the command with the provided data.
38
38
  * @param data - The data to use for creating the new command instance.
@@ -16,7 +16,7 @@ declare class CommandQueue {
16
16
  /**
17
17
  * Removes and returns the first command from the queue.
18
18
  * @returns The first command in the queue, or undefined if the queue is empty.
19
- * @throws {TwoFALibError} If the queue is empty.
19
+ * @throws {FavaLibError} If the queue is empty.
20
20
  */
21
21
  dequeue(): Command | undefined;
22
22
  /**
@@ -1,4 +1,4 @@
1
- import { TwoFALibError } from '../TwoFALibError.mjs';
1
+ import { FavaLibError } from '../FavaLibError.mjs';
2
2
  /**
3
3
  * Represents a queue of commands with timestamp-based sorting.
4
4
  */
@@ -24,11 +24,11 @@ class CommandQueue {
24
24
  /**
25
25
  * Removes and returns the first command from the queue.
26
26
  * @returns The first command in the queue, or undefined if the queue is empty.
27
- * @throws {TwoFALibError} If the queue is empty.
27
+ * @throws {FavaLibError} If the queue is empty.
28
28
  */
29
29
  dequeue() {
30
30
  if (this.isEmpty()) {
31
- throw new TwoFALibError('Command queue is empty');
31
+ throw new FavaLibError('Command queue is empty');
32
32
  }
33
33
  return this.queue.shift();
34
34
  }
@@ -1,4 +1,4 @@
1
- import type TwoFaLibMediator from '../../TwoFaLibMediator.mjs';
1
+ import type FavaLibMediator from '../../FavaLibMediator.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import type Entry from '../../interfaces/Entry.mjs';
4
4
  export type AddEntryData = Entry;
@@ -17,7 +17,7 @@ declare class AddEntryCommand extends Command<AddEntryData> {
17
17
  * @inheritdoc
18
18
  * @throws {InvalidCommandError} If the command data is invalid.
19
19
  */
20
- execute(mediator: TwoFaLibMediator): Promise<void>;
20
+ execute(mediator: FavaLibMediator): Promise<void>;
21
21
  /**
22
22
  * @inheritdoc
23
23
  */
@@ -1,4 +1,4 @@
1
- import { InvalidCommandError } from '../../TwoFALibError.mjs';
1
+ import { InvalidCommandError } from '../../FavaLibError.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import DeleteEntryCommand from './DeleteEntryCommand.mjs';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type TwoFaLibMediator from '../../TwoFaLibMediator.mjs';
1
+ import type FavaLibMediator from '../../FavaLibMediator.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import type { DeviceId, DeviceInfo } from '../../interfaces/SyncTypes.mjs';
4
4
  import type { PublicKey } from '../../interfaces/CryptoLib.mjs';
@@ -22,7 +22,7 @@ declare class AddSyncDeviceCommand extends Command<AddSyncDeviceData> {
22
22
  * @inheritdoc
23
23
  * @throws {InvalidCommandError} If the command data is invalid.
24
24
  */
25
- execute(mediator: TwoFaLibMediator): Promise<void>;
25
+ execute(mediator: FavaLibMediator): Promise<void>;
26
26
  /**
27
27
  * @inheritdoc
28
28
  */
@@ -1,4 +1,4 @@
1
- import { InvalidCommandError, TwoFALibError } from '../../TwoFALibError.mjs';
1
+ import { InvalidCommandError, FavaLibError } from '../../FavaLibError.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  /**
4
4
  * Represents a command that when executed add an entry to the vault.
@@ -28,7 +28,7 @@ class AddSyncDeviceCommand extends Command {
28
28
  * @inheritdoc
29
29
  */
30
30
  createUndoCommand() {
31
- throw new TwoFALibError('Not implemented yet');
31
+ throw new FavaLibError('Not implemented yet');
32
32
  }
33
33
  /**
34
34
  * Validates the command data.
@@ -1,4 +1,4 @@
1
- import type TwoFaLibMediator from '../../TwoFaLibMediator.mjs';
1
+ import type FavaLibMediator from '../../FavaLibMediator.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import type { DeviceFriendlyName, DeviceId, DeviceType } from '../../interfaces/SyncTypes.mjs';
4
4
  export interface ChangeDeviceInfoData {
@@ -23,7 +23,7 @@ declare class ChangeDeviceInfoCommand extends Command<ChangeDeviceInfoData> {
23
23
  * @inheritdoc
24
24
  * @throws {InvalidCommandError} If the referenced device cannot be found
25
25
  */
26
- execute(mediator: TwoFaLibMediator): Promise<void>;
26
+ execute(mediator: FavaLibMediator): Promise<void>;
27
27
  /**
28
28
  * @inheritdoc
29
29
  */
@@ -32,6 +32,6 @@ declare class ChangeDeviceInfoCommand extends Command<ChangeDeviceInfoData> {
32
32
  * Validates the command data.
33
33
  * @inheritdoc
34
34
  */
35
- validate(mediator: TwoFaLibMediator): boolean;
35
+ validate(mediator: FavaLibMediator): boolean;
36
36
  }
37
37
  export default ChangeDeviceInfoCommand;
@@ -1,4 +1,4 @@
1
- import { InvalidCommandError, TwoFALibError } from '../../TwoFALibError.mjs';
1
+ import { InvalidCommandError, FavaLibError } from '../../FavaLibError.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  /**
4
4
  * Represents a command that when executed changes the device info of a sync device
@@ -43,7 +43,7 @@ class ChangeDeviceInfoCommand extends Command {
43
43
  * @inheritdoc
44
44
  */
45
45
  createUndoCommand() {
46
- throw new TwoFALibError('Not implemented yet');
46
+ throw new FavaLibError('Not implemented yet');
47
47
  }
48
48
  /**
49
49
  * Validates the command data.
@@ -1,5 +1,5 @@
1
1
  import Command from '../BaseCommand.mjs';
2
- import type TwoFaLibMediator from '../../TwoFaLibMediator.mjs';
2
+ import type FavaLibMediator from '../../FavaLibMediator.mjs';
3
3
  import type { EntryId } from '../../interfaces/Entry.mjs';
4
4
  export interface DeleteEntryData {
5
5
  entryId: EntryId;
@@ -20,7 +20,7 @@ declare class DeleteEntryCommand extends Command<DeleteEntryData> {
20
20
  * @inheritdoc
21
21
  * @throws {InvalidCommandError} If the command data is invalid or the entry doesn't exist.
22
22
  */
23
- execute(mediator: TwoFaLibMediator): Promise<void>;
23
+ execute(mediator: FavaLibMediator): Promise<void>;
24
24
  /**
25
25
  * @inheritdoc
26
26
  * @throws {InvalidCommandError} If the deleted entry content is not available.
@@ -1,4 +1,4 @@
1
- import { InvalidCommandError } from '../../TwoFALibError.mjs';
1
+ import { InvalidCommandError } from '../../FavaLibError.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import AddEntryCommand from './AddEntryCommand.mjs';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type TwoFaLibMediator from '../../TwoFaLibMediator.mjs';
1
+ import type FavaLibMediator from '../../FavaLibMediator.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  import type Entry from '../../interfaces/Entry.mjs';
4
4
  import { EntryId } from '../../interfaces/Entry.mjs';
@@ -23,7 +23,7 @@ declare class UpdateEntryCommand extends Command<UpdateEntryData> {
23
23
  * @inheritdoc
24
24
  * @throws {InvalidCommandError} If the command data is invalid.
25
25
  */
26
- execute(mediator: TwoFaLibMediator): Promise<void>;
26
+ execute(mediator: FavaLibMediator): Promise<void>;
27
27
  /**
28
28
  * @inheritdoc
29
29
  * @throws {InvalidCommandError} If the original entry is not available.
@@ -1,4 +1,4 @@
1
- import { InvalidCommandError } from '../../TwoFALibError.mjs';
1
+ import { InvalidCommandError } from '../../FavaLibError.mjs';
2
2
  import Command from '../BaseCommand.mjs';
3
3
  /**
4
4
  * Represents a command that when executed updates an entry in the vault.
@@ -2,7 +2,7 @@ import { TypedEventTarget } from 'typescript-event-target';
2
2
  import type { PlatformProviders } from './interfaces/PlatformProviders.mjs';
3
3
  import type { EncryptedPrivateKey, EncryptedSymmetricKey, PrivateKey, PublicKey, Salt, SymmetricKey } from './interfaces/CryptoLib.mjs';
4
4
  import type { DeviceFriendlyName, DeviceType } from './interfaces/SyncTypes.mjs';
5
- import type { TwoFaLibEventMapEvents } from './interfaces/Events.mjs';
5
+ import type { FavaLibEventMapEvents } from './interfaces/Events.mjs';
6
6
  import type { PasswordExtraDict } from './interfaces/PasswordExtraDict.js';
7
7
  import type { Vault, VaultSyncState } from './interfaces/Vault.mjs';
8
8
  import type { SaveFunction } from './interfaces/SaveFunction.mjs';
@@ -14,7 +14,7 @@ import StorageOperationsManager from './subclasses/StorageOperationsManager.mjs'
14
14
  /**
15
15
  * The Two-Factor Library, this is the main entry point.
16
16
  */
17
- declare class TwoFaLib extends TypedEventTarget<TwoFaLibEventMapEvents> {
17
+ declare class FavaLib extends TypedEventTarget<FavaLibEventMapEvents> {
18
18
  static readonly version = "0.0.1";
19
19
  private readonly favaMeta;
20
20
  readonly deviceType: DeviceType;
@@ -32,7 +32,7 @@ declare class TwoFaLib extends TypedEventTarget<TwoFaLibEventMapEvents> {
32
32
  deviceType: DeviceType;
33
33
  };
34
34
  /**
35
- * Constructs a new instance of TwoFaLib. If a serverUrl is provided, the library will use it for its sync operations.
35
+ * Constructs a new instance of FavaLib. If a serverUrl is provided, the library will use it for its sync operations.
36
36
  * @param deviceType - The identifier for this device type (e.g. 2fa-cli).
37
37
  * @param platformProviders - The platform-specific providers containing CryptoLib and other providers.
38
38
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
@@ -88,7 +88,7 @@ declare class TwoFaLib extends TypedEventTarget<TwoFaLibEventMapEvents> {
88
88
  setDeviceFriendlyName(deviceFriendlyName: DeviceFriendlyName): Promise<void>;
89
89
  /**
90
90
  * Dispatches a library event.
91
- * @param eventType - The type of the event to dispatch, uses the TwoFaLibEvent enum.
91
+ * @param eventType - The type of the event to dispatch, uses the FavaLibEvent enum.
92
92
  * @param data - Optional data to include with the event.
93
93
  */
94
94
  private dispatchLibEvent;
@@ -99,4 +99,4 @@ declare class TwoFaLib extends TypedEventTarget<TwoFaLibEventMapEvents> {
99
99
  */
100
100
  private log;
101
101
  }
102
- export default TwoFaLib;
102
+ export default FavaLib;
@@ -1,7 +1,7 @@
1
1
  import { TypedEventTarget } from 'typescript-event-target';
2
- import TwoFaLibMediator from './TwoFaLibMediator.mjs';
3
- import { TwoFaLibEvent } from './TwoFaLibEvent.mjs';
4
- import { InitializationError, SyncError, TwoFALibError, } from './TwoFALibError.mjs';
2
+ import FavaLibMediator from './FavaLibMediator.mjs';
3
+ import { FavaLibEvent } from './FavaLibEvent.mjs';
4
+ import { InitializationError, SyncError, FavaLibError, } from './FavaLibError.mjs';
5
5
  import SyncManager, { ConnectionStatus } from './subclasses/SyncManager.mjs';
6
6
  import LibraryLoader from './subclasses/LibraryLoader.mjs';
7
7
  import ExportImportManager from './subclasses/ExportImportManager.mjs';
@@ -14,7 +14,7 @@ import ChangeDeviceInfoCommand from './Command/commands/ChangeDeviceInfoCommand.
14
14
  /**
15
15
  * The Two-Factor Library, this is the main entry point.
16
16
  */
17
- class TwoFaLib extends TypedEventTarget {
17
+ class FavaLib extends TypedEventTarget {
18
18
  // TOOD: load this from package.json
19
19
  static { this.version = '0.0.1'; }
20
20
  /**
@@ -28,7 +28,7 @@ class TwoFaLib extends TypedEventTarget {
28
28
  };
29
29
  }
30
30
  /**
31
- * Constructs a new instance of TwoFaLib. If a serverUrl is provided, the library will use it for its sync operations.
31
+ * Constructs a new instance of FavaLib. If a serverUrl is provided, the library will use it for its sync operations.
32
32
  * @param deviceType - The identifier for this device type (e.g. 2fa-cli).
33
33
  * @param platformProviders - The platform-specific providers containing CryptoLib and other providers.
34
34
  * @param passwordExtraDict - Additional words to be used for password strength evaluation.
@@ -68,7 +68,7 @@ class TwoFaLib extends TypedEventTarget {
68
68
  this.deviceType = deviceType;
69
69
  this.publicKey = publicKey;
70
70
  this.privateKey = privateKey;
71
- this.mediator = new TwoFaLibMediator();
71
+ this.mediator = new FavaLibMediator();
72
72
  this.mediator.registerComponents([
73
73
  ['libraryLoader', new LibraryLoader(platformProviders)],
74
74
  [
@@ -97,7 +97,7 @@ class TwoFaLib extends TypedEventTarget {
97
97
  else {
98
98
  // If no syncmanager we're ready now, otherwise the syncmanager is responsible for emitting the ready event
99
99
  // We do this with a delay of 1, so that there is time to add event listeners
100
- setTimeout(() => this.dispatchLibEvent(TwoFaLibEvent.Ready), 1);
100
+ setTimeout(() => this.dispatchLibEvent(FavaLibEvent.Ready), 1);
101
101
  }
102
102
  // populate the ready property
103
103
  let setReady;
@@ -106,9 +106,9 @@ class TwoFaLib extends TypedEventTarget {
106
106
  });
107
107
  const handleReadyEvent = () => {
108
108
  setReady();
109
- this.removeEventListener(TwoFaLibEvent.Ready, handleReadyEvent);
109
+ this.removeEventListener(FavaLibEvent.Ready, handleReadyEvent);
110
110
  };
111
- this.addEventListener(TwoFaLibEvent.Ready, handleReadyEvent);
111
+ this.addEventListener(FavaLibEvent.Ready, handleReadyEvent);
112
112
  }
113
113
  /**
114
114
  * @returns The persistent storage manager instance which can be used to store data.
@@ -168,7 +168,7 @@ class TwoFaLib extends TypedEventTarget {
168
168
  this.mediator.unRegisterComponent('syncManager');
169
169
  this.mediator.registerComponent('syncManager', newSyncManager);
170
170
  const success = await new Promise((resolve) => {
171
- this.addEventListener(TwoFaLibEvent.ConnectionToSyncServerStatusChanged, (event) => {
171
+ this.addEventListener(FavaLibEvent.ConnectionToSyncServerStatusChanged, (event) => {
172
172
  if (event.detail.newStatus === ConnectionStatus.CONNECTED) {
173
173
  resolve(true);
174
174
  }
@@ -208,13 +208,13 @@ class TwoFaLib extends TypedEventTarget {
208
208
  };
209
209
  const command = ChangeDeviceInfoCommand.create(data);
210
210
  if (!command.validate(this.mediator)) {
211
- throw new TwoFALibError('Device friendly name has invalid length, max 256 characters');
211
+ throw new FavaLibError('Device friendly name has invalid length, max 256 characters');
212
212
  }
213
213
  await this.mediator.getComponent('commandManager').execute(command);
214
214
  }
215
215
  /**
216
216
  * Dispatches a library event.
217
- * @param eventType - The type of the event to dispatch, uses the TwoFaLibEvent enum.
217
+ * @param eventType - The type of the event to dispatch, uses the FavaLibEvent enum.
218
218
  * @param data - Optional data to include with the event.
219
219
  */
220
220
  dispatchLibEvent(eventType, data) {
@@ -226,7 +226,7 @@ class TwoFaLib extends TypedEventTarget {
226
226
  * @param message - The message to log.
227
227
  */
228
228
  log(severity, message) {
229
- this.dispatchLibEvent(TwoFaLibEvent.Log, { severity, message });
229
+ this.dispatchLibEvent(FavaLibEvent.Log, { severity, message });
230
230
  }
231
231
  }
232
- export default TwoFaLib;
232
+ export default FavaLib;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Custom error class for the libs errors.
3
3
  */
4
- export declare class TwoFALibError extends Error {
4
+ export declare class FavaLibError extends Error {
5
5
  /**
6
6
  * Creates a new Error.
7
7
  * @param message - The error message.
@@ -11,37 +11,37 @@ export declare class TwoFALibError extends Error {
11
11
  /**
12
12
  * Error thrown during lib initialization failures.
13
13
  */
14
- export declare class InitializationError extends TwoFALibError {
14
+ export declare class InitializationError extends FavaLibError {
15
15
  }
16
16
  /**
17
17
  * Error thrown during authentication, e.g. wrong password for locked vault.
18
18
  */
19
- export declare class AuthenticationError extends TwoFALibError {
19
+ export declare class AuthenticationError extends FavaLibError {
20
20
  }
21
21
  /**
22
22
  * Error thrown when an entry is requested but not found.
23
23
  */
24
- export declare class EntryNotFoundError extends TwoFALibError {
24
+ export declare class EntryNotFoundError extends FavaLibError {
25
25
  }
26
26
  /**
27
27
  * Error thrown when token generation fails.
28
28
  */
29
- export declare class TokenGenerationError extends TwoFALibError {
29
+ export declare class TokenGenerationError extends FavaLibError {
30
30
  }
31
31
  /**
32
32
  * Error thrown when an unexpected error occurs during cryptographic operations.
33
33
  */
34
- export declare class CryptoError extends TwoFALibError {
34
+ export declare class CryptoError extends FavaLibError {
35
35
  }
36
36
  /**
37
37
  * Error thrown when an unexpected error occurs during export/import operations.
38
38
  */
39
- export declare class ExportImportError extends TwoFALibError {
39
+ export declare class ExportImportError extends FavaLibError {
40
40
  }
41
41
  /**
42
42
  * Error thrown when an unexpected error occurs during synchronization.
43
43
  */
44
- export declare class SyncError extends TwoFALibError {
44
+ export declare class SyncError extends FavaLibError {
45
45
  }
46
46
  /**
47
47
  * Error thrown when synchronization is in the wrong state for the operation.
@@ -73,5 +73,5 @@ export declare class SyncNoServerConnectionError extends SyncError {
73
73
  /**
74
74
  * Error thrown when an invalid command is being executed.
75
75
  */
76
- export declare class InvalidCommandError extends TwoFALibError {
76
+ export declare class InvalidCommandError extends FavaLibError {
77
77
  }
@@ -2,50 +2,50 @@
2
2
  /**
3
3
  * Custom error class for the libs errors.
4
4
  */
5
- export class TwoFALibError extends Error {
5
+ export class FavaLibError extends Error {
6
6
  /**
7
7
  * Creates a new Error.
8
8
  * @param message - The error message.
9
9
  */
10
10
  constructor(message) {
11
11
  super(message);
12
- this.name = 'TwoFALibError';
12
+ this.name = 'FavaLibError';
13
13
  }
14
14
  }
15
15
  /**
16
16
  * Error thrown during lib initialization failures.
17
17
  */
18
- export class InitializationError extends TwoFALibError {
18
+ export class InitializationError extends FavaLibError {
19
19
  }
20
20
  /**
21
21
  * Error thrown during authentication, e.g. wrong password for locked vault.
22
22
  */
23
- export class AuthenticationError extends TwoFALibError {
23
+ export class AuthenticationError extends FavaLibError {
24
24
  }
25
25
  /**
26
26
  * Error thrown when an entry is requested but not found.
27
27
  */
28
- export class EntryNotFoundError extends TwoFALibError {
28
+ export class EntryNotFoundError extends FavaLibError {
29
29
  }
30
30
  /**
31
31
  * Error thrown when token generation fails.
32
32
  */
33
- export class TokenGenerationError extends TwoFALibError {
33
+ export class TokenGenerationError extends FavaLibError {
34
34
  }
35
35
  /**
36
36
  * Error thrown when an unexpected error occurs during cryptographic operations.
37
37
  */
38
- export class CryptoError extends TwoFALibError {
38
+ export class CryptoError extends FavaLibError {
39
39
  }
40
40
  /**
41
41
  * Error thrown when an unexpected error occurs during export/import operations.
42
42
  */
43
- export class ExportImportError extends TwoFALibError {
43
+ export class ExportImportError extends FavaLibError {
44
44
  }
45
45
  /**
46
46
  * Error thrown when an unexpected error occurs during synchronization.
47
47
  */
48
- export class SyncError extends TwoFALibError {
48
+ export class SyncError extends FavaLibError {
49
49
  }
50
50
  /**
51
51
  * Error thrown when synchronization is in the wrong state for the operation.
@@ -56,7 +56,7 @@ export class SyncInWrongStateError extends SyncError {
56
56
  */
57
57
  constructor(message) {
58
58
  super(message ?? 'Unexpected state while syncing');
59
- this.name = 'TwoFALibError';
59
+ this.name = 'FavaLibError';
60
60
  }
61
61
  }
62
62
  /**
@@ -69,7 +69,7 @@ export class SyncAddDeviceFlowConflictError extends SyncError {
69
69
  constructor(message) {
70
70
  super(message ??
71
71
  "Can't start an add device flow while a previous one is still active");
72
- this.name = 'TwoFALibError';
72
+ this.name = 'FavaLibError';
73
73
  }
74
74
  }
75
75
  /**
@@ -81,11 +81,11 @@ export class SyncNoServerConnectionError extends SyncError {
81
81
  */
82
82
  constructor(message) {
83
83
  super(message ?? 'No server connection available');
84
- this.name = 'TwoFALibError';
84
+ this.name = 'FavaLibError';
85
85
  }
86
86
  }
87
87
  /**
88
88
  * Error thrown when an invalid command is being executed.
89
89
  */
90
- export class InvalidCommandError extends TwoFALibError {
90
+ export class InvalidCommandError extends FavaLibError {
91
91
  }
@@ -1,4 +1,4 @@
1
- export declare enum TwoFaLibEvent {
1
+ export declare enum FavaLibEvent {
2
2
  Changed = "changed",
3
3
  LoadedFromLockedRepresentation = "loadedFromLockedRepresentation",
4
4
  ConnectToExistingVaultFinished = "connectToExistingVaultFinished",
@@ -0,0 +1,9 @@
1
+ export var FavaLibEvent;
2
+ (function (FavaLibEvent) {
3
+ FavaLibEvent["Changed"] = "changed";
4
+ FavaLibEvent["LoadedFromLockedRepresentation"] = "loadedFromLockedRepresentation";
5
+ FavaLibEvent["ConnectToExistingVaultFinished"] = "connectToExistingVaultFinished";
6
+ FavaLibEvent["ConnectionToSyncServerStatusChanged"] = "connectionToSyncServerStatusChanged";
7
+ FavaLibEvent["Log"] = "log";
8
+ FavaLibEvent["Ready"] = "ready";
9
+ })(FavaLibEvent || (FavaLibEvent = {}));
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Mediator class for managing and accessing various components of the TwoFaLib.
2
+ * Mediator class for managing and accessing various components of the FavaLib.
3
3
  */
4
- declare class TwoFaLibMediator {
4
+ declare class FavaLibMediator {
5
5
  private components;
6
6
  /**
7
7
  * Unregister a component with the mediator. Is used in testing
@@ -34,4 +34,4 @@ declare class TwoFaLibMediator {
34
34
  */
35
35
  componentIsInitialised<T extends keyof typeof this.components>(key: T): boolean;
36
36
  }
37
- export default TwoFaLibMediator;
37
+ export default FavaLibMediator;
@@ -1,8 +1,8 @@
1
- import { InitializationError } from './TwoFALibError.mjs';
1
+ import { InitializationError } from './FavaLibError.mjs';
2
2
  /**
3
- * Mediator class for managing and accessing various components of the TwoFaLib.
3
+ * Mediator class for managing and accessing various components of the FavaLib.
4
4
  */
5
- class TwoFaLibMediator {
5
+ class FavaLibMediator {
6
6
  constructor() {
7
7
  this.components = {};
8
8
  }
@@ -55,4 +55,4 @@ class TwoFaLibMediator {
55
55
  return Boolean(this.components[key]);
56
56
  }
57
57
  }
58
- export default TwoFaLibMediator;
58
+ export default FavaLibMediator;
@@ -1,19 +1,19 @@
1
1
  import type { EmptyObject } from 'type-fest';
2
- import type { TwoFaLibEvent } from '../TwoFaLibEvent.mjs';
2
+ import type { FavaLibEvent } from '../FavaLibEvent.mjs';
3
3
  import type { ConnectionStatus } from '../subclasses/SyncManager.mjs';
4
- export interface TwoFaLibEventMap {
5
- [TwoFaLibEvent.Changed]: EmptyObject;
6
- [TwoFaLibEvent.LoadedFromLockedRepresentation]: EmptyObject;
7
- [TwoFaLibEvent.ConnectToExistingVaultFinished]: EmptyObject;
8
- [TwoFaLibEvent.ConnectionToSyncServerStatusChanged]: {
4
+ export interface FavaLibEventMap {
5
+ [FavaLibEvent.Changed]: EmptyObject;
6
+ [FavaLibEvent.LoadedFromLockedRepresentation]: EmptyObject;
7
+ [FavaLibEvent.ConnectToExistingVaultFinished]: EmptyObject;
8
+ [FavaLibEvent.ConnectionToSyncServerStatusChanged]: {
9
9
  newStatus: ConnectionStatus;
10
10
  };
11
- [TwoFaLibEvent.Log]: {
11
+ [FavaLibEvent.Log]: {
12
12
  severity: 'info' | 'warning';
13
13
  message: string;
14
14
  };
15
- [TwoFaLibEvent.Ready]: EmptyObject;
15
+ [FavaLibEvent.Ready]: EmptyObject;
16
16
  }
17
- export type TwoFaLibEventMapEvents = {
18
- [K in keyof TwoFaLibEventMap]: CustomEvent<TwoFaLibEventMap[K]>;
17
+ export type FavaLibEventMapEvents = {
18
+ [K in keyof FavaLibEventMap]: CustomEvent<FavaLibEventMap[K]>;
19
19
  };
@@ -22,5 +22,9 @@ export interface PlatformProviders {
22
22
  * OpenPGP encryption library
23
23
  */
24
24
  OpenPgpLib: new () => OpenPgpLib;
25
+ /**
26
+ * genUuidV4 function
27
+ */
28
+ genUuidV4: () => string;
25
29
  }
26
30
  export default PlatformProviders;
@@ -1,8 +1,8 @@
1
1
  import type { Tagged } from 'type-fest';
2
2
  import type { Encrypted, EncryptedPrivateKey, EncryptedSymmetricKey, Salt } from './CryptoLib.mjs';
3
3
  import type Entry from './Entry.mjs';
4
- import { DeviceFriendlyName, DeviceId, SyncDevice } from './SyncTypes.mjs';
5
- import { SyncCommandFromClient } from 'favaserver/ClientMessage';
4
+ import type { DeviceFriendlyName, DeviceId, SyncDevice } from './SyncTypes.mjs';
5
+ import type { SyncCommandFromClient } from 'favaserver/ClientMessage';
6
6
  export type Vault = Entry[];
7
7
  export type EncryptedVaultStateString = Encrypted<VaultStateString>;
8
8
  export interface LockedRepresentation {
package/build/main.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import TwoFaLib from './TwoFaLib.mjs';
1
+ import FavaLib from './FavaLib.mjs';
2
2
  import type Entry from './interfaces/Entry.mjs';
3
3
  import type { EntryId, NewEntry, EntryMeta, EntryType, TotpPayload, Token, EntryMetaWithToken } from './interfaces/Entry.mjs';
4
4
  import type CryptoLib from './interfaces/CryptoLib.mjs';
@@ -7,8 +7,8 @@ import type { PublicSyncDevice, DeviceId, DeviceType, DeviceFriendlyName, Device
7
7
  import type { EncryptedVaultStateString, LockedRepresentationString } from './interfaces/Vault.mjs';
8
8
  import type { SaveFunction } from './interfaces/SaveFunction.mjs';
9
9
  import type { PlatformProviders } from './interfaces/PlatformProviders.mjs';
10
- import { TwoFALibError, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError } from './TwoFALibError.mjs';
11
- import { TwoFaLibEvent } from './TwoFaLibEvent.mjs';
12
- import { getTwoFaLibVaultCreationUtils } from './utils/creationUtils.mjs';
13
- export { TwoFaLib, TwoFALibError, getTwoFaLibVaultCreationUtils, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, TwoFaLibEvent, };
10
+ import { FavaLibError, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError } from './FavaLibError.mjs';
11
+ import { FavaLibEvent } from './FavaLibEvent.mjs';
12
+ import { getFavaLibVaultCreationUtils } from './utils/creationUtils.mjs';
13
+ export { FavaLib, FavaLibError, getFavaLibVaultCreationUtils, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, FavaLibEvent, };
14
14
  export type { Entry, EntryId, NewEntry, EntryMeta, EntryMetaWithToken, EntryType, TotpPayload, Token, EncryptedVaultStateString, LockedRepresentationString, CryptoLib, Encrypted, EncryptedPrivateKey, EncryptedPublicKey, EncryptedSymmetricKey, PrivateKey, SymmetricKey, PublicKey, Password, Salt, DeviceId, DeviceType, DeviceFriendlyName, DeviceInfo, PublicSyncDevice, SaveFunction, PlatformProviders, };
package/build/main.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import TwoFaLib from './TwoFaLib.mjs';
2
- import { TwoFALibError, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, } from './TwoFALibError.mjs';
3
- import { TwoFaLibEvent } from './TwoFaLibEvent.mjs';
4
- import { getTwoFaLibVaultCreationUtils } from './utils/creationUtils.mjs';
5
- export { TwoFaLib, TwoFALibError, getTwoFaLibVaultCreationUtils, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, TwoFaLibEvent, };
1
+ import FavaLib from './FavaLib.mjs';
2
+ import { FavaLibError, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, } from './FavaLibError.mjs';
3
+ import { FavaLibEvent } from './FavaLibEvent.mjs';
4
+ import { getFavaLibVaultCreationUtils } from './utils/creationUtils.mjs';
5
+ export { FavaLib, FavaLibError, getFavaLibVaultCreationUtils, InitializationError, AuthenticationError, EntryNotFoundError, TokenGenerationError, FavaLibEvent, };
@@ -1,7 +1,7 @@
1
1
  import forge from 'node-forge';
2
2
  import { base64ToUint8Array, stringToUint8Array, uint8ArrayToBase64, uint8ArrayToString, } from 'uint8array-extras';
3
3
  import { argon2id } from 'hash-wasm';
4
- import { CryptoError } from '../../TwoFALibError.mjs';
4
+ import { CryptoError } from '../../FavaLibError.mjs';
5
5
  /**
6
6
  * Normalizes line endings in a string so they match the
7
7
  * node cryptoprovider format