import { Observable } from "rxjs"; import { KdfConfig } from "../../auth/models/domain/kdf-config"; import { BiometricKey } from "../../auth/types/biometric-key"; import { GeneratorOptions } from "../../tools/generator/generator-options"; import { GeneratedPasswordHistory, PasswordGeneratorOptions } from "../../tools/generator/password"; import { UsernameGeneratorOptions } from "../../tools/generator/username"; import { UserId } from "../../types/guid"; import { KdfType } from "../enums"; import { Account } from "../models/domain/account"; import { EncString } from "../models/domain/enc-string"; import { StorageOptions } from "../models/domain/storage-options"; /** * Options for customizing the initiation behavior. */ export type InitOptions = { /** * Whether or not to run state migrations as part of the init process. Defaults to true. * * If false, the init method will instead wait for migrations to complete before doing its * other init operations. Make sure migrations have either already completed, or will complete * before calling {@link StateService.init} with `runMigrations: false`. */ runMigrations?: boolean; }; export abstract class StateService { accounts$: Observable<{ [userId: string]: T }>; activeAccount$: Observable; addAccount: (account: T) => Promise; setActiveUser: (userId: string) => Promise; clean: (options?: StorageOptions) => Promise; init: (initOptions?: InitOptions) => Promise; /** * Gets the user's auto key */ getUserKeyAutoUnlock: (options?: StorageOptions) => Promise; /** * Sets the user's auto key */ setUserKeyAutoUnlock: (value: string, options?: StorageOptions) => Promise; /** * Gets the user's biometric key */ getUserKeyBiometric: (options?: StorageOptions) => Promise; /** * Checks if the user has a biometric key available */ hasUserKeyBiometric: (options?: StorageOptions) => Promise; /** * Sets the user's biometric key */ setUserKeyBiometric: (value: BiometricKey, options?: StorageOptions) => Promise; /** * Gets the user key encrypted by the Pin key. * Used when Lock with MP on Restart is disabled */ getPinKeyEncryptedUserKey: (options?: StorageOptions) => Promise; /** * Sets the user key encrypted by the Pin key. * Used when Lock with MP on Restart is disabled */ setPinKeyEncryptedUserKey: (value: EncString, options?: StorageOptions) => Promise; /** * Gets the ephemeral version of the user key encrypted by the Pin key. * Used when Lock with MP on Restart is enabled */ getPinKeyEncryptedUserKeyEphemeral: (options?: StorageOptions) => Promise; /** * Sets the ephemeral version of the user key encrypted by the Pin key. * Used when Lock with MP on Restart is enabled */ setPinKeyEncryptedUserKeyEphemeral: (value: EncString, options?: StorageOptions) => Promise; /** * @deprecated For backwards compatible purposes only, use DesktopAutofillSettingsService */ setEnableDuckDuckGoBrowserIntegration: ( value: boolean, options?: StorageOptions, ) => Promise; /** * @deprecated For migration purposes only, use getUserKeyMasterKey instead */ getEncryptedCryptoSymmetricKey: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use getUserKeyAuto instead */ getCryptoMasterKeyAuto: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use setUserKeyAuto instead */ setCryptoMasterKeyAuto: (value: string, options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use getUserKeyBiometric instead */ getCryptoMasterKeyBiometric: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use hasUserKeyBiometric instead */ hasCryptoMasterKeyBiometric: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use setUserKeyBiometric instead */ setCryptoMasterKeyBiometric: (value: BiometricKey, options?: StorageOptions) => Promise; getDecryptedPasswordGenerationHistory: ( options?: StorageOptions, ) => Promise; setDecryptedPasswordGenerationHistory: ( value: GeneratedPasswordHistory[], options?: StorageOptions, ) => Promise; /** * @deprecated For migration purposes only, use getDecryptedUserKeyPin instead */ getDecryptedPinProtected: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use setDecryptedUserKeyPin instead */ setDecryptedPinProtected: (value: EncString, options?: StorageOptions) => Promise; getDuckDuckGoSharedKey: (options?: StorageOptions) => Promise; setDuckDuckGoSharedKey: (value: string, options?: StorageOptions) => Promise; getEmail: (options?: StorageOptions) => Promise; setEmail: (value: string, options?: StorageOptions) => Promise; getEmailVerified: (options?: StorageOptions) => Promise; setEmailVerified: (value: boolean, options?: StorageOptions) => Promise; getEnableBrowserIntegration: (options?: StorageOptions) => Promise; setEnableBrowserIntegration: (value: boolean, options?: StorageOptions) => Promise; getEnableBrowserIntegrationFingerprint: (options?: StorageOptions) => Promise; setEnableBrowserIntegrationFingerprint: ( value: boolean, options?: StorageOptions, ) => Promise; getEncryptedPasswordGenerationHistory: ( options?: StorageOptions, ) => Promise; setEncryptedPasswordGenerationHistory: ( value: GeneratedPasswordHistory[], options?: StorageOptions, ) => Promise; /** * @deprecated For migration purposes only, use getEncryptedUserKeyPin instead */ getEncryptedPinProtected: (options?: StorageOptions) => Promise; /** * @deprecated For migration purposes only, use setEncryptedUserKeyPin instead */ setEncryptedPinProtected: (value: string, options?: StorageOptions) => Promise; getIsAuthenticated: (options?: StorageOptions) => Promise; getKdfConfig: (options?: StorageOptions) => Promise; setKdfConfig: (kdfConfig: KdfConfig, options?: StorageOptions) => Promise; getKdfType: (options?: StorageOptions) => Promise; setKdfType: (value: KdfType, options?: StorageOptions) => Promise; getLastActive: (options?: StorageOptions) => Promise; setLastActive: (value: number, options?: StorageOptions) => Promise; getLastSync: (options?: StorageOptions) => Promise; setLastSync: (value: string, options?: StorageOptions) => Promise; getMinimizeOnCopyToClipboard: (options?: StorageOptions) => Promise; setMinimizeOnCopyToClipboard: (value: boolean, options?: StorageOptions) => Promise; getOrganizationInvitation: (options?: StorageOptions) => Promise; setOrganizationInvitation: (value: any, options?: StorageOptions) => Promise; getPasswordGenerationOptions: (options?: StorageOptions) => Promise; setPasswordGenerationOptions: ( value: PasswordGeneratorOptions, options?: StorageOptions, ) => Promise; getUsernameGenerationOptions: (options?: StorageOptions) => Promise; setUsernameGenerationOptions: ( value: UsernameGeneratorOptions, options?: StorageOptions, ) => Promise; getGeneratorOptions: (options?: StorageOptions) => Promise; setGeneratorOptions: (value: GeneratorOptions, options?: StorageOptions) => Promise; /** * Gets the user's Pin, encrypted by the user key */ getProtectedPin: (options?: StorageOptions) => Promise; /** * Sets the user's Pin, encrypted by the user key */ setProtectedPin: (value: string, options?: StorageOptions) => Promise; getUserId: (options?: StorageOptions) => Promise; getVaultTimeout: (options?: StorageOptions) => Promise; setVaultTimeout: (value: number, options?: StorageOptions) => Promise; getVaultTimeoutAction: (options?: StorageOptions) => Promise; setVaultTimeoutAction: (value: string, options?: StorageOptions) => Promise; nextUpActiveUser: () => Promise; }