mirror of
https://github.com/bitwarden/browser
synced 2026-01-01 08:03:20 +00:00
[PM-24030] Migrate abstract services in libs/common strict TS (#15727)
Migrates the abstract classes in libs/common to be strict ts compatible. Primarily by adding abstract to every field and converting it to a function syntax instead of lambda.
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 { Fido2CredentialView } from "../../../vault/models/view/fido2-credential.view";
|
||||
|
||||
/**
|
||||
@@ -17,11 +15,11 @@ export abstract class Fido2AuthenticatorService<ParentWindowReference> {
|
||||
* @param abortController An AbortController that can be used to abort the operation.
|
||||
* @returns A promise that resolves with the new credential and an attestation signature.
|
||||
**/
|
||||
makeCredential: (
|
||||
abstract makeCredential(
|
||||
params: Fido2AuthenticatorMakeCredentialsParams,
|
||||
window: ParentWindowReference,
|
||||
abortController?: AbortController,
|
||||
) => Promise<Fido2AuthenticatorMakeCredentialResult>;
|
||||
): Promise<Fido2AuthenticatorMakeCredentialResult>;
|
||||
|
||||
/**
|
||||
* Generate an assertion using an existing credential as describe in:
|
||||
@@ -31,11 +29,11 @@ export abstract class Fido2AuthenticatorService<ParentWindowReference> {
|
||||
* @param abortController An AbortController that can be used to abort the operation.
|
||||
* @returns A promise that resolves with the asserted credential and an assertion signature.
|
||||
*/
|
||||
getAssertion: (
|
||||
abstract getAssertion(
|
||||
params: Fido2AuthenticatorGetAssertionParams,
|
||||
window: ParentWindowReference,
|
||||
abortController?: AbortController,
|
||||
) => Promise<Fido2AuthenticatorGetAssertionResult>;
|
||||
): Promise<Fido2AuthenticatorGetAssertionResult>;
|
||||
|
||||
/**
|
||||
* Discover credentials for a given Relying Party
|
||||
@@ -43,7 +41,7 @@ export abstract class Fido2AuthenticatorService<ParentWindowReference> {
|
||||
* @param rpId The Relying Party's ID
|
||||
* @returns A promise that resolves with an array of discoverable credentials
|
||||
*/
|
||||
silentCredentialDiscovery: (rpId: string) => Promise<Fido2CredentialView[]>;
|
||||
abstract silentCredentialDiscovery(rpId: string): Promise<Fido2CredentialView[]>;
|
||||
}
|
||||
|
||||
// FIXME: update to use a const object instead of a typescript enum
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
export const UserRequestedFallbackAbortReason = "UserRequestedFallback";
|
||||
|
||||
export type UserVerification = "discouraged" | "preferred" | "required";
|
||||
@@ -16,7 +14,7 @@ export type UserVerification = "discouraged" | "preferred" | "required";
|
||||
* and for returning the results of the latter operations to the Web Authentication API's callers.
|
||||
*/
|
||||
export abstract class Fido2ClientService<ParentWindowReference> {
|
||||
isFido2FeatureEnabled: (hostname: string, origin: string) => Promise<boolean>;
|
||||
abstract isFido2FeatureEnabled(hostname: string, origin: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Allows WebAuthn Relying Party scripts to request the creation of a new public key credential source.
|
||||
@@ -26,11 +24,11 @@ export abstract class Fido2ClientService<ParentWindowReference> {
|
||||
* @param abortController An AbortController that can be used to abort the operation.
|
||||
* @returns A promise that resolves with the new credential.
|
||||
*/
|
||||
createCredential: (
|
||||
abstract createCredential(
|
||||
params: CreateCredentialParams,
|
||||
window: ParentWindowReference,
|
||||
abortController?: AbortController,
|
||||
) => Promise<CreateCredentialResult>;
|
||||
): Promise<CreateCredentialResult>;
|
||||
|
||||
/**
|
||||
* Allows WebAuthn Relying Party scripts to discover and use an existing public key credential, with the user’s consent.
|
||||
@@ -41,11 +39,11 @@ export abstract class Fido2ClientService<ParentWindowReference> {
|
||||
* @param abortController An AbortController that can be used to abort the operation.
|
||||
* @returns A promise that resolves with the asserted credential.
|
||||
*/
|
||||
assertCredential: (
|
||||
abstract assertCredential(
|
||||
params: AssertCredentialParams,
|
||||
window: ParentWindowReference,
|
||||
abortController?: AbortController,
|
||||
) => Promise<AssertCredentialResult>;
|
||||
): Promise<AssertCredentialResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
/**
|
||||
* Parameters used to ask the user to confirm the creation of a new credential.
|
||||
*/
|
||||
@@ -69,11 +67,11 @@ export abstract class Fido2UserInterfaceService<ParentWindowReference> {
|
||||
* @param fallbackSupported Whether or not the browser natively supports WebAuthn.
|
||||
* @param abortController An abort controller that can be used to cancel/close the session.
|
||||
*/
|
||||
newSession: (
|
||||
abstract newSession(
|
||||
fallbackSupported: boolean,
|
||||
window: ParentWindowReference,
|
||||
abortController?: AbortController,
|
||||
) => Promise<Fido2UserInterfaceSession>;
|
||||
): Promise<Fido2UserInterfaceSession>;
|
||||
}
|
||||
|
||||
export abstract class Fido2UserInterfaceSession {
|
||||
@@ -84,9 +82,9 @@ export abstract class Fido2UserInterfaceSession {
|
||||
* @param abortController An abort controller that can be used to cancel/close the session.
|
||||
* @returns The ID of the cipher that contains the credentials the user picked. If not cipher was picked, return cipherId = undefined to to let the authenticator throw the error.
|
||||
*/
|
||||
pickCredential: (
|
||||
abstract pickCredential(
|
||||
params: PickCredentialParams,
|
||||
) => Promise<{ cipherId: string; userVerified: boolean }>;
|
||||
): Promise<{ cipherId: string; userVerified: boolean }>;
|
||||
|
||||
/**
|
||||
* Ask the user to confirm the creation of a new credential.
|
||||
@@ -95,30 +93,30 @@ export abstract class Fido2UserInterfaceSession {
|
||||
* @param abortController An abort controller that can be used to cancel/close the session.
|
||||
* @returns The ID of the cipher where the new credential should be saved.
|
||||
*/
|
||||
confirmNewCredential: (
|
||||
abstract confirmNewCredential(
|
||||
params: NewCredentialParams,
|
||||
) => Promise<{ cipherId: string; userVerified: boolean }>;
|
||||
): Promise<{ cipherId: string; userVerified: boolean }>;
|
||||
|
||||
/**
|
||||
* Make sure that the vault is unlocked.
|
||||
* This will open a window and ask the user to login or unlock the vault if necessary.
|
||||
*/
|
||||
ensureUnlockedVault: () => Promise<void>;
|
||||
abstract ensureUnlockedVault(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Inform the user that the operation was cancelled because their vault contains excluded credentials.
|
||||
*
|
||||
* @param existingCipherIds The IDs of the excluded credentials.
|
||||
*/
|
||||
informExcludedCredential: (existingCipherIds: string[]) => Promise<void>;
|
||||
abstract informExcludedCredential(existingCipherIds: string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Inform the user that the operation was cancelled because their vault does not contain any useable credentials.
|
||||
*/
|
||||
informCredentialNotFound: (abortController?: AbortController) => Promise<void>;
|
||||
abstract informCredentialNotFound(abortController?: AbortController): Promise<void>;
|
||||
|
||||
/**
|
||||
* Close the session, including any windows that may be open.
|
||||
*/
|
||||
close: () => void;
|
||||
abstract close(): void;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { BiometricKey } from "../../auth/types/biometric-key";
|
||||
import { Account } from "../models/domain/account";
|
||||
import { StorageOptions } from "../models/domain/storage-options";
|
||||
@@ -19,47 +17,47 @@ export type InitOptions = {
|
||||
};
|
||||
|
||||
export abstract class StateService<T extends Account = Account> {
|
||||
addAccount: (account: T) => Promise<void>;
|
||||
clean: (options?: StorageOptions) => Promise<void>;
|
||||
init: (initOptions?: InitOptions) => Promise<void>;
|
||||
abstract addAccount(account: T): Promise<void>;
|
||||
abstract clean(options?: StorageOptions): Promise<void>;
|
||||
abstract init(initOptions?: InitOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Gets the user's auto key
|
||||
*/
|
||||
getUserKeyAutoUnlock: (options?: StorageOptions) => Promise<string>;
|
||||
abstract getUserKeyAutoUnlock(options?: StorageOptions): Promise<string>;
|
||||
/**
|
||||
* Sets the user's auto key
|
||||
*/
|
||||
setUserKeyAutoUnlock: (value: string | null, options?: StorageOptions) => Promise<void>;
|
||||
abstract setUserKeyAutoUnlock(value: string | null, options?: StorageOptions): Promise<void>;
|
||||
/**
|
||||
* Gets the user's biometric key
|
||||
*/
|
||||
getUserKeyBiometric: (options?: StorageOptions) => Promise<string>;
|
||||
abstract getUserKeyBiometric(options?: StorageOptions): Promise<string>;
|
||||
/**
|
||||
* Checks if the user has a biometric key available
|
||||
*/
|
||||
hasUserKeyBiometric: (options?: StorageOptions) => Promise<boolean>;
|
||||
abstract hasUserKeyBiometric(options?: StorageOptions): Promise<boolean>;
|
||||
/**
|
||||
* Sets the user's biometric key
|
||||
*/
|
||||
setUserKeyBiometric: (value: BiometricKey, options?: StorageOptions) => Promise<void>;
|
||||
abstract setUserKeyBiometric(value: BiometricKey, options?: StorageOptions): Promise<void>;
|
||||
/**
|
||||
* @deprecated For backwards compatible purposes only, use DesktopAutofillSettingsService
|
||||
*/
|
||||
setEnableDuckDuckGoBrowserIntegration: (
|
||||
abstract setEnableDuckDuckGoBrowserIntegration(
|
||||
value: boolean,
|
||||
options?: StorageOptions,
|
||||
) => Promise<void>;
|
||||
getDuckDuckGoSharedKey: (options?: StorageOptions) => Promise<string>;
|
||||
setDuckDuckGoSharedKey: (value: string, options?: StorageOptions) => Promise<void>;
|
||||
): Promise<void>;
|
||||
abstract getDuckDuckGoSharedKey(options?: StorageOptions): Promise<string>;
|
||||
abstract setDuckDuckGoSharedKey(value: string, options?: StorageOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @deprecated Use `TokenService.hasAccessToken$()` or `AuthService.authStatusFor$` instead.
|
||||
*/
|
||||
getIsAuthenticated: (options?: StorageOptions) => Promise<boolean>;
|
||||
abstract getIsAuthenticated(options?: StorageOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* @deprecated Use `AccountService.activeAccount$` instead.
|
||||
*/
|
||||
getUserId: (options?: StorageOptions) => Promise<string>;
|
||||
abstract getUserId(options?: StorageOptions): Promise<string>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user