From 4d92371ef9853e3ec05481b95c2e7aba61d3a0ce Mon Sep 17 00:00:00 2001 From: addison Date: Thu, 11 Nov 2021 11:54:20 -0500 Subject: [PATCH] [review] Sorted state service methods --- common/src/abstractions/state.service.ts | 214 ++-- common/src/services/state.service.ts | 1221 ++++++++++------------ 2 files changed, 685 insertions(+), 750 deletions(-) diff --git a/common/src/abstractions/state.service.ts b/common/src/abstractions/state.service.ts index ef389c3b..ec63f140 100644 --- a/common/src/abstractions/state.service.ts +++ b/common/src/abstractions/state.service.ts @@ -27,224 +27,224 @@ import { SendView } from '../models/view/sendView'; export abstract class StateService { accounts: BehaviorSubject<{ [userId: string]: Account }>; - setActiveUser: (userId: string) => Promise; addAccount: (account: Account) => Promise; + setActiveUser: (userId: string) => Promise; purge: (options?: StorageOptions) => Promise; getAccessToken: (options?: StorageOptions) => Promise; + setAccessToken: (value: string, options?: StorageOptions) => Promise; getAddEditCipherInfo: (options?: StorageOptions) => Promise; + setAddEditCipherInfo: (value: any, 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; - getAutoFillOnPageLoadDefault: (options?: StorageOptions) => Promise; + setApiKeyClientSecret: (value: string, options?: StorageOptions) => Promise; getAutoConfirmFingerPrints: (options?: StorageOptions) => Promise; + setAutoConfirmFingerprints: (value: boolean, options?: StorageOptions) => Promise; + getAutoFillOnPageLoadDefault: (options?: StorageOptions) => Promise; + setAutoFillOnPageLoadDefault: (value: boolean, options?: StorageOptions) => Promise; getBiometricAwaitingAcceptance: (options?: StorageOptions) => Promise; + setBiometricAwaitingAcceptance: (value: boolean, options?: StorageOptions) => Promise; getBiometricFingerprintValidated: (options?: StorageOptions) => Promise; + setBiometricFingerprintValidated: (value: boolean, options?: StorageOptions) => Promise; getBiometricLocked: (options?: StorageOptions) => Promise; + setBiometricLocked: (value: boolean, options?: StorageOptions) => Promise; getBiometricText: (options?: StorageOptions) => Promise; + setBiometricText: (value: string, options?: StorageOptions) => Promise; getBiometricUnlock: (options?: StorageOptions) => Promise; + setBiometricUnlock: (value: boolean, options?: StorageOptions) => Promise; getCanAccessPremium: (options?: StorageOptions) => Promise; getClearClipboard: (options?: StorageOptions) => Promise; + setClearClipboard: (value: number, options?: StorageOptions) => Promise; getCollapsedGroupings: (options?: StorageOptions) => Promise>; + setCollapsedGroupings: (value: Set, options?: StorageOptions) => Promise; getConvertAccountToKeyConnector: (options?: StorageOptions) => Promise; + setConvertAccountToKeyConnector: (value: boolean, options?: StorageOptions) => Promise; getCryptoMasterKey: (options?: StorageOptions) => Promise; + setCryptoMasterKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; getCryptoMasterKeyB64: (options: StorageOptions) => Promise; + setCryptoMasterKeyB64: (value: string, options: StorageOptions) => Promise; getDecodedToken: (options?: StorageOptions) => Promise; + setDecodedToken: (value: any, options?: StorageOptions) => Promise; getDecryptedCiphers: (options?: StorageOptions) => Promise; + setDecryptedCiphers: (value: CipherView[], options?: StorageOptions) => Promise; getDecryptedCollections: (options?: StorageOptions) => Promise; + setDecryptedCollections: (value: CollectionView[], options?: StorageOptions) => Promise; getDecryptedCryptoSymmetricKey: (options?: StorageOptions) => Promise; + setDecryptedCryptoSymmetricKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; getDecryptedFolders: (options?: StorageOptions) => Promise; + setDecryptedFolders: (value: FolderView[], options?: StorageOptions) => Promise; getDecryptedOrganizationKeys: (options?: StorageOptions) => Promise>; + setDecryptedOrganizationKeys: (value: Map, options?: StorageOptions) => Promise; getDecryptedPasswordGenerationHistory: (options?: StorageOptions) => Promise; + setDecryptedPasswordGenerationHistory: (value: GeneratedPasswordHistory[], options?: StorageOptions) => Promise; getDecryptedPinProtected: (options?: StorageOptions) => Promise; + setDecryptedPinProtected: (value: EncString, options?: StorageOptions) => Promise; getDecryptedPolicies: (options?: StorageOptions) => Promise; + setDecryptedPolicies: (value: Policy[], options?: StorageOptions) => Promise; getDecryptedPrivateKey: (options?: StorageOptions) => Promise; + setDecryptedPrivateKey: (value: ArrayBuffer, options?: StorageOptions) => Promise; getDecryptedProviderKeys: (options?: StorageOptions) => Promise>; + setDecryptedProviderKeys: (value: Map, options?: StorageOptions) => Promise; getDecryptedSends: (options?: StorageOptions) => Promise; + setDecryptedSends: (value: SendView[], options?: StorageOptions) => Promise; getDefaultUriMatch: (options?: StorageOptions) => Promise; + setDefaultUriMatch: (value: UriMatchType, options?: StorageOptions) => Promise; getDisableAddLoginNotification: (options?: StorageOptions) => Promise; + setDisableAddLoginNotification: (value: boolean, options?: StorageOptions) => Promise; getDisableAutoBiometricsPrompt: (options?: StorageOptions) => Promise; + setDisableAutoBiometricsPrompt: (value: boolean, options?: StorageOptions) => Promise; getDisableAutoTotpCopy: (options?: StorageOptions) => Promise; + setDisableAutoTotpCopy: (value: boolean, options?: StorageOptions) => Promise; getDisableBadgeCounter: (options?: StorageOptions) => Promise; + setDisableBadgeCounter: (value: boolean, options?: StorageOptions) => Promise; getDisableChangedPasswordNotification: (options?: StorageOptions) => Promise; + setDisableChangedPasswordNotification: (value: boolean, options?: StorageOptions) => Promise; getDisableContextMenuItem: (options?: StorageOptions) => Promise; + setDisableContextMenuItem: (value: boolean, options?: StorageOptions) => Promise; getDisableFavicon: (options?: StorageOptions) => Promise; + 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; 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; getEnableAutoFillOnPageLoad: (options?: StorageOptions) => Promise; + setEnableAutoFillOnPageLoad: (value: boolean, options?: StorageOptions) => Promise; getEnableBiometric: (options?: StorageOptions) => Promise; + setEnableBiometric: (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; getEnableFullWidth: (options?: StorageOptions) => Promise; + setEnableFullWidth: (value: boolean, options?: StorageOptions) => Promise; getEnableGravitars: (options?: StorageOptions) => Promise; + setEnableGravitars: (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; getEncryptedCollections: (options?: StorageOptions) => Promise<{ [id: string]: CollectionData }>; + setEncryptedCollections: (value: { [id: string]: CollectionData }, options?: StorageOptions) => Promise; getEncryptedCryptoSymmetricKey: (options?: StorageOptions) => Promise; + setEncryptedCryptoSymmetricKey: (value: string, options?: StorageOptions) => Promise; getEncryptedFolders: (options?: StorageOptions) => Promise<{ [id: string]: FolderData }>; + setEncryptedFolders: (value: { [id: string]: FolderData }, options?: StorageOptions) => Promise; getEncryptedOrganizationKeys: (options?: StorageOptions) => Promise; + setEncryptedOrganizationKeys: (value: Map, options?: StorageOptions) => Promise; getEncryptedPasswordGenerationHistory: (options?: StorageOptions) => Promise; + setEncryptedPasswordGenerationHistory: (value: GeneratedPasswordHistory[], options?: StorageOptions) => Promise; getEncryptedPinProtected: (options?: StorageOptions) => Promise; + setEncryptedPinProtected: (value: string, options?: StorageOptions) => Promise; getEncryptedPolicies: (options?: StorageOptions) => Promise<{ [id: string]: PolicyData }>; + setEncryptedPolicies: (value: { [id: string]: PolicyData }, options?: StorageOptions) => Promise; getEncryptedPrivateKey: (options?: StorageOptions) => Promise; + setEncryptedPrivateKey: (value: string, options?: StorageOptions) => Promise; getEncryptedProviderKeys: (options?: StorageOptions) => Promise; + setEncryptedProviderKeys: (value: any, options?: StorageOptions) => Promise; getEncryptedSends: (options?: StorageOptions) => Promise<{ [id: string]: SendData }>; + setEncryptedSends: (value: { [id: string]: SendData }, options?: StorageOptions) => Promise; getEntityId: (options?: StorageOptions) => Promise; + setEntityId: (value: string, options?: StorageOptions) => Promise; getEntityType: (options?: StorageOptions) => Promise; + setEntityType: (value: string, options?: StorageOptions) => Promise; getEnvironmentUrls: (options?: StorageOptions) => Promise; + setEnvironmentUrls: (value: any, options?: StorageOptions) => Promise; getEquivalentDomains: (options?: StorageOptions) => Promise; + setEquivalentDomains: (value: string, options?: StorageOptions) => Promise; getEventCollection: (options?: StorageOptions) => Promise; + setEventCollection: (value: EventData[], options?: StorageOptions) => Promise; getEverBeenUnlocked: (options?: StorageOptions) => Promise; + setEverBeenUnlocked: (value: boolean, options?: StorageOptions) => Promise; getForcePasswordReset: (options?: StorageOptions) => Promise; + setForcePasswordReset: (value: boolean, options?: StorageOptions) => Promise; getInstalledVersion: (options?: StorageOptions) => Promise; + setInstalledVersion: (value: string, options?: StorageOptions) => Promise; getIsAuthenticated: (options?: StorageOptions) => Promise; getKdfIterations: (options?: StorageOptions) => Promise; + setKdfIterations: (value: number, 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; getLegacyEtmKey: (options?: StorageOptions) => Promise; + setLegacyEtmKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; getLocalData: (options?: StorageOptions) => Promise; + setLocalData: (value: string, options?: StorageOptions) => Promise; getLocale: (options?: StorageOptions) => Promise; + setLocale: (value: string, options?: StorageOptions) => Promise; getLoginRedirect: (options?: StorageOptions) => Promise; + setLoginRedirect: (value: any, options?: StorageOptions) => Promise; getMainWindowSize: (options?: StorageOptions) => Promise; + setMainWindowSize: (value: number, options?: StorageOptions) => Promise; getMinimizeOnCopyToClipboard: (options?: StorageOptions) => Promise; + setMinimizeOnCopyToClipboard: (value: boolean, options?: StorageOptions) => Promise; getNeverDomains: (options?: StorageOptions) => Promise<{ [id: string]: any }>; + setNeverDomains: (value: { [id: string]: any }, options?: StorageOptions) => Promise; getNoAutoPromptBiometrics: (options?: StorageOptions) => Promise; + setNoAutoPromptBiometrics: (value: boolean, options?: StorageOptions) => Promise; getNoAutoPromptBiometricsText: (options?: StorageOptions) => Promise; + setNoAutoPromptBiometricsText: (value: string, options?: StorageOptions) => Promise; getOpenAtLogin: (options?: StorageOptions) => Promise; + setOpenAtLogin: (value: boolean, options?: StorageOptions) => Promise; getOrganizationInvitation: (options?: StorageOptions) => Promise; + setOrganizationInvitation: (value: any, options?: StorageOptions) => Promise; getOrganizations: (options?: StorageOptions) => Promise<{ [id: string]: OrganizationData }>; + setOrganizations: (value: { [id: string]: OrganizationData }, options?: StorageOptions) => Promise; getPasswordGenerationOptions: (options?: StorageOptions) => Promise; + setPasswordGenerationOptions: (value: any, options?: StorageOptions) => Promise; getProtectedPin: (options?: StorageOptions) => Promise; + setProtectedPin: (value: string, options?: StorageOptions) => Promise; getProviders: (options?: StorageOptions) => Promise<{ [id: string]: ProviderData }>; + setProviders: (value: { [id: string]: ProviderData }, options?: StorageOptions) => Promise; getPublicKey: (options?: StorageOptions) => Promise; + setPublicKey: (value: ArrayBuffer, 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; getSettings: (options?: StorageOptions) => Promise; + setSettings: (value: string, options?: StorageOptions) => Promise; getSsoCodeVerifier: (options?: StorageOptions) => Promise; + setSsoCodeVerifier: (value: string, options?: StorageOptions) => Promise; getSsoOrgIdentifier: (options?: StorageOptions) => Promise; + setSsoOrganizationIdentifier: (value: string, options?: StorageOptions) => Promise; getSsoState: (options?: StorageOptions) => Promise; + setSsoState: (value: string, options?: StorageOptions) => Promise; getTheme: (options?: StorageOptions) => Promise; + setTheme: (value: string, options?: StorageOptions) => Promise; getTwoFactorToken: (options?: StorageOptions) => Promise; + setTwoFactorToken: (value: string, options?: StorageOptions) => Promise; getUserId: (options?: StorageOptions) => Promise; getUsesKeyConnector: (options?: StorageOptions) => Promise; - getVaultTimeout: (options?: StorageOptions) => Promise; - getVaultTimeoutAction: (options?: StorageOptions) => Promise; - getWindow: () => Promise>; - setAccessToken: (value: string, options?: StorageOptions) => Promise; - setAddEditCipherInfo: (value: any, options?: StorageOptions) => Promise; - setAlwaysShowDock: (value: boolean, options?: StorageOptions) => Promise; - setApiKeyClientId: (value: string, options?: StorageOptions) => Promise; - setApiKeyClientSecret: (value: string, options?: StorageOptions) => Promise; - setAutoConfirmFingerprints: (value: boolean, options?: StorageOptions) => Promise; - setAutoFillOnPageLoadDefault: (value: boolean, options?: StorageOptions) => Promise; - setBiometricAwaitingAcceptance: (value: boolean, options?: StorageOptions) => Promise; - setBiometricFingerprintValidated: (value: boolean, options?: StorageOptions) => Promise; - setBiometricLocked: (value: boolean, options?: StorageOptions) => Promise; - setBiometricText: (value: string, options?: StorageOptions) => Promise; - setBiometricUnlock: (value: boolean, options?: StorageOptions) => Promise; - setClearClipboard: (value: number, options?: StorageOptions) => Promise; - setCollapsedGroupings: (value: Set, options?: StorageOptions) => Promise; - setConvertAccountToKeyConnector: (value: boolean, options?: StorageOptions) => Promise; - setCryptoMasterKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; - setCryptoMasterKeyB64: (value: string, options: StorageOptions) => Promise; - setDecodedToken: (value: any, options?: StorageOptions) => Promise; - setDecryptedCiphers: (value: CipherView[], options?: StorageOptions) => Promise; - setDecryptedCollections: (value: CollectionView[], options?: StorageOptions) => Promise; - setDecryptedCryptoSymmetricKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; - setDecryptedFolders: (value: FolderView[], options?: StorageOptions) => Promise; - setDecryptedOrganizationKeys: (value: Map, options?: StorageOptions) => Promise; - setDecryptedPasswordGenerationHistory: (value: GeneratedPasswordHistory[], options?: StorageOptions) => Promise; - setDecryptedPinProtected: (value: EncString, options?: StorageOptions) => Promise; - setDecryptedPolicies: (value: Policy[], options?: StorageOptions) => Promise; - setDecryptedPrivateKey: (value: ArrayBuffer, options?: StorageOptions) => Promise; - setDecryptedProviderKeys: (value: Map, options?: StorageOptions) => Promise; - setDecryptedSends: (value: SendView[], options?: StorageOptions) => Promise; - setDefaultUriMatch: (value: UriMatchType, options?: StorageOptions) => Promise; - setDisableAddLoginNotification: (value: boolean, options?: StorageOptions) => Promise; - setDisableAutoBiometricsPrompt: (value: boolean, options?: StorageOptions) => Promise; - setDisableAutoTotpCopy: (value: boolean, options?: StorageOptions) => Promise; - setDisableBadgeCounter: (value: boolean, options?: StorageOptions) => Promise; - setDisableChangedPasswordNotification: (value: boolean, options?: StorageOptions) => Promise; - setDisableContextMenuItem: (value: boolean, options?: StorageOptions) => Promise; - setDisableFavicon: (value: boolean, options?: StorageOptions) => Promise; - setDisableGa: (value: boolean, options?: StorageOptions) => Promise; - setDontShowCardsCurrentTab: (value: boolean, options?: StorageOptions) => Promise; - setDontShowIdentitiesCurrentTab: (value: boolean, options?: StorageOptions) => Promise; - setEmail: (value: string, options?: StorageOptions) => Promise; - setEmailVerified: (value: boolean, options?: StorageOptions) => Promise; - setEnableAlwaysOnTop: (value: boolean, options?: StorageOptions) => Promise; - setEnableAutoFillOnPageLoad: (value: boolean, options?: StorageOptions) => Promise; - setEnableBiometric: (value: boolean, options?: StorageOptions) => Promise; - setEnableBrowserIntegration: (value: boolean, options?: StorageOptions) => Promise; - setEnableBrowserIntegrationFingerprint: (value: boolean, options?: StorageOptions) => Promise; - setEnableCloseToTray: (value: boolean, options?: StorageOptions) => Promise; - setEnableFullWidth: (value: boolean, options?: StorageOptions) => Promise; - setEnableGravitars: (value: boolean, options?: StorageOptions) => Promise; - setEnableMinimizeToTray: (value: boolean, options?: StorageOptions) => Promise; - setEnableStartToTray: (value: boolean, options?: StorageOptions) => Promise; - setEnableTray: (value: boolean, options?: StorageOptions) => Promise; - setEncryptedCiphers: (value: { [id: string]: CipherData }, options?: StorageOptions) => Promise; - setEncryptedCollections: (value: { [id: string]: CollectionData }, options?: StorageOptions) => Promise; - setEncryptedCryptoSymmetricKey: (value: string, options?: StorageOptions) => Promise; - setEncryptedFolders: (value: { [id: string]: FolderData }, options?: StorageOptions) => Promise; - setEncryptedOrganizationKeys: (value: Map, options?: StorageOptions) => Promise; - setEncryptedPasswordGenerationHistory: (value: GeneratedPasswordHistory[], options?: StorageOptions) => Promise; - setEncryptedPinProtected: (value: string, options?: StorageOptions) => Promise; - setEncryptedPolicies: (value: { [id: string]: PolicyData }, options?: StorageOptions) => Promise; - setEncryptedPrivateKey: (value: string, options?: StorageOptions) => Promise; - setEncryptedProviderKeys: (value: any, options?: StorageOptions) => Promise; - setEncryptedSends: (value: { [id: string]: SendData }, options?: StorageOptions) => Promise; - setEntityId: (value: string, options?: StorageOptions) => Promise; - setEntityType: (value: string, options?: StorageOptions) => Promise; - setEnvironmentUrls: (value: any, options?: StorageOptions) => Promise; - setEquivalentDomains: (value: string, options?: StorageOptions) => Promise; - setEventCollection: (value: EventData[], options?: StorageOptions) => Promise; - setEverBeenUnlocked: (value: boolean, options?: StorageOptions) => Promise; - setForcePasswordReset: (value: boolean, options?: StorageOptions) => Promise; - setInstalledVersion: (value: string, options?: StorageOptions) => Promise; - setKdfIterations: (value: number, options?: StorageOptions) => Promise; - setKdfType: (value: KdfType, options?: StorageOptions) => Promise; - setKeyHash: (value: string, options?: StorageOptions) => Promise; - setLastActive: (value: number, options?: StorageOptions) => Promise; - setLastSync: (value: string, options?: StorageOptions) => Promise; - setLegacyEtmKey: (value: SymmetricCryptoKey, options?: StorageOptions) => Promise; - setLocalData: (value: string, options?: StorageOptions) => Promise; - setLocale: (value: string, options?: StorageOptions) => Promise; - setLoginRedirect: (value: any, options?: StorageOptions) => Promise; - setMainWindowSize: (value: number, options?: StorageOptions) => Promise; - setMinimizeOnCopyToClipboard: (value: boolean, options?: StorageOptions) => Promise; - setNeverDomains: (value: { [id: string]: any }, options?: StorageOptions) => Promise; - setNoAutoPromptBiometrics: (value: boolean, options?: StorageOptions) => Promise; - setNoAutoPromptBiometricsText: (value: string, options?: StorageOptions) => Promise; - setOpenAtLogin: (value: boolean, options?: StorageOptions) => Promise; - setOrganizationInvitation: (value: any, options?: StorageOptions) => Promise; - setOrganizations: (value: { [id: string]: OrganizationData }, options?: StorageOptions) => Promise; - setPasswordGenerationOptions: (value: any, options?: StorageOptions) => Promise; - setProtectedPin: (value: string, options?: StorageOptions) => Promise; - setProviders: (value: { [id: string]: ProviderData }, options?: StorageOptions) => Promise; - setPublicKey: (value: ArrayBuffer, options?: StorageOptions) => Promise; - setRefreshToken: (value: string, options?: StorageOptions) => Promise; - setRememberedEmail: (value: string, options?: StorageOptions) => Promise; - setSecurityStamp: (value: string, options?: StorageOptions) => Promise; - setSettings: (value: string, options?: StorageOptions) => Promise; - setSsoCodeVerifier: (value: string, options?: StorageOptions) => Promise; - setSsoOrganizationIdentifier: (value: string, options?: StorageOptions) => Promise; - setSsoState: (value: string, options?: StorageOptions) => Promise; - setTheme: (value: string, options?: StorageOptions) => Promise; - setTwoFactorToken: (value: string, options?: StorageOptions) => Promise; setUsesKeyConnector: (vaule: boolean, options?: StorageOptions) => Promise; + getVaultTimeout: (options?: StorageOptions) => Promise; setVaultTimeout: (value: number, options?: StorageOptions) => Promise; + getVaultTimeoutAction: (options?: StorageOptions) => Promise; setVaultTimeoutAction: (value: string, options?: StorageOptions) => Promise; + getWindow: () => Promise>; setWindow: (value: Map) => Promise; } diff --git a/common/src/services/state.service.ts b/common/src/services/state.service.ts index 4997f4b6..73ccce55 100644 --- a/common/src/services/state.service.ts +++ b/common/src/services/state.service.ts @@ -68,102 +68,185 @@ export class StateService implements StateServiceAbstraction { await this.setActiveUser(account.userId); } - async getEnableGravitars(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.enableGravitars ?? true; + async setActiveUser(userId: string): Promise { + if (!this.state.accounts[userId]) { + return; + } + this.state.activeUserId = userId; + await this.pushAccounts(); } - async getAddEditCipherInfo(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).addEditCipherInfo; - } - - async getUserId(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).userId; - } - - async getEmail(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.email; - } - - async getIsAuthenticated(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.isAuthenticated ?? false; - } - - async getCanAccessPremium(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.canAccessPremium ?? false; + async purge(options?: StorageOptions): Promise { + await this.secureStorageService.remove(options?.userId ?? this.state.activeUserId); + await this.storageService.remove(options?.userId ?? this.state.activeUserId); + delete this.state.accounts[options?.userId ?? this.state.activeUserId]; + await this.pushAccounts(); } async getAccessToken(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.accessToken; } - async getDecodedToken(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decodedToken; + async setAccessToken(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.accessToken = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getAddEditCipherInfo(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).addEditCipherInfo; + } + + async setAddEditCipherInfo(value: any, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.addEditCipherInfo = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } async getAlwaysShowDock(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.alwaysShowDock ?? false; } + async setAlwaysShowDock(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.alwaysShowDock = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + async getApiKeyClientId(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.apiKeyClientId; } + async setApiKeyClientId(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.apiKeyClientId = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getApiKeyClientSecret(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.apiKeyClientSecret; } + async setApiKeyClientSecret(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.apiKeyClientId = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getAutoConfirmFingerPrints(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions))).autoConfirmFingerPrints ?? true; } + async setAutoConfirmFingerprints(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.autoConfirmFingerPrints = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + async getAutoFillOnPageLoadDefault(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.autoFillOnPageLoadDefault ?? false; } + async setAutoFillOnPageLoadDefault(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.autoFillOnPageLoadDefault = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getBiometricAwaitingAcceptance(options?: StorageOptions): Promise { return (await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.biometricAwaitingAcceptance ?? false; } + async setBiometricAwaitingAcceptance(value: boolean, options?: StorageOptions): Promise { + const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); + globals.biometricAwaitingAcceptance = value; + await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getBiometricFingerprintValidated(options?: StorageOptions): Promise { return (await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.biometricFingerprintValidated ?? false; } + async setBiometricFingerprintValidated(value: boolean, options?: StorageOptions): Promise { + const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); + globals.biometricFingerprintValidated = value; + await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getBiometricLocked(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).biometricLocked ?? false; + } + + async setBiometricLocked(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.biometricLocked = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getBiometricText(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.biometricText; } + async setBiometricText(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.biometricText = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + async getBiometricUnlock(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.biometricUnlock ?? false; } - async getEncryptedCiphers(options?: StorageOptions): Promise<{ [id: string]: CipherData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedCiphers; + async setBiometricUnlock(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.biometricUnlock = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async getDecryptedCiphers(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCiphers; + async getCanAccessPremium(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.canAccessPremium ?? false; } async getClearClipboard(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.clearClipboard; } + async setClearClipboard(value: number, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.clearClipboard = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getCollapsedGroupings(options?: StorageOptions): Promise> { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.collapsedGroupings; } - async getEncryptedCollections(options?: StorageOptions): Promise<{ [id: string]: CollectionData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedCollections; + async setCollapsedGroupings(value: Set, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.collapsedGroupings = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async getDecryptedCollections(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCollections; + async getConvertAccountToKeyConnector(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.convertAccountToKeyConnector; + } + + async setConvertAccountToKeyConnector(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.convertAccountToKeyConnector = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } async getCryptoMasterKey(options?: StorageOptions): Promise { return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.cryptoMasterKey; } + async setCryptoMasterKey(value: SymmetricCryptoKey, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.cryptoMasterKey = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + async getCryptoMasterKeyB64(options: StorageOptions): Promise { try { if (options?.keySuffix == null) { @@ -176,463 +259,6 @@ export class StateService implements StateServiceAbstraction { } } - async getEncryptedCryptoSymmetricKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedCryptoSymmetricKey; - } - - async getDecryptedCryptoSymmetricKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCryptoSymmetricKey; - } - - async getDefaultUriMatch(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.defaultUriMatch; - } - - async getDisableAddLoginNotification(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAddLoginNotification ?? false; - } - - async getDisableAutoBiometricsPrompt(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAutoBiometricsPrompt ?? false; - } - - async getDisableAutoTotpCopy(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAutoTotpCopy ?? false; - } - - async getDisableBadgeCounter(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableBadgeCounter ?? false; - } - - async getDisableChangedPasswordNotification(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableChangedPasswordNotification ?? false; - } - - async getDisableContextMenuItem(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableContextMenuItem ?? false; - } - - async getDisableFavicon(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.disableFavicon ?? false; - } - - async getDisableGa(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableGa ?? false; - } - - async getDontShowCardsCurrentTab(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.dontShowCardsCurrentTab ?? false; - } - - async getDontShowIdentitiesCurrentTab(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.dontShowIdentitiesCurrentTab ?? false; - } - - async getEmailVerified(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.emailVerified ?? false; - } - - async getEnableAlwaysOnTop(options?: StorageOptions): Promise { - const accountPreference = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableAlwaysOnTop; - const globalPreference = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableAlwaysOnTop; - return accountPreference ?? globalPreference ?? false; - } - - async getEnableAutoFillOnPageLoad(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableAutoFillOnPageLoad ?? false; - } - - async getEnableBiometric(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBiometrics ?? false; - } - - async getEnableBrowserIntegration(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBrowserIntegration ?? false; - } - - async getEnableBrowserIntegrationFingerprint(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBrowserIntegrationFingerprint ?? false; - } - - async getEnableCloseToTray(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableCloseToTray ?? false; - } - - async getEnableMinimizeToTray(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableMinimizeToTray ?? false; - } - - async getEnableStartToTray(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableStartToTray ?? false; - } - - async getEnableTray(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableTray ?? false; - } - - async getEncryptedOrganizationKeys(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedOrganizationKeys; - } - - async getDecryptedOrganizationKeys(options?: StorageOptions): Promise> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedOrganizationKeys; - } - - async getEncryptedPrivateKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPrivateKey; - } - - async getDecryptedPrivateKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPrivateKey; - } - - async getEncryptedProviderKeys(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedProviderKeys; - } - - async getDecryptedProviderKeys(options?: StorageOptions): Promise> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedProviderKeys; - } - - async getEntityId(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.entityId; - } - - async getEntityType(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.entityType; - } - - async getEnvironmentUrls(options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - return account?.environmentUrls ?? null; - } - - async getEquivalentDomains(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.equivalentDomains; - } - - async getEventCollection(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.eventCollection; - } - - async getEncryptedFolders(options?: StorageOptions): Promise<{ [id: string]: FolderData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedFolders; - } - - async getDecryptedFolders(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedFolders; - } - - async getForcePasswordReset(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.forcePasswordReset ?? false; - } - - async getInstalledVersion(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.installedVersion; - } - - async getKdfIterations(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.kdfIterations; - } - - async getKdfType(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.kdfType; - } - - async getKeyHash(options?: StorageOptions): Promise { - return (await this.getAccount(options ?? { storageLocation: StorageLocation.Both }))?.keyHash; - } - - async getLastSync(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.lastSync; - } - - async getLastActive(options?: StorageOptions): Promise { - const lastActive = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.lastActive; - return lastActive ?? (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions))).lastActive; - } - - async getLegacyEtmKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.legacyEtmKey; - } - - async getLocalData(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.localData; - } - - async getLocale(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.locale; - } - - async getLoginRedirect(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.loginRedirect; - } - - async getMainWindowSize(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.mainWindowSize; - } - - async getMinimizeOnCopyToClipboard(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.minimizeOnCopyToClipboard ?? false; - } - - async getNeverDomains(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.neverDomains; - } - - async getNoAutoPromptBiometrics(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.noAutoPromptBiometrics ?? false; - } - - async getNoAutoPromptBiometricsText(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.noAutoPromptBiometricsText; - } - - async getOpenAtLogin(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.openAtLogin ?? false; - } - - async getEncryptedPasswordGenerationHistory(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPasswordGenerationHistory; - } - - async getDecryptedPasswordGenerationHistory(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPasswordGenerationHistory; - } - - async getPasswordGenerationOptions(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.passwordGenerationOptions; - } - - async getEncryptedPinProtected(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPinProtected; - } - - async getDecryptedPinProtected(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPinProtected; - } - - async getEncryptedPolicies(options?: StorageOptions): Promise<{ [id: string]: PolicyData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPolicies; - } - - async getDecryptedPolicies(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPolicies; - } - - async getProtectedPin(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.protectedPin; - } - - async getProviders(options?: StorageOptions): Promise<{ [id: string]: ProviderData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.providers; - } - - async getPublicKey(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.publicKey; - } - - async getRefreshToken(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.refreshToken; - } - - async getRememberedEmail(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.rememberedEmail; - } - - async getSecurityStamp(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.securityStamp; - } - - async getEncryptedSends(options?: StorageOptions): Promise<{ [id: string]: SendData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedSends; - } - - async getDecryptedSends(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedSends; - } - - async getSettings(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.settings; - } - - async getSsoCodeVerifier(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.ssoCodeVerifier; - } - - async getSsoOrgIdentifier(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.ssoOrganizationIdentifier; - } - - async getSsoState(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.ssoState; - } - - async getTheme(options?: StorageOptions): Promise { - const accountTheme = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.theme; - const globalTheme = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.theme; - return accountTheme ?? globalTheme; - } - - async getTwoFactorToken(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.twoFactorToken; - } - - async getVaultTimeout(options?: StorageOptions): Promise { - const accountVaultTimeout = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeout; - const globalVaultTimeout = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeout; - return accountVaultTimeout ?? globalVaultTimeout; - } - - async getVaultTimeoutAction(options?: StorageOptions): Promise { - const accountVaultTimeoutAction = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeoutAction; - const globalVaultTimeoutAction = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeoutAction; - return accountVaultTimeoutAction ?? globalVaultTimeoutAction; - } - - async getOrganizations(options?: StorageOptions): Promise<{ [id: string]: OrganizationData }> { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).organizations; - } - - async getEverBeenUnlocked(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions))).everBeenUnlocked ?? false; - } - - async getBiometricLocked(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).biometricLocked ?? false; - } - - async getWindow(): Promise> { - const globals = await this.getGlobals({ storageLocation: StorageLocation.Disk }); - return Object.keys(globals.window).length > 0 ? - globals.window : - new Map(); - } - - async getOrganizationInvitation(options?: StorageOptions): Promise { - return (await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions))).organizationInvitation; - } - - async getConvertAccountToKeyConnector(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.convertAccountToKeyConnector; - } - - async getUsesKeyConnector(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.usesKeyConnector; - } - - async getEnableFullWidth(options?: StorageOptions): Promise { - return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.enableFullWidth ?? false; - } - - async setAccessToken(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.accessToken = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setDecodedToken(value: any, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decodedToken = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setAlwaysShowDock(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.alwaysShowDock = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setApiKeyClientId(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.apiKeyClientId = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setApiKeyClientSecret(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.apiKeyClientSecret = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setAutoConfirmFingerprints(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.autoConfirmFingerPrints = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setAutoFillOnPageLoadDefault(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.autoFillOnPageLoadDefault = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setBiometricAwaitingAcceptance(value: boolean, options?: StorageOptions): Promise { - const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); - globals.biometricAwaitingAcceptance = value; - await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setBiometricFingerprintValidated(value: boolean, options?: StorageOptions): Promise { - const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); - globals.biometricFingerprintValidated = value; - await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setBiometricText(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.biometricText = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setBiometricUnlock(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.biometricUnlock = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setEncryptedCiphers(value: { [id: string]: CipherData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - account.encryptedCiphers = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - } - - async setDecryptedCiphers(value: CipherView[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedCiphers = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setClearClipboard(value: number, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.clearClipboard = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setCollapsedGroupings(value: Set, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.collapsedGroupings = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setEncryptedCollections(value: { [id: string]: CollectionData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - account.encryptedCollections = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - } - - async setDecryptedCollections(value: CollectionView[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedCollections = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setCryptoMasterKey(value: SymmetricCryptoKey, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.cryptoMasterKey = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - async setCryptoMasterKeyB64(value: string, options: StorageOptions): Promise { try { if (value != null && options?.keySuffix == null) { @@ -648,10 +274,38 @@ export class StateService implements StateServiceAbstraction { } } - async setEncryptedCryptoSymmetricKey(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.encryptedCryptoSymmetricKey = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getDecodedToken(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decodedToken; + } + + async setDecodedToken(value: any, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decodedToken = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedCiphers(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCiphers; + } + + async setDecryptedCiphers(value: CipherView[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedCiphers = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedCollections(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCollections; + } + + async setDecryptedCollections(value: CollectionView[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedCollections = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedCryptoSymmetricKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedCryptoSymmetricKey; } async setDecryptedCryptoSymmetricKey(value: SymmetricCryptoKey, options?: StorageOptions): Promise { @@ -660,84 +314,219 @@ export class StateService implements StateServiceAbstraction { await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDecryptedFolders(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedFolders; + } + + async setDecryptedFolders(value: FolderView[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedFolders = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedOrganizationKeys(options?: StorageOptions): Promise> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedOrganizationKeys; + } + + async setDecryptedOrganizationKeys(value: Map, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedOrganizationKeys = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedPasswordGenerationHistory(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPasswordGenerationHistory; + } + + async setDecryptedPasswordGenerationHistory(value: GeneratedPasswordHistory[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedPasswordGenerationHistory = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedPinProtected(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPinProtected; + } + + async setDecryptedPinProtected(value: EncString, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedPinProtected = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedPolicies(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPolicies; + } + + async setDecryptedPolicies(value: Policy[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedPolicies = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedPrivateKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedPrivateKey; + } + + async setDecryptedPrivateKey(value: ArrayBuffer, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedPrivateKey = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedProviderKeys(options?: StorageOptions): Promise> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedProviderKeys; + } + + async setDecryptedProviderKeys(value: Map, options?: StorageOptions): Promise { + const account = (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))); + account.decryptedProviderKeys = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDecryptedSends(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.decryptedSends; + } + + async setDecryptedSends(value: SendView[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); + account.decryptedSends = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getDefaultUriMatch(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.defaultUriMatch; + } + async setDefaultUriMatch(value: UriMatchType, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.defaultUriMatch = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableAddLoginNotification(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAddLoginNotification ?? false; + } + async setDisableAddLoginNotification(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableAddLoginNotification = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableAutoBiometricsPrompt(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAutoBiometricsPrompt ?? false; + } + async setDisableAutoBiometricsPrompt(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableAutoBiometricsPrompt = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableAutoTotpCopy(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableAutoTotpCopy ?? false; + } + async setDisableAutoTotpCopy(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableAutoTotpCopy = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableBadgeCounter(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableBadgeCounter ?? false; + } + async setDisableBadgeCounter(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableBadgeCounter = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableChangedPasswordNotification(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableChangedPasswordNotification ?? false; + } + async setDisableChangedPasswordNotification(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableChangedPasswordNotification = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableContextMenuItem(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableContextMenuItem ?? false; + } + async setDisableContextMenuItem(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableContextMenuItem = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDisableFavicon(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.disableFavicon ?? false; + } + async setDisableFavicon(value: boolean, options?: StorageOptions): Promise { const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); globals.disableFavicon = value; await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); } + async getDisableGa(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.disableGa ?? false; + } + async setDisableGa(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.disableGa = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDontShowCardsCurrentTab(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.dontShowCardsCurrentTab ?? false; + } + async setDontShowCardsCurrentTab(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.dontShowCardsCurrentTab = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getDontShowIdentitiesCurrentTab(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.dontShowIdentitiesCurrentTab ?? false; + } + async setDontShowIdentitiesCurrentTab(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.dontShowIdentitiesCurrentTab = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEmail(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.email; + } async setEmail(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.email = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEmailVerified(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.emailVerified ?? false; + } async setEmailVerified(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.emailVerified = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEnableAlwaysOnTop(options?: StorageOptions): Promise { + const accountPreference = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableAlwaysOnTop; + const globalPreference = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableAlwaysOnTop; + return accountPreference ?? globalPreference ?? false; + } async setEnableAlwaysOnTop(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.enableAlwaysOnTop = value; @@ -748,156 +537,302 @@ export class StateService implements StateServiceAbstraction { await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEnableAutoFillOnPageLoad(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableAutoFillOnPageLoad ?? false; + } async setEnableAutoFillOnPageLoad(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.enableAutoFillOnPageLoad = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEnableBiometric(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBiometrics ?? false; + } async setEnableBiometric(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.enableBiometrics = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEnableBrowserIntegration(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBrowserIntegration ?? false; + } async setEnableBrowserIntegration(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.enableBrowserIntegration = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEnableBrowserIntegrationFingerprint(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableBrowserIntegrationFingerprint ?? false; + } async setEnableBrowserIntegrationFingerprint(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.enableBrowserIntegrationFingerprint = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEnableCloseToTray(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableCloseToTray ?? false; + } async setEnableCloseToTray(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.enableCloseToTray = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEnableFullWidth(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.enableFullWidth ?? false; + } + async setEnableFullWidth(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + account.enableFullWidth = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + } + + async getEnableGravitars(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.enableGravitars ?? true; + } + async setEnableGravitars(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + account.enableGravitars = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + } + + async getEnableMinimizeToTray(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.enableMinimizeToTray ?? false; + } async setEnableMinimizeToTray(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.enableMinimizeToTray = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEnableStartToTray(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableStartToTray ?? false; + } async setEnableStartToTray(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.enableStartToTray = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEnableTray(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.enableTray ?? false; + } async setEnableTray(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.enableTray = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedOrganizationKeys(value: any, options?: StorageOptions): Promise { + async getEncryptedCiphers(options?: StorageOptions): Promise<{ [id: string]: CipherData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedCiphers; + } + async setEncryptedCiphers(value: { [id: string]: CipherData; }, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + account.encryptedCiphers = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + } + + async getEncryptedCollections(options?: StorageOptions): Promise<{ [id: string]: CollectionData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedCollections; + } + async setEncryptedCollections(value: { [id: string]: CollectionData; }, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + account.encryptedCollections = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + } + + async getEncryptedCryptoSymmetricKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedCryptoSymmetricKey; + } + async setEncryptedCryptoSymmetricKey(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.encryptedCryptoSymmetricKey = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + + async getEncryptedFolders(options?: StorageOptions): Promise<{ [id: string]: FolderData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedFolders; + } + async setEncryptedFolders(value: { [id: string]: FolderData; }, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + account.encryptedFolders = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + } + + async getEncryptedOrganizationKeys(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedOrganizationKeys; + } + async setEncryptedOrganizationKeys(value: Map, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.encryptedOrganizationKeys = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setDecryptedOrganizationKeys(value: Map, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedOrganizationKeys = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + async getEncryptedPasswordGenerationHistory(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPasswordGenerationHistory; + } + async setEncryptedPasswordGenerationHistory(value: GeneratedPasswordHistory[], options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.encryptedPasswordGenerationHistory = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEncryptedPinProtected(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPinProtected; + } + async setEncryptedPinProtected(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.encryptedPinProtected = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + + async getEncryptedPolicies(options?: StorageOptions): Promise<{ [id: string]: PolicyData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPolicies; + } + async setEncryptedPolicies(value: { [id: string]: PolicyData; }, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.encryptedPolicies = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + + async getEncryptedPrivateKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedPrivateKey; + } async setEncryptedPrivateKey(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.encryptedPrivateKey = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setDecryptedPrivateKey(value: ArrayBuffer, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedPrivateKey = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + async getEncryptedProviderKeys(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.encryptedProviderKeys; + } + async setEncryptedProviderKeys(value: any, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.encryptedProviderKeys = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getEncryptedSends(options?: StorageOptions): Promise<{ [id: string]: SendData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.encryptedSends; + } + async setEncryptedSends(value: { [id: string]: SendData; }, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + account.encryptedSends = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + } + + async getEntityId(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.entityId; + } async setEntityId(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.entityId = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEntityType(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.entityType; + } async setEntityType(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.entityType = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEnvironmentUrls(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.environmentUrls; + } async setEnvironmentUrls(value: any, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.environmentUrls = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEquivalentDomains(value: any, options?: StorageOptions): Promise { + async getEquivalentDomains(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.equivalentDomains; + } + async setEquivalentDomains(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.equivalentDomains = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getEventCollection(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.eventCollection; + } async setEventCollection(value: EventData[], options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.eventCollection = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedFolders(value: { [id: string]: FolderData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - account.encryptedFolders = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + async getEverBeenUnlocked(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions))).everBeenUnlocked ?? false; + } + async setEverBeenUnlocked(value: boolean, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.everBeenUnlocked = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setDecryptedFolders(value: FolderView[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedFolders = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); + async getForcePasswordReset(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.forcePasswordReset ?? false; } - async setForcePasswordReset(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.forcePasswordReset = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getInstalledVersion(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.installedVersion; + } async setInstalledVersion(value: string, options?: StorageOptions): Promise { const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)); globals.installedVersion = value; await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getIsAuthenticated(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.isAuthenticated ?? false; + } + + async getKdfIterations(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.kdfIterations; + } async setKdfIterations(value: number, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.kdfIterations = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getKdfType(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.kdfType; + } async setKdfType(value: KdfType, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.kdfType = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getKeyHash(options?: StorageOptions): Promise { + return (await this.getAccount(options ?? { storageLocation: StorageLocation.Both }))?.keyHash; + } async setKeyHash(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.keyHash = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setLastSync(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - account.lastSync = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + async getLastActive(options?: StorageOptions): Promise { + const lastActive = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.lastActive; + return lastActive ?? (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions))).lastActive; } - async setLastActive(value: number, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); if (account != null) { @@ -910,192 +845,227 @@ export class StateService implements StateServiceAbstraction { await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getLastSync(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.lastSync; + } + async setLastSync(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + account.lastSync = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + } + + async getLegacyEtmKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.legacyEtmKey; + } async setLegacyEtmKey(value: SymmetricCryptoKey, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.legacyEtmKey = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setLocalData(value: any, options?: StorageOptions): Promise { + async getLocalData(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.localData; + } + async setLocalData(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.localData = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getLocale(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.locale; + } async setLocale(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.locale = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getLoginRedirect(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.loginRedirect; + } async setLoginRedirect(value: any, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.loginRedirect = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getMainWindowSize(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.mainWindowSize; + } async setMainWindowSize(value: number, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.mainWindowSize = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getMinimizeOnCopyToClipboard(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.minimizeOnCopyToClipboard ?? false; + } async setMinimizeOnCopyToClipboard(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.minimizeOnCopyToClipboard = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setNeverDomains(value: string[], options?: StorageOptions): Promise { + async getNeverDomains(options?: StorageOptions): Promise<{ [id: string]: any; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.neverDomains; + } + async setNeverDomains(value: { [id: string]: any; }, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.neverDomains = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getNoAutoPromptBiometrics(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.noAutoPromptBiometrics ?? false; + } async setNoAutoPromptBiometrics(value: boolean, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.noAutoPromptBiometrics = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getNoAutoPromptBiometricsText(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.noAutoPromptBiometricsText; + } async setNoAutoPromptBiometricsText(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.noAutoPromptBiometricsText = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } + async getOpenAtLogin(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.openAtLogin ?? false; + } async setOpenAtLogin(value: boolean, options?: StorageOptions): Promise { const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)); globals.openAtLogin = value; await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setOrganizations(value: { [id: string]: OrganizationData }, options?: StorageOptions): Promise { + async getOrganizationInvitation(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions))).organizationInvitation; + } + async setOrganizationInvitation(value: any, options?: StorageOptions): Promise { + const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); + globals.organizationInvitation = value; + await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); + } + + async getOrganizations(options?: StorageOptions): Promise<{ [id: string]: OrganizationData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).organizations; + } + async setOrganizations(value: { [id: string]: OrganizationData; }, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.organizations = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedPasswordGenerationHistory(value: GeneratedPasswordHistory[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.encryptedPasswordGenerationHistory = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getPasswordGenerationOptions(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.passwordGenerationOptions; } - - async setDecryptedPasswordGenerationHistory(value: GeneratedPasswordHistory[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedPasswordGenerationHistory = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - async setPasswordGenerationOptions(value: any, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.passwordGenerationOptions = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedPinProtected(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.encryptedPinProtected = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getProtectedPin(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.protectedPin; } - - async setDecryptedPinProtected(value: EncString, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedPinProtected = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setEncryptedPolicies(value: { [id: string]: PolicyData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.encryptedPolicies = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setDecryptedPolicies(value: Policy[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedPolicies = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - async setProtectedPin(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); account.protectedPin = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setProviders(value: { [id: string]: ProviderData }, options?: StorageOptions): Promise { + async getProviders(options?: StorageOptions): Promise<{ [id: string]: ProviderData; }> { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.providers; + } + async setProviders(value: { [id: string]: ProviderData; }, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.providers = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedProviderKeys(value: { [id: string]: ProviderData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.encryptedProviderKeys = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getPublicKey(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.publicKey; } - - async setDecryptedProviderKeys(value: Map, options?: StorageOptions): Promise { - const account = (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))); - account.decryptedProviderKeys = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - async setPublicKey(value: ArrayBuffer, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.publicKey = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getRefreshToken(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.refreshToken; + } async setRefreshToken(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.refreshToken = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getRememberedEmail(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.rememberedEmail; + } + async setRememberedEmail(value: string, options?: StorageOptions): Promise { + const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + globals.rememberedEmail = value; + await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + } + + async getSecurityStamp(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.securityStamp; + } async setSecurityStamp(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.securityStamp = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEncryptedSends(value: { [id: string]: SendData }, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); - account.encryptedSends = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); + async getSettings(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)))?.settings; } - - async setDecryptedSends(value: SendView[], options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.decryptedSends = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setSettings(value: any, options?: StorageOptions): Promise { + async setSettings(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); account.settings = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskMemoryOptions)); } + async getSsoCodeVerifier(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.ssoCodeVerifier; + } async setSsoCodeVerifier(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.ssoCodeVerifier = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getSsoOrgIdentifier(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.ssoOrganizationIdentifier; + } async setSsoOrganizationIdentifier(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); account.ssoOrganizationIdentifier = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); } + async getSsoState(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.ssoState; + } async setSsoState(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); account.ssoState = value; await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } + async getTheme(options?: StorageOptions): Promise { + const accountTheme = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.theme; + const globalTheme = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.theme; + return accountTheme ?? globalTheme; + } async setTheme(value: string, options?: StorageOptions): Promise { const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); if (account != null) { @@ -1108,64 +1078,21 @@ export class StateService implements StateServiceAbstraction { await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); } + async getTwoFactorToken(options?: StorageOptions): Promise { + return (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)))?.twoFactorToken; + } async setTwoFactorToken(value: string, options?: StorageOptions): Promise { const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); globals.twoFactorToken = value; await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); } - async setVaultTimeout(value: number, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.vaultTimeout = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getUserId(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))).userId; } - async setVaultTimeoutAction(value: string, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.vaultTimeoutAction = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setEverBeenUnlocked(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.everBeenUnlocked = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); - } - - async setBiometricLocked(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.biometricLocked = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setEnableGravitars(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); - account.enableGravitars = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); - } - - async setAddEditCipherInfo(value: any, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)); - account.addEditCipherInfo = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setRememberedEmail(value: string, options?: StorageOptions): Promise { - const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); - globals.rememberedEmail = value; - await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); - } - - async setOrganizationInvitation(value: any, options?: StorageOptions): Promise { - const globals = await this.getGlobals(this.reconcileOptions(options, this.defaultInMemoryOptions)); - globals.organizationInvitation = value; - await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultInMemoryOptions)); - } - - async setConvertAccountToKeyConnector(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); - account.convertAccountToKeyConnector = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + async getUsesKeyConnector(options?: StorageOptions): Promise { + return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))?.usesKeyConnector; } async setUsesKeyConnector(value: boolean, options?: StorageOptions): Promise { @@ -1174,18 +1101,33 @@ export class StateService implements StateServiceAbstraction { await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions)); } - async setEnableFullWidth(value: boolean, options?: StorageOptions): Promise { - const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); - account.enableFullWidth = value; - await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskLocalOptions)); + async getVaultTimeout(options?: StorageOptions): Promise { + const accountVaultTimeout = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeout; + const globalVaultTimeout = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeout; + return accountVaultTimeout ?? globalVaultTimeout; + } + async setVaultTimeout(value: number, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.vaultTimeout = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async setActiveUser(userId: string): Promise { - if (!this.state.accounts[userId]) { - return; - } - this.state.activeUserId = userId; - await this.pushAccounts(); + async getVaultTimeoutAction(options?: StorageOptions): Promise { + const accountVaultTimeoutAction = (await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeoutAction; + const globalVaultTimeoutAction = (await this.getGlobals(this.reconcileOptions(options, this.defaultOnDiskOptions)))?.vaultTimeoutAction; + return accountVaultTimeoutAction ?? globalVaultTimeoutAction; + } + async setVaultTimeoutAction(value: string, options?: StorageOptions): Promise { + const account = await this.getAccount(this.reconcileOptions(options, this.defaultOnDiskOptions)); + account.vaultTimeoutAction = value; + await this.saveAccount(account, this.reconcileOptions(options, this.defaultOnDiskOptions)); + } + + async getWindow(): Promise> { + const globals = await this.getGlobals({ storageLocation: StorageLocation.Disk }); + return Object.keys(globals.window).length > 0 ? + globals.window : + new Map(); } async setWindow(value: Map, options?: StorageOptions): Promise { @@ -1194,13 +1136,6 @@ export class StateService implements StateServiceAbstraction { return await this.saveGlobals(globals, this.reconcileOptions(options, this.defaultOnDiskOptions)); } - async purge(options?: StorageOptions): Promise { - await this.secureStorageService.remove(options?.userId ?? this.state.activeUserId); - await this.storageService.remove(options?.userId ?? this.state.activeUserId); - delete this.state.accounts[options?.userId ?? this.state.activeUserId]; - await this.pushAccounts(); - } - private async getGlobals(options: StorageOptions): Promise { let globals: Globals; if (this.useMemory(options.storageLocation)) {