import { StateService as StateServiceAbstraction } from "../abstractions/state.service" ; import { Account , AccountData , AccountKeys , AccountProfile , AccountTokens , } from "../models/domain/account" ; import { LogService } from "../abstractions/log.service" ; import { StorageService } from "../abstractions/storage.service" ; import { HtmlStorageLocation } from "../enums/htmlStorageLocation" ; import { KdfType } from "../enums/kdfType" ; import { StorageLocation } from "../enums/storageLocation" ; import { UriMatchType } from "../enums/uriMatchType" ; import { CipherView } from "../models/view/cipherView" ; import { CollectionView } from "../models/view/collectionView" ; import { FolderView } from "../models/view/folderView" ; import { SendView } from "../models/view/sendView" ; import { EncString } from "../models/domain/encString" ; import { GeneratedPasswordHistory } from "../models/domain/generatedPasswordHistory" ; import { GlobalState } from "../models/domain/globalState" ; import { Policy } from "../models/domain/policy" ; import { State } from "../models/domain/state" ; import { StorageOptions } from "../models/domain/storageOptions" ; import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey" ; import { CipherData } from "../models/data/cipherData" ; import { CollectionData } from "../models/data/collectionData" ; import { EventData } from "../models/data/eventData" ; import { FolderData } from "../models/data/folderData" ; import { OrganizationData } from "../models/data/organizationData" ; import { PolicyData } from "../models/data/policyData" ; import { ProviderData } from "../models/data/providerData" ; import { SendData } from "../models/data/sendData" ; import { BehaviorSubject } from "rxjs" ; import { StateMigrationService } from "../abstractions/stateMigration.service" ; import { EnvironmentUrls } from "../models/domain/environmentUrls" ; export class StateService < TAccount extends Account = Account > implements StateServiceAbstraction < TAccount > { accounts = new BehaviorSubject < { [ userId ] : TAccount ; } > ( { } ) ; activeAccount = new BehaviorSubject < string > ( null ) ; protected state : State < TAccount > = new State < TAccount > ( ) ; constructor ( protected storageService , protected secureStorageService , protected logService , protected stateMigrationService ) { } async init ( ) { if ( await this . stateMigrationService . needsMigration ( ) ) { await this . stateMigrationService . migrate ( ) ; } if ( this . state . activeUserId == null ) { await this . loadStateFromDisk ( ) ; } } async loadStateFromDisk ( ) { if ( ( await this . getActiveUserIdFromStorage ( ) ) != null ) { const diskState = await this . storageService . get < State < TAccount > > ( "state" , await this . defaultOnDiskOptions ( ) ) ; this . state = diskState ; await this . pruneInMemoryAccounts ( ) ; await this . pushAccounts ( ) ; } } async addAccount ( account ) { await this . setAccountEnvironmentUrls ( account ) ; this . state . accounts [ account . profile . userId ] = account ; await this . scaffoldNewAccountStorage ( account ) ; await this . setActiveUser ( account . profile . userId ) ; this . activeAccount . next ( account . profile . userId ) ; } async setActiveUser ( userId ) { this . state . activeUserId = userId ; const storedState = await this . storageService . get < State < TAccount > > ( "state" , await this . defaultOnDiskOptions ( ) ) ; storedState . activeUserId = userId ; await this . saveStateToStorage ( storedState , await this . defaultOnDiskOptions ( ) ) ; await this . pushAccounts ( ) ; this . activeAccount . next ( this . state . activeUserId ) ; } async clean ( options ? ) { await this . setAccessToken ( null , { userId : options ?. userId } ) ; if ( options ?. userId == null || options . userId === ( await this . getUserId ( ) ) ) { for ( const userId in this . state . accounts ) { if ( userId == null ) { continue ; } if ( await this . getIsAuthenticated ( { userId : userId } ) ) { await this . setActiveUser ( userId ) ; break ; } await this . setActiveUser ( null ) ; } } await this . removeAccountFromSessionStorage ( options ?. userId ) ; await this . removeAccountFromLocalStorage ( options ?. userId ) ; await this . removeAccountFromSecureStorage ( options ?. userId ) ; this . removeAccountFromMemory ( options ?. userId ) ; await this . pushAccounts ( ) ; } async getAccessToken ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. tokens ?. accessToken ; } async setAccessToken ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . tokens . accessToken = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getAddEditCipherInfo ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. addEditCipherInfo ; } async setAddEditCipherInfo ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . addEditCipherInfo = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getAlwaysShowDock ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. alwaysShowDock ?? false ) ; } async setAlwaysShowDock ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . alwaysShowDock = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getApiKeyClientId ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. apiKeyClientId ; } async setApiKeyClientId ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . apiKeyClientId = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getApiKeyClientSecret ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys ?. apiKeyClientSecret ; } async setApiKeyClientSecret ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . apiKeyClientSecret = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getAutoConfirmFingerPrints ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. autoConfirmFingerPrints ?? true ) ; } async setAutoConfirmFingerprints ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . autoConfirmFingerPrints = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getAutoFillOnPageLoadDefault ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. autoFillOnPageLoadDefault ?? false ) ; } async setAutoFillOnPageLoadDefault ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . autoFillOnPageLoadDefault = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getBiometricAwaitingAcceptance ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. biometricAwaitingAcceptance ?? false ) ; } async setBiometricAwaitingAcceptance ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . biometricAwaitingAcceptance = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getBiometricFingerprintValidated ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. biometricFingerprintValidated ?? false ) ; } async setBiometricFingerprintValidated ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . biometricFingerprintValidated = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getBiometricLocked ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. settings ?. biometricLocked ?? false ) ; } async setBiometricLocked ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . settings . biometricLocked = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getBiometricText ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. biometricText ; } async setBiometricText ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . biometricText = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getBiometricUnlock ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. biometricUnlock ?? false ) ; } async setBiometricUnlock ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . biometricUnlock = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getCanAccessPremium ( options ? ) { if ( ! ( await this . getIsAuthenticated ( options ) ) ) { return false ; } const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; if ( account . profile . hasPremiumPersonally ) { return true ; } const organizations = await this . getOrganizations ( options ) ; if ( organizations == null ) { return false ; } for ( const id of Object . keys ( organizations ) ) { const o = organizations [ id ] ; if ( o . enabled && o . usersGetPremium && ! o . isProviderUser ) { return true ; } } return false ; } async getClearClipboard ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. settings ?. clearClipboard ?? null ) ; } async setClearClipboard ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . settings . clearClipboard = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getCollapsedGroupings ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. collapsedGroupings ; } async setCollapsedGroupings ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . collapsedGroupings = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getConvertAccountToKeyConnector ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. convertAccountToKeyConnector ; } async setConvertAccountToKeyConnector ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . convertAccountToKeyConnector = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getCryptoMasterKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. cryptoMasterKey ; } async setCryptoMasterKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . cryptoMasterKey = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getCryptoMasterKeyAuto ( options ? ) { options = this . reconcileOptions ( this . reconcileOptions ( options , { keySuffix : "auto" } ) , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return null ; } return await this . secureStorageService . get ( `${ options . userId }_masterkey_auto` , options ) ; } async setCryptoMasterKeyAuto ( value , options ? ) { options = this . reconcileOptions ( this . reconcileOptions ( options , { keySuffix : "auto" } ) , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return ; } await this . secureStorageService . save ( `${ options . userId }_masterkey_auto` , value , options ) ; } async getCryptoMasterKeyB64 ( options ? ) { options = this . reconcileOptions ( options , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return null ; } return await this . secureStorageService . get ( `${ options ?. userId }_masterkey` , options ) ; } async setCryptoMasterKeyB64 ( value , options ? ) { options = this . reconcileOptions ( options , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return ; } await this . secureStorageService . save ( `${ options . userId }_masterkey` , value , options ) ; } async getCryptoMasterKeyBiometric ( options ? ) { options = this . reconcileOptions ( this . reconcileOptions ( options , { keySuffix : "biometric" } ) , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return null ; } return await this . secureStorageService . get ( `${ options . userId }_masterkey_biometric` , options ) ; } async hasCryptoMasterKeyBiometric ( options ? ) { options = this . reconcileOptions ( this . reconcileOptions ( options , { keySuffix : "biometric" } ) , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return false ; } return await this . secureStorageService . has ( `${ options . userId }_masterkey_biometric` , options ) ; } async setCryptoMasterKeyBiometric ( value , options ? ) { options = this . reconcileOptions ( this . reconcileOptions ( options , { keySuffix : "biometric" } ) , await this . defaultSecureStorageOptions ( ) ) ; if ( options ?. userId == null ) { return ; } await this . secureStorageService . save ( `${ options . userId }_masterkey_biometric` , value , options ) ; } async getDecodedToken ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. tokens ?. decodedToken ; } async setDecodedToken ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . tokens . decodedToken = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedCiphers ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. ciphers ?. decrypted ; } async setDecryptedCiphers ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . ciphers . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedCollections ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. collections ?. decrypted ; } async setDecryptedCollections ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . collections . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedCryptoSymmetricKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. cryptoSymmetricKey ?. decrypted ; } async setDecryptedCryptoSymmetricKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . cryptoSymmetricKey . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedFolders ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. folders ?. decrypted ; } async setDecryptedFolders ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . folders . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedOrganizationKeys ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. organizationKeys ?. decrypted ; } async setDecryptedOrganizationKeys ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . organizationKeys . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedPasswordGenerationHistory ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. passwordGenerationHistory ?. decrypted ; } async setDecryptedPasswordGenerationHistory ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . passwordGenerationHistory . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedPinProtected ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. settings ?. pinProtected ?. decrypted ; } async setDecryptedPinProtected ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . settings . pinProtected . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedPolicies ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. policies ?. decrypted ; } async setDecryptedPolicies ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . policies . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedPrivateKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. privateKey ?. decrypted ; } async setDecryptedPrivateKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . privateKey . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedProviderKeys ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. providerKeys ?. decrypted ; } async setDecryptedProviderKeys ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . providerKeys . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDecryptedSends ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. sends ?. decrypted ; } async setDecryptedSends ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . sends . decrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getDefaultUriMatch ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. defaultUriMatch ; } async setDefaultUriMatch ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . defaultUriMatch = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableAddLoginNotification ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableAddLoginNotification ?? false ) ; } async setDisableAddLoginNotification ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableAddLoginNotification = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableAutoBiometricsPrompt ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableAutoBiometricsPrompt ?? false ) ; } async setDisableAutoBiometricsPrompt ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableAutoBiometricsPrompt = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableAutoTotpCopy ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableAutoTotpCopy ?? false ) ; } async setDisableAutoTotpCopy ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableAutoTotpCopy = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableBadgeCounter ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableBadgeCounter ?? false ) ; } async setDisableBadgeCounter ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableBadgeCounter = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableChangedPasswordNotification ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableChangedPasswordNotification ?? false ) ; } async setDisableChangedPasswordNotification ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableChangedPasswordNotification = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableContextMenuItem ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableContextMenuItem ?? false ) ; } async setDisableContextMenuItem ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableContextMenuItem = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDisableFavicon ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. disableFavicon ?? false ) ; } async setDisableFavicon ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . disableFavicon = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getDisableGa ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. disableGa ?? false ) ; } async setDisableGa ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . disableGa = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDontShowCardsCurrentTab ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. dontShowCardsCurrentTab ?? false ) ; } async setDontShowCardsCurrentTab ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . dontShowCardsCurrentTab = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getDontShowIdentitiesCurrentTab ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. dontShowIdentitiesCurrentTab ?? false ) ; } async setDontShowIdentitiesCurrentTab ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . dontShowIdentitiesCurrentTab = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEmail ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. email ; } async setEmail ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . email = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEmailVerified ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile . emailVerified ?? false ) ; } async setEmailVerified ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . emailVerified = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableAlwaysOnTop ( options ? ) { const accountPreference = ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableAlwaysOnTop ; const globalPreference = ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. enableAlwaysOnTop ; return accountPreference ?? globalPreference ?? false ; } async setEnableAlwaysOnTop ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableAlwaysOnTop = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . enableAlwaysOnTop = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableAutoFillOnPageLoad ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableAutoFillOnPageLoad ?? false ) ; } async setEnableAutoFillOnPageLoad ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableAutoFillOnPageLoad = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableBiometric ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. enableBiometrics ?? false ) ; } async setEnableBiometric ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . enableBiometrics = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableBrowserIntegration ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableBrowserIntegration ?? false ) ; } async setEnableBrowserIntegration ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableBrowserIntegration = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableBrowserIntegrationFingerprint ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableBrowserIntegrationFingerprint ?? false ) ; } async setEnableBrowserIntegrationFingerprint ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableBrowserIntegrationFingerprint = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableCloseToTray ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableCloseToTray ?? false ) ; } async setEnableCloseToTray ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableCloseToTray = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableFullWidth ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. settings ?. enableFullWidth ?? false ) ; } async setEnableFullWidth ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . settings . enableFullWidth = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getEnableGravitars ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. settings ?. enableGravitars ?? false ) ; } async setEnableGravitars ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . settings . enableGravitars = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getEnableMinimizeToTray ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableMinimizeToTray ?? false ) ; } async setEnableMinimizeToTray ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableMinimizeToTray = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableStartToTray ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings . enableStartToTray ?? false ) ; } async setEnableStartToTray ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableStartToTray = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEnableTray ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. enableTray ?? false ) ; } async setEnableTray ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . enableTray = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedCiphers ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. data ?. ciphers ?. encrypted ; } async setEncryptedCiphers ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . data . ciphers . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getEncryptedCollections ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. data ?. collections ?. encrypted ; } async setEncryptedCollections ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . data . collections . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getEncryptedCryptoSymmetricKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys . cryptoSymmetricKey . encrypted ; } async setEncryptedCryptoSymmetricKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . cryptoSymmetricKey . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedFolders ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. data ?. folders ?. encrypted ; } async setEncryptedFolders ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . data . folders . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getEncryptedOrganizationKeys ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys ?. organizationKeys . encrypted ; } async setEncryptedOrganizationKeys ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . organizationKeys . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedPasswordGenerationHistory ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. data ?. passwordGenerationHistory ?. encrypted ; } async setEncryptedPasswordGenerationHistory ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . data . passwordGenerationHistory . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedPinProtected ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. pinProtected ?. encrypted ; } async setEncryptedPinProtected ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . pinProtected . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedPolicies ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. data ?. policies ?. encrypted ; } async setEncryptedPolicies ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . data . policies . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedPrivateKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys ?. privateKey ?. encrypted ; } async setEncryptedPrivateKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . privateKey . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedProviderKeys ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys ?. providerKeys ?. encrypted ; } async setEncryptedProviderKeys ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . providerKeys . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEncryptedSends ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. data ?. sends . encrypted ; } async setEncryptedSends ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . data . sends . encrypted = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getEntityId ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. profile ?. entityId ; } async setEntityId ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . profile . entityId = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getEntityType ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. profile ?. entityType ; } async setEntityType ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . profile . entityType = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getEnvironmentUrls ( options ? ) { if ( this . state . activeUserId == null ) { return await this . getGlobalEnvironmentUrls ( options ) ; } options = this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ; return ( await this . getAccount ( options ) ) ?. settings ?. environmentUrls ?? new EnvironmentUrls ( ) ; } async setEnvironmentUrls ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . environmentUrls = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEquivalentDomains ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. equivalentDomains ; } async setEquivalentDomains ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . equivalentDomains = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEventCollection ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. data ?. eventCollection ; } async setEventCollection ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . data . eventCollection = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getEverBeenUnlocked ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. everBeenUnlocked ?? false ) ; } async setEverBeenUnlocked ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . everBeenUnlocked = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getForcePasswordReset ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. profile ?. forcePasswordReset ?? false ) ; } async setForcePasswordReset ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . profile . forcePasswordReset = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getInstalledVersion ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. installedVersion ; } async setInstalledVersion ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . installedVersion = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getIsAuthenticated ( options ? ) { return ( await this . getAccessToken ( options ) ) != null && ( await this . getUserId ( options ) ) != null ; } async getKdfIterations ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. kdfIterations ; } async setKdfIterations ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . kdfIterations = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getKdfType ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. kdfType ; } async setKdfType ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . kdfType = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getKeyHash ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. keyHash ; } async setKeyHash ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . profile . keyHash = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getLastActive ( options ? ) { const lastActive = ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. lastActive ; return ( lastActive ?? ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. lastActive ) ; } async setLastActive ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; if ( account != null ) { account . profile . lastActive = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . lastActive = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getLastSync ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. profile ?. lastSync ; } async setLastSync ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . profile . lastSync = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getLegacyEtmKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. keys ?. legacyEtmKey ; } async setLegacyEtmKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . keys . legacyEtmKey = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getLocalData ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. localData ; } async setLocalData ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . localData = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getLocale ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. locale ; } async setLocale ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . locale = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getLoginRedirect ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. loginRedirect ; } async setLoginRedirect ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; globals . loginRedirect = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getMainWindowSize ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. mainWindowSize ; } async setMainWindowSize ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; globals . mainWindowSize = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getMinimizeOnCopyToClipboard ( options ? ) { return ( ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. minimizeOnCopyToClipboard ?? false ) ; } async setMinimizeOnCopyToClipboard ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . minimizeOnCopyToClipboard = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getNeverDomains ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. neverDomains ; } async setNeverDomains ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . neverDomains = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getNoAutoPromptBiometrics ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. noAutoPromptBiometrics ?? false ) ; } async setNoAutoPromptBiometrics ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . noAutoPromptBiometrics = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getNoAutoPromptBiometricsText ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. noAutoPromptBiometricsText ; } async setNoAutoPromptBiometricsText ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . noAutoPromptBiometricsText = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getOpenAtLogin ( options ? ) { return ( ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. openAtLogin ?? false ) ; } async setOpenAtLogin ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . openAtLogin = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getOrganizationInvitation ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. organizationInvitation ; } async setOrganizationInvitation ( value , options ? ) { 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 ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. data ?. organizations ; } async setOrganizations ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . data . organizations = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getPasswordGenerationOptions ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. passwordGenerationOptions ; } async setPasswordGenerationOptions ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . passwordGenerationOptions = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getProtectedPin ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. settings ?. protectedPin ; } async setProtectedPin ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . settings . protectedPin = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getProviders ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. data ?. providers ; } async setProviders ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . data . providers = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getPublicKey ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. keys ?. publicKey ; } async setPublicKey ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . keys . publicKey = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getRefreshToken ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. tokens ?. refreshToken ; } async setRefreshToken ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; account . tokens . refreshToken = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getRememberedEmail ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. rememberedEmail ; } async setRememberedEmail ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . rememberedEmail = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getSecurityStamp ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. tokens ?. securityStamp ; } async setSecurityStamp ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . tokens . securityStamp = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getSettings ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ) ?. settings ?. settings ; } async setSettings ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; account . settings . settings = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskMemoryOptions ( ) ) ) ; } async getSsoCodeVerifier ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. ssoCodeVerifier ; } async setSsoCodeVerifier ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . ssoCodeVerifier = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getSsoOrgIdentifier ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. ssoOrganizationIdentifier ; } async setSsoOrganizationIdentifier ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . ssoOrganizationIdentifier = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getSsoState ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. ssoState ; } async setSsoState ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . ssoState = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } async getTheme ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. theme ; } async setTheme ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . theme = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getTwoFactorToken ( options ? ) { return ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. twoFactorToken ; } async setTwoFactorToken ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; globals . twoFactorToken = value ; await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getUserId ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ) ?. profile ?. userId ; } async getUsesKeyConnector ( options ? ) { return ( await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ) ?. profile ?. usesKeyConnector ; } async setUsesKeyConnector ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; account . profile . usesKeyConnector = value ; await this . saveAccount ( account , this . reconcileOptions ( options , this . defaultInMemoryOptions ) ) ; } async getVaultTimeout ( options ? ) { const accountVaultTimeout = ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. settings ?. vaultTimeout ; return accountVaultTimeout ; } async setVaultTimeout ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . settings . vaultTimeout = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getVaultTimeoutAction ( options ? ) { const accountVaultTimeoutAction = ( await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. settings ?. vaultTimeoutAction ; const globalVaultTimeoutAction = ( await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ) ?. vaultTimeoutAction ; return accountVaultTimeoutAction ?? globalVaultTimeoutAction ; } async setVaultTimeoutAction ( value , options ? ) { const account = await this . getAccount ( this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; account . settings . vaultTimeoutAction = value ; await this . saveAccount ( account , this . reconcileOptions ( options , await this . defaultOnDiskLocalOptions ( ) ) ) ; } async getStateVersion ( ) { return ( await this . getGlobals ( await this . defaultOnDiskLocalOptions ( ) ) ) . stateVersion ?? 1 ; } async setStateVersion ( value ) { const globals = await this . getGlobals ( await this . defaultOnDiskOptions ( ) ) ; globals . stateVersion = value ; await this . saveGlobals ( globals , await this . defaultOnDiskOptions ( ) ) ; } async getWindow ( ) { const globals = await this . getGlobals ( await this . defaultOnDiskOptions ( ) ) ; return globals ?. window != null && Object . keys ( globals . window ) . length > 0 ? globals . window : new Map < string , any > ( ) ; } async setWindow ( value , options ? ) { const globals = await this . getGlobals ( this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; globals . window = value ; return await this . saveGlobals ( globals , this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ) ; } protected async getGlobals ( options ) { let globals ; if ( this . useMemory ( options . storageLocation ) ) { globals = this . getGlobalsFromMemory ( ) ; } if ( this . useDisk && globals == null ) { globals = await this . getGlobalsFromDisk ( options ) ; } return globals ?? new GlobalState ( ) ; } protected async saveGlobals ( globals , options ) { return this . useMemory ( options . storageLocation ) ? this . saveGlobalsToMemory ( globals ) : await this . saveGlobalsToDisk ( globals , options ) ; } protected getGlobalsFromMemory ( ) { return this . state . globals ; } protected async getGlobalsFromDisk ( options ) { return ( await this . storageService . get < State < TAccount > > ( "state" , options ) ) ?. globals ; } protected saveGlobalsToMemory ( globals ) { this . state . globals = globals ; } protected async saveGlobalsToDisk ( globals , options ) { if ( options . useSecureStorage ) { const state = ( await this . secureStorageService . get < State < TAccount > > ( "state" , options ) ) ?? new State ( ) ; state . globals = globals ; await this . secureStorageService . save ( "state" , state , options ) ; } else { const state = ( await this . storageService . get < State < TAccount > > ( "state" , options ) ) ?? new State ( ) ; state . globals = globals ; await this . saveStateToStorage ( state , options ) ; } } protected async getAccount ( options ) { try { let account ; if ( this . useMemory ( options . storageLocation ) ) { account = this . getAccountFromMemory ( options ) ; } if ( this . useDisk ( options . storageLocation ) && account == null ) { account = await this . getAccountFromDisk ( options ) ; } return account ; } catch ( e ) { this . logService . error ( e ) ; } } protected getAccountFromMemory ( options ) { if ( this . state . accounts == null ) { return null ; } return this . state . accounts [ this . getUserIdFromMemory ( options ) ] ; } protected getUserIdFromMemory ( options ) { return options ?. userId != null ? this . state . accounts [ options . userId ] ?. profile ?. userId : this . state . activeUserId ; } protected async getAccountFromDisk ( options ) { if ( options ?. userId == null && this . state . activeUserId == null ) { return null ; } const state = options ?. useSecureStorage ? ( await this . secureStorageService . get < State < TAccount > > ( "state" , options ) ) ?? ( await this . storageService . get < State < TAccount > > ( "state" , this . reconcileOptions ( options , { htmlStorageLocation : HtmlStorageLocation . Local } ) ) ) : await this . storageService . get < State < TAccount > > ( "state" , options ) ; return state ?. accounts [ options ?. userId ?? this . state . activeUserId ] ; } protected useMemory ( storageLocation ) { return storageLocation === StorageLocation . Memory || storageLocation === StorageLocation . Both ; } protected useDisk ( storageLocation ) { return storageLocation === StorageLocation . Disk || storageLocation === StorageLocation . Both ; } protected async saveAccount ( account , options = { storageLocation : StorageLocation . Both , useSecureStorage : false , } ) { return this . useMemory ( options . storageLocation ) ? await this . saveAccountToMemory ( account ) : await this . saveAccountToDisk ( account , options ) ; } protected async saveAccountToDisk ( account , options ) { const storageLocation = options . useSecureStorage ? this . secureStorageService : this . storageService ; const state = ( await storageLocation . get < State < TAccount > > ( "state" , options ) ) ?? new State < TAccount > ( ) ; state . accounts [ account . profile . userId ] = account ; await storageLocation . save ( "state" , state , options ) ; } protected async saveAccountToMemory ( account ) { if ( this . getAccountFromMemory ( { userId : account . profile . userId } ) !== null ) { this . state . accounts [ account . profile . userId ] = account ; } await this . pushAccounts ( ) ; } protected async scaffoldNewAccountStorage ( account ) { await this . scaffoldNewAccountLocalStorage ( account ) ; await this . scaffoldNewAccountSessionStorage ( account ) ; await this . scaffoldNewAccountMemoryStorage ( account ) ; } protected async scaffoldNewAccountLocalStorage ( account ) { const storedState = ( await this . storageService . get < State < TAccount > > ( "state" , await this . defaultOnDiskLocalOptions ( ) ) ) ?? new State < TAccount > ( ) ; const storedAccount = storedState . accounts [ account . profile . userId ] ; if ( storedAccount != null ) { account . settings = storedAccount . settings ; } storedState . accounts [ account . profile . userId ] = account ; await this . saveStateToStorage ( storedState , await this . defaultOnDiskLocalOptions ( ) ) ; } protected async scaffoldNewAccountMemoryStorage ( account ) { const storedState = ( await this . storageService . get < State < TAccount > > ( "state" , await this . defaultOnDiskMemoryOptions ( ) ) ) ?? new State < TAccount > ( ) ; const storedAccount = storedState . accounts [ account . profile . userId ] ; if ( storedAccount != null ) { account . settings = storedAccount . settings ; } storedState . accounts [ account . profile . userId ] = account ; await this . saveStateToStorage ( storedState , await this . defaultOnDiskMemoryOptions ( ) ) ; } protected async scaffoldNewAccountSessionStorage ( account ) { const storedState = ( await this . storageService . get < State < TAccount > > ( "state" , await this . defaultOnDiskOptions ( ) ) ) ?? new State < TAccount > ( ) ; const storedAccount = storedState . accounts [ account . profile . userId ] ; if ( storedAccount != null ) { account . settings = storedAccount . settings ; } storedState . accounts [ account . profile . userId ] = account ; await this . saveStateToStorage ( storedState , await this . defaultOnDiskOptions ( ) ) ; } protected async pushAccounts ( ) { await this . pruneInMemoryAccounts ( ) ; if ( this . state ?. accounts == null || Object . keys ( this . state . accounts ) . length < 1 ) { this . accounts . next ( null ) ; return ; } this . accounts . next ( this . state . accounts ) ; } protected reconcileOptions ( requestedOptions , defaultOptions ) { if ( requestedOptions == null ) { return defaultOptions ; } requestedOptions . userId = requestedOptions ?. userId ?? defaultOptions . userId ; requestedOptions . storageLocation = requestedOptions ?. storageLocation ?? defaultOptions . storageLocation ; requestedOptions . useSecureStorage = requestedOptions ?. useSecureStorage ?? defaultOptions . useSecureStorage ; requestedOptions . htmlStorageLocation = requestedOptions ?. htmlStorageLocation ?? defaultOptions . htmlStorageLocation ; requestedOptions . keySuffix = requestedOptions ?. keySuffix ?? defaultOptions . keySuffix ; return requestedOptions ; } protected get defaultInMemoryOptions ( ) : StorageOptions { return { storageLocation : StorageLocation . Memory , userId : this . state . activeUserId } ; } protected async defaultOnDiskOptions ( ) { return { storageLocation : StorageLocation . Disk , htmlStorageLocation : HtmlStorageLocation . Session , userId : this . state . activeUserId ?? ( await this . getActiveUserIdFromStorage ( ) ) , useSecureStorage : false , } ; } protected async defaultOnDiskLocalOptions ( ) { return { storageLocation : StorageLocation . Disk , htmlStorageLocation : HtmlStorageLocation . Local , userId : this . state . activeUserId ?? ( await this . getActiveUserIdFromStorage ( ) ) , useSecureStorage : false , } ; } protected async defaultOnDiskMemoryOptions ( ) { return { storageLocation : StorageLocation . Disk , htmlStorageLocation : HtmlStorageLocation . Memory , userId : this . state . activeUserId ?? ( await this . getUserId ( ) ) , useSecureStorage : false , } ; } protected async defaultSecureStorageOptions ( ) { return { storageLocation : StorageLocation . Disk , useSecureStorage : true , userId : this . state . activeUserId ?? ( await this . getActiveUserIdFromStorage ( ) ) , } ; } protected async getActiveUserIdFromStorage ( ) { const state = await this . storageService . get < State < TAccount > > ( "state" ) ; return state ?. activeUserId ; } protected async removeAccountFromLocalStorage ( userId = this . state . activeUserId ) { const state = await this . storageService . get < State < TAccount > > ( "state" , { htmlStorageLocation : HtmlStorageLocation . Local , } ) ; if ( state ?. accounts [ userId ] == null ) { return ; } state . accounts [ userId ] = this . resetAccount ( state . accounts [ userId ] ) ; await this . saveStateToStorage ( state , await this . defaultOnDiskLocalOptions ( ) ) ; } protected async removeAccountFromSessionStorage ( userId = this . state . activeUserId ) { const state = await this . storageService . get < State < TAccount > > ( "state" , { htmlStorageLocation : HtmlStorageLocation . Session , } ) ; if ( state ?. accounts [ userId ] == null ) { return ; } state . accounts [ userId ] = this . resetAccount ( state . accounts [ userId ] ) ; await this . saveStateToStorage ( state , await this . defaultOnDiskOptions ( ) ) ; } protected async removeAccountFromSecureStorage ( userId = this . state . activeUserId ) { await this . setCryptoMasterKeyAuto ( null , { userId : userId } ) ; await this . setCryptoMasterKeyBiometric ( null , { userId : userId } ) ; await this . setCryptoMasterKeyB64 ( null , { userId : userId } ) ; } protected removeAccountFromMemory ( userId = this . state . activeUserId ) { delete this . state . accounts [ userId ] ; } protected async saveStateToStorage ( state , options ) { await this . storageService . save ( "state" , state , options ) ; } protected async pruneInMemoryAccounts ( ) { for ( const userId in this . state . accounts ) { if ( ! ( await this . getIsAuthenticated ( { userId : userId } ) ) ) { delete this . state . accounts [ userId ] ; } } } protected resetAccount ( account ) { account . data = new AccountData ( ) ; account . keys = new AccountKeys ( ) ; account . profile = new AccountProfile ( ) ; account . tokens = new AccountTokens ( ) ; return account ; } protected async setAccountEnvironmentUrls ( account ) { account . settings . environmentUrls = await this . getGlobalEnvironmentUrls ( ) ; return account ; } protected async getGlobalEnvironmentUrls ( options ? ) { options = this . reconcileOptions ( options , await this . defaultOnDiskOptions ( ) ) ; return ( await this . getGlobals ( options ) ) . environmentUrls ?? new EnvironmentUrls ( ) ; } }