mirror of
https://github.com/bitwarden/browser
synced 2026-02-06 19:53:59 +00:00
Convert remaining tool owned abstract services to strict
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<CombinedState<Record<string, SendData>>>;
|
||||
|
||||
export abstract class SendStateProvider {
|
||||
encryptedState$: Observable<EncryptedSendState>;
|
||||
decryptedState$: Observable<SendView[]>;
|
||||
abstract encryptedState$: Observable<EncryptedSendState>;
|
||||
abstract decryptedState$: Observable<SendView[]>;
|
||||
|
||||
getEncryptedSends: () => Promise<EncryptedSendState>;
|
||||
abstract getEncryptedSends(): Promise<EncryptedSendState>;
|
||||
|
||||
setEncryptedSends: (value: { [id: string]: SendData }, userId: UserId) => Promise<void>;
|
||||
abstract setEncryptedSends(value: { [id: string]: SendData }, userId: UserId): Promise<void>;
|
||||
|
||||
getDecryptedSends: () => Promise<SendView[]>;
|
||||
abstract getDecryptedSends(): Promise<SendView[]>;
|
||||
|
||||
setDecryptedSends: (value: SendView[]) => Promise<void>;
|
||||
abstract setDecryptedSends(value: SendView[]): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -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<any>;
|
||||
postImportOrganizationCiphers: (
|
||||
abstract postImportCiphers(request: ImportCiphersRequest): Promise<any>;
|
||||
abstract postImportOrganizationCiphers(
|
||||
organizationId: string,
|
||||
request: ImportOrganizationCiphersRequest,
|
||||
) => Promise<any>;
|
||||
): Promise<any>;
|
||||
}
|
||||
|
||||
@@ -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<CollectionView[]>;
|
||||
abstract getAllAdminCollections(organizationId: string): Promise<CollectionView[]>;
|
||||
}
|
||||
|
||||
@@ -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<ImportResult>;
|
||||
getImporter: (
|
||||
): Promise<ImportResult>;
|
||||
abstract getImporter(
|
||||
format: ImportType | "bitwardenpasswordprotected",
|
||||
promptForPassword_callback: () => Promise<string>,
|
||||
organizationId: string,
|
||||
) => Importer;
|
||||
): Importer;
|
||||
}
|
||||
|
||||
@@ -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<Options, Policy> {
|
||||
* @param userId: identifies the user state to retrieve
|
||||
* @returns the strategy's durable user state
|
||||
*/
|
||||
durableState: (userId: UserId) => SingleUserState<Options>;
|
||||
abstract durableState(userId: UserId): SingleUserState<Options>;
|
||||
|
||||
/** Gets the default options. */
|
||||
defaults$: (userId: UserId) => Observable<Options>;
|
||||
abstract defaults$(userId: UserId): Observable<Options>;
|
||||
|
||||
/** 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<Options, Policy> {
|
||||
* 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<AdminPolicy[]>,
|
||||
) => Observable<PolicyEvaluator<Policy, Options>>;
|
||||
|
||||
@@ -40,5 +38,5 @@ export abstract class GeneratorStrategy<Options, Policy> {
|
||||
* @param options The options used to generate the credentials.
|
||||
* @returns a promise that resolves to the generated credentials.
|
||||
*/
|
||||
generate: (options: Options) => Promise<string>;
|
||||
abstract generate(options: Options): Promise<string>;
|
||||
}
|
||||
|
||||
@@ -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<Options, Policy> {
|
||||
* The observable updates when the options are saved.
|
||||
* @param userId: Identifies the user making the request
|
||||
*/
|
||||
options$: (userId: UserId) => Observable<Options>;
|
||||
abstract options$(userId: UserId): Observable<Options>;
|
||||
|
||||
/** 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<PolicyEvaluator<Policy, Options>>;
|
||||
abstract evaluator$(userId: UserId): Observable<PolicyEvaluator<Policy, Options>>;
|
||||
|
||||
/** Gets the default options. */
|
||||
defaults$: (userId: UserId) => Observable<Options>;
|
||||
abstract defaults$(userId: UserId): Observable<Options>;
|
||||
|
||||
/** 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<Options>;
|
||||
abstract enforcePolicy(userId: UserId, options: Options): Promise<Options>;
|
||||
|
||||
/** Generates credentials
|
||||
* @param options the options to generate credentials with
|
||||
* @returns a promise that resolves with the generated credentials
|
||||
*/
|
||||
generate: (options: Options) => Promise<string>;
|
||||
abstract generate(options: Options): Promise<string>;
|
||||
|
||||
/** 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<void>;
|
||||
abstract saveOptions(userId: UserId, options: Options): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -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<Policy, PolicyTarget> {
|
||||
/** 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<Policy, PolicyTarget> {
|
||||
* @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<Policy, PolicyTarget> {
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -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<GeneratedCredential | null>;
|
||||
): Promise<GeneratedCredential | null>;
|
||||
|
||||
/** 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<GeneratedCredential | null>;
|
||||
abstract take(userId: UserId, credential: string): Promise<GeneratedCredential | null>;
|
||||
|
||||
/** 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<GeneratedCredential[]>;
|
||||
abstract clear(userId: UserId): Promise<GeneratedCredential[]>;
|
||||
|
||||
/** 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<GeneratedCredential[]>;
|
||||
abstract credentials$(userId: UserId): Observable<GeneratedCredential[]>;
|
||||
}
|
||||
|
||||
@@ -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<string>;
|
||||
generatePassphrase: (options: PasswordGeneratorOptions) => Promise<string>;
|
||||
getOptions: () => Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
getOptions$: () => Observable<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
enforcePasswordGeneratorPoliciesOnOptions: (
|
||||
abstract generatePassword(options: PasswordGeneratorOptions): Promise<string>;
|
||||
abstract generatePassphrase(options: PasswordGeneratorOptions): Promise<string>;
|
||||
abstract getOptions(): Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
abstract getOptions$(): Observable<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
abstract enforcePasswordGeneratorPoliciesOnOptions(
|
||||
options: PasswordGeneratorOptions,
|
||||
) => Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
saveOptions: (options: PasswordGeneratorOptions) => Promise<void>;
|
||||
getHistory: () => Promise<GeneratedPasswordHistory[]>;
|
||||
addHistory: (password: string) => Promise<void>;
|
||||
clear: (userId?: string) => Promise<GeneratedPasswordHistory[]>;
|
||||
): Promise<[PasswordGeneratorOptions, PasswordGeneratorPolicyOptions]>;
|
||||
abstract saveOptions(options: PasswordGeneratorOptions): Promise<void>;
|
||||
abstract getHistory(): Promise<GeneratedPasswordHistory[]>;
|
||||
abstract addHistory(password: string): Promise<void>;
|
||||
abstract clear(userId?: string): Promise<GeneratedPasswordHistory[]>;
|
||||
}
|
||||
|
||||
@@ -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<string>;
|
||||
generateWord: (options: UsernameGeneratorOptions) => Promise<string>;
|
||||
generateSubaddress: (options: UsernameGeneratorOptions) => Promise<string>;
|
||||
generateCatchall: (options: UsernameGeneratorOptions) => Promise<string>;
|
||||
generateForwarded: (options: UsernameGeneratorOptions) => Promise<string>;
|
||||
getOptions: () => Promise<UsernameGeneratorOptions>;
|
||||
getOptions$: () => Observable<UsernameGeneratorOptions>;
|
||||
saveOptions: (options: UsernameGeneratorOptions) => Promise<void>;
|
||||
abstract generateUsername(options: UsernameGeneratorOptions): Promise<string>;
|
||||
abstract generateWord(options: UsernameGeneratorOptions): Promise<string>;
|
||||
abstract generateSubaddress(options: UsernameGeneratorOptions): Promise<string>;
|
||||
abstract generateCatchall(options: UsernameGeneratorOptions): Promise<string>;
|
||||
abstract generateForwarded(options: UsernameGeneratorOptions): Promise<string>;
|
||||
abstract getOptions(): Promise<UsernameGeneratorOptions>;
|
||||
abstract getOptions$(): Observable<UsernameGeneratorOptions>;
|
||||
abstract saveOptions(options: UsernameGeneratorOptions): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -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<GeneratorNavigation>;
|
||||
abstract options$(userId: UserId): Observable<GeneratorNavigation>;
|
||||
|
||||
/** Gets the default options. */
|
||||
defaults$: (userId: UserId) => Observable<GeneratorNavigation>;
|
||||
abstract defaults$(userId: UserId): Observable<GeneratorNavigation>;
|
||||
|
||||
/** 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<PolicyEvaluator<GeneratorNavigationPolicy, GeneratorNavigation>>;
|
||||
): Observable<PolicyEvaluator<GeneratorNavigationPolicy, GeneratorNavigation>>;
|
||||
|
||||
/** 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<GeneratorNavigation>;
|
||||
abstract enforcePolicy(
|
||||
userId: UserId,
|
||||
options: GeneratorNavigation,
|
||||
): Promise<GeneratorNavigation>;
|
||||
|
||||
/** 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<void>;
|
||||
abstract saveOptions(userId: UserId, options: GeneratorNavigation): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user