diff --git a/apps/desktop/src/platform/main/biometric/biometrics.service.abstraction.ts b/apps/desktop/src/platform/main/biometric/biometrics.service.abstraction.ts index 2d5c1d19ebb..fb7ce048b5a 100644 --- a/apps/desktop/src/platform/main/biometric/biometrics.service.abstraction.ts +++ b/apps/desktop/src/platform/main/biometric/biometrics.service.abstraction.ts @@ -1,6 +1,6 @@ export abstract class BiometricsServiceAbstraction { - osSupportsBiometric: () => Promise; - canAuthBiometric: ({ + abstract osSupportsBiometric(): Promise; + abstract canAuthBiometric({ service, key, userId, @@ -8,11 +8,11 @@ export abstract class BiometricsServiceAbstraction { service: string; key: string; userId: string; - }) => Promise; - authenticateBiometric: () => Promise; - getBiometricKey: (service: string, key: string) => Promise; - setBiometricKey: (service: string, key: string, value: string) => Promise; - setEncryptionKeyHalf: ({ + }): Promise; + abstract authenticateBiometric(): Promise; + abstract getBiometricKey(service: string, key: string): Promise; + abstract setBiometricKey(service: string, key: string, value: string): Promise; + abstract setEncryptionKeyHalf({ service, key, value, @@ -20,23 +20,23 @@ export abstract class BiometricsServiceAbstraction { service: string; key: string; value: string; - }) => void; - deleteBiometricKey: (service: string, key: string) => Promise; + }): void; + abstract deleteBiometricKey(service: string, key: string): Promise; } export interface OsBiometricService { - osSupportsBiometric: () => Promise; - authenticateBiometric: () => Promise; - getBiometricKey: ( + osSupportsBiometric(): Promise; + authenticateBiometric(): Promise; + getBiometricKey( service: string, key: string, clientKeyHalfB64: string | undefined, - ) => Promise; - setBiometricKey: ( + ): Promise; + setBiometricKey( service: string, key: string, value: string, clientKeyHalfB64: string | undefined, - ) => Promise; - deleteBiometricKey: (service: string, key: string) => Promise; + ): Promise; + deleteBiometricKey(service: string, key: string): Promise; } diff --git a/libs/angular/src/platform/abstractions/form-validation-errors.service.ts b/libs/angular/src/platform/abstractions/form-validation-errors.service.ts index 08a12443a0c..266afff5f34 100644 --- a/libs/angular/src/platform/abstractions/form-validation-errors.service.ts +++ b/libs/angular/src/platform/abstractions/form-validation-errors.service.ts @@ -9,5 +9,5 @@ export interface FormGroupControls { } export abstract class FormValidationErrorsService { - getFormValidationErrors: (controls: FormGroupControls) => AllValidationErrors[]; + abstract getFormValidationErrors(controls: FormGroupControls): AllValidationErrors[]; } diff --git a/libs/angular/src/platform/services/theming/theming.service.abstraction.ts b/libs/angular/src/platform/services/theming/theming.service.abstraction.ts index 9a012a7f75b..4306d312c5e 100644 --- a/libs/angular/src/platform/services/theming/theming.service.abstraction.ts +++ b/libs/angular/src/platform/services/theming/theming.service.abstraction.ts @@ -11,12 +11,12 @@ export abstract class AbstractThemingService { * The effective theme based on the user configured choice and the current system theme if * the configured choice is {@link ThemeType.System}. */ - theme$: Observable; + abstract theme$: Observable; /** * Listens for effective theme changes and applies changes to the provided document. * @param document The document that should have theme classes applied to it. * * @returns A subscription that can be unsubscribed from to cancel the application of theme classes. */ - applyThemeChangesTo: (document: Document) => Subscription; + abstract applyThemeChangesTo(document: Document): Subscription; } diff --git a/libs/common/src/platform/abstractions/app-id.service.ts b/libs/common/src/platform/abstractions/app-id.service.ts index c1414dd01ff..c2c1a23ef5e 100644 --- a/libs/common/src/platform/abstractions/app-id.service.ts +++ b/libs/common/src/platform/abstractions/app-id.service.ts @@ -1,8 +1,8 @@ import { Observable } from "rxjs"; export abstract class AppIdService { - appId$: Observable; - anonymousAppId$: Observable; - getAppId: () => Promise; - getAnonymousAppId: () => Promise; + abstract appId$: Observable; + abstract anonymousAppId$: Observable; + abstract getAppId(): Promise; + abstract getAnonymousAppId(): Promise; } diff --git a/libs/common/src/platform/abstractions/broadcaster.service.ts b/libs/common/src/platform/abstractions/broadcaster.service.ts index 5df3c033433..8abfb5a90c5 100644 --- a/libs/common/src/platform/abstractions/broadcaster.service.ts +++ b/libs/common/src/platform/abstractions/broadcaster.service.ts @@ -9,13 +9,13 @@ export abstract class BroadcasterService { /** * @deprecated Use the observable from the appropriate service instead. */ - send: (message: MessageBase, id?: string) => void; + abstract send(message: MessageBase, id?: string): void; /** * @deprecated Use the observable from the appropriate service instead. */ - subscribe: (id: string, messageCallback: (message: MessageBase) => void) => void; + abstract subscribe(id: string, messageCallback: (message: MessageBase) => void): void; /** * @deprecated Use the observable from the appropriate service instead. */ - unsubscribe: (id: string) => void; + abstract unsubscribe(id: string): void; } diff --git a/libs/common/src/platform/abstractions/config/config-api.service.abstraction.ts b/libs/common/src/platform/abstractions/config/config-api.service.abstraction.ts index 63534becf34..3c191f59ccc 100644 --- a/libs/common/src/platform/abstractions/config/config-api.service.abstraction.ts +++ b/libs/common/src/platform/abstractions/config/config-api.service.abstraction.ts @@ -5,5 +5,5 @@ export abstract class ConfigApiServiceAbstraction { /** * Fetches the server configuration for the given user. If no user is provided, the configuration will not contain user-specific context. */ - get: (userId: UserId | undefined) => Promise; + abstract get(userId: UserId | undefined): Promise; } diff --git a/libs/common/src/platform/abstractions/crypto-function.service.ts b/libs/common/src/platform/abstractions/crypto-function.service.ts index db432abc34c..18c14677dd0 100644 --- a/libs/common/src/platform/abstractions/crypto-function.service.ts +++ b/libs/common/src/platform/abstractions/crypto-function.service.ts @@ -3,85 +3,85 @@ import { DecryptParameters } from "../models/domain/decrypt-parameters"; import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key"; export abstract class CryptoFunctionService { - pbkdf2: ( + abstract pbkdf2( password: string | Uint8Array, salt: string | Uint8Array, algorithm: "sha256" | "sha512", iterations: number, - ) => Promise; - argon2: ( + ): Promise; + abstract argon2( password: string | Uint8Array, salt: string | Uint8Array, iterations: number, memory: number, parallelism: number, - ) => Promise; - hkdf: ( + ): Promise; + abstract hkdf( ikm: Uint8Array, salt: string | Uint8Array, info: string | Uint8Array, outputByteSize: number, algorithm: "sha256" | "sha512", - ) => Promise; - hkdfExpand: ( + ): Promise; + abstract hkdfExpand( prk: Uint8Array, info: string | Uint8Array, outputByteSize: number, algorithm: "sha256" | "sha512", - ) => Promise; - hash: ( + ): Promise; + abstract hash( value: string | Uint8Array, algorithm: "sha1" | "sha256" | "sha512" | "md5", - ) => Promise; - hmac: ( + ): Promise; + abstract hmac( value: Uint8Array, key: Uint8Array, algorithm: "sha1" | "sha256" | "sha512", - ) => Promise; - compare: (a: Uint8Array, b: Uint8Array) => Promise; - hmacFast: ( + ): Promise; + abstract compare(a: Uint8Array, b: Uint8Array): Promise; + abstract hmacFast( value: Uint8Array | string, key: Uint8Array | string, algorithm: "sha1" | "sha256" | "sha512", - ) => Promise; - compareFast: (a: Uint8Array | string, b: Uint8Array | string) => Promise; - aesEncrypt: (data: Uint8Array, iv: Uint8Array, key: Uint8Array) => Promise; - aesDecryptFastParameters: ( + ): Promise; + abstract compareFast(a: Uint8Array | string, b: Uint8Array | string): Promise; + abstract aesEncrypt(data: Uint8Array, iv: Uint8Array, key: Uint8Array): Promise; + abstract aesDecryptFastParameters( data: string, iv: string, mac: string, key: SymmetricCryptoKey, - ) => DecryptParameters; - aesDecryptFast: ( + ): DecryptParameters; + abstract aesDecryptFast( parameters: DecryptParameters, mode: "cbc" | "ecb", - ) => Promise; - aesDecrypt: ( + ): Promise; + abstract aesDecrypt( data: Uint8Array, iv: Uint8Array, key: Uint8Array, mode: "cbc" | "ecb", - ) => Promise; - rsaEncrypt: ( + ): Promise; + abstract rsaEncrypt( data: Uint8Array, publicKey: Uint8Array, algorithm: "sha1" | "sha256", - ) => Promise; - rsaDecrypt: ( + ): Promise; + abstract rsaDecrypt( data: Uint8Array, privateKey: Uint8Array, algorithm: "sha1" | "sha256", - ) => Promise; - rsaExtractPublicKey: (privateKey: Uint8Array) => Promise; - rsaGenerateKeyPair: (length: 1024 | 2048 | 4096) => Promise<[Uint8Array, Uint8Array]>; + ): Promise; + abstract rsaExtractPublicKey(privateKey: Uint8Array): Promise; + abstract rsaGenerateKeyPair(length: 1024 | 2048 | 4096): Promise<[Uint8Array, Uint8Array]>; /** * Generates a key of the given length suitable for use in AES encryption */ - aesGenerateKey: (bitLength: 128 | 192 | 256 | 512) => Promise; + abstract aesGenerateKey(bitLength: 128 | 192 | 256 | 512): Promise; /** * Generates a random array of bytes of the given length. Uses a cryptographically secure random number generator. * * Do not use this for generating encryption keys. Use aesGenerateKey or rsaGenerateKeyPair instead. */ - randomBytes: (length: number) => Promise; + abstract randomBytes(length: number): Promise; } diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index a5a2d452334..44ff5216809 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -12,7 +12,7 @@ import { EncString } from "../models/domain/enc-string"; import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key"; export abstract class CryptoService { - activeUserKey$: Observable; + abstract activeUserKey$: Observable; /** * Sets the provided user key and stores * any other necessary versions (such as auto, biometrics, @@ -22,105 +22,105 @@ export abstract class CryptoService { * @param key The user key to set * @param userId The desired user */ - setUserKey: (key: UserKey, userId?: string) => Promise; + abstract setUserKey(key: UserKey, userId?: string): Promise; /** * Gets the user key from memory and sets it again, * kicking off a refresh of any additional keys * (such as auto, biometrics, or pin) */ - refreshAdditionalKeys: () => Promise; + abstract refreshAdditionalKeys(): Promise; /** * Observable value that returns whether or not the currently active user has ever had auser key, * i.e. has ever been unlocked/decrypted. This is key for differentiating between TDE locked and standard locked states. */ - everHadUserKey$: Observable; + abstract everHadUserKey$: Observable; /** * Retrieves the user key * @param userId The desired user * @returns The user key */ - getUserKey: (userId?: string) => Promise; + abstract getUserKey(userId?: string): Promise; /** * Checks if the user is using an old encryption scheme that used the master key * for encryption of data instead of the user key. */ - isLegacyUser: (masterKey?: MasterKey, userId?: string) => Promise; + abstract isLegacyUser(masterKey?: MasterKey, userId?: string): Promise; /** * Use for encryption/decryption of data in order to support legacy * encryption models. It will return the user key if available, * if not it will return the master key. * @param userId The desired user */ - getUserKeyWithLegacySupport: (userId?: string) => Promise; + abstract getUserKeyWithLegacySupport(userId?: string): Promise; /** * Retrieves the user key from storage * @param keySuffix The desired version of the user's key to retrieve * @param userId The desired user * @returns The user key */ - getUserKeyFromStorage: (keySuffix: KeySuffixOptions, userId?: string) => Promise; + abstract getUserKeyFromStorage(keySuffix: KeySuffixOptions, userId?: string): Promise; /** * Determines whether the user key is available for the given user. * @param userId The desired user. If not provided, the active user will be used. If no active user exists, the method will return false. * @returns True if the user key is available */ - hasUserKey: (userId?: UserId) => Promise; + abstract hasUserKey(userId?: UserId): Promise; /** * Determines whether the user key is available for the given user in memory. * @param userId The desired user. If not provided, the active user will be used. If no active user exists, the method will return false. * @returns True if the user key is available */ - hasUserKeyInMemory: (userId?: string) => Promise; + abstract hasUserKeyInMemory(userId?: string): Promise; /** * @param keySuffix The desired version of the user's key to check * @param userId The desired user * @returns True if the provided version of the user key is stored */ - hasUserKeyStored: (keySuffix: KeySuffixOptions, userId?: string) => Promise; + abstract hasUserKeyStored(keySuffix: KeySuffixOptions, userId?: string): Promise; /** * Generates a new user key * @param masterKey The user's master key * @returns A new user key and the master key protected version of it */ - makeUserKey: (key: MasterKey) => Promise<[UserKey, EncString]>; + abstract makeUserKey(key: MasterKey): Promise<[UserKey, EncString]>; /** * Clears the user key * @param clearStoredKeys Clears all stored versions of the user keys as well, * such as the biometrics key * @param userId The desired user */ - clearUserKey: (clearSecretStorage?: boolean, userId?: string) => Promise; + abstract clearUserKey(clearSecretStorage?: boolean, userId?: string): Promise; /** * Clears the user's stored version of the user key * @param keySuffix The desired version of the key to clear * @param userId The desired user */ - clearStoredUserKey: (keySuffix: KeySuffixOptions, userId?: string) => Promise; + abstract clearStoredUserKey(keySuffix: KeySuffixOptions, userId?: string): Promise; /** * Stores the master key encrypted user key * @param userKeyMasterKey The master key encrypted user key to set * @param userId The desired user */ - setMasterKeyEncryptedUserKey: (UserKeyMasterKey: string, userId?: string) => Promise; + abstract setMasterKeyEncryptedUserKey(UserKeyMasterKey: string, userId?: string): Promise; /** * Sets the user's master key * @param key The user's master key to set * @param userId The desired user */ - setMasterKey: (key: MasterKey, userId?: string) => Promise; + abstract setMasterKey(key: MasterKey, userId?: string): Promise; /** * @param userId The desired user * @returns The user's master key */ - getMasterKey: (userId?: string) => Promise; + abstract getMasterKey(userId?: string): Promise; /** * @param password The user's master password that will be used to derive a master key if one isn't found * @param userId The desired user */ - getOrDeriveMasterKey: (password: string, userId?: string) => Promise; + abstract getOrDeriveMasterKey(password: string, userId?: string): Promise; /** * Generates a master key from the provided password * @param password The user's master password @@ -129,17 +129,17 @@ export abstract class CryptoService { * @param KdfConfig The user's key derivation function configuration * @returns A master key derived from the provided password */ - makeMasterKey: ( + abstract makeMasterKey( password: string, email: string, kdf: KdfType, KdfConfig: KdfConfig, - ) => Promise; + ): Promise; /** * Clears the user's master key * @param userId The desired user */ - clearMasterKey: (userId?: string) => Promise; + abstract clearMasterKey(userId?: string): Promise; /** * Encrypts the existing (or provided) user key with the * provided master key @@ -147,10 +147,10 @@ export abstract class CryptoService { * @param userKey The user key * @returns The user key and the master key protected version of it */ - encryptUserKeyWithMasterKey: ( + abstract encryptUserKeyWithMasterKey( masterKey: MasterKey, userKey?: UserKey, - ) => Promise<[UserKey, EncString]>; + ): Promise<[UserKey, EncString]>; /** * Decrypts the user key with the provided master key * @param masterKey The user's master key @@ -158,11 +158,11 @@ export abstract class CryptoService { * @param userId The desired user * @returns The user key */ - decryptUserKeyWithMasterKey: ( + abstract decryptUserKeyWithMasterKey( masterKey: MasterKey, userKey?: EncString, userId?: string, - ) => Promise; + ): Promise; /** * Creates a master password hash from the user's master password. Can * be used for local authentication or for server authentication depending @@ -172,21 +172,25 @@ export abstract class CryptoService { * @param hashPurpose The iterations to use for the hash * @returns The user's master password hash */ - hashMasterKey: (password: string, key: MasterKey, hashPurpose?: HashPurpose) => Promise; + abstract hashMasterKey( + password: string, + key: MasterKey, + hashPurpose?: HashPurpose, + ): Promise; /** * Sets the user's master password hash * @param keyHash The user's master password hash to set */ - setMasterKeyHash: (keyHash: string) => Promise; + abstract setMasterKeyHash(keyHash: string): Promise; /** * @returns The user's master password hash */ - getMasterKeyHash: () => Promise; + abstract getMasterKeyHash(): Promise; /** * Clears the user's stored master password hash * @param userId The desired user */ - clearMasterKeyHash: (userId?: string) => Promise; + abstract clearMasterKeyHash(userId?: string): Promise; /** * Compares the provided master password to the stored password hash and server password hash. * Updates the stored hash if outdated. @@ -195,107 +199,109 @@ export abstract class CryptoService { * @returns True if the provided master password matches either the stored * key hash or the server key hash */ - compareAndUpdateKeyHash: (masterPassword: string, masterKey: MasterKey) => Promise; + abstract compareAndUpdateKeyHash(masterPassword: string, masterKey: MasterKey): Promise; /** * Stores the encrypted organization keys and clears any decrypted * organization keys currently in memory * @param orgs The organizations to set keys for * @param providerOrgs The provider organizations to set keys for */ - setOrgKeys: ( + abstract setOrgKeys( orgs: ProfileOrganizationResponse[], providerOrgs: ProfileProviderOrganizationResponse[], - ) => Promise; - activeUserOrgKeys$: Observable>; + ): Promise; + abstract activeUserOrgKeys$: Observable>; /** * Returns the organization's symmetric key * @deprecated Use the observable activeUserOrgKeys$ and `map` to the desired orgKey instead * @param orgId The desired organization * @returns The organization's symmetric key */ - getOrgKey: (orgId: string) => Promise; + abstract getOrgKey(orgId: string): Promise; /** * @deprecated Use the observable activeUserOrgKeys$ instead * @returns A record of the organization Ids to their symmetric keys */ - getOrgKeys: () => Promise>; + abstract getOrgKeys(): Promise>; /** * Uses the org key to derive a new symmetric key for encrypting data * @param orgKey The organization's symmetric key */ - makeDataEncKey: (key: T) => Promise<[SymmetricCryptoKey, EncString]>; + abstract makeDataEncKey( + key: T, + ): Promise<[SymmetricCryptoKey, EncString]>; /** * Clears the user's stored organization keys * @param memoryOnly Clear only the in-memory keys * @param userId The desired user */ - clearOrgKeys: (memoryOnly?: boolean, userId?: string) => Promise; + abstract clearOrgKeys(memoryOnly?: boolean, userId?: string): Promise; /** * Stores the encrypted provider keys and clears any decrypted * provider keys currently in memory * @param providers The providers to set keys for */ - activeUserProviderKeys$: Observable>; - setProviderKeys: (orgs: ProfileProviderResponse[]) => Promise; + abstract activeUserProviderKeys$: Observable>; + abstract setProviderKeys(orgs: ProfileProviderResponse[]): Promise; /** * @param providerId The desired provider * @returns The provider's symmetric key */ - getProviderKey: (providerId: string) => Promise; + abstract getProviderKey(providerId: string): Promise; /** * @returns A record of the provider Ids to their symmetric keys */ - getProviderKeys: () => Promise>; + abstract getProviderKeys(): Promise>; /** * @param memoryOnly Clear only the in-memory keys * @param userId The desired user */ - clearProviderKeys: (memoryOnly?: boolean, userId?: string) => Promise; + abstract clearProviderKeys(memoryOnly?: boolean, userId?: string): Promise; /** * Returns the public key from memory. If not available, extracts it * from the private key and stores it in memory * @returns The user's public key */ - getPublicKey: () => Promise; + abstract getPublicKey(): Promise; /** * Creates a new organization key and encrypts it with the user's public key. * This method can also return Provider keys for creating new Provider users. * @returns The new encrypted org key and the decrypted key itself */ - makeOrgKey: () => Promise<[EncString, T]>; + abstract makeOrgKey(): Promise<[EncString, T]>; /** * Sets the the user's encrypted private key in storage and * clears the decrypted private key from memory * Note: does not clear the private key if null is provided * @param encPrivateKey An encrypted private key */ - setPrivateKey: (encPrivateKey: string) => Promise; + abstract setPrivateKey(encPrivateKey: string): Promise; /** * Returns the private key from memory. If not available, decrypts it * from storage and stores it in memory * @returns The user's private key */ - getPrivateKey: () => Promise; + abstract getPrivateKey(): Promise; /** * Generates a fingerprint phrase for the user based on their public key * @param fingerprintMaterial Fingerprint material * @param publicKey The user's public key * @returns The user's fingerprint phrase */ - getFingerprint: (fingerprintMaterial: string, publicKey?: Uint8Array) => Promise; + abstract getFingerprint(fingerprintMaterial: string, publicKey?: Uint8Array): Promise; /** * Generates a new keypair * @param key A key to encrypt the private key with. If not provided, * defaults to the user key * @returns A new keypair: [publicKey in Base64, encrypted privateKey] */ - makeKeyPair: (key?: SymmetricCryptoKey) => Promise<[string, EncString]>; + abstract makeKeyPair(key?: SymmetricCryptoKey): Promise<[string, EncString]>; /** * Clears the user's key pair * @param memoryOnly Clear only the in-memory keys * @param userId The desired user */ - clearKeyPair: (memoryOnly?: boolean, userId?: string) => Promise; + abstract clearKeyPair(memoryOnly?: boolean, userId?: string): Promise; /** * @param pin The user's pin * @param salt The user's salt @@ -303,14 +309,19 @@ export abstract class CryptoService { * @param kdfConfig The user's kdf config * @returns A key derived from the user's pin */ - makePinKey: (pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig) => Promise; + abstract makePinKey( + pin: string, + salt: string, + kdf: KdfType, + kdfConfig: KdfConfig, + ): Promise; /** * Clears the user's pin keys from storage * Note: This will remove the stored pin and as a result, * disable pin protection for the user * @param userId The desired user */ - clearPinKeys: (userId?: string) => Promise; + abstract clearPinKeys(userId?: string): Promise; /** * Decrypts the user key with their pin * @param pin The user's PIN @@ -321,13 +332,13 @@ export abstract class CryptoService { * it will be retrieved from storage * @returns The decrypted user key */ - decryptUserKeyWithPin: ( + abstract decryptUserKeyWithPin( pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig, protectedKeyCs?: EncString, - ) => Promise; + ): Promise; /** * Creates a new Pin key that encrypts the user key instead of the * master key. Clears the old Pin key from state. @@ -340,55 +351,55 @@ export abstract class CryptoService { * places depending on if Master Password on Restart was enabled) * @returns The user key */ - decryptAndMigrateOldPinKey: ( + abstract decryptAndMigrateOldPinKey( masterPasswordOnRestart: boolean, pin: string, email: string, kdf: KdfType, kdfConfig: KdfConfig, oldPinKey: EncString, - ) => Promise; + ): Promise; /** * Replaces old master auto keys with new user auto keys */ - migrateAutoKeyIfNeeded: (userId?: string) => Promise; + abstract migrateAutoKeyIfNeeded(userId?: string): Promise; /** * @param keyMaterial The key material to derive the send key from * @returns A new send key */ - makeSendKey: (keyMaterial: Uint8Array) => Promise; + abstract makeSendKey(keyMaterial: Uint8Array): Promise; /** * Clears all of the user's keys from storage * @param userId The user's Id */ - clearKeys: (userId?: string) => Promise; + abstract clearKeys(userId?: string): Promise; /** * RSA encrypts a value. * @param data The data to encrypt * @param publicKey The public key to use for encryption, if not provided, the user's public key will be used * @returns The encrypted data */ - rsaEncrypt: (data: Uint8Array, publicKey?: Uint8Array) => Promise; + abstract rsaEncrypt(data: Uint8Array, publicKey?: Uint8Array): Promise; /** * Decrypts a value using RSA. * @param encValue The encrypted value to decrypt * @param privateKeyValue The private key to use for decryption * @returns The decrypted value */ - rsaDecrypt: (encValue: string, privateKeyValue?: Uint8Array) => Promise; - randomNumber: (min: number, max: number) => Promise; + abstract rsaDecrypt(encValue: string, privateKeyValue?: Uint8Array): Promise; + abstract randomNumber(min: number, max: number): Promise; /** * Generates a new cipher key * @returns A new cipher key */ - makeCipherKey: () => Promise; + abstract makeCipherKey(): Promise; /** * Initialize all necessary crypto keys needed for a new account. * Warning! This completely replaces any existing keys! * @returns The user's newly created public key, private key, and encrypted private key */ - initAccount: () => Promise<{ + abstract initAccount(): Promise<{ userKey: UserKey; publicKey: string; privateKey: EncString; @@ -400,18 +411,18 @@ export abstract class CryptoService { * @remarks * Should always be called before updating a users KDF config. */ - validateKdfConfig: (kdf: KdfType, kdfConfig: KdfConfig) => void; + abstract validateKdfConfig(kdf: KdfType, kdfConfig: KdfConfig): void; /** * @deprecated Left for migration purposes. Use decryptUserKeyWithPin instead. */ - decryptMasterKeyWithPin: ( + abstract decryptMasterKeyWithPin( pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig, protectedKeyCs?: EncString, - ) => Promise; + ): Promise; /** * Previously, the master key was used for any additional key like the biometrics or pin key. * We have switched to using the user key for these purposes. This method is for clearing the state @@ -419,30 +430,36 @@ export abstract class CryptoService { * @param keySuffix The desired type of key to clear * @param userId The desired user */ - clearDeprecatedKeys: (keySuffix: KeySuffixOptions, userId?: string) => Promise; + abstract clearDeprecatedKeys(keySuffix: KeySuffixOptions, userId?: string): Promise; /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.encrypt */ - encrypt: (plainValue: string | Uint8Array, key?: SymmetricCryptoKey) => Promise; + abstract encrypt(plainValue: string | Uint8Array, key?: SymmetricCryptoKey): Promise; /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.encryptToBytes */ - encryptToBytes: (plainValue: Uint8Array, key?: SymmetricCryptoKey) => Promise; + abstract encryptToBytes( + plainValue: Uint8Array, + key?: SymmetricCryptoKey, + ): Promise; /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.decryptToBytes */ - decryptToBytes: (encString: EncString, key?: SymmetricCryptoKey) => Promise; + abstract decryptToBytes(encString: EncString, key?: SymmetricCryptoKey): Promise; /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.decryptToUtf8 */ - decryptToUtf8: (encString: EncString, key?: SymmetricCryptoKey) => Promise; + abstract decryptToUtf8(encString: EncString, key?: SymmetricCryptoKey): Promise; /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.decryptToBytes */ - decryptFromBytes: (encBuffer: EncArrayBuffer, key: SymmetricCryptoKey) => Promise; + abstract decryptFromBytes( + encBuffer: EncArrayBuffer, + key: SymmetricCryptoKey, + ): Promise; } diff --git a/libs/common/src/platform/abstractions/encrypt.service.ts b/libs/common/src/platform/abstractions/encrypt.service.ts index a5120e6898f..9b4dde3676f 100644 --- a/libs/common/src/platform/abstractions/encrypt.service.ts +++ b/libs/common/src/platform/abstractions/encrypt.service.ts @@ -7,23 +7,26 @@ import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key"; export abstract class EncryptService { abstract encrypt(plainValue: string | Uint8Array, key: SymmetricCryptoKey): Promise; - abstract encryptToBytes: ( + abstract encryptToBytes( plainValue: Uint8Array, key?: SymmetricCryptoKey, - ) => Promise; - abstract decryptToUtf8: (encString: EncString, key: SymmetricCryptoKey) => Promise; - abstract decryptToBytes: (encThing: Encrypted, key: SymmetricCryptoKey) => Promise; - abstract rsaEncrypt: (data: Uint8Array, publicKey: Uint8Array) => Promise; - abstract rsaDecrypt: (data: EncString, privateKey: Uint8Array) => Promise; - abstract resolveLegacyKey: (key: SymmetricCryptoKey, encThing: Encrypted) => SymmetricCryptoKey; - abstract decryptItems: ( + ): Promise; + abstract decryptToUtf8(encString: EncString, key: SymmetricCryptoKey): Promise; + abstract decryptToBytes(encThing: Encrypted, key: SymmetricCryptoKey): Promise; + abstract rsaEncrypt(data: Uint8Array, publicKey: Uint8Array): Promise; + abstract rsaDecrypt(data: EncString, privateKey: Uint8Array): Promise; + abstract resolveLegacyKey(key: SymmetricCryptoKey, encThing: Encrypted): SymmetricCryptoKey; + abstract decryptItems( items: Decryptable[], key: SymmetricCryptoKey, - ) => Promise; + ): Promise; /** * Generates a base64-encoded hash of the given value * @param value The value to hash * @param algorithm The hashing algorithm to use */ - hash: (value: string | Uint8Array, algorithm: "sha1" | "sha256" | "sha512") => Promise; + abstract hash( + value: string | Uint8Array, + algorithm: "sha1" | "sha256" | "sha512", + ): Promise; } diff --git a/libs/common/src/platform/abstractions/file-download/file-download.service.ts b/libs/common/src/platform/abstractions/file-download/file-download.service.ts index 44d082d72bf..8bb70483eb7 100644 --- a/libs/common/src/platform/abstractions/file-download/file-download.service.ts +++ b/libs/common/src/platform/abstractions/file-download/file-download.service.ts @@ -1,5 +1,5 @@ import { FileDownloadRequest } from "./file-download.request"; export abstract class FileDownloadService { - download: (request: FileDownloadRequest) => void; + abstract download(request: FileDownloadRequest): void; } diff --git a/libs/common/src/platform/abstractions/file-upload/file-upload.service.ts b/libs/common/src/platform/abstractions/file-upload/file-upload.service.ts index e6a323817c9..5f26a666206 100644 --- a/libs/common/src/platform/abstractions/file-upload/file-upload.service.ts +++ b/libs/common/src/platform/abstractions/file-upload/file-upload.service.ts @@ -3,12 +3,12 @@ import { EncArrayBuffer } from "../../models/domain/enc-array-buffer"; import { EncString } from "../../models/domain/enc-string"; export abstract class FileUploadService { - upload: ( + abstract upload( uploadData: { url: string; fileUploadType: FileUploadType }, fileName: EncString, encryptedFileData: EncArrayBuffer, fileUploadMethods: FileUploadApiMethods, - ) => Promise; + ): Promise; } export type FileUploadApiMethods = { diff --git a/libs/common/src/platform/abstractions/i18n.service.ts b/libs/common/src/platform/abstractions/i18n.service.ts index 7b6eb9edc8a..a1b44d956a9 100644 --- a/libs/common/src/platform/abstractions/i18n.service.ts +++ b/libs/common/src/platform/abstractions/i18n.service.ts @@ -3,8 +3,8 @@ import { Observable } from "rxjs"; import { TranslationService } from "./translation.service"; export abstract class I18nService extends TranslationService { - userSetLocale$: Observable; - locale$: Observable; + abstract userSetLocale$: Observable; + abstract locale$: Observable; abstract setLocale(locale: string): Promise; abstract init(): Promise; } diff --git a/libs/common/src/platform/abstractions/key-generation.service.ts b/libs/common/src/platform/abstractions/key-generation.service.ts index a015182f89f..223eb75038f 100644 --- a/libs/common/src/platform/abstractions/key-generation.service.ts +++ b/libs/common/src/platform/abstractions/key-generation.service.ts @@ -11,7 +11,7 @@ export abstract class KeyGenerationService { * 512 bits = 64 bytes * @returns Generated key. */ - createKey: (bitLength: 256 | 512) => Promise; + abstract createKey(bitLength: 256 | 512): Promise; /** * Generates key material from CSPRNG and derives a 64 byte key from it. * Uses HKDF, see {@link https://datatracker.ietf.org/doc/html/rfc5869 RFC 5869} @@ -22,11 +22,11 @@ export abstract class KeyGenerationService { * @param salt Optional. If not provided will be generated from CSPRNG. * @returns An object containing the salt, key material, and derived key. */ - createKeyWithPurpose: ( + abstract createKeyWithPurpose( bitLength: 128 | 192 | 256 | 512, purpose: string, salt?: string, - ) => Promise<{ salt: string; material: CsprngArray; derivedKey: SymmetricCryptoKey }>; + ): Promise<{ salt: string; material: CsprngArray; derivedKey: SymmetricCryptoKey }>; /** * Derives a 64 byte key from key material. * @remark The key material should be generated from {@link createKey}, or {@link createKeyWithPurpose}. @@ -37,11 +37,11 @@ export abstract class KeyGenerationService { * Different purposes results in different keys, even with the same material. * @returns 64 byte derived key. */ - deriveKeyFromMaterial: ( + abstract deriveKeyFromMaterial( material: CsprngArray, salt: string, purpose: string, - ) => Promise; + ): Promise; /** * Derives a 32 byte key from a password using a key derivation function. * @param password Password to derive the key from. @@ -50,10 +50,10 @@ export abstract class KeyGenerationService { * @param kdfConfig Configuration for the key derivation function. * @returns 32 byte derived key. */ - deriveKeyFromPassword: ( + abstract deriveKeyFromPassword( password: string | Uint8Array, salt: string | Uint8Array, kdf: KdfType, kdfConfig: KdfConfig, - ) => Promise; + ): Promise; } diff --git a/libs/common/src/platform/abstractions/log.service.ts b/libs/common/src/platform/abstractions/log.service.ts index 17db5976871..dffa3ca8d3e 100644 --- a/libs/common/src/platform/abstractions/log.service.ts +++ b/libs/common/src/platform/abstractions/log.service.ts @@ -1,9 +1,9 @@ import { LogLevelType } from "../enums/log-level-type.enum"; export abstract class LogService { - debug: (message: string) => void; - info: (message: string) => void; - warning: (message: string) => void; - error: (message: string) => void; - write: (level: LogLevelType, message: string) => void; + abstract debug(message: string): void; + abstract info(message: string): void; + abstract warning(message: string): void; + abstract error(message: string): void; + abstract write(level: LogLevelType, message: string): void; } diff --git a/libs/common/src/platform/abstractions/messaging.service.ts b/libs/common/src/platform/abstractions/messaging.service.ts index 7c5f05f9198..ab4332c2839 100644 --- a/libs/common/src/platform/abstractions/messaging.service.ts +++ b/libs/common/src/platform/abstractions/messaging.service.ts @@ -1,3 +1,3 @@ export abstract class MessagingService { - send: (subscriber: string, arg?: any) => void; + abstract send(subscriber: string, arg?: any): void; } diff --git a/libs/common/src/platform/abstractions/platform-utils.service.ts b/libs/common/src/platform/abstractions/platform-utils.service.ts index 0053b7d1d7c..d518a17f7b4 100644 --- a/libs/common/src/platform/abstractions/platform-utils.service.ts +++ b/libs/common/src/platform/abstractions/platform-utils.service.ts @@ -12,34 +12,34 @@ export type ClipboardOptions = { }; export abstract class PlatformUtilsService { - getDevice: () => DeviceType; - getDeviceString: () => string; - getClientType: () => ClientType; - isFirefox: () => boolean; - isChrome: () => boolean; - isEdge: () => boolean; - isOpera: () => boolean; - isVivaldi: () => boolean; - isSafari: () => boolean; - isMacAppStore: () => boolean; - isViewOpen: () => Promise; - launchUri: (uri: string, options?: any) => void; - getApplicationVersion: () => Promise; - getApplicationVersionNumber: () => Promise; - supportsWebAuthn: (win: Window) => boolean; - supportsDuo: () => boolean; - showToast: ( + abstract getDevice(): DeviceType; + abstract getDeviceString(): string; + abstract getClientType(): ClientType; + abstract isFirefox(): boolean; + abstract isChrome(): boolean; + abstract isEdge(): boolean; + abstract isOpera(): boolean; + abstract isVivaldi(): boolean; + abstract isSafari(): boolean; + abstract isMacAppStore(): boolean; + abstract isViewOpen(): Promise; + abstract launchUri(uri: string, options?: any): void; + abstract getApplicationVersion(): Promise; + abstract getApplicationVersionNumber(): Promise; + abstract supportsWebAuthn(win: Window): boolean; + abstract supportsDuo(): boolean; + abstract showToast( type: "error" | "success" | "warning" | "info", title: string, text: string | string[], options?: ToastOptions, - ) => void; - isDev: () => boolean; - isSelfHost: () => boolean; - copyToClipboard: (text: string, options?: ClipboardOptions) => void | boolean; - readFromClipboard: () => Promise; - supportsBiometric: () => Promise; - authenticateBiometric: () => Promise; - supportsSecureStorage: () => boolean; - getAutofillKeyboardShortcut: () => Promise; + ): void; + abstract isDev(): boolean; + abstract isSelfHost(): boolean; + abstract copyToClipboard(text: string, options?: ClipboardOptions): void | boolean; + abstract readFromClipboard(): Promise; + abstract supportsBiometric(): Promise; + abstract authenticateBiometric(): Promise; + abstract supportsSecureStorage(): boolean; + abstract getAutofillKeyboardShortcut(): Promise; } diff --git a/libs/common/src/platform/abstractions/system.service.ts b/libs/common/src/platform/abstractions/system.service.ts index 5a7e11f9a12..204e336fbf4 100644 --- a/libs/common/src/platform/abstractions/system.service.ts +++ b/libs/common/src/platform/abstractions/system.service.ts @@ -1,8 +1,8 @@ import { AuthService } from "../../auth/abstractions/auth.service"; export abstract class SystemService { - startProcessReload: (authService: AuthService) => Promise; - cancelProcessReload: () => void; - clearClipboard: (clipboardValue: string, timeoutMs?: number) => Promise; - clearPendingClipboard: () => Promise; + abstract startProcessReload(authService: AuthService): Promise; + abstract cancelProcessReload(): void; + abstract clearClipboard(clipboardValue: string, timeoutMs?: number): Promise; + abstract clearPendingClipboard(): Promise; } diff --git a/libs/common/src/platform/abstractions/translation.service.ts b/libs/common/src/platform/abstractions/translation.service.ts index 797965038a7..8a8faff1d8f 100644 --- a/libs/common/src/platform/abstractions/translation.service.ts +++ b/libs/common/src/platform/abstractions/translation.service.ts @@ -1,8 +1,8 @@ export abstract class TranslationService { - supportedTranslationLocales: string[]; - translationLocale: string; - collator: Intl.Collator; - localeNames: Map; - t: (id: string, p1?: string | number, p2?: string | number, p3?: string | number) => string; - translate: (id: string, p1?: string, p2?: string, p3?: string) => string; + abstract supportedTranslationLocales: string[]; + abstract translationLocale: string; + abstract collator: Intl.Collator; + abstract localeNames: Map; + abstract t(id: string, p1?: string | number, p2?: string | number, p3?: string | number): string; + abstract translate(id: string, p1?: string, p2?: string, p3?: string): string; } diff --git a/libs/common/src/platform/abstractions/validation.service.ts b/libs/common/src/platform/abstractions/validation.service.ts index c0985847bff..b5aa71381a2 100644 --- a/libs/common/src/platform/abstractions/validation.service.ts +++ b/libs/common/src/platform/abstractions/validation.service.ts @@ -1,3 +1,3 @@ export abstract class ValidationService { - showError: (data: any) => string[]; + abstract showError(data: any): string[]; } diff --git a/libs/common/src/platform/biometrics/biometric-state.service.ts b/libs/common/src/platform/biometrics/biometric-state.service.ts index 82c05542b4e..20bba497172 100644 --- a/libs/common/src/platform/biometrics/biometric-state.service.ts +++ b/libs/common/src/platform/biometrics/biometric-state.service.ts @@ -18,42 +18,42 @@ export abstract class BiometricStateService { /** * `true` if the currently active user has elected to store a biometric key to unlock their vault. */ - biometricUnlockEnabled$: Observable; // used to be biometricUnlock + abstract biometricUnlockEnabled$: Observable; // used to be biometricUnlock /** * If the user has elected to require a password on first unlock of an application instance, this key will store the * encrypted client key half used to unlock the vault. * * Tracks the currently active user */ - encryptedClientKeyHalf$: Observable; + abstract encryptedClientKeyHalf$: Observable; /** * whether or not a password is required on first unlock after opening the application * * tracks the currently active user */ - requirePasswordOnStart$: Observable; + abstract requirePasswordOnStart$: Observable; /** * Indicates the user has been warned about the security implications of using biometrics and, depending on the OS, * * tracks the currently active user. */ - dismissedRequirePasswordOnStartCallout$: Observable; + abstract dismissedRequirePasswordOnStartCallout$: Observable; /** * Whether the user has cancelled the biometric prompt. * * tracks the currently active user */ - promptCancelled$: Observable; + abstract promptCancelled$: Observable; /** * Whether the user has elected to automatically prompt for biometrics. * * tracks the currently active user */ - promptAutomatically$: Observable; + abstract promptAutomatically$: Observable; /** * Whether or not IPC fingerprint has been validated by the user this session. */ - fingerprintValidated$: Observable; + abstract fingerprintValidated$: Observable; /** * Updates the require password on start state for the currently active user. diff --git a/libs/common/src/platform/state/derived-state.provider.ts b/libs/common/src/platform/state/derived-state.provider.ts index cf0a0c56c77..21860482479 100644 --- a/libs/common/src/platform/state/derived-state.provider.ts +++ b/libs/common/src/platform/state/derived-state.provider.ts @@ -17,9 +17,9 @@ export abstract class DerivedStateProvider { * well as some memory persistent information. * @param dependencies The dependencies of the derive function */ - get: ( + abstract get( parentState$: Observable, deriveDefinition: DeriveDefinition, dependencies: TDeps, - ) => DerivedState; + ): DerivedState; } diff --git a/libs/common/src/platform/state/global-state.provider.ts b/libs/common/src/platform/state/global-state.provider.ts index 7c791b6b4d9..5aa2b26a5b7 100644 --- a/libs/common/src/platform/state/global-state.provider.ts +++ b/libs/common/src/platform/state/global-state.provider.ts @@ -9,5 +9,5 @@ export abstract class GlobalStateProvider { * Gets a {@link GlobalState} scoped to the given {@link KeyDefinition} * @param keyDefinition - The {@link KeyDefinition} for which you want the state for. */ - get: (keyDefinition: KeyDefinition) => GlobalState; + abstract get(keyDefinition: KeyDefinition): GlobalState; } diff --git a/libs/common/src/platform/state/state.provider.ts b/libs/common/src/platform/state/state.provider.ts index ddbb6a7c875..a1e51552c73 100644 --- a/libs/common/src/platform/state/state.provider.ts +++ b/libs/common/src/platform/state/state.provider.ts @@ -19,7 +19,7 @@ import { ActiveUserStateProvider, SingleUserStateProvider } from "./user-state.p */ export abstract class StateProvider { /** @see{@link ActiveUserStateProvider.activeUserId$} */ - activeUserId$: Observable; + abstract activeUserId$: Observable; /** * Gets a state observable for a given key and userId. @@ -149,10 +149,10 @@ export abstract class StateProvider { ): SingleUserState; /** @see{@link GlobalStateProvider.get} */ - getGlobal: (keyDefinition: KeyDefinition) => GlobalState; - getDerived: ( + abstract getGlobal(keyDefinition: KeyDefinition): GlobalState; + abstract getDerived( parentState$: Observable, deriveDefinition: DeriveDefinition, dependencies: TDeps, - ) => DerivedState; + ): DerivedState; } diff --git a/libs/common/src/platform/state/user-state.provider.ts b/libs/common/src/platform/state/user-state.provider.ts index 2f18f3678d8..3af10218f87 100644 --- a/libs/common/src/platform/state/user-state.provider.ts +++ b/libs/common/src/platform/state/user-state.provider.ts @@ -39,7 +39,7 @@ export abstract class ActiveUserStateProvider { /** * Convenience re-emission of active user ID from {@link AccountService.activeAccount$} */ - activeUserId$: Observable; + abstract activeUserId$: Observable; /** * Gets a {@link ActiveUserState} scoped to the given {@link KeyDefinition}, but updates when active user changes such diff --git a/libs/common/src/platform/theming/theme-state.service.ts b/libs/common/src/platform/theming/theme-state.service.ts index 42b5b1770cc..9c31733416b 100644 --- a/libs/common/src/platform/theming/theme-state.service.ts +++ b/libs/common/src/platform/theming/theme-state.service.ts @@ -7,13 +7,13 @@ export abstract class ThemeStateService { /** * The users selected theme. */ - selectedTheme$: Observable; + abstract selectedTheme$: Observable; /** * A method for updating the current users configured theme. * @param theme The chosen user theme. */ - setSelectedTheme: (theme: ThemeType) => Promise; + abstract setSelectedTheme(theme: ThemeType): Promise; } const THEME_SELECTION = new KeyDefinition(THEMING_DISK, "selection", {