import { Observable } from "rxjs"; import { OrganizationData } from "../../admin-console/models/data/organization.data"; import { AdminAuthRequestStorable } from "../../auth/models/domain/admin-auth-req-storable"; import { ForceSetPasswordReason } from "../../auth/models/domain/force-set-password-reason"; import { KdfConfig } from "../../auth/models/domain/kdf-config"; import { BiometricKey } from "../../auth/types/biometric-key"; import { EventData } from "../../models/data/event.data"; import { WindowState } from "../../models/domain/window-state"; import { GeneratorOptions } from "../../tools/generator/generator-options"; import { GeneratedPasswordHistory, PasswordGeneratorOptions } from "../../tools/generator/password"; import { UsernameGeneratorOptions } from "../../tools/generator/username"; import { SendData } from "../../tools/send/models/data/send.data"; import { SendView } from "../../tools/send/models/view/send.view"; import { UserId } from "../../types/guid"; import { DeviceKey, MasterKey } from "../../types/key"; import { CipherData } from "../../vault/models/data/cipher.data"; import { LocalData } from "../../vault/models/data/local.data"; import { CipherView } from "../../vault/models/view/cipher.view"; import { AddEditCipherInfo } from "../../vault/types/add-edit-cipher-info"; import { KdfType } from "../enums"; import { ServerConfigData } from "../models/data/server-config.data"; import { Account, AccountDecryptionOptions } from "../models/domain/account"; import { EncString } from "../models/domain/enc-string"; import { StorageOptions } from "../models/domain/storage-options"; import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key"; /** * 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; /** * @deprecated use accountService.activeAccount$ instead */ activeAccountUnlocked$: Observable; addAccount: (account: T) => Promise; setActiveUser: (userId: string) => Promise; clean: (options?: StorageOptions) => Promise; init: (initOptions?: InitOptions) => Promise; getAccessToken: (options?: StorageOptions) => Promise; setAccessToken: (value: string, options?: StorageOptions) => Promise; getAddEditCipherInfo: (options?: StorageOptions) => Promise; setAddEditCipherInfo: (value: AddEditCipherInfo, options?: StorageOptions) => Promise; getAlwaysShowDock: (options?: StorageOptions) => Promise; setAlwaysShowDock: (value: boolean, options?: StorageOptions) => Promise; getApiKeyClientId: (options?: StorageOptions) => Promise; setApiKeyClientId: (value: string, options?: StorageOptions) => Promise; getApiKeyClientSecret: (options?: StorageOptions) => Promise; setApiKeyClientSecret: (value: string, options?: StorageOptions) => Promise; getAutoConfirmFingerPrints: (options?: StorageOptions) => Promise; setAutoConfirmFingerprints: (value: boolean, options?: StorageOptions) => Promise; getBiometricFingerprintValidated: (options?: StorageOptions) => Promise; setBiometricFingerprintValidated: (value: boolean, options?: StorageOptions) => Promise; getCanAccessPremium: (options?: StorageOptions) => Promise; getHasPremiumPersonally: (options?: StorageOptions) => Promise; setHasPremiumPersonally: (value: boolean, options?: StorageOptions) => Promise; setHasPremiumFromOrganization: (value: boolean, options?: StorageOptions) => Promise; getHasPremiumFromOrganization: (options?: StorageOptions) => Promise; getConvertAccountToKeyConnector: (options?: StorageOptions) => Promise; setConvertAccountToKeyConnector: (value: boolean, options?: StorageOptions) => Promise; /** * Gets the user's master key */ getMasterKey: (options?: StorageOptions) => Promise; /** * Sets the user's master key */ setMasterKey: (value: MasterKey, options?: StorageOptions) => Promise; /** * Gets the user key encrypted by the master key */ getMasterKeyEncryptedUserKey: (options?: StorageOptions) => Promise; /** * Sets the user key encrypted by the master key */ setMasterKeyEncryptedUserKey: (value: string, options?: StorageOptions) => 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 migration purposes only, use getUserKeyMasterKey instead */ getEncryptedCryptoSymmetricKey: (options?: StorageOptions) => Promise; /** * @deprecated For legacy purposes only, use getMasterKey instead */ getCryptoMasterKey: (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; getDecryptedCiphers: (options?: StorageOptions) => Promise; setDecryptedCiphers: (value: CipherView[], 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; /** * @deprecated Do not call this directly, use SendService */ getDecryptedSends: (options?: StorageOptions) => Promise; /** * @deprecated Do not call this directly, use SendService */ setDecryptedSends: (value: SendView[], options?: StorageOptions) => Promise; /** * @deprecated Do not call this, use SettingsService */ getDisableFavicon: (options?: StorageOptions) => Promise; /** * @deprecated Do not call this, use SettingsService */ setDisableFavicon: (value: boolean, options?: StorageOptions) => Promise; getDisableGa: (options?: StorageOptions) => Promise; setDisableGa: (value: boolean, options?: StorageOptions) => Promise; getDontShowCardsCurrentTab: (options?: StorageOptions) => Promise; setDontShowCardsCurrentTab: (value: boolean, options?: StorageOptions) => Promise; getDontShowIdentitiesCurrentTab: (options?: StorageOptions) => Promise; setDontShowIdentitiesCurrentTab: (value: boolean, options?: StorageOptions) => Promise; getDuckDuckGoSharedKey: (options?: StorageOptions) => Promise; setDuckDuckGoSharedKey: (value: string, options?: StorageOptions) => Promise; getDeviceKey: (options?: StorageOptions) => Promise; setDeviceKey: (value: DeviceKey | null, options?: StorageOptions) => Promise; getAdminAuthRequest: (options?: StorageOptions) => Promise; setAdminAuthRequest: ( adminAuthRequest: AdminAuthRequestStorable, options?: StorageOptions, ) => Promise; getShouldTrustDevice: (options?: StorageOptions) => Promise; setShouldTrustDevice: (value: boolean, options?: StorageOptions) => Promise; getAccountDecryptionOptions: ( options?: StorageOptions, ) => Promise; setAccountDecryptionOptions: ( value: AccountDecryptionOptions, options?: StorageOptions, ) => Promise; getEmail: (options?: StorageOptions) => Promise; setEmail: (value: string, options?: StorageOptions) => Promise; getEmailVerified: (options?: StorageOptions) => Promise; setEmailVerified: (value: boolean, options?: StorageOptions) => Promise; getEnableAlwaysOnTop: (options?: StorageOptions) => Promise; setEnableAlwaysOnTop: (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; getEnableCloseToTray: (options?: StorageOptions) => Promise; setEnableCloseToTray: (value: boolean, options?: StorageOptions) => Promise; getEnableDuckDuckGoBrowserIntegration: (options?: StorageOptions) => Promise; setEnableDuckDuckGoBrowserIntegration: ( value: boolean, options?: StorageOptions, ) => Promise; getEnableMinimizeToTray: (options?: StorageOptions) => Promise; setEnableMinimizeToTray: (value: boolean, options?: StorageOptions) => Promise; getEnableStartToTray: (options?: StorageOptions) => Promise; setEnableStartToTray: (value: boolean, options?: StorageOptions) => Promise; getEnableTray: (options?: StorageOptions) => Promise; setEnableTray: (value: boolean, options?: StorageOptions) => Promise; getEncryptedCiphers: (options?: StorageOptions) => Promise<{ [id: string]: CipherData }>; setEncryptedCiphers: ( value: { [id: string]: CipherData }, 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; /** * @deprecated Do not call this directly, use SendService */ getEncryptedSends: (options?: StorageOptions) => Promise<{ [id: string]: SendData }>; /** * @deprecated Do not call this directly, use SendService */ setEncryptedSends: (value: { [id: string]: SendData }, options?: StorageOptions) => Promise; getEventCollection: (options?: StorageOptions) => Promise; setEventCollection: (value: EventData[], options?: StorageOptions) => Promise; getEverBeenUnlocked: (options?: StorageOptions) => Promise; setEverBeenUnlocked: (value: boolean, options?: StorageOptions) => Promise; getForceSetPasswordReason: (options?: StorageOptions) => Promise; setForceSetPasswordReason: ( value: ForceSetPasswordReason, options?: StorageOptions, ) => Promise; getInstalledVersion: (options?: StorageOptions) => Promise; setInstalledVersion: (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; getKeyHash: (options?: StorageOptions) => Promise; setKeyHash: (value: string, options?: StorageOptions) => Promise; getLastActive: (options?: StorageOptions) => Promise; setLastActive: (value: number, options?: StorageOptions) => Promise; getLastSync: (options?: StorageOptions) => Promise; setLastSync: (value: string, options?: StorageOptions) => Promise; getLocalData: (options?: StorageOptions) => Promise<{ [cipherId: string]: LocalData }>; setLocalData: ( value: { [cipherId: string]: LocalData }, options?: StorageOptions, ) => Promise; getLocale: (options?: StorageOptions) => Promise; setLocale: (value: string, options?: StorageOptions) => Promise; getMainWindowSize: (options?: StorageOptions) => Promise; setMainWindowSize: (value: number, options?: StorageOptions) => Promise; getMinimizeOnCopyToClipboard: (options?: StorageOptions) => Promise; setMinimizeOnCopyToClipboard: (value: boolean, options?: StorageOptions) => Promise; getOpenAtLogin: (options?: StorageOptions) => Promise; setOpenAtLogin: (value: boolean, options?: StorageOptions) => Promise; getOrganizationInvitation: (options?: StorageOptions) => Promise; setOrganizationInvitation: (value: any, options?: StorageOptions) => Promise; /** * @deprecated Do not call this directly, use OrganizationService */ getOrganizations: (options?: StorageOptions) => Promise<{ [id: string]: OrganizationData }>; /** * @deprecated Do not call this directly, use OrganizationService */ setOrganizations: ( value: { [id: string]: OrganizationData }, 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; getRefreshToken: (options?: StorageOptions) => Promise; setRefreshToken: (value: string, options?: StorageOptions) => Promise; getRememberedEmail: (options?: StorageOptions) => Promise; setRememberedEmail: (value: string, options?: StorageOptions) => Promise; getSecurityStamp: (options?: StorageOptions) => Promise; setSecurityStamp: (value: string, options?: StorageOptions) => Promise; getTwoFactorToken: (options?: StorageOptions) => Promise; setTwoFactorToken: (value: string, options?: StorageOptions) => Promise; getUserId: (options?: StorageOptions) => Promise; getUsesKeyConnector: (options?: StorageOptions) => Promise; setUsesKeyConnector: (value: boolean, options?: StorageOptions) => Promise; getVaultTimeout: (options?: StorageOptions) => Promise; setVaultTimeout: (value: number, options?: StorageOptions) => Promise; getVaultTimeoutAction: (options?: StorageOptions) => Promise; setVaultTimeoutAction: (value: string, options?: StorageOptions) => Promise; getApproveLoginRequests: (options?: StorageOptions) => Promise; setApproveLoginRequests: (value: boolean, options?: StorageOptions) => Promise; getWindow: () => Promise; setWindow: (value: WindowState) => Promise; /** * @deprecated Do not call this directly, use ConfigService */ getServerConfig: (options?: StorageOptions) => Promise; /** * @deprecated Do not call this directly, use ConfigService */ setServerConfig: (value: ServerConfigData, options?: StorageOptions) => Promise; getAvatarColor: (options?: StorageOptions) => Promise; setAvatarColor: (value: string, options?: StorageOptions) => Promise; /** * fetches string value of URL user tried to navigate to while unauthenticated. * @param options Defines the storage options for the URL; Defaults to session Storage. * @returns route called prior to successful login. */ getDeepLinkRedirectUrl: (options?: StorageOptions) => Promise; /** * Store URL in session storage by default, but can be configured. Developed to handle * unauthN interrupted navigation. * @param url URL of route * @param options Defines the storage options for the URL; Defaults to session Storage. */ setDeepLinkRedirectUrl: (url: string, options?: StorageOptions) => Promise; nextUpActiveUser: () => Promise; }