diff --git a/libs/common/src/tools/cryptography/organization-encryptor.abstraction.ts b/libs/common/src/tools/cryptography/organization-encryptor.abstraction.ts index cf17bc1e4a9..5365307f725 100644 --- a/libs/common/src/tools/cryptography/organization-encryptor.abstraction.ts +++ b/libs/common/src/tools/cryptography/organization-encryptor.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Jsonify } from "type-fest"; import { EncString } from "../../key-management/crypto/models/enc-string"; @@ -10,7 +8,7 @@ import { OrganizationId } from "../../types/guid"; */ export abstract class OrganizationEncryptor { /** Identifies the organization bound to the encryptor. */ - readonly organizationId: OrganizationId; + abstract readonly organizationId: OrganizationId; /** Protects secrets in `value` with an organization-specific key. * @param secret the object to protect. This object is mutated during encryption. diff --git a/libs/common/src/tools/cryptography/user-encryptor.abstraction.ts b/libs/common/src/tools/cryptography/user-encryptor.abstraction.ts index 242fee7c7f8..303e1b918e6 100644 --- a/libs/common/src/tools/cryptography/user-encryptor.abstraction.ts +++ b/libs/common/src/tools/cryptography/user-encryptor.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Jsonify } from "type-fest"; import { EncString } from "../../key-management/crypto/models/enc-string"; @@ -10,7 +8,7 @@ import { UserId } from "../../types/guid"; */ export abstract class UserEncryptor { /** Identifies the user bound to the encryptor. */ - readonly userId: UserId; + abstract readonly userId: UserId; /** Protects secrets in `value` with a user-specific key. * @param secret the object to protect. This object is mutated during encryption. diff --git a/libs/common/src/tools/send/services/send-state.provider.abstraction.ts b/libs/common/src/tools/send/services/send-state.provider.abstraction.ts index 78c15064ff7..bcba6965195 100644 --- a/libs/common/src/tools/send/services/send-state.provider.abstraction.ts +++ b/libs/common/src/tools/send/services/send-state.provider.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import type { Simplify } from "type-fest"; @@ -9,15 +7,16 @@ import { SendData } from "../models/data/send.data"; import { SendView } from "../models/view/send.view"; type EncryptedSendState = Simplify>>; + export abstract class SendStateProvider { - encryptedState$: Observable; - decryptedState$: Observable; + abstract encryptedState$: Observable; + abstract decryptedState$: Observable; - getEncryptedSends: () => Promise; + abstract getEncryptedSends(): Promise; - setEncryptedSends: (value: { [id: string]: SendData }, userId: UserId) => Promise; + abstract setEncryptedSends(value: { [id: string]: SendData }, userId: UserId): Promise; - getDecryptedSends: () => Promise; + abstract getDecryptedSends(): Promise; - setDecryptedSends: (value: SendView[]) => Promise; + abstract setDecryptedSends(value: SendView[]): Promise; } diff --git a/libs/importer/src/services/import-api.service.abstraction.ts b/libs/importer/src/services/import-api.service.abstraction.ts index 74fd8f94008..0f8ccd260dd 100644 --- a/libs/importer/src/services/import-api.service.abstraction.ts +++ b/libs/importer/src/services/import-api.service.abstraction.ts @@ -1,12 +1,10 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { ImportCiphersRequest } from "@bitwarden/common/models/request/import-ciphers.request"; import { ImportOrganizationCiphersRequest } from "@bitwarden/common/models/request/import-organization-ciphers.request"; export abstract class ImportApiServiceAbstraction { - postImportCiphers: (request: ImportCiphersRequest) => Promise; - postImportOrganizationCiphers: ( + abstract postImportCiphers(request: ImportCiphersRequest): Promise; + abstract postImportOrganizationCiphers( organizationId: string, request: ImportOrganizationCiphersRequest, - ) => Promise; + ): Promise; } diff --git a/libs/importer/src/services/import-collection.service.abstraction.ts b/libs/importer/src/services/import-collection.service.abstraction.ts index 48e6e7a4a8c..cdc2d616bc4 100644 --- a/libs/importer/src/services/import-collection.service.abstraction.ts +++ b/libs/importer/src/services/import-collection.service.abstraction.ts @@ -1,9 +1,7 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore // This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop. // eslint-disable-next-line no-restricted-imports import { CollectionView } from "@bitwarden/admin-console/common"; export abstract class ImportCollectionServiceAbstraction { - getAllAdminCollections: (organizationId: string) => Promise; + abstract getAllAdminCollections(organizationId: string): Promise; } diff --git a/libs/importer/src/services/import.service.abstraction.ts b/libs/importer/src/services/import.service.abstraction.ts index d869dc71cc7..760a073e4cb 100644 --- a/libs/importer/src/services/import.service.abstraction.ts +++ b/libs/importer/src/services/import.service.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore // This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop. // eslint-disable-next-line no-restricted-imports import { CollectionView } from "@bitwarden/admin-console/common"; @@ -10,19 +8,19 @@ import { ImportOption, ImportType } from "../models/import-options"; import { ImportResult } from "../models/import-result"; export abstract class ImportServiceAbstraction { - featuredImportOptions: readonly ImportOption[]; - regularImportOptions: readonly ImportOption[]; - getImportOptions: () => ImportOption[]; - import: ( + abstract featuredImportOptions: readonly ImportOption[]; + abstract regularImportOptions: readonly ImportOption[]; + abstract getImportOptions(): ImportOption[]; + abstract import( importer: Importer, fileContents: string, organizationId?: string, selectedImportTarget?: FolderView | CollectionView, canAccessImportExport?: boolean, - ) => Promise; - getImporter: ( + ): Promise; + abstract getImporter( format: ImportType | "bitwardenpasswordprotected", promptForPassword_callback: () => Promise, organizationId: string, - ) => Importer; + ): Importer; } diff --git a/libs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts b/libs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts index 3506c7458e4..b67c0e569b4 100644 --- a/libs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts +++ b/libs/tools/generator/core/src/abstractions/generator-strategy.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { PolicyType } from "@bitwarden/common/admin-console/enums"; @@ -17,13 +15,13 @@ export abstract class GeneratorStrategy { * @param userId: identifies the user state to retrieve * @returns the strategy's durable user state */ - durableState: (userId: UserId) => SingleUserState; + abstract durableState(userId: UserId): SingleUserState; /** Gets the default options. */ - defaults$: (userId: UserId) => Observable; + abstract defaults$(userId: UserId): Observable; /** Identifies the policy enforced by the generator. */ - policy: PolicyType; + abstract get policy(): PolicyType; /** Operator function that converts a policy collection observable to a single * policy evaluator observable. @@ -32,7 +30,7 @@ export abstract class GeneratorStrategy { * then the evaluator defaults to the application's limits. * @throws when the policy's type does not match the generator's policy type. */ - toEvaluator: () => ( + abstract toEvaluator(): ( source: Observable, ) => Observable>; @@ -40,5 +38,5 @@ export abstract class GeneratorStrategy { * @param options The options used to generate the credentials. * @returns a promise that resolves to the generated credentials. */ - generate: (options: Options) => Promise; + abstract generate(options: Options): Promise; } diff --git a/libs/tools/generator/core/src/abstractions/generator.service.abstraction.ts b/libs/tools/generator/core/src/abstractions/generator.service.abstraction.ts index 9c12dba44c7..d8027cf516f 100644 --- a/libs/tools/generator/core/src/abstractions/generator.service.abstraction.ts +++ b/libs/tools/generator/core/src/abstractions/generator.service.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { UserId } from "@bitwarden/common/types/guid"; @@ -16,34 +14,34 @@ export abstract class GeneratorService { * The observable updates when the options are saved. * @param userId: Identifies the user making the request */ - options$: (userId: UserId) => Observable; + abstract options$(userId: UserId): Observable; /** An observable monitoring the options used to enforce policy. * The observable updates when the policy changes. * @param userId: Identifies the user making the request */ - evaluator$: (userId: UserId) => Observable>; + abstract evaluator$(userId: UserId): Observable>; /** Gets the default options. */ - defaults$: (userId: UserId) => Observable; + abstract defaults$(userId: UserId): Observable; /** Enforces the policy on the given options * @param userId: Identifies the user making the request * @param options the options to enforce the policy on * @returns a new instance of the options with the policy enforced */ - enforcePolicy: (userId: UserId, options: Options) => Promise; + abstract enforcePolicy(userId: UserId, options: Options): Promise; /** Generates credentials * @param options the options to generate credentials with * @returns a promise that resolves with the generated credentials */ - generate: (options: Options) => Promise; + abstract generate(options: Options): Promise; /** Saves the given options to disk. * @param userId: Identifies the user making the request * @param options the options to save * @returns a promise that resolves when the options are saved */ - saveOptions: (userId: UserId, options: Options) => Promise; + abstract saveOptions(userId: UserId, options: Options): Promise; } diff --git a/libs/tools/generator/core/src/abstractions/policy-evaluator.abstraction.ts b/libs/tools/generator/core/src/abstractions/policy-evaluator.abstraction.ts index 08b8d3c4649..8dca7dfb327 100644 --- a/libs/tools/generator/core/src/abstractions/policy-evaluator.abstraction.ts +++ b/libs/tools/generator/core/src/abstractions/policy-evaluator.abstraction.ts @@ -1,15 +1,13 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore /** Applies policy to a generation request */ export abstract class PolicyEvaluator { /** The policy to enforce */ - policy: Policy; + abstract policy: Policy; /** Returns true when a policy is being enforced by the evaluator. * @remarks `applyPolicy` should be called when a policy is not in * effect to enforce the application's default policy. */ - policyInEffect: boolean; + abstract policyInEffect: boolean; /** Apply policy to a set of options. * @param options The options to build from. These options are not altered. @@ -17,7 +15,7 @@ export abstract class PolicyEvaluator { * @remarks This method only applies policy overrides. * Pass the result to `sanitize` to ensure consistency. */ - applyPolicy: (options: PolicyTarget) => PolicyTarget; + abstract applyPolicy(options: PolicyTarget): PolicyTarget; /** Ensures internal options consistency. * @param options The options to cascade. These options are not altered. @@ -26,5 +24,5 @@ export abstract class PolicyEvaluator { * pairs of flags and values (e.g. `number` and `minNumber`). If the flag * and value are inconsistent, the flag cascades to the value. */ - sanitize: (options: PolicyTarget) => PolicyTarget; + abstract sanitize(options: PolicyTarget): PolicyTarget; } diff --git a/libs/tools/generator/extensions/history/src/generator-history.abstraction.ts b/libs/tools/generator/extensions/history/src/generator-history.abstraction.ts index 3e3d4002be4..2e4f9c0f471 100644 --- a/libs/tools/generator/extensions/history/src/generator-history.abstraction.ts +++ b/libs/tools/generator/extensions/history/src/generator-history.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { UserId } from "@bitwarden/common/types/guid"; @@ -26,12 +24,12 @@ export abstract class GeneratorHistoryService { * may contain several credentials that are better modelled as atomic versions of the * vault item itself. */ - track: ( + abstract track( userId: UserId, credential: string, category: CredentialType, date?: Date, - ) => Promise; + ): Promise; /** Removes a matching credential from the history service. * @param userId identifies the user taking the credential. @@ -40,18 +38,18 @@ export abstract class GeneratorHistoryService { * the promise completes with null. * @remarks this can be used to extract an entry when a credential is stored in the vault. */ - take: (userId: UserId, credential: string) => Promise; + abstract take(userId: UserId, credential: string): Promise; /** Deletes a user's credential history. * @param userId identifies the user taking the credential. * @returns A promise that completes when the history is cleared. */ - clear: (userId: UserId) => Promise; + abstract clear(userId: UserId): Promise; /** Lists all credentials for a user. * @param userId identifies the user listing the credential. * @remarks This field is eventually consistent with `track` and `take` operations. * It is not guaranteed to immediately reflect those changes. */ - credentials$: (userId: UserId) => Observable; + abstract credentials$(userId: UserId): Observable; } diff --git a/libs/tools/generator/extensions/legacy/src/password-generation.service.abstraction.ts b/libs/tools/generator/extensions/legacy/src/password-generation.service.abstraction.ts index 09faed1810e..8bed8ff41e5 100644 --- a/libs/tools/generator/extensions/legacy/src/password-generation.service.abstraction.ts +++ b/libs/tools/generator/extensions/legacy/src/password-generation.service.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { PasswordGeneratorPolicyOptions } from "@bitwarden/common/admin-console/models/domain/password-generator-policy-options"; @@ -9,15 +7,15 @@ import { PasswordGeneratorOptions } from "./password-generator-options"; /** @deprecated Use {@link GeneratorService} with a password or passphrase {@link GeneratorStrategy} instead. */ export abstract class PasswordGenerationServiceAbstraction { - generatePassword: (options: PasswordGeneratorOptions) => Promise; - generatePassphrase: (options: PasswordGeneratorOptions) => Promise; - getOptions: () => Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; - getOptions$: () => Observable<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; - enforcePasswordGeneratorPoliciesOnOptions: ( + abstract generatePassword(options: PasswordGeneratorOptions): Promise; + abstract generatePassphrase(options: PasswordGeneratorOptions): Promise; + abstract getOptions(): Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; + abstract getOptions$(): Observable<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; + abstract enforcePasswordGeneratorPoliciesOnOptions( options: PasswordGeneratorOptions, - ) => Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; - saveOptions: (options: PasswordGeneratorOptions) => Promise; - getHistory: () => Promise; - addHistory: (password: string) => Promise; - clear: (userId?: string) => Promise; + ): Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>; + abstract saveOptions(options: PasswordGeneratorOptions): Promise; + abstract getHistory(): Promise; + abstract addHistory(password: string): Promise; + abstract clear(userId?: string): Promise; } diff --git a/libs/tools/generator/extensions/legacy/src/username-generation.service.abstraction.ts b/libs/tools/generator/extensions/legacy/src/username-generation.service.abstraction.ts index 2b19ac8a706..355f54fae40 100644 --- a/libs/tools/generator/extensions/legacy/src/username-generation.service.abstraction.ts +++ b/libs/tools/generator/extensions/legacy/src/username-generation.service.abstraction.ts @@ -1,17 +1,15 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { UsernameGeneratorOptions } from "./username-generation-options"; /** @deprecated Use {@link GeneratorService} with a username {@link GeneratorStrategy} instead. */ export abstract class UsernameGenerationServiceAbstraction { - generateUsername: (options: UsernameGeneratorOptions) => Promise; - generateWord: (options: UsernameGeneratorOptions) => Promise; - generateSubaddress: (options: UsernameGeneratorOptions) => Promise; - generateCatchall: (options: UsernameGeneratorOptions) => Promise; - generateForwarded: (options: UsernameGeneratorOptions) => Promise; - getOptions: () => Promise; - getOptions$: () => Observable; - saveOptions: (options: UsernameGeneratorOptions) => Promise; + abstract generateUsername(options: UsernameGeneratorOptions): Promise; + abstract generateWord(options: UsernameGeneratorOptions): Promise; + abstract generateSubaddress(options: UsernameGeneratorOptions): Promise; + abstract generateCatchall(options: UsernameGeneratorOptions): Promise; + abstract generateForwarded(options: UsernameGeneratorOptions): Promise; + abstract getOptions(): Promise; + abstract getOptions$(): Observable; + abstract saveOptions(options: UsernameGeneratorOptions): Promise; } diff --git a/libs/tools/generator/extensions/navigation/src/generator-navigation.service.abstraction.ts b/libs/tools/generator/extensions/navigation/src/generator-navigation.service.abstraction.ts index 91ef0449ba8..ff74264260b 100644 --- a/libs/tools/generator/extensions/navigation/src/generator-navigation.service.abstraction.ts +++ b/libs/tools/generator/extensions/navigation/src/generator-navigation.service.abstraction.ts @@ -1,5 +1,3 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { Observable } from "rxjs"; import { UserId } from "@bitwarden/common/types/guid"; @@ -15,30 +13,33 @@ export abstract class GeneratorNavigationService { * The observable updates when the options are saved. * @param userId: Identifies the user making the request */ - options$: (userId: UserId) => Observable; + abstract options$(userId: UserId): Observable; /** Gets the default options. */ - defaults$: (userId: UserId) => Observable; + abstract defaults$(userId: UserId): Observable; /** An observable monitoring the options used to enforce policy. * The observable updates when the policy changes. * @param userId: Identifies the user making the request */ - evaluator$: ( + abstract evaluator$( userId: UserId, - ) => Observable>; + ): Observable>; /** Enforces the policy on the given options * @param userId: Identifies the user making the request * @param options the options to enforce the policy on * @returns a new instance of the options with the policy enforced */ - enforcePolicy: (userId: UserId, options: GeneratorNavigation) => Promise; + abstract enforcePolicy( + userId: UserId, + options: GeneratorNavigation, + ): Promise; /** Saves the navigation options to disk. * @param userId: Identifies the user making the request * @param options the options to save * @returns a promise that resolves when the options are saved */ - saveOptions: (userId: UserId, options: GeneratorNavigation) => Promise; + abstract saveOptions(userId: UserId, options: GeneratorNavigation): Promise; }