mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
Remove deprecated factory methods (#9077)
Note: Some of the init code here will be usable in the future for a different dependency framework.
This commit is contained in:
parent
b4c8bdf468
commit
a0efc78a52
@ -1,27 +0,0 @@
|
|||||||
import { OrganizationService as AbstractOrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/services/organization/organization.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import { stateProviderFactory } from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import { StateServiceInitOptions } from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type OrganizationServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type OrganizationServiceInitOptions = OrganizationServiceFactoryOptions &
|
|
||||||
StateServiceInitOptions;
|
|
||||||
|
|
||||||
export function organizationServiceFactory(
|
|
||||||
cache: { organizationService?: AbstractOrganizationService } & CachedServices,
|
|
||||||
opts: OrganizationServiceInitOptions,
|
|
||||||
): Promise<AbstractOrganizationService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"organizationService",
|
|
||||||
opts,
|
|
||||||
async () => new OrganizationService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
import { PolicyService as AbstractPolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
|
||||||
import { PolicyService } from "@bitwarden/common/admin-console/services/policy/policy.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
import {
|
|
||||||
organizationServiceFactory,
|
|
||||||
OrganizationServiceInitOptions,
|
|
||||||
} from "./organization-service.factory";
|
|
||||||
|
|
||||||
type PolicyServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type PolicyServiceInitOptions = PolicyServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
OrganizationServiceInitOptions;
|
|
||||||
|
|
||||||
export function policyServiceFactory(
|
|
||||||
cache: { policyService?: AbstractPolicyService } & CachedServices,
|
|
||||||
opts: PolicyServiceInitOptions,
|
|
||||||
): Promise<AbstractPolicyService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"policyService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new PolicyService(
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await organizationServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
MessagingServiceInitOptions,
|
|
||||||
messagingServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/messaging-service.factory";
|
|
||||||
|
|
||||||
type AccountServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AccountServiceInitOptions = AccountServiceFactoryOptions &
|
|
||||||
MessagingServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
GlobalStateProviderInitOptions;
|
|
||||||
|
|
||||||
export function accountServiceFactory(
|
|
||||||
cache: { accountService?: AccountService } & CachedServices,
|
|
||||||
opts: AccountServiceInitOptions,
|
|
||||||
): Promise<AccountService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"accountService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AccountServiceImplementation(
|
|
||||||
await messagingServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
import { AuthRequestService, AuthRequestServiceAbstraction } from "@bitwarden/auth/common";
|
|
||||||
|
|
||||||
import {
|
|
||||||
apiServiceFactory,
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
appIdServiceFactory,
|
|
||||||
AppIdServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/app-id-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
FactoryOptions,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
import { accountServiceFactory, AccountServiceInitOptions } from "./account-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "./master-password-service.factory";
|
|
||||||
|
|
||||||
type AuthRequestServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AuthRequestServiceInitOptions = AuthRequestServiceFactoryOptions &
|
|
||||||
AppIdServiceInitOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function authRequestServiceFactory(
|
|
||||||
cache: { authRequestService?: AuthRequestServiceAbstraction } & CachedServices,
|
|
||||||
opts: AuthRequestServiceInitOptions,
|
|
||||||
): Promise<AuthRequestServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"authRequestService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AuthRequestService(
|
|
||||||
await appIdServiceFactory(cache, opts),
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
import { AuthService as AbstractAuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
|
||||||
import { AuthService } from "@bitwarden/common/auth/services/auth.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
FactoryOptions,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
MessagingServiceInitOptions,
|
|
||||||
messagingServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/messaging-service.factory";
|
|
||||||
import {
|
|
||||||
StateServiceInitOptions,
|
|
||||||
stateServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
import { AccountServiceInitOptions, accountServiceFactory } from "./account-service.factory";
|
|
||||||
import { TokenServiceInitOptions, tokenServiceFactory } from "./token-service.factory";
|
|
||||||
|
|
||||||
type AuthServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AuthServiceInitOptions = AuthServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MessagingServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
TokenServiceInitOptions;
|
|
||||||
|
|
||||||
export function authServiceFactory(
|
|
||||||
cache: { authService?: AbstractAuthService } & CachedServices,
|
|
||||||
opts: AuthServiceInitOptions,
|
|
||||||
): Promise<AbstractAuthService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"authService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AuthService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await messagingServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { AvatarService as AvatarServiceAbstraction } from "@bitwarden/common/auth/abstractions/avatar.service";
|
|
||||||
import { AvatarService } from "@bitwarden/common/auth/services/avatar.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type AvatarServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AvatarServiceInitOptions = AvatarServiceFactoryOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function avatarServiceFactory(
|
|
||||||
cache: { avatarService?: AvatarServiceAbstraction } & CachedServices,
|
|
||||||
opts: AvatarServiceInitOptions,
|
|
||||||
): Promise<AvatarServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"avatarService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AvatarService(
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
|
||||||
import { DeviceTrustService } from "@bitwarden/common/auth/services/device-trust.service.implementation";
|
|
||||||
|
|
||||||
import {
|
|
||||||
DevicesApiServiceInitOptions,
|
|
||||||
devicesApiServiceFactory,
|
|
||||||
} from "../../../background/service-factories/devices-api-service.factory";
|
|
||||||
import {
|
|
||||||
AppIdServiceInitOptions,
|
|
||||||
appIdServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/app-id-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-function-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
FactoryOptions,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
i18nServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
import { logServiceFactory } from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
import {
|
|
||||||
StateProviderInitOptions,
|
|
||||||
stateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import {
|
|
||||||
SecureStorageServiceInitOptions,
|
|
||||||
secureStorageServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/storage-service.factory";
|
|
||||||
|
|
||||||
import {
|
|
||||||
UserDecryptionOptionsServiceInitOptions,
|
|
||||||
userDecryptionOptionsServiceFactory,
|
|
||||||
} from "./user-decryption-options-service.factory";
|
|
||||||
|
|
||||||
type DeviceTrustServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type DeviceTrustServiceInitOptions = DeviceTrustServiceFactoryOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
CryptoFunctionServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
AppIdServiceInitOptions &
|
|
||||||
DevicesApiServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
SecureStorageServiceInitOptions &
|
|
||||||
UserDecryptionOptionsServiceInitOptions;
|
|
||||||
|
|
||||||
export function deviceTrustServiceFactory(
|
|
||||||
cache: { deviceTrustService?: DeviceTrustServiceAbstraction } & CachedServices,
|
|
||||||
opts: DeviceTrustServiceInitOptions,
|
|
||||||
): Promise<DeviceTrustServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"deviceTrustService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DeviceTrustService(
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await appIdServiceFactory(cache, opts),
|
|
||||||
await devicesApiServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await secureStorageServiceFactory(cache, opts),
|
|
||||||
await userDecryptionOptionsServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import { KdfConfigService as AbstractKdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/services/kdf-config.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
StateProviderInitOptions,
|
|
||||||
stateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type KdfConfigServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type KdfConfigServiceInitOptions = KdfConfigServiceFactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function kdfConfigServiceFactory(
|
|
||||||
cache: { kdfConfigService?: AbstractKdfConfigService } & CachedServices,
|
|
||||||
opts: KdfConfigServiceInitOptions,
|
|
||||||
): Promise<AbstractKdfConfigService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"kdfConfigService",
|
|
||||||
opts,
|
|
||||||
async () => new KdfConfigService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
import { KeyConnectorService as AbstractKeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
|
||||||
import { KeyConnectorService } from "@bitwarden/common/auth/services/key-connector.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
OrganizationServiceInitOptions,
|
|
||||||
organizationServiceFactory,
|
|
||||||
} from "../../../admin-console/background/service-factories/organization-service.factory";
|
|
||||||
import {
|
|
||||||
apiServiceFactory,
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
import { accountServiceFactory, AccountServiceInitOptions } from "./account-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "./master-password-service.factory";
|
|
||||||
import { TokenServiceInitOptions, tokenServiceFactory } from "./token-service.factory";
|
|
||||||
|
|
||||||
type KeyConnectorServiceFactoryOptions = FactoryOptions & {
|
|
||||||
keyConnectorServiceOptions: {
|
|
||||||
logoutCallback: (expired: boolean, userId?: string) => Promise<void>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type KeyConnectorServiceInitOptions = KeyConnectorServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
TokenServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
OrganizationServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function keyConnectorServiceFactory(
|
|
||||||
cache: { keyConnectorService?: AbstractKeyConnectorService } & CachedServices,
|
|
||||||
opts: KeyConnectorServiceInitOptions,
|
|
||||||
): Promise<AbstractKeyConnectorService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"keyConnectorService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new KeyConnectorService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await organizationServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
opts.keyConnectorServiceOptions.logoutCallback,
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import { LoginEmailServiceAbstraction, LoginEmailService } from "@bitwarden/auth/common";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type LoginEmailServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type LoginEmailServiceInitOptions = LoginEmailServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function loginEmailServiceFactory(
|
|
||||||
cache: { loginEmailService?: LoginEmailServiceAbstraction } & CachedServices,
|
|
||||||
opts: LoginEmailServiceInitOptions,
|
|
||||||
): Promise<LoginEmailServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"loginEmailService",
|
|
||||||
opts,
|
|
||||||
async () => new LoginEmailService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,154 +0,0 @@
|
|||||||
import { LoginStrategyService, LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
|
||||||
|
|
||||||
import {
|
|
||||||
policyServiceFactory,
|
|
||||||
PolicyServiceInitOptions,
|
|
||||||
} from "../../../admin-console/background/service-factories/policy-service.factory";
|
|
||||||
import {
|
|
||||||
vaultTimeoutSettingsServiceFactory,
|
|
||||||
VaultTimeoutSettingsServiceInitOptions,
|
|
||||||
} from "../../../background/service-factories/vault-timeout-settings-service.factory";
|
|
||||||
import {
|
|
||||||
apiServiceFactory,
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import { appIdServiceFactory } from "../../../platform/background/service-factories/app-id-service.factory";
|
|
||||||
import {
|
|
||||||
billingAccountProfileStateServiceFactory,
|
|
||||||
BillingAccountProfileStateServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/billing-account-profile-state-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
environmentServiceFactory,
|
|
||||||
EnvironmentServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/environment-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
globalStateProviderFactory,
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
messagingServiceFactory,
|
|
||||||
MessagingServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/messaging-service.factory";
|
|
||||||
import {
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
import {
|
|
||||||
passwordStrengthServiceFactory,
|
|
||||||
PasswordStrengthServiceInitOptions,
|
|
||||||
} from "../../../tools/background/service_factories/password-strength-service.factory";
|
|
||||||
|
|
||||||
import { accountServiceFactory, AccountServiceInitOptions } from "./account-service.factory";
|
|
||||||
import {
|
|
||||||
authRequestServiceFactory,
|
|
||||||
AuthRequestServiceInitOptions,
|
|
||||||
} from "./auth-request-service.factory";
|
|
||||||
import {
|
|
||||||
deviceTrustServiceFactory,
|
|
||||||
DeviceTrustServiceInitOptions,
|
|
||||||
} from "./device-trust-service.factory";
|
|
||||||
import { kdfConfigServiceFactory, KdfConfigServiceInitOptions } from "./kdf-config-service.factory";
|
|
||||||
import {
|
|
||||||
keyConnectorServiceFactory,
|
|
||||||
KeyConnectorServiceInitOptions,
|
|
||||||
} from "./key-connector-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "./master-password-service.factory";
|
|
||||||
import { tokenServiceFactory, TokenServiceInitOptions } from "./token-service.factory";
|
|
||||||
import { twoFactorServiceFactory, TwoFactorServiceInitOptions } from "./two-factor-service.factory";
|
|
||||||
import {
|
|
||||||
internalUserDecryptionOptionServiceFactory,
|
|
||||||
UserDecryptionOptionsServiceInitOptions,
|
|
||||||
} from "./user-decryption-options-service.factory";
|
|
||||||
|
|
||||||
type LoginStrategyServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type LoginStrategyServiceInitOptions = LoginStrategyServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
TokenServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
MessagingServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
KeyConnectorServiceInitOptions &
|
|
||||||
EnvironmentServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
TwoFactorServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
PolicyServiceInitOptions &
|
|
||||||
PasswordStrengthServiceInitOptions &
|
|
||||||
DeviceTrustServiceInitOptions &
|
|
||||||
AuthRequestServiceInitOptions &
|
|
||||||
UserDecryptionOptionsServiceInitOptions &
|
|
||||||
GlobalStateProviderInitOptions &
|
|
||||||
BillingAccountProfileStateServiceInitOptions &
|
|
||||||
VaultTimeoutSettingsServiceInitOptions &
|
|
||||||
KdfConfigServiceInitOptions;
|
|
||||||
|
|
||||||
export function loginStrategyServiceFactory(
|
|
||||||
cache: { loginStrategyService?: LoginStrategyServiceAbstraction } & CachedServices,
|
|
||||||
opts: LoginStrategyServiceInitOptions,
|
|
||||||
): Promise<LoginStrategyServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"loginStrategyService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new LoginStrategyService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
await appIdServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await messagingServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await keyConnectorServiceFactory(cache, opts),
|
|
||||||
await environmentServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await twoFactorServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await passwordStrengthServiceFactory(cache, opts),
|
|
||||||
await policyServiceFactory(cache, opts),
|
|
||||||
await deviceTrustServiceFactory(cache, opts),
|
|
||||||
await authRequestServiceFactory(cache, opts),
|
|
||||||
await internalUserDecryptionOptionServiceFactory(cache, opts),
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
await billingAccountProfileStateServiceFactory(cache, opts),
|
|
||||||
await vaultTimeoutSettingsServiceFactory(cache, opts),
|
|
||||||
await kdfConfigServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
import {
|
|
||||||
InternalMasterPasswordServiceAbstraction,
|
|
||||||
MasterPasswordServiceAbstraction,
|
|
||||||
} from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { MasterPasswordService } from "@bitwarden/common/auth/services/master-password/master-password.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
encryptServiceFactory,
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type MasterPasswordServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type MasterPasswordServiceInitOptions = MasterPasswordServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions;
|
|
||||||
|
|
||||||
export function internalMasterPasswordServiceFactory(
|
|
||||||
cache: { masterPasswordService?: InternalMasterPasswordServiceAbstraction } & CachedServices,
|
|
||||||
opts: MasterPasswordServiceInitOptions,
|
|
||||||
): Promise<InternalMasterPasswordServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"masterPasswordService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new MasterPasswordService(
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function masterPasswordServiceFactory(
|
|
||||||
cache: { masterPasswordService?: InternalMasterPasswordServiceAbstraction } & CachedServices,
|
|
||||||
opts: MasterPasswordServiceInitOptions,
|
|
||||||
): Promise<MasterPasswordServiceAbstraction> {
|
|
||||||
return (await internalMasterPasswordServiceFactory(
|
|
||||||
cache,
|
|
||||||
opts,
|
|
||||||
)) as MasterPasswordServiceAbstraction;
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
import { PinServiceAbstraction, PinService } from "@bitwarden/auth/common";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-function-service.factory";
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
StateProviderInitOptions,
|
|
||||||
stateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import {
|
|
||||||
StateServiceInitOptions,
|
|
||||||
stateServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
import { AccountServiceInitOptions, accountServiceFactory } from "./account-service.factory";
|
|
||||||
import { KdfConfigServiceInitOptions, kdfConfigServiceFactory } from "./kdf-config-service.factory";
|
|
||||||
import {
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
masterPasswordServiceFactory,
|
|
||||||
} from "./master-password-service.factory";
|
|
||||||
|
|
||||||
type PinServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type PinServiceInitOptions = PinServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
CryptoFunctionServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
KdfConfigServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
StateServiceInitOptions;
|
|
||||||
|
|
||||||
export function pinServiceFactory(
|
|
||||||
cache: { pinService?: PinServiceAbstraction } & CachedServices,
|
|
||||||
opts: PinServiceInitOptions,
|
|
||||||
): Promise<PinServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"pinService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new PinService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await kdfConfigServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await masterPasswordServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
|
|
||||||
import { SsoLoginService } from "@bitwarden/common/auth/services/sso-login.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type SsoLoginServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SsoLoginServiceInitOptions = SsoLoginServiceFactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function ssoLoginServiceFactory(
|
|
||||||
cache: { ssoLoginService?: SsoLoginServiceAbstraction } & CachedServices,
|
|
||||||
opts: SsoLoginServiceInitOptions,
|
|
||||||
): Promise<SsoLoginServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"ssoLoginService",
|
|
||||||
opts,
|
|
||||||
async () => new SsoLoginService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
import { TokenService as AbstractTokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/services/token.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
import {
|
|
||||||
SingleUserStateProviderInitOptions,
|
|
||||||
singleUserStateProviderFactory,
|
|
||||||
} from "../../../platform/background/service-factories/single-user-state-provider.factory";
|
|
||||||
import {
|
|
||||||
SecureStorageServiceInitOptions,
|
|
||||||
secureStorageServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/storage-service.factory";
|
|
||||||
|
|
||||||
type TokenServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type TokenServiceInitOptions = TokenServiceFactoryOptions &
|
|
||||||
SingleUserStateProviderInitOptions &
|
|
||||||
GlobalStateProviderInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
SecureStorageServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function tokenServiceFactory(
|
|
||||||
cache: { tokenService?: AbstractTokenService } & CachedServices,
|
|
||||||
opts: TokenServiceInitOptions,
|
|
||||||
): Promise<AbstractTokenService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"tokenService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new TokenService(
|
|
||||||
await singleUserStateProviderFactory(cache, opts),
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
(await platformUtilsServiceFactory(cache, opts)).supportsSecureStorage(),
|
|
||||||
await secureStorageServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
import { TwoFactorService as AbstractTwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/services/two-factor.service";
|
|
||||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import { globalStateProviderFactory } from "../../../platform/background/service-factories/global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
i18nServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
|
|
||||||
type TwoFactorServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type TwoFactorServiceInitOptions = TwoFactorServiceFactoryOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
GlobalStateProvider;
|
|
||||||
|
|
||||||
export async function twoFactorServiceFactory(
|
|
||||||
cache: { twoFactorService?: AbstractTwoFactorService } & CachedServices,
|
|
||||||
opts: TwoFactorServiceInitOptions,
|
|
||||||
): Promise<AbstractTwoFactorService> {
|
|
||||||
const service = await factory(
|
|
||||||
cache,
|
|
||||||
"twoFactorService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new TwoFactorService(
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
service.init();
|
|
||||||
return service;
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
import {
|
|
||||||
InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
UserDecryptionOptionsService,
|
|
||||||
UserDecryptionOptionsServiceAbstraction,
|
|
||||||
} from "@bitwarden/auth/common";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type UserDecryptionOptionsServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type UserDecryptionOptionsServiceInitOptions = UserDecryptionOptionsServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function userDecryptionOptionsServiceFactory(
|
|
||||||
cache: {
|
|
||||||
userDecryptionOptionsService?: InternalUserDecryptionOptionsServiceAbstraction;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: UserDecryptionOptionsServiceInitOptions,
|
|
||||||
): Promise<UserDecryptionOptionsServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"userDecryptionOptionsService",
|
|
||||||
opts,
|
|
||||||
async () => new UserDecryptionOptionsService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function internalUserDecryptionOptionServiceFactory(
|
|
||||||
cache: {
|
|
||||||
userDecryptionOptionsService?: InternalUserDecryptionOptionsServiceAbstraction;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: UserDecryptionOptionsServiceInitOptions,
|
|
||||||
): Promise<InternalUserDecryptionOptionsServiceAbstraction> {
|
|
||||||
return (await userDecryptionOptionsServiceFactory(
|
|
||||||
cache,
|
|
||||||
opts,
|
|
||||||
)) as InternalUserDecryptionOptionsServiceAbstraction;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
import { UserVerificationApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/user-verification/user-verification-api.service.abstraction";
|
|
||||||
import { UserVerificationApiService } from "@bitwarden/common/auth/services/user-verification/user-verification-api.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
|
|
||||||
type UserVerificationApiServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type UserVerificationApiServiceInitOptions = UserVerificationApiServiceFactoryOptions &
|
|
||||||
ApiServiceInitOptions;
|
|
||||||
|
|
||||||
export function userVerificationApiServiceFactory(
|
|
||||||
cache: { userVerificationApiService?: UserVerificationApiServiceAbstraction } & CachedServices,
|
|
||||||
opts: UserVerificationApiServiceInitOptions,
|
|
||||||
): Promise<UserVerificationApiServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"userVerificationApiService",
|
|
||||||
opts,
|
|
||||||
async () => new UserVerificationApiService(await apiServiceFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
import { UserVerificationService as AbstractUserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
VaultTimeoutSettingsServiceInitOptions,
|
|
||||||
vaultTimeoutSettingsServiceFactory,
|
|
||||||
} from "../../../background/service-factories/vault-timeout-settings-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
i18nServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
import {
|
|
||||||
StateServiceInitOptions,
|
|
||||||
stateServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
import { accountServiceFactory, AccountServiceInitOptions } from "./account-service.factory";
|
|
||||||
import { KdfConfigServiceInitOptions, kdfConfigServiceFactory } from "./kdf-config-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "./master-password-service.factory";
|
|
||||||
import { PinServiceInitOptions, pinServiceFactory } from "./pin-service.factory";
|
|
||||||
import {
|
|
||||||
userDecryptionOptionsServiceFactory,
|
|
||||||
UserDecryptionOptionsServiceInitOptions,
|
|
||||||
} from "./user-decryption-options-service.factory";
|
|
||||||
import {
|
|
||||||
UserVerificationApiServiceInitOptions,
|
|
||||||
userVerificationApiServiceFactory,
|
|
||||||
} from "./user-verification-api-service.factory";
|
|
||||||
|
|
||||||
type UserVerificationServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type UserVerificationServiceInitOptions = UserVerificationServiceFactoryOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
UserVerificationApiServiceInitOptions &
|
|
||||||
UserDecryptionOptionsServiceInitOptions &
|
|
||||||
PinServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
VaultTimeoutSettingsServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
KdfConfigServiceInitOptions;
|
|
||||||
|
|
||||||
export function userVerificationServiceFactory(
|
|
||||||
cache: { userVerificationService?: AbstractUserVerificationService } & CachedServices,
|
|
||||||
opts: UserVerificationServiceInitOptions,
|
|
||||||
): Promise<AbstractUserVerificationService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"userVerificationService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new UserVerificationService(
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await userVerificationApiServiceFactory(cache, opts),
|
|
||||||
await userDecryptionOptionsServiceFactory(cache, opts),
|
|
||||||
await pinServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await vaultTimeoutSettingsServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await kdfConfigServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
import {
|
|
||||||
accountServiceFactory,
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
UserVerificationServiceInitOptions,
|
|
||||||
userVerificationServiceFactory,
|
|
||||||
} from "../../../auth/background/service-factories/user-verification-service.factory";
|
|
||||||
import {
|
|
||||||
EventCollectionServiceInitOptions,
|
|
||||||
eventCollectionServiceFactory,
|
|
||||||
} from "../../../background/service-factories/event-collection-service.factory";
|
|
||||||
import { billingAccountProfileStateServiceFactory } from "../../../platform/background/service-factories/billing-account-profile-state-service.factory";
|
|
||||||
import {
|
|
||||||
browserScriptInjectorServiceFactory,
|
|
||||||
BrowserScriptInjectorServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/browser-script-injector-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import {
|
|
||||||
TotpServiceInitOptions,
|
|
||||||
totpServiceFactory,
|
|
||||||
} from "../../../vault/background/service_factories/totp-service.factory";
|
|
||||||
import { AutofillService as AbstractAutoFillService } from "../../services/abstractions/autofill.service";
|
|
||||||
import AutofillService from "../../services/autofill.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AutofillSettingsServiceInitOptions,
|
|
||||||
autofillSettingsServiceFactory,
|
|
||||||
} from "./autofill-settings-service.factory";
|
|
||||||
import {
|
|
||||||
DomainSettingsServiceInitOptions,
|
|
||||||
domainSettingsServiceFactory,
|
|
||||||
} from "./domain-settings-service.factory";
|
|
||||||
|
|
||||||
type AutoFillServiceOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AutoFillServiceInitOptions = AutoFillServiceOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
AutofillSettingsServiceInitOptions &
|
|
||||||
TotpServiceInitOptions &
|
|
||||||
EventCollectionServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
UserVerificationServiceInitOptions &
|
|
||||||
DomainSettingsServiceInitOptions &
|
|
||||||
BrowserScriptInjectorServiceInitOptions &
|
|
||||||
AccountServiceInitOptions;
|
|
||||||
|
|
||||||
export function autofillServiceFactory(
|
|
||||||
cache: { autofillService?: AbstractAutoFillService } & CachedServices,
|
|
||||||
opts: AutoFillServiceInitOptions,
|
|
||||||
): Promise<AbstractAutoFillService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"autofillService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AutofillService(
|
|
||||||
await cipherServiceFactory(cache, opts),
|
|
||||||
await autofillSettingsServiceFactory(cache, opts),
|
|
||||||
await totpServiceFactory(cache, opts),
|
|
||||||
await eventCollectionServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await domainSettingsServiceFactory(cache, opts),
|
|
||||||
await userVerificationServiceFactory(cache, opts),
|
|
||||||
await billingAccountProfileStateServiceFactory(cache, opts),
|
|
||||||
await browserScriptInjectorServiceFactory(cache, opts),
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
import { AutofillSettingsService } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
policyServiceFactory,
|
|
||||||
PolicyServiceInitOptions,
|
|
||||||
} from "../../../admin-console/background/service-factories/policy-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
export type AutofillSettingsServiceInitOptions = FactoryOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
PolicyServiceInitOptions;
|
|
||||||
|
|
||||||
export function autofillSettingsServiceFactory(
|
|
||||||
cache: { autofillSettingsService?: AutofillSettingsService } & CachedServices,
|
|
||||||
opts: AutofillSettingsServiceInitOptions,
|
|
||||||
): Promise<AutofillSettingsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"autofillSettingsService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new AutofillSettingsService(
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await policyServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { BadgeSettingsService } from "@bitwarden/common/autofill/services/badge-settings.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
export type BadgeSettingsServiceInitOptions = FactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function badgeSettingsServiceFactory(
|
|
||||||
cache: { badgeSettingsService?: BadgeSettingsService } & CachedServices,
|
|
||||||
opts: BadgeSettingsServiceInitOptions,
|
|
||||||
): Promise<BadgeSettingsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"badgeSettingsService",
|
|
||||||
opts,
|
|
||||||
async () => new BadgeSettingsService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { DefaultDomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
export type DomainSettingsServiceInitOptions = FactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function domainSettingsServiceFactory(
|
|
||||||
cache: { domainSettingsService?: DefaultDomainSettingsService } & CachedServices,
|
|
||||||
opts: DomainSettingsServiceInitOptions,
|
|
||||||
): Promise<DefaultDomainSettingsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"domainSettingsService",
|
|
||||||
opts,
|
|
||||||
async () => new DefaultDomainSettingsService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { UserNotificationSettingsService } from "@bitwarden/common/autofill/services/user-notification-settings.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
export type UserNotificationSettingsServiceInitOptions = FactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function userNotificationSettingsServiceFactory(
|
|
||||||
cache: { userNotificationSettingsService?: UserNotificationSettingsService } & CachedServices,
|
|
||||||
opts: UserNotificationSettingsServiceInitOptions,
|
|
||||||
): Promise<UserNotificationSettingsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"userNotificationSettingsService",
|
|
||||||
opts,
|
|
||||||
async () => new UserNotificationSettingsService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,39 +1,14 @@
|
|||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
import {
|
|
||||||
authServiceFactory,
|
|
||||||
AuthServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import { CachedServices } from "../../platform/background/service-factories/factory-options";
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import { AutofillCipherTypeId } from "../types";
|
import { AutofillCipherTypeId } from "../types";
|
||||||
|
|
||||||
import { MainContextMenuHandler } from "./main-context-menu-handler";
|
import { MainContextMenuHandler } from "./main-context-menu-handler";
|
||||||
|
|
||||||
const NOT_IMPLEMENTED = (..._args: unknown[]) => Promise.resolve();
|
|
||||||
|
|
||||||
const LISTENED_TO_COMMANDS = [
|
|
||||||
"loggedIn",
|
|
||||||
"unlocked",
|
|
||||||
"syncCompleted",
|
|
||||||
"bgUpdateContextMenu",
|
|
||||||
"editedCipher",
|
|
||||||
"addedCipher",
|
|
||||||
"deletedCipher",
|
|
||||||
];
|
|
||||||
|
|
||||||
export class CipherContextMenuHandler {
|
export class CipherContextMenuHandler {
|
||||||
constructor(
|
constructor(
|
||||||
private mainContextMenuHandler: MainContextMenuHandler,
|
private mainContextMenuHandler: MainContextMenuHandler,
|
||||||
@ -41,110 +16,6 @@ export class CipherContextMenuHandler {
|
|||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static async create(cachedServices: CachedServices) {
|
|
||||||
const stateFactory = new StateFactory(GlobalState, Account);
|
|
||||||
const serviceOptions: AuthServiceInitOptions & CipherServiceInitOptions = {
|
|
||||||
apiServiceOptions: {
|
|
||||||
logoutCallback: NOT_IMPLEMENTED,
|
|
||||||
},
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: false,
|
|
||||||
},
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: chrome.i18n.getUILanguage(),
|
|
||||||
},
|
|
||||||
keyConnectorServiceOptions: {
|
|
||||||
logoutCallback: NOT_IMPLEMENTED,
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
biometricCallback: () => Promise.resolve(false),
|
|
||||||
clipboardWriteCallback: NOT_IMPLEMENTED,
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: stateFactory,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return new CipherContextMenuHandler(
|
|
||||||
await MainContextMenuHandler.mv3Create(cachedServices),
|
|
||||||
await authServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await cipherServiceFactory(cachedServices, serviceOptions),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async windowsOnFocusChangedListener(windowId: number, serviceCache: CachedServices) {
|
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
|
||||||
const tab = await BrowserApi.getTabFromCurrentWindow();
|
|
||||||
await cipherContextMenuHandler.update(tab?.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnActivatedListener(
|
|
||||||
activeInfo: chrome.tabs.TabActiveInfo,
|
|
||||||
serviceCache: CachedServices,
|
|
||||||
) {
|
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
|
||||||
const tab = await BrowserApi.getTab(activeInfo.tabId);
|
|
||||||
await cipherContextMenuHandler.update(tab.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnReplacedListener(
|
|
||||||
addedTabId: number,
|
|
||||||
removedTabId: number,
|
|
||||||
serviceCache: CachedServices,
|
|
||||||
) {
|
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
|
||||||
const tab = await BrowserApi.getTab(addedTabId);
|
|
||||||
await cipherContextMenuHandler.update(tab.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnUpdatedListener(
|
|
||||||
tabId: number,
|
|
||||||
changeInfo: chrome.tabs.TabChangeInfo,
|
|
||||||
tab: chrome.tabs.Tab,
|
|
||||||
serviceCache: CachedServices,
|
|
||||||
) {
|
|
||||||
if (changeInfo.status !== "complete") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
|
||||||
await cipherContextMenuHandler.update(tab.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async messageListener(
|
|
||||||
message: { command: string },
|
|
||||||
sender: chrome.runtime.MessageSender,
|
|
||||||
cachedServices: CachedServices,
|
|
||||||
) {
|
|
||||||
if (!CipherContextMenuHandler.shouldListen(message)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(cachedServices);
|
|
||||||
await cipherContextMenuHandler.messageListener(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static shouldListen(message: { command: string }) {
|
|
||||||
return LISTENED_TO_COMMANDS.includes(message.command);
|
|
||||||
}
|
|
||||||
|
|
||||||
async messageListener(message: { command: string }, sender?: chrome.runtime.MessageSender) {
|
|
||||||
if (!CipherContextMenuHandler.shouldListen(message)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeTabs = await BrowserApi.getActiveTabs();
|
|
||||||
if (!activeTabs || activeTabs.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.update(activeTabs[0].url);
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(url: string) {
|
async update(url: string) {
|
||||||
if (this.mainContextMenuHandler.initRunning) {
|
if (this.mainContextMenuHandler.initRunning) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,41 +20,19 @@ import {
|
|||||||
NOOP_COMMAND_SUFFIX,
|
NOOP_COMMAND_SUFFIX,
|
||||||
} from "@bitwarden/common/autofill/constants";
|
} from "@bitwarden/common/autofill/constants";
|
||||||
import { EventType } from "@bitwarden/common/enums";
|
import { EventType } from "@bitwarden/common/enums";
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
import { accountServiceFactory } from "../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
authServiceFactory,
|
|
||||||
AuthServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import { KeyConnectorServiceInitOptions } from "../../auth/background/service-factories/key-connector-service.factory";
|
|
||||||
import { userVerificationServiceFactory } from "../../auth/background/service-factories/user-verification-service.factory";
|
|
||||||
import { openUnlockPopout } from "../../auth/popup/utils/auth-popout-window";
|
import { openUnlockPopout } from "../../auth/popup/utils/auth-popout-window";
|
||||||
import { autofillSettingsServiceFactory } from "../../autofill/background/service_factories/autofill-settings-service.factory";
|
|
||||||
import { eventCollectionServiceFactory } from "../../background/service-factories/event-collection-service.factory";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import { CachedServices } from "../../platform/background/service-factories/factory-options";
|
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import { passwordGenerationServiceFactory } from "../../tools/background/service_factories/password-generation-service.factory";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import { totpServiceFactory } from "../../vault/background/service_factories/totp-service.factory";
|
|
||||||
import {
|
import {
|
||||||
openAddEditVaultItemPopout,
|
openAddEditVaultItemPopout,
|
||||||
openVaultItemPasswordRepromptPopout,
|
openVaultItemPasswordRepromptPopout,
|
||||||
} from "../../vault/popup/utils/vault-popout-window";
|
} from "../../vault/popup/utils/vault-popout-window";
|
||||||
import { LockedVaultPendingNotificationsData } from "../background/abstractions/notification.background";
|
import { LockedVaultPendingNotificationsData } from "../background/abstractions/notification.background";
|
||||||
import { autofillServiceFactory } from "../background/service_factories/autofill-service.factory";
|
|
||||||
import { copyToClipboard, GeneratePasswordToClipboardCommand } from "../clipboard";
|
|
||||||
import { AutofillTabCommand } from "../commands/autofill-tab-command";
|
|
||||||
import { AutofillCipherTypeId } from "../types";
|
import { AutofillCipherTypeId } from "../types";
|
||||||
|
|
||||||
export type CopyToClipboardOptions = { text: string; tab: chrome.tabs.Tab };
|
export type CopyToClipboardOptions = { text: string; tab: chrome.tabs.Tab };
|
||||||
@ -63,9 +41,6 @@ export type AutofillAction = (tab: chrome.tabs.Tab, cipher: CipherView) => Promi
|
|||||||
|
|
||||||
export type GeneratePasswordToClipboardAction = (tab: chrome.tabs.Tab) => Promise<void>;
|
export type GeneratePasswordToClipboardAction = (tab: chrome.tabs.Tab) => Promise<void>;
|
||||||
|
|
||||||
const NOT_IMPLEMENTED = (..._args: unknown[]) =>
|
|
||||||
Promise.reject<never>("This action is not implemented inside of a service worker context.");
|
|
||||||
|
|
||||||
export class ContextMenuClickedHandler {
|
export class ContextMenuClickedHandler {
|
||||||
constructor(
|
constructor(
|
||||||
private copyToClipboard: CopyToClipboardAction,
|
private copyToClipboard: CopyToClipboardAction,
|
||||||
@ -79,92 +54,6 @@ export class ContextMenuClickedHandler {
|
|||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static async mv3Create(cachedServices: CachedServices) {
|
|
||||||
const stateFactory = new StateFactory(GlobalState, Account);
|
|
||||||
const serviceOptions: AuthServiceInitOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
KeyConnectorServiceInitOptions = {
|
|
||||||
apiServiceOptions: {
|
|
||||||
logoutCallback: NOT_IMPLEMENTED,
|
|
||||||
},
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: false,
|
|
||||||
},
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: chrome.i18n.getUILanguage(),
|
|
||||||
},
|
|
||||||
keyConnectorServiceOptions: {
|
|
||||||
logoutCallback: NOT_IMPLEMENTED,
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
biometricCallback: NOT_IMPLEMENTED,
|
|
||||||
clipboardWriteCallback: NOT_IMPLEMENTED,
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: stateFactory,
|
|
||||||
},
|
|
||||||
autofillSettingsServiceOptions: {
|
|
||||||
stateFactory: autofillSettingsServiceFactory,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const generatePasswordToClipboardCommand = new GeneratePasswordToClipboardCommand(
|
|
||||||
await passwordGenerationServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await autofillSettingsServiceFactory(cachedServices, serviceOptions),
|
|
||||||
);
|
|
||||||
|
|
||||||
const autofillCommand = new AutofillTabCommand(
|
|
||||||
await autofillServiceFactory(cachedServices, serviceOptions),
|
|
||||||
);
|
|
||||||
|
|
||||||
return new ContextMenuClickedHandler(
|
|
||||||
(options) => copyToClipboard(options.tab, options.text),
|
|
||||||
(tab) => generatePasswordToClipboardCommand.generatePasswordToClipboard(tab),
|
|
||||||
(tab, cipher) => autofillCommand.doAutofillTabWithCipherCommand(tab, cipher),
|
|
||||||
await authServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await cipherServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await totpServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await eventCollectionServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await userVerificationServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await accountServiceFactory(cachedServices, serviceOptions),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async onClickedListener(
|
|
||||||
info: chrome.contextMenus.OnClickData,
|
|
||||||
tab?: chrome.tabs.Tab,
|
|
||||||
cachedServices: CachedServices = {},
|
|
||||||
) {
|
|
||||||
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
|
||||||
await contextMenuClickedHandler.run(info, tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async messageListener(
|
|
||||||
message: { command: string; data: LockedVaultPendingNotificationsData },
|
|
||||||
sender: chrome.runtime.MessageSender,
|
|
||||||
cachedServices: CachedServices,
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
message.command !== "unlockCompleted" ||
|
|
||||||
message.data.target !== "contextmenus.background"
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
|
||||||
await contextMenuClickedHandler.run(
|
|
||||||
message.data.commandToRetry.message.contextMenuOnClickData,
|
|
||||||
message.data.commandToRetry.sender.tab,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(info: chrome.contextMenus.OnClickData, tab: chrome.tabs.Tab) {
|
async run(info: chrome.contextMenus.OnClickData, tab: chrome.tabs.Tab) {
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,28 +20,10 @@ import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/s
|
|||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
import { autofillSettingsServiceFactory } from "../../autofill/background/service_factories/autofill-settings-service.factory";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import { billingAccountProfileStateServiceFactory } from "../../platform/background/service-factories/billing-account-profile-state-service.factory";
|
|
||||||
import { CachedServices } from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/state-service.factory";
|
|
||||||
import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service";
|
import { BrowserStateService } from "../../platform/services/abstractions/browser-state.service";
|
||||||
|
|
||||||
import { InitContextMenuItems } from "./abstractions/main-context-menu-handler";
|
import { InitContextMenuItems } from "./abstractions/main-context-menu-handler";
|
||||||
@ -168,41 +150,6 @@ export class MainContextMenuHandler {
|
|||||||
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static async mv3Create(cachedServices: CachedServices) {
|
|
||||||
const stateFactory = new StateFactory(GlobalState, Account);
|
|
||||||
const serviceOptions: StateServiceInitOptions & I18nServiceInitOptions & LogServiceInitOptions =
|
|
||||||
{
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: false,
|
|
||||||
},
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: chrome.i18n.getUILanguage(),
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: stateFactory,
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
clipboardWriteCallback: () => Promise.resolve(),
|
|
||||||
biometricCallback: () => Promise.resolve(false),
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return new MainContextMenuHandler(
|
|
||||||
await stateServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await autofillSettingsServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await i18nServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await logServiceFactory(cachedServices, serviceOptions),
|
|
||||||
await billingAccountProfileStateServiceFactory(cachedServices, serviceOptions),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @returns a boolean showing whether or not items were created
|
* @returns a boolean showing whether or not items were created
|
||||||
|
@ -1178,7 +1178,7 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshBadge() {
|
async refreshBadge() {
|
||||||
await new UpdateBadge(self).run({ existingServices: this as any });
|
await new UpdateBadge(self, this).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshMenu(forLocked = false) {
|
async refreshMenu(forLocked = false) {
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
import { CipherFileUploadService as CipherFileUploadServiceAbstraction } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
|
|
||||||
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
FileUploadServiceInitOptions,
|
|
||||||
fileUploadServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/file-upload-service.factory";
|
|
||||||
|
|
||||||
type CipherFileUploadServiceFactoyOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
FileUploadServiceInitOptions;
|
|
||||||
|
|
||||||
export function cipherFileUploadServiceFactory(
|
|
||||||
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
|
||||||
opts: CipherFileUploadServiceInitOptions,
|
|
||||||
): Promise<CipherFileUploadServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"cipherFileUploadService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new CipherFileUploadService(
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await fileUploadServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { CipherFileUploadService as CipherFileUploadServiceAbstraction } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
|
|
||||||
import { CipherFileUploadService } from "@bitwarden/common/vault/services/file-upload/cipher-file-upload.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
FileUploadServiceInitOptions,
|
|
||||||
fileUploadServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/file-upload-service.factory";
|
|
||||||
|
|
||||||
type CipherFileUploadServiceFactoyOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
FileUploadServiceInitOptions;
|
|
||||||
|
|
||||||
export function cipherFileUploadServiceFactory(
|
|
||||||
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
|
||||||
opts: CipherFileUploadServiceInitOptions,
|
|
||||||
): Promise<CipherFileUploadServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"cipherFileUploadService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new CipherFileUploadService(
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await fileUploadServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices-api.service.abstraction";
|
|
||||||
import { DevicesApiServiceImplementation } from "@bitwarden/common/auth/services/devices-api.service.implementation";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
|
|
||||||
type DevicesApiServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type DevicesApiServiceInitOptions = DevicesApiServiceFactoryOptions & ApiServiceInitOptions;
|
|
||||||
|
|
||||||
export function devicesApiServiceFactory(
|
|
||||||
cache: { devicesApiService?: DevicesApiServiceAbstraction } & CachedServices,
|
|
||||||
opts: DevicesApiServiceInitOptions,
|
|
||||||
): Promise<DevicesApiServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"devicesApiService",
|
|
||||||
opts,
|
|
||||||
async () => new DevicesApiServiceImplementation(await apiServiceFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
import { EventCollectionService as AbstractEventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
|
||||||
import { EventCollectionService } from "@bitwarden/common/services/event/event-collection.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
organizationServiceFactory,
|
|
||||||
OrganizationServiceInitOptions,
|
|
||||||
} from "../../admin-console/background/service-factories/organization-service.factory";
|
|
||||||
import {
|
|
||||||
authServiceFactory,
|
|
||||||
AuthServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import { stateProviderFactory } from "../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import { StateServiceInitOptions } from "../../platform/background/service-factories/state-service.factory";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
|
|
||||||
import {
|
|
||||||
eventUploadServiceFactory,
|
|
||||||
EventUploadServiceInitOptions,
|
|
||||||
} from "./event-upload-service.factory";
|
|
||||||
|
|
||||||
type EventCollectionServiceOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type EventCollectionServiceInitOptions = EventCollectionServiceOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
OrganizationServiceInitOptions &
|
|
||||||
EventUploadServiceInitOptions &
|
|
||||||
AuthServiceInitOptions;
|
|
||||||
|
|
||||||
export function eventCollectionServiceFactory(
|
|
||||||
cache: { eventCollectionService?: AbstractEventCollectionService } & CachedServices,
|
|
||||||
opts: EventCollectionServiceInitOptions,
|
|
||||||
): Promise<AbstractEventCollectionService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"eventCollectionService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new EventCollectionService(
|
|
||||||
await cipherServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await organizationServiceFactory(cache, opts),
|
|
||||||
await eventUploadServiceFactory(cache, opts),
|
|
||||||
await authServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
import { EventUploadService as AbstractEventUploadService } from "@bitwarden/common/abstractions/event/event-upload.service";
|
|
||||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AuthServiceInitOptions,
|
|
||||||
authServiceFactory,
|
|
||||||
} from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/log-service.factory";
|
|
||||||
import { stateProviderFactory } from "../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import { StateServiceInitOptions } from "../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type EventUploadServiceOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type EventUploadServiceInitOptions = EventUploadServiceOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
AuthServiceInitOptions;
|
|
||||||
|
|
||||||
export function eventUploadServiceFactory(
|
|
||||||
cache: { eventUploadService?: AbstractEventUploadService } & CachedServices,
|
|
||||||
opts: EventUploadServiceInitOptions,
|
|
||||||
): Promise<AbstractEventUploadService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"eventUploadService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new EventUploadService(
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await authServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
import {
|
|
||||||
PasswordGenerationService,
|
|
||||||
PasswordGenerationServiceAbstraction,
|
|
||||||
} from "@bitwarden/common/tools/generator/password";
|
|
||||||
|
|
||||||
import {
|
|
||||||
policyServiceFactory,
|
|
||||||
PolicyServiceInitOptions,
|
|
||||||
} from "../../admin-console/background/service-factories/policy-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type PasswordGenerationServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type PasswordGenerationServiceInitOptions = PasswordGenerationServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
PolicyServiceInitOptions &
|
|
||||||
StateServiceInitOptions;
|
|
||||||
|
|
||||||
export function passwordGenerationServiceFactory(
|
|
||||||
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
|
|
||||||
opts: PasswordGenerationServiceInitOptions,
|
|
||||||
): Promise<PasswordGenerationServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"passwordGenerationService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new PasswordGenerationService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await policyServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
import { SearchService as AbstractSearchService } from "@bitwarden/common/abstractions/search.service";
|
|
||||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type SearchServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SearchServiceInitOptions = SearchServiceFactoryOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function searchServiceFactory(
|
|
||||||
cache: { searchService?: AbstractSearchService } & CachedServices,
|
|
||||||
opts: SearchServiceInitOptions,
|
|
||||||
): Promise<AbstractSearchService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"searchService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new SearchService(
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service";
|
|
||||||
import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/key-generation-service.factory";
|
|
||||||
|
|
||||||
import {
|
|
||||||
SendStateProviderInitOptions,
|
|
||||||
sendStateProviderFactory,
|
|
||||||
} from "./send-state-provider.factory";
|
|
||||||
|
|
||||||
type SendServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SendServiceInitOptions = SendServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
SendStateProviderInitOptions &
|
|
||||||
EncryptServiceInitOptions;
|
|
||||||
|
|
||||||
export function sendServiceFactory(
|
|
||||||
cache: { sendService?: InternalSendService } & CachedServices,
|
|
||||||
opts: SendServiceInitOptions,
|
|
||||||
): Promise<InternalSendService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"sendService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new SendService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await sendStateProviderFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import { SendStateProvider } from "@bitwarden/common/tools/send/services/send-state.provider";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
FactoryOptions,
|
|
||||||
factory,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
StateProviderInitOptions,
|
|
||||||
stateProviderFactory,
|
|
||||||
} from "../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type SendStateProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SendStateProviderInitOptions = SendStateProviderFactoryOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function sendStateProviderFactory(
|
|
||||||
cache: { sendStateProvider?: SendStateProvider } & CachedServices,
|
|
||||||
opts: SendStateProviderInitOptions,
|
|
||||||
): Promise<SendStateProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"sendStateProvider",
|
|
||||||
opts,
|
|
||||||
async () => new SendStateProvider(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
import { VaultTimeoutService as AbstractVaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
accountServiceFactory,
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
authServiceFactory,
|
|
||||||
AuthServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/master-password-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
messagingServiceFactory,
|
|
||||||
MessagingServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/messaging-service.factory";
|
|
||||||
import {
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/platform-utils-service.factory";
|
|
||||||
import {
|
|
||||||
stateEventRunnerServiceFactory,
|
|
||||||
StateEventRunnerServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/state-event-runner-service.factory";
|
|
||||||
import {
|
|
||||||
StateServiceInitOptions,
|
|
||||||
stateServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/state-service.factory";
|
|
||||||
import VaultTimeoutService from "../../services/vault-timeout/vault-timeout.service";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import {
|
|
||||||
collectionServiceFactory,
|
|
||||||
CollectionServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/collection-service.factory";
|
|
||||||
import {
|
|
||||||
folderServiceFactory,
|
|
||||||
FolderServiceInitOptions,
|
|
||||||
} from "../../vault/background/service_factories/folder-service.factory";
|
|
||||||
|
|
||||||
import { searchServiceFactory, SearchServiceInitOptions } from "./search-service.factory";
|
|
||||||
import {
|
|
||||||
vaultTimeoutSettingsServiceFactory,
|
|
||||||
VaultTimeoutSettingsServiceInitOptions,
|
|
||||||
} from "./vault-timeout-settings-service.factory";
|
|
||||||
|
|
||||||
type VaultTimeoutServiceFactoryOptions = FactoryOptions & {
|
|
||||||
vaultTimeoutServiceOptions: {
|
|
||||||
lockedCallback: (userId?: string) => Promise<void>;
|
|
||||||
loggedOutCallback: (expired: boolean, userId?: string) => Promise<void>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type VaultTimeoutServiceInitOptions = VaultTimeoutServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
FolderServiceInitOptions &
|
|
||||||
CollectionServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
MessagingServiceInitOptions &
|
|
||||||
SearchServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
AuthServiceInitOptions &
|
|
||||||
VaultTimeoutSettingsServiceInitOptions &
|
|
||||||
StateEventRunnerServiceInitOptions;
|
|
||||||
|
|
||||||
export function vaultTimeoutServiceFactory(
|
|
||||||
cache: { vaultTimeoutService?: AbstractVaultTimeoutService } & CachedServices,
|
|
||||||
opts: VaultTimeoutServiceInitOptions,
|
|
||||||
): Promise<AbstractVaultTimeoutService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"vaultTimeoutService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new VaultTimeoutService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await cipherServiceFactory(cache, opts),
|
|
||||||
await folderServiceFactory(cache, opts),
|
|
||||||
await collectionServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await messagingServiceFactory(cache, opts),
|
|
||||||
await searchServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await authServiceFactory(cache, opts),
|
|
||||||
await vaultTimeoutSettingsServiceFactory(cache, opts),
|
|
||||||
await stateEventRunnerServiceFactory(cache, opts),
|
|
||||||
opts.vaultTimeoutServiceOptions.lockedCallback,
|
|
||||||
opts.vaultTimeoutServiceOptions.loggedOutCallback,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
import { VaultTimeoutSettingsService as AbstractVaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/services/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
|
|
||||||
|
|
||||||
import {
|
|
||||||
policyServiceFactory,
|
|
||||||
PolicyServiceInitOptions,
|
|
||||||
} from "../../admin-console/background/service-factories/policy-service.factory";
|
|
||||||
import {
|
|
||||||
accountServiceFactory,
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
pinServiceFactory,
|
|
||||||
PinServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/pin-service.factory";
|
|
||||||
import {
|
|
||||||
tokenServiceFactory,
|
|
||||||
TokenServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/token-service.factory";
|
|
||||||
import {
|
|
||||||
userDecryptionOptionsServiceFactory,
|
|
||||||
UserDecryptionOptionsServiceInitOptions,
|
|
||||||
} from "../../auth/background/service-factories/user-decryption-options-service.factory";
|
|
||||||
import {
|
|
||||||
biometricStateServiceFactory,
|
|
||||||
BiometricStateServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/biometric-state-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
logServiceFactory,
|
|
||||||
LogServiceInitOptions,
|
|
||||||
} from "../../platform/background/service-factories/log-service.factory";
|
|
||||||
import {
|
|
||||||
StateProviderInitOptions,
|
|
||||||
stateProviderFactory,
|
|
||||||
} from "../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
type VaultTimeoutSettingsServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type VaultTimeoutSettingsServiceInitOptions = VaultTimeoutSettingsServiceFactoryOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
PinServiceInitOptions &
|
|
||||||
UserDecryptionOptionsServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
TokenServiceInitOptions &
|
|
||||||
PolicyServiceInitOptions &
|
|
||||||
BiometricStateServiceInitOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function vaultTimeoutSettingsServiceFactory(
|
|
||||||
cache: { vaultTimeoutSettingsService?: AbstractVaultTimeoutSettingsService } & CachedServices,
|
|
||||||
opts: VaultTimeoutSettingsServiceInitOptions,
|
|
||||||
): Promise<AbstractVaultTimeoutSettingsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"vaultTimeoutSettingsService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new VaultTimeoutSettingsService(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await pinServiceFactory(cache, opts),
|
|
||||||
await userDecryptionOptionsServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
await policyServiceFactory(cache, opts),
|
|
||||||
await biometricStateServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
VaultTimeoutStringType.OnRestart, // default vault timeout
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
import { ActiveUserStateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
|
||||||
import { DefaultActiveUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-active-user-state.provider";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
accountServiceFactory,
|
|
||||||
} from "../../../auth/background/service-factories/account-service.factory";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
SingleUserStateProviderInitOptions,
|
|
||||||
singleUserStateProviderFactory,
|
|
||||||
} from "./single-user-state-provider.factory";
|
|
||||||
|
|
||||||
type ActiveUserStateProviderFactory = FactoryOptions;
|
|
||||||
|
|
||||||
export type ActiveUserStateProviderInitOptions = ActiveUserStateProviderFactory &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
SingleUserStateProviderInitOptions;
|
|
||||||
|
|
||||||
export async function activeUserStateProviderFactory(
|
|
||||||
cache: { activeUserStateProvider?: ActiveUserStateProvider } & CachedServices,
|
|
||||||
opts: ActiveUserStateProviderInitOptions,
|
|
||||||
): Promise<ActiveUserStateProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"activeUserStateProvider",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultActiveUserStateProvider(
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await singleUserStateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
import { ApiService as AbstractApiService } from "@bitwarden/common/abstractions/api.service";
|
|
||||||
import { ApiService } from "@bitwarden/common/services/api.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
tokenServiceFactory,
|
|
||||||
TokenServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/token-service.factory";
|
|
||||||
import {
|
|
||||||
vaultTimeoutSettingsServiceFactory,
|
|
||||||
VaultTimeoutSettingsServiceInitOptions,
|
|
||||||
} from "../../../background/service-factories/vault-timeout-settings-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../background/service-factories/factory-options";
|
|
||||||
|
|
||||||
import { AppIdServiceInitOptions, appIdServiceFactory } from "./app-id-service.factory";
|
|
||||||
import {
|
|
||||||
environmentServiceFactory,
|
|
||||||
EnvironmentServiceInitOptions,
|
|
||||||
} from "./environment-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "./platform-utils-service.factory";
|
|
||||||
|
|
||||||
type ApiServiceFactoryOptions = FactoryOptions & {
|
|
||||||
apiServiceOptions: {
|
|
||||||
logoutCallback: (expired: boolean) => Promise<void>;
|
|
||||||
customUserAgent?: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ApiServiceInitOptions = ApiServiceFactoryOptions &
|
|
||||||
TokenServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
EnvironmentServiceInitOptions &
|
|
||||||
AppIdServiceInitOptions &
|
|
||||||
VaultTimeoutSettingsServiceInitOptions;
|
|
||||||
|
|
||||||
export function apiServiceFactory(
|
|
||||||
cache: { apiService?: AbstractApiService } & CachedServices,
|
|
||||||
opts: ApiServiceInitOptions,
|
|
||||||
): Promise<AbstractApiService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"apiService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new ApiService(
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await environmentServiceFactory(cache, opts),
|
|
||||||
await appIdServiceFactory(cache, opts),
|
|
||||||
await vaultTimeoutSettingsServiceFactory(cache, opts),
|
|
||||||
opts.apiServiceOptions.logoutCallback,
|
|
||||||
opts.apiServiceOptions.customUserAgent,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import { AppIdService as AbstractAppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
|
||||||
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "./global-state-provider.factory";
|
|
||||||
|
|
||||||
type AppIdServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type AppIdServiceInitOptions = AppIdServiceFactoryOptions & GlobalStateProviderInitOptions;
|
|
||||||
|
|
||||||
export function appIdServiceFactory(
|
|
||||||
cache: { appIdService?: AbstractAppIdService } & CachedServices,
|
|
||||||
opts: AppIdServiceInitOptions,
|
|
||||||
): Promise<AbstractAppIdService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"appIdService",
|
|
||||||
opts,
|
|
||||||
async () => new AppIdService(await globalStateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { DefaultBillingAccountProfileStateService } from "@bitwarden/common/billing/services/account/billing-account-profile-state.service";
|
|
||||||
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import { StateProviderInitOptions, stateProviderFactory } from "./state-provider.factory";
|
|
||||||
|
|
||||||
type BillingAccountProfileStateServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type BillingAccountProfileStateServiceInitOptions =
|
|
||||||
BillingAccountProfileStateServiceFactoryOptions & StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function billingAccountProfileStateServiceFactory(
|
|
||||||
cache: {
|
|
||||||
billingAccountProfileStateService?: BillingAccountProfileStateService;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: BillingAccountProfileStateServiceInitOptions,
|
|
||||||
): Promise<BillingAccountProfileStateService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"billingAccountProfileStateService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultBillingAccountProfileStateService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import {
|
|
||||||
BiometricStateService,
|
|
||||||
DefaultBiometricStateService,
|
|
||||||
} from "@bitwarden/common/platform/biometrics/biometric-state.service";
|
|
||||||
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import { StateProviderInitOptions, stateProviderFactory } from "./state-provider.factory";
|
|
||||||
|
|
||||||
type BiometricStateServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type BiometricStateServiceInitOptions = BiometricStateServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function biometricStateServiceFactory(
|
|
||||||
cache: { biometricStateService?: BiometricStateService } & CachedServices,
|
|
||||||
opts: BiometricStateServiceInitOptions,
|
|
||||||
): Promise<BiometricStateService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"biometricStateService",
|
|
||||||
opts,
|
|
||||||
async () => new DefaultBiometricStateService(await stateProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../background/service-factories/log-service.factory";
|
|
||||||
import { BrowserScriptInjectorService } from "../../services/browser-script-injector.service";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "./platform-utils-service.factory";
|
|
||||||
|
|
||||||
type BrowserScriptInjectorServiceOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type BrowserScriptInjectorServiceInitOptions = BrowserScriptInjectorServiceOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function browserScriptInjectorServiceFactory(
|
|
||||||
cache: { browserScriptInjectorService?: BrowserScriptInjectorService } & CachedServices,
|
|
||||||
opts: BrowserScriptInjectorServiceInitOptions,
|
|
||||||
): Promise<BrowserScriptInjectorService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"browserScriptInjectorService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new BrowserScriptInjectorService(
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
import { ConfigApiServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config-api.service.abstraction";
|
|
||||||
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
tokenServiceFactory,
|
|
||||||
TokenServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/token-service.factory";
|
|
||||||
|
|
||||||
import { apiServiceFactory, ApiServiceInitOptions } from "./api-service.factory";
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
|
|
||||||
type ConfigApiServiceFactoyOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type ConfigApiServiceInitOptions = ConfigApiServiceFactoyOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
TokenServiceInitOptions;
|
|
||||||
|
|
||||||
export function configApiServiceFactory(
|
|
||||||
cache: { configApiService?: ConfigApiServiceAbstraction } & CachedServices,
|
|
||||||
opts: ConfigApiServiceInitOptions,
|
|
||||||
): Promise<ConfigApiServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"configApiService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new ConfigApiService(
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
|
|
||||||
|
|
||||||
import { configApiServiceFactory, ConfigApiServiceInitOptions } from "./config-api.service.factory";
|
|
||||||
import {
|
|
||||||
environmentServiceFactory,
|
|
||||||
EnvironmentServiceInitOptions,
|
|
||||||
} from "./environment-service.factory";
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
|
|
||||||
import { stateProviderFactory, StateProviderInitOptions } from "./state-provider.factory";
|
|
||||||
|
|
||||||
type ConfigServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type ConfigServiceInitOptions = ConfigServiceFactoryOptions &
|
|
||||||
ConfigApiServiceInitOptions &
|
|
||||||
EnvironmentServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function configServiceFactory(
|
|
||||||
cache: { configService?: ConfigService } & CachedServices,
|
|
||||||
opts: ConfigServiceInitOptions,
|
|
||||||
): Promise<ConfigService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"configService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultConfigService(
|
|
||||||
await configApiServiceFactory(cache, opts),
|
|
||||||
await environmentServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
|
||||||
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
|
||||||
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
|
|
||||||
type CryptoFunctionServiceFactoryOptions = FactoryOptions & {
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: Window | typeof globalThis;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CryptoFunctionServiceInitOptions = CryptoFunctionServiceFactoryOptions;
|
|
||||||
|
|
||||||
export function cryptoFunctionServiceFactory(
|
|
||||||
cache: { cryptoFunctionService?: CryptoFunctionService } & CachedServices,
|
|
||||||
opts: CryptoFunctionServiceFactoryOptions,
|
|
||||||
): Promise<CryptoFunctionService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"cryptoFunctionService",
|
|
||||||
opts,
|
|
||||||
() => new WebCryptoFunctionService(opts.cryptoFunctionServiceOptions.win),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
import { CryptoService as AbstractCryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
accountServiceFactory,
|
|
||||||
} from "../../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
KdfConfigServiceInitOptions,
|
|
||||||
kdfConfigServiceFactory,
|
|
||||||
} from "../../../auth/background/service-factories/kdf-config-service.factory";
|
|
||||||
import {
|
|
||||||
internalMasterPasswordServiceFactory,
|
|
||||||
MasterPasswordServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/master-password-service.factory";
|
|
||||||
import {
|
|
||||||
PinServiceInitOptions,
|
|
||||||
pinServiceFactory,
|
|
||||||
} from "../../../auth/background/service-factories/pin-service.factory";
|
|
||||||
import {
|
|
||||||
StateServiceInitOptions,
|
|
||||||
stateServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../background/service-factories/log-service.factory";
|
|
||||||
import { BrowserCryptoService } from "../../services/browser-crypto.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
BiometricStateServiceInitOptions,
|
|
||||||
biometricStateServiceFactory,
|
|
||||||
} from "./biometric-state-service.factory";
|
|
||||||
import {
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
} from "./crypto-function-service.factory";
|
|
||||||
import { encryptServiceFactory, EncryptServiceInitOptions } from "./encrypt-service.factory";
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "./key-generation-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "./platform-utils-service.factory";
|
|
||||||
import { StateProviderInitOptions, stateProviderFactory } from "./state-provider.factory";
|
|
||||||
|
|
||||||
type CryptoServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type CryptoServiceInitOptions = CryptoServiceFactoryOptions &
|
|
||||||
PinServiceInitOptions &
|
|
||||||
MasterPasswordServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
CryptoFunctionServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
BiometricStateServiceInitOptions &
|
|
||||||
KdfConfigServiceInitOptions;
|
|
||||||
|
|
||||||
export function cryptoServiceFactory(
|
|
||||||
cache: { cryptoService?: AbstractCryptoService } & CachedServices,
|
|
||||||
opts: CryptoServiceInitOptions,
|
|
||||||
): Promise<AbstractCryptoService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"cryptoService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new BrowserCryptoService(
|
|
||||||
await pinServiceFactory(cache, opts),
|
|
||||||
await internalMasterPasswordServiceFactory(cache, opts),
|
|
||||||
await keyGenerationServiceFactory(cache, opts),
|
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await biometricStateServiceFactory(cache, opts),
|
|
||||||
await kdfConfigServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
import { DerivedStateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- For dependency creation
|
|
||||||
import { InlineDerivedStateProvider } from "@bitwarden/common/platform/state/implementations/inline-derived-state";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
|
|
||||||
type DerivedStateProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type DerivedStateProviderInitOptions = DerivedStateProviderFactoryOptions;
|
|
||||||
|
|
||||||
export async function derivedStateProviderFactory(
|
|
||||||
cache: { derivedStateProvider?: DerivedStateProvider } & CachedServices,
|
|
||||||
opts: DerivedStateProviderInitOptions,
|
|
||||||
): Promise<DerivedStateProvider> {
|
|
||||||
return factory(cache, "derivedStateProvider", opts, async () => new InlineDerivedStateProvider());
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
import { EncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/encrypt.service.implementation";
|
|
||||||
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../background/service-factories/log-service.factory";
|
|
||||||
|
|
||||||
import {
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
} from "./crypto-function-service.factory";
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
|
|
||||||
type EncryptServiceFactoryOptions = FactoryOptions & {
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: boolean;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type EncryptServiceInitOptions = EncryptServiceFactoryOptions &
|
|
||||||
CryptoFunctionServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function encryptServiceFactory(
|
|
||||||
cache: { encryptService?: EncryptServiceImplementation } & CachedServices,
|
|
||||||
opts: EncryptServiceInitOptions,
|
|
||||||
): Promise<EncryptServiceImplementation> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"encryptService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new EncryptServiceImplementation(
|
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
opts.encryptServiceOptions.logMacFailures,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
import {
|
|
||||||
accountServiceFactory,
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/account-service.factory";
|
|
||||||
import { BrowserEnvironmentService } from "../../services/browser-environment.service";
|
|
||||||
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
|
|
||||||
import { stateProviderFactory, StateProviderInitOptions } from "./state-provider.factory";
|
|
||||||
|
|
||||||
type EnvironmentServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type EnvironmentServiceInitOptions = EnvironmentServiceFactoryOptions &
|
|
||||||
StateProviderInitOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function environmentServiceFactory(
|
|
||||||
cache: { environmentService?: BrowserEnvironmentService } & CachedServices,
|
|
||||||
opts: EnvironmentServiceInitOptions,
|
|
||||||
): Promise<BrowserEnvironmentService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"environmentService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new BrowserEnvironmentService(
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
export type CachedServices = Record<string, unknown>;
|
|
||||||
|
|
||||||
export type FactoryOptions = {
|
|
||||||
alwaysInitializeNewService?: boolean;
|
|
||||||
doNotStoreInitializedService?: boolean;
|
|
||||||
[optionsKey: string]: unknown;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function factory<
|
|
||||||
TCache extends CachedServices,
|
|
||||||
TName extends keyof TCache,
|
|
||||||
TOpts extends FactoryOptions,
|
|
||||||
>(
|
|
||||||
cachedServices: TCache,
|
|
||||||
name: TName,
|
|
||||||
opts: TOpts,
|
|
||||||
factory: () => TCache[TName] | Promise<TCache[TName]>,
|
|
||||||
): Promise<TCache[TName]> {
|
|
||||||
let instance = cachedServices[name];
|
|
||||||
if (opts.alwaysInitializeNewService || !instance) {
|
|
||||||
const instanceOrPromise = factory();
|
|
||||||
instance = instanceOrPromise instanceof Promise ? await instanceOrPromise : instanceOrPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!opts.doNotStoreInitializedService) {
|
|
||||||
cachedServices[name] = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance as TCache[TName];
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/platform/abstractions/file-upload/file-upload.service";
|
|
||||||
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../background/service-factories/factory-options";
|
|
||||||
|
|
||||||
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
|
|
||||||
|
|
||||||
type FileUploadServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type FileUploadServiceInitOptions = FileUploadServiceFactoryOptions & LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function fileUploadServiceFactory(
|
|
||||||
cache: { fileUploadService?: FileUploadServiceAbstraction } & CachedServices,
|
|
||||||
opts: FileUploadServiceInitOptions,
|
|
||||||
): Promise<FileUploadServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"fileUploadService",
|
|
||||||
opts,
|
|
||||||
async () => new FileUploadService(await logServiceFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
|
||||||
import { DefaultGlobalStateProvider } from "@bitwarden/common/platform/state/implementations/default-global-state.provider";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
StorageServiceProviderInitOptions,
|
|
||||||
storageServiceProviderFactory,
|
|
||||||
} from "./storage-service-provider.factory";
|
|
||||||
|
|
||||||
type GlobalStateProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type GlobalStateProviderInitOptions = GlobalStateProviderFactoryOptions &
|
|
||||||
StorageServiceProviderInitOptions;
|
|
||||||
|
|
||||||
export async function globalStateProviderFactory(
|
|
||||||
cache: { globalStateProvider?: GlobalStateProvider } & CachedServices,
|
|
||||||
opts: GlobalStateProviderInitOptions,
|
|
||||||
): Promise<GlobalStateProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"globalStateProvider",
|
|
||||||
opts,
|
|
||||||
async () => new DefaultGlobalStateProvider(await storageServiceProviderFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { I18nService as AbstractI18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
||||||
import { I18nService as BaseI18nService } from "@bitwarden/common/platform/services/i18n.service";
|
|
||||||
|
|
||||||
import I18nService from "../../services/i18n.service";
|
|
||||||
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "./global-state-provider.factory";
|
|
||||||
|
|
||||||
type I18nServiceFactoryOptions = FactoryOptions & {
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type I18nServiceInitOptions = I18nServiceFactoryOptions & GlobalStateProviderInitOptions;
|
|
||||||
|
|
||||||
export async function i18nServiceFactory(
|
|
||||||
cache: { i18nService?: AbstractI18nService } & CachedServices,
|
|
||||||
opts: I18nServiceInitOptions,
|
|
||||||
): Promise<AbstractI18nService> {
|
|
||||||
const service = await factory(
|
|
||||||
cache,
|
|
||||||
"i18nService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new I18nService(
|
|
||||||
opts.i18nServiceOptions.systemLanguage,
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!(service as BaseI18nService as any).inited) {
|
|
||||||
await (service as BaseI18nService).init();
|
|
||||||
}
|
|
||||||
return service;
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { KeyGenerationService as KeyGenerationServiceAbstraction } from "@bitwarden/common/platform/abstractions/key-generation.service";
|
|
||||||
import { KeyGenerationService } from "@bitwarden/common/platform/services/key-generation.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
} from "./crypto-function-service.factory";
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
|
|
||||||
type KeyGenerationServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type KeyGenerationServiceInitOptions = KeyGenerationServiceFactoryOptions &
|
|
||||||
CryptoFunctionServiceInitOptions;
|
|
||||||
|
|
||||||
export function keyGenerationServiceFactory(
|
|
||||||
cache: { keyGenerationService?: KeyGenerationServiceAbstraction } & CachedServices,
|
|
||||||
opts: KeyGenerationServiceInitOptions,
|
|
||||||
): Promise<KeyGenerationServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"keyGenerationService",
|
|
||||||
opts,
|
|
||||||
async () => new KeyGenerationService(await cryptoFunctionServiceFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { LogLevelType } from "@bitwarden/common/platform/enums/log-level-type.enum";
|
|
||||||
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
|
|
||||||
|
|
||||||
import { FactoryOptions, CachedServices, factory } from "./factory-options";
|
|
||||||
|
|
||||||
type LogServiceFactoryOptions = FactoryOptions & {
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: boolean;
|
|
||||||
filter?: (level: LogLevelType) => boolean;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type LogServiceInitOptions = LogServiceFactoryOptions;
|
|
||||||
|
|
||||||
export function logServiceFactory(
|
|
||||||
cache: { logService?: LogService } & CachedServices,
|
|
||||||
opts: LogServiceInitOptions,
|
|
||||||
): Promise<LogService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"logService",
|
|
||||||
opts,
|
|
||||||
() => new ConsoleLogService(opts.logServiceOptions.isDev, opts.logServiceOptions.filter),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
import { MessageSender } from "@bitwarden/common/platform/messaging";
|
|
||||||
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
|
|
||||||
type MessagingServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type MessageSenderInitOptions = MessagingServiceFactoryOptions;
|
|
||||||
|
|
||||||
export function messageSenderFactory(
|
|
||||||
cache: { messagingService?: MessageSender } & CachedServices,
|
|
||||||
opts: MessageSenderInitOptions,
|
|
||||||
): Promise<MessageSender> {
|
|
||||||
// NOTE: Name needs to match that of MainBackground property until we delete these.
|
|
||||||
return factory(cache, "messagingService", opts, () => {
|
|
||||||
throw new Error("Not implemented, not expected to be used.");
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
// Export old messaging service stuff to minimize changes
|
|
||||||
export {
|
|
||||||
messageSenderFactory as messagingServiceFactory,
|
|
||||||
MessageSenderInitOptions as MessagingServiceInitOptions,
|
|
||||||
} from "./message-sender.factory";
|
|
@ -1,34 +0,0 @@
|
|||||||
import { ClientType } from "@bitwarden/common/enums";
|
|
||||||
import { MigrationBuilderService } from "@bitwarden/common/platform/services/migration-builder.service";
|
|
||||||
import { MigrationRunner } from "@bitwarden/common/platform/services/migration-runner";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import { LogServiceInitOptions, logServiceFactory } from "./log-service.factory";
|
|
||||||
import {
|
|
||||||
DiskStorageServiceInitOptions,
|
|
||||||
diskStorageServiceFactory,
|
|
||||||
} from "./storage-service.factory";
|
|
||||||
|
|
||||||
type MigrationRunnerFactory = FactoryOptions;
|
|
||||||
|
|
||||||
export type MigrationRunnerInitOptions = MigrationRunnerFactory &
|
|
||||||
DiskStorageServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export async function migrationRunnerFactory(
|
|
||||||
cache: { migrationRunner?: MigrationRunner } & CachedServices,
|
|
||||||
opts: MigrationRunnerInitOptions,
|
|
||||||
): Promise<MigrationRunner> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"migrationRunner",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new MigrationRunner(
|
|
||||||
await diskStorageServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
new MigrationBuilderService(),
|
|
||||||
ClientType.Browser,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
|
|
||||||
import { BackgroundPlatformUtilsService } from "../../services/platform-utils/background-platform-utils.service";
|
|
||||||
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
import { MessagingServiceInitOptions, messagingServiceFactory } from "./messaging-service.factory";
|
|
||||||
|
|
||||||
type PlatformUtilsServiceFactoryOptions = FactoryOptions & {
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
clipboardWriteCallback: (clipboardValue: string, clearMs: number) => Promise<void>;
|
|
||||||
biometricCallback: () => Promise<boolean>;
|
|
||||||
win: Window & typeof globalThis;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PlatformUtilsServiceInitOptions = PlatformUtilsServiceFactoryOptions &
|
|
||||||
MessagingServiceInitOptions;
|
|
||||||
|
|
||||||
export function platformUtilsServiceFactory(
|
|
||||||
cache: { platformUtilsService?: PlatformUtilsService } & CachedServices,
|
|
||||||
opts: PlatformUtilsServiceInitOptions,
|
|
||||||
): Promise<PlatformUtilsService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"platformUtilsService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new BackgroundPlatformUtilsService(
|
|
||||||
await messagingServiceFactory(cache, opts),
|
|
||||||
opts.platformUtilsServiceOptions.clipboardWriteCallback,
|
|
||||||
opts.platformUtilsServiceOptions.biometricCallback,
|
|
||||||
opts.platformUtilsServiceOptions.win,
|
|
||||||
null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
import { SingleUserStateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
|
||||||
import { DefaultSingleUserStateProvider } from "@bitwarden/common/platform/state/implementations/default-single-user-state.provider";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
StateEventRegistrarServiceInitOptions,
|
|
||||||
stateEventRegistrarServiceFactory,
|
|
||||||
} from "./state-event-registrar-service.factory";
|
|
||||||
import {
|
|
||||||
StorageServiceProviderInitOptions,
|
|
||||||
storageServiceProviderFactory,
|
|
||||||
} from "./storage-service-provider.factory";
|
|
||||||
|
|
||||||
type SingleUserStateProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SingleUserStateProviderInitOptions = SingleUserStateProviderFactoryOptions &
|
|
||||||
StorageServiceProviderInitOptions &
|
|
||||||
StateEventRegistrarServiceInitOptions;
|
|
||||||
|
|
||||||
export async function singleUserStateProviderFactory(
|
|
||||||
cache: { singleUserStateProvider?: SingleUserStateProvider } & CachedServices,
|
|
||||||
opts: SingleUserStateProviderInitOptions,
|
|
||||||
): Promise<SingleUserStateProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"singleUserStateProvider",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultSingleUserStateProvider(
|
|
||||||
await storageServiceProviderFactory(cache, opts),
|
|
||||||
await stateEventRegistrarServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
// eslint-disable-next-line import/no-restricted-paths
|
|
||||||
import { StateEventRegistrarService } from "@bitwarden/common/platform/state/state-event-registrar.service";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "./global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
StorageServiceProviderInitOptions,
|
|
||||||
storageServiceProviderFactory,
|
|
||||||
} from "./storage-service-provider.factory";
|
|
||||||
|
|
||||||
type StateEventRegistrarServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type StateEventRegistrarServiceInitOptions = StateEventRegistrarServiceFactoryOptions &
|
|
||||||
GlobalStateProviderInitOptions &
|
|
||||||
StorageServiceProviderInitOptions;
|
|
||||||
|
|
||||||
export async function stateEventRegistrarServiceFactory(
|
|
||||||
cache: {
|
|
||||||
stateEventRegistrarService?: StateEventRegistrarService;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: StateEventRegistrarServiceInitOptions,
|
|
||||||
): Promise<StateEventRegistrarService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"stateEventRegistrarService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new StateEventRegistrarService(
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
await storageServiceProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
import { StateEventRunnerService } from "@bitwarden/common/platform/state";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "./global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
StorageServiceProviderInitOptions,
|
|
||||||
storageServiceProviderFactory,
|
|
||||||
} from "./storage-service-provider.factory";
|
|
||||||
|
|
||||||
type StateEventRunnerServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type StateEventRunnerServiceInitOptions = StateEventRunnerServiceFactoryOptions &
|
|
||||||
GlobalStateProviderInitOptions &
|
|
||||||
StorageServiceProviderInitOptions;
|
|
||||||
|
|
||||||
export function stateEventRunnerServiceFactory(
|
|
||||||
cache: { stateEventRunnerService?: StateEventRunnerService } & CachedServices,
|
|
||||||
opts: StateEventRunnerServiceInitOptions,
|
|
||||||
): Promise<StateEventRunnerService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"stateEventRunnerService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new StateEventRunnerService(
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
await storageServiceProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
|
||||||
// eslint-disable-next-line import/no-restricted-paths -- We need the implementation to inject, but generally this should not be accessed
|
|
||||||
import { DefaultStateProvider } from "@bitwarden/common/platform/state/implementations/default-state.provider";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ActiveUserStateProviderInitOptions,
|
|
||||||
activeUserStateProviderFactory,
|
|
||||||
} from "./active-user-state-provider.factory";
|
|
||||||
import {
|
|
||||||
DerivedStateProviderInitOptions,
|
|
||||||
derivedStateProviderFactory,
|
|
||||||
} from "./derived-state-provider.factory";
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
GlobalStateProviderInitOptions,
|
|
||||||
globalStateProviderFactory,
|
|
||||||
} from "./global-state-provider.factory";
|
|
||||||
import {
|
|
||||||
SingleUserStateProviderInitOptions,
|
|
||||||
singleUserStateProviderFactory,
|
|
||||||
} from "./single-user-state-provider.factory";
|
|
||||||
|
|
||||||
type StateProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type StateProviderInitOptions = StateProviderFactoryOptions &
|
|
||||||
GlobalStateProviderInitOptions &
|
|
||||||
ActiveUserStateProviderInitOptions &
|
|
||||||
SingleUserStateProviderInitOptions &
|
|
||||||
DerivedStateProviderInitOptions;
|
|
||||||
|
|
||||||
export async function stateProviderFactory(
|
|
||||||
cache: { stateProvider?: StateProvider } & CachedServices,
|
|
||||||
opts: StateProviderInitOptions,
|
|
||||||
): Promise<StateProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"stateProvider",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultStateProvider(
|
|
||||||
await activeUserStateProviderFactory(cache, opts),
|
|
||||||
await singleUserStateProviderFactory(cache, opts),
|
|
||||||
await globalStateProviderFactory(cache, opts),
|
|
||||||
await derivedStateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
|
|
||||||
import {
|
|
||||||
accountServiceFactory,
|
|
||||||
AccountServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/account-service.factory";
|
|
||||||
import {
|
|
||||||
tokenServiceFactory,
|
|
||||||
TokenServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/token-service.factory";
|
|
||||||
import { Account } from "../../../models/account";
|
|
||||||
import { DefaultBrowserStateService } from "../../services/default-browser-state.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
environmentServiceFactory,
|
|
||||||
EnvironmentServiceInitOptions,
|
|
||||||
} from "./environment-service.factory";
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
|
|
||||||
import { migrationRunnerFactory, MigrationRunnerInitOptions } from "./migration-runner.factory";
|
|
||||||
import {
|
|
||||||
diskStorageServiceFactory,
|
|
||||||
secureStorageServiceFactory,
|
|
||||||
memoryStorageServiceFactory,
|
|
||||||
DiskStorageServiceInitOptions,
|
|
||||||
SecureStorageServiceInitOptions,
|
|
||||||
MemoryStorageServiceInitOptions,
|
|
||||||
} from "./storage-service.factory";
|
|
||||||
|
|
||||||
type StateServiceFactoryOptions = FactoryOptions & {
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: StateFactory<GlobalState, Account>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type StateServiceInitOptions = StateServiceFactoryOptions &
|
|
||||||
DiskStorageServiceInitOptions &
|
|
||||||
SecureStorageServiceInitOptions &
|
|
||||||
MemoryStorageServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
AccountServiceInitOptions &
|
|
||||||
EnvironmentServiceInitOptions &
|
|
||||||
TokenServiceInitOptions &
|
|
||||||
MigrationRunnerInitOptions;
|
|
||||||
|
|
||||||
export async function stateServiceFactory(
|
|
||||||
cache: { stateService?: DefaultBrowserStateService } & CachedServices,
|
|
||||||
opts: StateServiceInitOptions,
|
|
||||||
): Promise<DefaultBrowserStateService> {
|
|
||||||
const service = await factory(
|
|
||||||
cache,
|
|
||||||
"stateService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new DefaultBrowserStateService(
|
|
||||||
await diskStorageServiceFactory(cache, opts),
|
|
||||||
await secureStorageServiceFactory(cache, opts),
|
|
||||||
await memoryStorageServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
opts.stateServiceOptions.stateFactory,
|
|
||||||
await accountServiceFactory(cache, opts),
|
|
||||||
await environmentServiceFactory(cache, opts),
|
|
||||||
await tokenServiceFactory(cache, opts),
|
|
||||||
await migrationRunnerFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// TODO: If we run migration through a chrome installed/updated event we can turn off running migrations
|
|
||||||
await service.init();
|
|
||||||
return service;
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
import { StorageServiceProvider } from "@bitwarden/common/platform/services/storage-service.provider";
|
|
||||||
|
|
||||||
import { CachedServices, FactoryOptions, factory } from "./factory-options";
|
|
||||||
import {
|
|
||||||
DiskStorageServiceInitOptions,
|
|
||||||
MemoryStorageServiceInitOptions,
|
|
||||||
observableDiskStorageServiceFactory,
|
|
||||||
observableMemoryStorageServiceFactory,
|
|
||||||
} from "./storage-service.factory";
|
|
||||||
|
|
||||||
type StorageServiceProviderFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type StorageServiceProviderInitOptions = StorageServiceProviderFactoryOptions &
|
|
||||||
MemoryStorageServiceInitOptions &
|
|
||||||
DiskStorageServiceInitOptions;
|
|
||||||
|
|
||||||
export async function storageServiceProviderFactory(
|
|
||||||
cache: {
|
|
||||||
storageServiceProvider?: StorageServiceProvider;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: StorageServiceProviderInitOptions,
|
|
||||||
): Promise<StorageServiceProvider> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"storageServiceProvider",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new StorageServiceProvider(
|
|
||||||
await observableDiskStorageServiceFactory(cache, opts),
|
|
||||||
await observableMemoryStorageServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
import {
|
|
||||||
AbstractStorageService,
|
|
||||||
ObservableStorageService,
|
|
||||||
} from "@bitwarden/common/platform/abstractions/storage.service";
|
|
||||||
import { Lazy } from "@bitwarden/common/platform/misc/lazy";
|
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
|
||||||
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
|
|
||||||
|
|
||||||
import { BrowserApi } from "../../browser/browser-api";
|
|
||||||
import BrowserLocalStorageService from "../../services/browser-local-storage.service";
|
|
||||||
import BrowserMemoryStorageService from "../../services/browser-memory-storage.service";
|
|
||||||
import { LocalBackedSessionStorageService } from "../../services/local-backed-session-storage.service";
|
|
||||||
import { BackgroundMemoryStorageService } from "../../storage/background-memory-storage.service";
|
|
||||||
|
|
||||||
import { EncryptServiceInitOptions, encryptServiceFactory } from "./encrypt-service.factory";
|
|
||||||
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
||||||
import {
|
|
||||||
KeyGenerationServiceInitOptions,
|
|
||||||
keyGenerationServiceFactory,
|
|
||||||
} from "./key-generation-service.factory";
|
|
||||||
import { LogServiceInitOptions, logServiceFactory } from "./log-service.factory";
|
|
||||||
import {
|
|
||||||
PlatformUtilsServiceInitOptions,
|
|
||||||
platformUtilsServiceFactory,
|
|
||||||
} from "./platform-utils-service.factory";
|
|
||||||
|
|
||||||
export type DiskStorageServiceInitOptions = FactoryOptions;
|
|
||||||
export type SecureStorageServiceInitOptions = FactoryOptions;
|
|
||||||
export type SessionStorageServiceInitOptions = FactoryOptions;
|
|
||||||
export type MemoryStorageServiceInitOptions = FactoryOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
KeyGenerationServiceInitOptions &
|
|
||||||
DiskStorageServiceInitOptions &
|
|
||||||
SessionStorageServiceInitOptions &
|
|
||||||
LogServiceInitOptions &
|
|
||||||
PlatformUtilsServiceInitOptions;
|
|
||||||
|
|
||||||
export function diskStorageServiceFactory(
|
|
||||||
cache: { diskStorageService?: AbstractStorageService } & CachedServices,
|
|
||||||
opts: DiskStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService> {
|
|
||||||
return factory(cache, "diskStorageService", opts, () => new BrowserLocalStorageService());
|
|
||||||
}
|
|
||||||
export function observableDiskStorageServiceFactory(
|
|
||||||
cache: {
|
|
||||||
diskStorageService?: AbstractStorageService & ObservableStorageService;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: DiskStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService & ObservableStorageService> {
|
|
||||||
return factory(cache, "diskStorageService", opts, () => new BrowserLocalStorageService());
|
|
||||||
}
|
|
||||||
|
|
||||||
export function secureStorageServiceFactory(
|
|
||||||
cache: { secureStorageService?: AbstractStorageService } & CachedServices,
|
|
||||||
opts: SecureStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService> {
|
|
||||||
return factory(cache, "secureStorageService", opts, () => new BrowserLocalStorageService());
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sessionStorageServiceFactory(
|
|
||||||
cache: { sessionStorageService?: AbstractStorageService } & CachedServices,
|
|
||||||
opts: SessionStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService> {
|
|
||||||
return factory(cache, "sessionStorageService", opts, () => new BrowserMemoryStorageService());
|
|
||||||
}
|
|
||||||
|
|
||||||
export function memoryStorageServiceFactory(
|
|
||||||
cache: { memoryStorageService?: AbstractStorageService } & CachedServices,
|
|
||||||
opts: MemoryStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService> {
|
|
||||||
return factory(cache, "memoryStorageService", opts, async () => {
|
|
||||||
if (BrowserApi.isManifestVersion(3)) {
|
|
||||||
return new LocalBackedSessionStorageService(
|
|
||||||
new Lazy(async () => {
|
|
||||||
const existingKey = await (
|
|
||||||
await sessionStorageServiceFactory(cache, opts)
|
|
||||||
).get<SymmetricCryptoKey>("session-key");
|
|
||||||
if (existingKey) {
|
|
||||||
return existingKey;
|
|
||||||
}
|
|
||||||
const { derivedKey } = await (
|
|
||||||
await keyGenerationServiceFactory(cache, opts)
|
|
||||||
).createKeyWithPurpose(128, "ephemeral", "bitwarden-ephemeral");
|
|
||||||
await (await sessionStorageServiceFactory(cache, opts)).save("session-key", derivedKey);
|
|
||||||
return derivedKey;
|
|
||||||
}),
|
|
||||||
await diskStorageServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await platformUtilsServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new MemoryStorageService();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function observableMemoryStorageServiceFactory(
|
|
||||||
cache: {
|
|
||||||
memoryStorageService?: AbstractStorageService & ObservableStorageService;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: MemoryStorageServiceInitOptions,
|
|
||||||
): Promise<AbstractStorageService & ObservableStorageService> {
|
|
||||||
return factory(cache, "memoryStorageService", opts, async () => {
|
|
||||||
return new BackgroundMemoryStorageService();
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
import { combine } from "./combine";
|
|
||||||
|
|
||||||
describe("combine", () => {
|
|
||||||
it("runs", async () => {
|
|
||||||
const combined = combine([
|
|
||||||
(arg: Record<string, unknown>, serviceCache: Record<string, unknown>) => {
|
|
||||||
arg["one"] = true;
|
|
||||||
serviceCache["one"] = true;
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
(arg: Record<string, unknown>, serviceCache: Record<string, unknown>) => {
|
|
||||||
if (serviceCache["one"] !== true) {
|
|
||||||
throw new Error("One should have ran.");
|
|
||||||
}
|
|
||||||
arg["two"] = true;
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const arg: Record<string, unknown> = {};
|
|
||||||
await combined(arg);
|
|
||||||
|
|
||||||
expect(arg["one"]).toBeTruthy();
|
|
||||||
|
|
||||||
expect(arg["two"]).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,15 +0,0 @@
|
|||||||
import { CachedServices } from "../background/service-factories/factory-options";
|
|
||||||
|
|
||||||
type Listener<T extends unknown[]> = (...args: [...T, CachedServices]) => Promise<void>;
|
|
||||||
|
|
||||||
export const combine = <T extends unknown[]>(
|
|
||||||
listeners: Listener<T>[],
|
|
||||||
startingServices: CachedServices = {},
|
|
||||||
) => {
|
|
||||||
return async (...args: T) => {
|
|
||||||
const cachedServices = { ...startingServices };
|
|
||||||
for (const listener of listeners) {
|
|
||||||
await listener(...[...args, cachedServices]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,49 +0,0 @@
|
|||||||
import { CipherContextMenuHandler } from "../../autofill/browser/cipher-context-menu-handler";
|
|
||||||
import { ContextMenuClickedHandler } from "../../autofill/browser/context-menu-clicked-handler";
|
|
||||||
|
|
||||||
import { combine } from "./combine";
|
|
||||||
import { onCommandListener } from "./on-command-listener";
|
|
||||||
import { onInstallListener } from "./on-install-listener";
|
|
||||||
import { UpdateBadge } from "./update-badge";
|
|
||||||
|
|
||||||
const windowsOnFocusChangedListener = combine([
|
|
||||||
UpdateBadge.windowsOnFocusChangedListener,
|
|
||||||
CipherContextMenuHandler.windowsOnFocusChangedListener,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const tabsOnActivatedListener = combine([
|
|
||||||
UpdateBadge.tabsOnActivatedListener,
|
|
||||||
CipherContextMenuHandler.tabsOnActivatedListener,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const tabsOnReplacedListener = combine([
|
|
||||||
UpdateBadge.tabsOnReplacedListener,
|
|
||||||
CipherContextMenuHandler.tabsOnReplacedListener,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const tabsOnUpdatedListener = combine([
|
|
||||||
UpdateBadge.tabsOnUpdatedListener,
|
|
||||||
CipherContextMenuHandler.tabsOnUpdatedListener,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const contextMenusClickedListener = ContextMenuClickedHandler.onClickedListener;
|
|
||||||
|
|
||||||
// TODO: All message listeners should be RuntimeMessage in Notifications follow up then this type annotation can be inferred
|
|
||||||
const runtimeMessageListener = combine<
|
|
||||||
[message: { command: string }, sender: chrome.runtime.MessageSender]
|
|
||||||
>([
|
|
||||||
UpdateBadge.messageListener,
|
|
||||||
CipherContextMenuHandler.messageListener,
|
|
||||||
ContextMenuClickedHandler.messageListener,
|
|
||||||
]);
|
|
||||||
|
|
||||||
export {
|
|
||||||
windowsOnFocusChangedListener,
|
|
||||||
tabsOnActivatedListener,
|
|
||||||
tabsOnReplacedListener,
|
|
||||||
tabsOnUpdatedListener,
|
|
||||||
contextMenusClickedListener,
|
|
||||||
runtimeMessageListener,
|
|
||||||
onCommandListener,
|
|
||||||
onInstallListener,
|
|
||||||
};
|
|
@ -1,109 +0,0 @@
|
|||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
|
|
||||||
import { authServiceFactory } from "../../auth/background/service-factories/auth-service.factory";
|
|
||||||
import { autofillServiceFactory } from "../../autofill/background/service_factories/autofill-service.factory";
|
|
||||||
import { autofillSettingsServiceFactory } from "../../autofill/background/service_factories/autofill-settings-service.factory";
|
|
||||||
import { GeneratePasswordToClipboardCommand } from "../../autofill/clipboard";
|
|
||||||
import { AutofillTabCommand } from "../../autofill/commands/autofill-tab-command";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import {
|
|
||||||
passwordGenerationServiceFactory,
|
|
||||||
PasswordGenerationServiceInitOptions,
|
|
||||||
} from "../../tools/background/service_factories/password-generation-service.factory";
|
|
||||||
import { CachedServices } from "../background/service-factories/factory-options";
|
|
||||||
import { logServiceFactory } from "../background/service-factories/log-service.factory";
|
|
||||||
import { BrowserApi } from "../browser/browser-api";
|
|
||||||
|
|
||||||
export const onCommandListener = async (command: string, tab: chrome.tabs.Tab) => {
|
|
||||||
switch (command) {
|
|
||||||
case "autofill_login":
|
|
||||||
await doAutoFillLogin(tab);
|
|
||||||
break;
|
|
||||||
case "generate_password":
|
|
||||||
await doGeneratePasswordToClipboard(tab);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const doAutoFillLogin = async (tab: chrome.tabs.Tab): Promise<void> => {
|
|
||||||
const cachedServices: CachedServices = {};
|
|
||||||
const opts = {
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: true,
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
clipboardWriteCallback: () => Promise.resolve(),
|
|
||||||
biometricCallback: () => Promise.resolve(false),
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: new StateFactory(GlobalState, Account),
|
|
||||||
},
|
|
||||||
apiServiceOptions: {
|
|
||||||
logoutCallback: () => Promise.resolve(),
|
|
||||||
},
|
|
||||||
keyConnectorServiceOptions: {
|
|
||||||
logoutCallback: () => Promise.resolve(),
|
|
||||||
},
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: BrowserApi.getUILanguage(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const logService = await logServiceFactory(cachedServices, opts);
|
|
||||||
const authService = await authServiceFactory(cachedServices, opts);
|
|
||||||
const autofillService = await autofillServiceFactory(cachedServices, opts);
|
|
||||||
|
|
||||||
const authStatus = await authService.getAuthStatus();
|
|
||||||
if (authStatus < AuthenticationStatus.Unlocked) {
|
|
||||||
// TODO: Add back in unlock on autofill
|
|
||||||
logService.info("Currently not unlocked, MV3 does not support unlock on autofill currently.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const command = new AutofillTabCommand(autofillService);
|
|
||||||
await command.doAutofillTabCommand(tab);
|
|
||||||
};
|
|
||||||
|
|
||||||
const doGeneratePasswordToClipboard = async (tab: chrome.tabs.Tab): Promise<void> => {
|
|
||||||
const stateFactory = new StateFactory(GlobalState, Account);
|
|
||||||
|
|
||||||
const cache = {};
|
|
||||||
const options: PasswordGenerationServiceInitOptions = {
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: false,
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
biometricCallback: () => Promise.resolve(true),
|
|
||||||
clipboardWriteCallback: () => Promise.resolve(),
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: stateFactory,
|
|
||||||
},
|
|
||||||
autofillSettingsServiceOptions: {
|
|
||||||
stateFactory: autofillSettingsServiceFactory,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const command = new GeneratePasswordToClipboardCommand(
|
|
||||||
await passwordGenerationServiceFactory(cache, options),
|
|
||||||
await autofillSettingsServiceFactory(cache, options),
|
|
||||||
);
|
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
command.generatePasswordToClipboard(tab);
|
|
||||||
};
|
|
@ -1,45 +0,0 @@
|
|||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import {
|
|
||||||
EnvironmentServiceInitOptions,
|
|
||||||
environmentServiceFactory,
|
|
||||||
} from "../background/service-factories/environment-service.factory";
|
|
||||||
import { BrowserApi } from "../browser/browser-api";
|
|
||||||
|
|
||||||
export async function onInstallListener(details: chrome.runtime.InstalledDetails) {
|
|
||||||
const cache = {};
|
|
||||||
const opts: EnvironmentServiceInitOptions = {
|
|
||||||
encryptServiceOptions: {
|
|
||||||
logMacFailures: false,
|
|
||||||
},
|
|
||||||
cryptoFunctionServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
logServiceOptions: {
|
|
||||||
isDev: false,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: new StateFactory(GlobalState, Account),
|
|
||||||
},
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
win: self,
|
|
||||||
biometricCallback: async () => false,
|
|
||||||
clipboardWriteCallback: async () => {},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const environmentService = await environmentServiceFactory(cache, opts);
|
|
||||||
|
|
||||||
setTimeout(async () => {
|
|
||||||
if (details.reason != null && details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
BrowserApi.createNewTab("https://bitwarden.com/browser-start/");
|
|
||||||
|
|
||||||
if (await environmentService.hasManagedEnvironment()) {
|
|
||||||
await environmentService.setUrlsToManagedEnvironment();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
@ -2,20 +2,12 @@ import { firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
import { BadgeSettingsService } from "@bitwarden/common/autofill/services/badge-settings.service";
|
import { BadgeSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/badge-settings.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
|
||||||
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
|
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
|
|
||||||
import { authServiceFactory } from "../../auth/background/service-factories/auth-service.factory";
|
import MainBackground from "../../background/main.background";
|
||||||
import { badgeSettingsServiceFactory } from "../../autofill/background/service_factories/badge-settings-service.factory";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import IconDetails from "../../vault/background/models/icon-details";
|
import IconDetails from "../../vault/background/models/icon-details";
|
||||||
import { cipherServiceFactory } from "../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import { BrowserApi } from "../browser/browser-api";
|
import { BrowserApi } from "../browser/browser-api";
|
||||||
import { BrowserPlatformUtilsService } from "../services/platform-utils/browser-platform-utils.service";
|
import { BrowserPlatformUtilsService } from "../services/platform-utils/browser-platform-utils.service";
|
||||||
|
|
||||||
@ -26,87 +18,23 @@ export type BadgeOptions = {
|
|||||||
|
|
||||||
export class UpdateBadge {
|
export class UpdateBadge {
|
||||||
private authService: AuthService;
|
private authService: AuthService;
|
||||||
private badgeSettingsService: BadgeSettingsService;
|
private badgeSettingsService: BadgeSettingsServiceAbstraction;
|
||||||
private cipherService: CipherService;
|
private cipherService: CipherService;
|
||||||
private badgeAction: typeof chrome.action | typeof chrome.browserAction;
|
private badgeAction: typeof chrome.action | typeof chrome.browserAction;
|
||||||
private sidebarAction: OperaSidebarAction | FirefoxSidebarAction;
|
private sidebarAction: OperaSidebarAction | FirefoxSidebarAction;
|
||||||
private inited = false;
|
|
||||||
private win: Window & typeof globalThis;
|
private win: Window & typeof globalThis;
|
||||||
|
|
||||||
private static readonly listenedToCommands = [
|
constructor(win: Window & typeof globalThis, services: MainBackground) {
|
||||||
"updateBadge",
|
|
||||||
"loggedIn",
|
|
||||||
"unlocked",
|
|
||||||
"syncCompleted",
|
|
||||||
"bgUpdateContextMenu",
|
|
||||||
"editedCipher",
|
|
||||||
"addedCipher",
|
|
||||||
"deletedCipher",
|
|
||||||
];
|
|
||||||
|
|
||||||
static async windowsOnFocusChangedListener(
|
|
||||||
windowId: number,
|
|
||||||
serviceCache: Record<string, unknown>,
|
|
||||||
) {
|
|
||||||
await new UpdateBadge(self).run({ windowId, existingServices: serviceCache });
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnActivatedListener(
|
|
||||||
activeInfo: chrome.tabs.TabActiveInfo,
|
|
||||||
serviceCache: Record<string, unknown>,
|
|
||||||
) {
|
|
||||||
await new UpdateBadge(self).run({
|
|
||||||
tabId: activeInfo.tabId,
|
|
||||||
existingServices: serviceCache,
|
|
||||||
windowId: activeInfo.windowId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnReplacedListener(
|
|
||||||
addedTabId: number,
|
|
||||||
removedTabId: number,
|
|
||||||
serviceCache: Record<string, unknown>,
|
|
||||||
) {
|
|
||||||
await new UpdateBadge(self).run({ tabId: addedTabId, existingServices: serviceCache });
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tabsOnUpdatedListener(
|
|
||||||
tabId: number,
|
|
||||||
changeInfo: chrome.tabs.TabChangeInfo,
|
|
||||||
tab: chrome.tabs.Tab,
|
|
||||||
serviceCache: Record<string, unknown>,
|
|
||||||
) {
|
|
||||||
await new UpdateBadge(self).run({
|
|
||||||
tabId,
|
|
||||||
existingServices: serviceCache,
|
|
||||||
windowId: tab.windowId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static async messageListener(
|
|
||||||
message: { command: string; tabId: number },
|
|
||||||
serviceCache: Record<string, unknown>,
|
|
||||||
) {
|
|
||||||
if (!UpdateBadge.listenedToCommands.includes(message.command)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await new UpdateBadge(self).run({ existingServices: serviceCache });
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(win: Window & typeof globalThis) {
|
|
||||||
this.badgeAction = BrowserApi.getBrowserAction();
|
this.badgeAction = BrowserApi.getBrowserAction();
|
||||||
this.sidebarAction = BrowserApi.getSidebarAction(self);
|
this.sidebarAction = BrowserApi.getSidebarAction(self);
|
||||||
this.win = win;
|
this.win = win;
|
||||||
|
|
||||||
|
this.badgeSettingsService = services.badgeSettingsService;
|
||||||
|
this.authService = services.authService;
|
||||||
|
this.cipherService = services.cipherService;
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(opts?: {
|
async run(opts?: { tabId?: number; windowId?: number }): Promise<void> {
|
||||||
tabId?: number;
|
|
||||||
windowId?: number;
|
|
||||||
existingServices?: Record<string, unknown>;
|
|
||||||
}): Promise<void> {
|
|
||||||
await this.initServices(opts?.existingServices);
|
|
||||||
|
|
||||||
const authStatus = await this.authService.getAuthStatus();
|
const authStatus = await this.authService.getAuthStatus();
|
||||||
|
|
||||||
await this.setBadgeBackgroundColor();
|
await this.setBadgeBackgroundColor();
|
||||||
@ -150,8 +78,6 @@ export class UpdateBadge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setUnlocked(opts: BadgeOptions) {
|
async setUnlocked(opts: BadgeOptions) {
|
||||||
await this.initServices();
|
|
||||||
|
|
||||||
await this.setBadgeIcon("");
|
await this.setBadgeIcon("");
|
||||||
|
|
||||||
const enableBadgeCounter = await firstValueFrom(this.badgeSettingsService.enableBadgeCounter$);
|
const enableBadgeCounter = await firstValueFrom(this.badgeSettingsService.enableBadgeCounter$);
|
||||||
@ -263,52 +189,6 @@ export class UpdateBadge {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initServices(existingServiceCache?: Record<string, unknown>): Promise<UpdateBadge> {
|
|
||||||
if (this.inited) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
const serviceCache: Record<string, unknown> = existingServiceCache || {};
|
|
||||||
const opts = {
|
|
||||||
cryptoFunctionServiceOptions: { win: self },
|
|
||||||
encryptServiceOptions: { logMacFailures: false },
|
|
||||||
logServiceOptions: { isDev: false },
|
|
||||||
platformUtilsServiceOptions: {
|
|
||||||
clipboardWriteCallback: (clipboardValue: string, clearMs: number) =>
|
|
||||||
Promise.reject("not implemented"),
|
|
||||||
biometricCallback: () => Promise.reject("not implemented"),
|
|
||||||
win: self,
|
|
||||||
},
|
|
||||||
stateServiceOptions: {
|
|
||||||
stateFactory: new StateFactory(GlobalState, Account),
|
|
||||||
},
|
|
||||||
apiServiceOptions: {
|
|
||||||
logoutCallback: () => Promise.reject("not implemented"),
|
|
||||||
},
|
|
||||||
keyConnectorServiceOptions: {
|
|
||||||
logoutCallback: () => Promise.reject("not implemented"),
|
|
||||||
},
|
|
||||||
i18nServiceOptions: {
|
|
||||||
systemLanguage: BrowserApi.getUILanguage(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
this.badgeSettingsService = await badgeSettingsServiceFactory(serviceCache, opts);
|
|
||||||
this.authService = await authServiceFactory(serviceCache, opts);
|
|
||||||
this.cipherService = await cipherServiceFactory(serviceCache, opts);
|
|
||||||
|
|
||||||
// Needed for cipher decryption
|
|
||||||
if (!self.bitwardenContainerService) {
|
|
||||||
new ContainerService(
|
|
||||||
serviceCache.cryptoService as CryptoService,
|
|
||||||
serviceCache.encryptService as EncryptService,
|
|
||||||
).attachToGlobal(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.inited = true;
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private isOperaSidebar(
|
private isOperaSidebar(
|
||||||
action: OperaSidebarAction | FirefoxSidebarAction,
|
action: OperaSidebarAction | FirefoxSidebarAction,
|
||||||
): action is OperaSidebarAction {
|
): action is OperaSidebarAction {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
import { ImportApiService, ImportApiServiceAbstraction } from "@bitwarden/importer/core";
|
|
||||||
|
|
||||||
import {
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
apiServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
|
|
||||||
export type ImportApiServiceInitOptions = FactoryOptions & ApiServiceInitOptions;
|
|
||||||
type ServiceCache = { importApiService?: ImportApiServiceAbstraction } & CachedServices;
|
|
||||||
|
|
||||||
export function importApiServiceFactory(
|
|
||||||
cache: ServiceCache,
|
|
||||||
opts: ImportApiServiceInitOptions,
|
|
||||||
): Promise<ImportApiServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"importApiService",
|
|
||||||
opts,
|
|
||||||
async () => new ImportApiService(await apiServiceFactory(cache, opts)),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
import { ImportService, ImportServiceAbstraction } from "@bitwarden/importer/core";
|
|
||||||
|
|
||||||
import {
|
|
||||||
pinServiceFactory,
|
|
||||||
PinServiceInitOptions,
|
|
||||||
} from "../../../auth/background/service-factories/pin-service.factory";
|
|
||||||
import {
|
|
||||||
cryptoServiceFactory,
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
cipherServiceFactory,
|
|
||||||
CipherServiceInitOptions,
|
|
||||||
} from "../../../vault/background/service_factories/cipher-service.factory";
|
|
||||||
import {
|
|
||||||
collectionServiceFactory,
|
|
||||||
CollectionServiceInitOptions,
|
|
||||||
} from "../../../vault/background/service_factories/collection-service.factory";
|
|
||||||
import {
|
|
||||||
folderServiceFactory,
|
|
||||||
FolderServiceInitOptions,
|
|
||||||
} from "../../../vault/background/service_factories/folder-service.factory";
|
|
||||||
|
|
||||||
import { importApiServiceFactory, ImportApiServiceInitOptions } from "./import-api-service.factory";
|
|
||||||
|
|
||||||
type ImportServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type ImportServiceInitOptions = ImportServiceFactoryOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
FolderServiceInitOptions &
|
|
||||||
ImportApiServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
CollectionServiceInitOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
PinServiceInitOptions;
|
|
||||||
|
|
||||||
export function importServiceFactory(
|
|
||||||
cache: {
|
|
||||||
importService?: ImportServiceAbstraction;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: ImportServiceInitOptions,
|
|
||||||
): Promise<ImportServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"importService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new ImportService(
|
|
||||||
await cipherServiceFactory(cache, opts),
|
|
||||||
await folderServiceFactory(cache, opts),
|
|
||||||
await importApiServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await collectionServiceFactory(cache, opts),
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await pinServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
import {
|
|
||||||
PasswordGenerationService,
|
|
||||||
PasswordGenerationServiceAbstraction,
|
|
||||||
} from "@bitwarden/common/tools/generator/password";
|
|
||||||
|
|
||||||
import {
|
|
||||||
policyServiceFactory,
|
|
||||||
PolicyServiceInitOptions,
|
|
||||||
} from "../../../admin-console/background/service-factories/policy-service.factory";
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type PasswordGenerationServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type PasswordGenerationServiceInitOptions = PasswordGenerationServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
PolicyServiceInitOptions &
|
|
||||||
StateServiceInitOptions;
|
|
||||||
|
|
||||||
export function passwordGenerationServiceFactory(
|
|
||||||
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
|
|
||||||
opts: PasswordGenerationServiceInitOptions,
|
|
||||||
): Promise<PasswordGenerationServiceAbstraction> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"passwordGenerationService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new PasswordGenerationService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await policyServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
import {
|
|
||||||
PasswordStrengthService,
|
|
||||||
PasswordStrengthServiceAbstraction,
|
|
||||||
} from "@bitwarden/common/tools/password-strength";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
|
|
||||||
type PasswordStrengthServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type PasswordStrengthServiceInitOptions = PasswordStrengthServiceFactoryOptions;
|
|
||||||
|
|
||||||
export function passwordStrengthServiceFactory(
|
|
||||||
cache: {
|
|
||||||
passwordStrengthService?: PasswordStrengthServiceAbstraction;
|
|
||||||
} & CachedServices,
|
|
||||||
opts: PasswordStrengthServiceInitOptions,
|
|
||||||
): Promise<PasswordStrengthServiceAbstraction> {
|
|
||||||
return factory(cache, "passwordStrengthService", opts, async () => new PasswordStrengthService());
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
import { CipherService as AbstractCipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
|
||||||
import { CipherService } from "@bitwarden/common/vault/services/cipher.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AutofillSettingsServiceInitOptions,
|
|
||||||
autofillSettingsServiceFactory,
|
|
||||||
} from "../../../autofill/background/service_factories/autofill-settings-service.factory";
|
|
||||||
import {
|
|
||||||
DomainSettingsServiceInitOptions,
|
|
||||||
domainSettingsServiceFactory,
|
|
||||||
} from "../../../autofill/background/service_factories/domain-settings-service.factory";
|
|
||||||
import {
|
|
||||||
CipherFileUploadServiceInitOptions,
|
|
||||||
cipherFileUploadServiceFactory,
|
|
||||||
} from "../../../background/service-factories/cipher-file-upload-service.factory";
|
|
||||||
import {
|
|
||||||
searchServiceFactory,
|
|
||||||
SearchServiceInitOptions,
|
|
||||||
} from "../../../background/service-factories/search-service.factory";
|
|
||||||
import {
|
|
||||||
apiServiceFactory,
|
|
||||||
ApiServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/api-service.factory";
|
|
||||||
import {
|
|
||||||
configServiceFactory,
|
|
||||||
ConfigServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/config-service.factory";
|
|
||||||
import {
|
|
||||||
cryptoServiceFactory,
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
EncryptServiceInitOptions,
|
|
||||||
encryptServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/encrypt-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import { stateProviderFactory } from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import {
|
|
||||||
stateServiceFactory,
|
|
||||||
StateServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type CipherServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type CipherServiceInitOptions = CipherServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
ApiServiceInitOptions &
|
|
||||||
CipherFileUploadServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
SearchServiceInitOptions &
|
|
||||||
StateServiceInitOptions &
|
|
||||||
AutofillSettingsServiceInitOptions &
|
|
||||||
DomainSettingsServiceInitOptions &
|
|
||||||
EncryptServiceInitOptions &
|
|
||||||
ConfigServiceInitOptions;
|
|
||||||
|
|
||||||
export function cipherServiceFactory(
|
|
||||||
cache: { cipherService?: AbstractCipherService } & CachedServices,
|
|
||||||
opts: CipherServiceInitOptions,
|
|
||||||
): Promise<AbstractCipherService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"cipherService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new CipherService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await domainSettingsServiceFactory(cache, opts),
|
|
||||||
await apiServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await searchServiceFactory(cache, opts),
|
|
||||||
await stateServiceFactory(cache, opts),
|
|
||||||
await autofillSettingsServiceFactory(cache, opts),
|
|
||||||
await encryptServiceFactory(cache, opts),
|
|
||||||
await cipherFileUploadServiceFactory(cache, opts),
|
|
||||||
await configServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import { CollectionService as AbstractCollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
|
|
||||||
import { CollectionService } from "@bitwarden/common/vault/services/collection.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
cryptoServiceFactory,
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import { stateProviderFactory } from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
import { StateServiceInitOptions } from "../../../platform/background/service-factories/state-service.factory";
|
|
||||||
|
|
||||||
type CollectionServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type CollectionServiceInitOptions = CollectionServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
StateServiceInitOptions;
|
|
||||||
|
|
||||||
export function collectionServiceFactory(
|
|
||||||
cache: { collectionService?: AbstractCollectionService } & CachedServices,
|
|
||||||
opts: CollectionServiceInitOptions,
|
|
||||||
): Promise<AbstractCollectionService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"collectionService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new CollectionService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
import { FolderService as AbstractFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
|
||||||
import { FolderService } from "@bitwarden/common/vault/services/folder/folder.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CryptoServiceInitOptions,
|
|
||||||
cryptoServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-service.factory";
|
|
||||||
import {
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
FactoryOptions,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
i18nServiceFactory,
|
|
||||||
I18nServiceInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/i18n-service.factory";
|
|
||||||
import {
|
|
||||||
stateProviderFactory,
|
|
||||||
StateProviderInitOptions,
|
|
||||||
} from "../../../platform/background/service-factories/state-provider.factory";
|
|
||||||
|
|
||||||
import { cipherServiceFactory, CipherServiceInitOptions } from "./cipher-service.factory";
|
|
||||||
|
|
||||||
type FolderServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type FolderServiceInitOptions = FolderServiceFactoryOptions &
|
|
||||||
CryptoServiceInitOptions &
|
|
||||||
CipherServiceInitOptions &
|
|
||||||
I18nServiceInitOptions &
|
|
||||||
StateProviderInitOptions;
|
|
||||||
|
|
||||||
export function folderServiceFactory(
|
|
||||||
cache: { folderService?: AbstractFolderService } & CachedServices,
|
|
||||||
opts: FolderServiceInitOptions,
|
|
||||||
): Promise<AbstractFolderService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"folderService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new FolderService(
|
|
||||||
await cryptoServiceFactory(cache, opts),
|
|
||||||
await i18nServiceFactory(cache, opts),
|
|
||||||
await cipherServiceFactory(cache, opts),
|
|
||||||
await stateProviderFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
import { SyncNotifierService as AbstractSyncNotifierService } from "@bitwarden/common/vault/abstractions/sync/sync-notifier.service.abstraction";
|
|
||||||
import { SyncNotifierService } from "@bitwarden/common/vault/services/sync/sync-notifier.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
|
|
||||||
type SyncNotifierServiceFactoryOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type SyncNotifierServiceInitOptions = SyncNotifierServiceFactoryOptions;
|
|
||||||
|
|
||||||
export function syncNotifierServiceFactory(
|
|
||||||
cache: { syncNotifierService?: AbstractSyncNotifierService } & CachedServices,
|
|
||||||
opts: SyncNotifierServiceInitOptions,
|
|
||||||
): Promise<AbstractSyncNotifierService> {
|
|
||||||
return factory(cache, "syncNotifierService", opts, () =>
|
|
||||||
Promise.resolve(new SyncNotifierService()),
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { TotpService as AbstractTotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
|
||||||
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CryptoFunctionServiceInitOptions,
|
|
||||||
cryptoFunctionServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/crypto-function-service.factory";
|
|
||||||
import {
|
|
||||||
FactoryOptions,
|
|
||||||
CachedServices,
|
|
||||||
factory,
|
|
||||||
} from "../../../platform/background/service-factories/factory-options";
|
|
||||||
import {
|
|
||||||
LogServiceInitOptions,
|
|
||||||
logServiceFactory,
|
|
||||||
} from "../../../platform/background/service-factories/log-service.factory";
|
|
||||||
|
|
||||||
type TotpServiceOptions = FactoryOptions;
|
|
||||||
|
|
||||||
export type TotpServiceInitOptions = TotpServiceOptions &
|
|
||||||
CryptoFunctionServiceInitOptions &
|
|
||||||
LogServiceInitOptions;
|
|
||||||
|
|
||||||
export function totpServiceFactory(
|
|
||||||
cache: { totpService?: AbstractTotpService } & CachedServices,
|
|
||||||
opts: TotpServiceInitOptions,
|
|
||||||
): Promise<AbstractTotpService> {
|
|
||||||
return factory(
|
|
||||||
cache,
|
|
||||||
"totpService",
|
|
||||||
opts,
|
|
||||||
async () =>
|
|
||||||
new TotpService(
|
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
|
||||||
await logServiceFactory(cache, opts),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user