mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[Pm-13097] Rename cryptoservice to keyservice and move it to km ownership (#11358)
* Rename cryptoservice to keyservice * Rename cryptoservice to keyservice * Move key service to key management ownership * Remove accidentally added file * Fix cli build * Fix browser build * Run prettier * Fix builds * Fix cli build * Fix tests * Fix incorrect renames * Rename webauthn-login-crypto-service * Fix build errors due to merge conflicts * Fix linting
This commit is contained in:
parent
554171b688
commit
b486fcc689
@ -16,7 +16,6 @@ import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config
|
|||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -26,7 +25,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
|
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
|
||||||
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
|
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
|
||||||
@ -49,7 +48,7 @@ export class LockComponent extends BaseLockComponent implements OnInit {
|
|||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
vaultTimeoutService: VaultTimeoutService,
|
vaultTimeoutService: VaultTimeoutService,
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
environmentService: EnvironmentService,
|
environmentService: EnvironmentService,
|
||||||
@ -79,7 +78,7 @@ export class LockComponent extends BaseLockComponent implements OnInit {
|
|||||||
i18nService,
|
i18nService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
messagingService,
|
messagingService,
|
||||||
cryptoService,
|
keyService,
|
||||||
vaultTimeoutService,
|
vaultTimeoutService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
environmentService,
|
environmentService,
|
||||||
|
@ -15,7 +15,6 @@ import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
|||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -24,6 +23,7 @@ import { ValidationService } from "@bitwarden/common/platform/abstractions/valid
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login-via-auth-request",
|
selector: "app-login-via-auth-request",
|
||||||
@ -32,7 +32,7 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legac
|
|||||||
export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
|
export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
|
||||||
constructor(
|
constructor(
|
||||||
router: Router,
|
router: Router,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
cryptoFunctionService: CryptoFunctionService,
|
cryptoFunctionService: CryptoFunctionService,
|
||||||
appIdService: AppIdService,
|
appIdService: AppIdService,
|
||||||
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
@ -55,7 +55,7 @@ export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
|
|||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
router,
|
router,
|
||||||
cryptoService,
|
keyService,
|
||||||
cryptoFunctionService,
|
cryptoFunctionService,
|
||||||
appIdService,
|
appIdService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
|
@ -7,7 +7,6 @@ import { FormValidationErrorsService } from "@bitwarden/angular/platform/abstrac
|
|||||||
import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -15,6 +14,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-register",
|
selector: "app-register",
|
||||||
@ -30,7 +30,7 @@ export class RegisterComponent extends BaseRegisterComponent {
|
|||||||
loginStrategyService: LoginStrategyServiceAbstraction,
|
loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
router: Router,
|
router: Router,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -47,7 +47,7 @@ export class RegisterComponent extends BaseRegisterComponent {
|
|||||||
loginStrategyService,
|
loginStrategyService,
|
||||||
router,
|
router,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
apiService,
|
apiService,
|
||||||
stateService,
|
stateService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -25,7 +25,6 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -37,7 +36,7 @@ import {
|
|||||||
VaultTimeoutStringType,
|
VaultTimeoutStringType,
|
||||||
} from "@bitwarden/common/types/vault-timeout.type";
|
} from "@bitwarden/common/types/vault-timeout.type";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { BiometricStateService, BiometricsService } from "@bitwarden/key-management";
|
import { KeyService, BiometricStateService, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BiometricErrors, BiometricErrorTypes } from "../../../models/biometricErrors";
|
import { BiometricErrors, BiometricErrorTypes } from "../../../models/biometricErrors";
|
||||||
import { BrowserApi } from "../../../platform/browser/browser-api";
|
import { BrowserApi } from "../../../platform/browser/browser-api";
|
||||||
@ -87,7 +86,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
public messagingService: MessagingService,
|
public messagingService: MessagingService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
@ -386,7 +385,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
const awaitDesktopDialogRef = AwaitDesktopDialogComponent.open(this.dialogService);
|
const awaitDesktopDialogRef = AwaitDesktopDialogComponent.open(this.dialogService);
|
||||||
const awaitDesktopDialogClosed = firstValueFrom(awaitDesktopDialogRef.closed);
|
const awaitDesktopDialogClosed = firstValueFrom(awaitDesktopDialogRef.closed);
|
||||||
|
|
||||||
await this.cryptoService.refreshAdditionalKeys();
|
await this.keyService.refreshAdditionalKeys();
|
||||||
|
|
||||||
await Promise.race([
|
await Promise.race([
|
||||||
awaitDesktopDialogClosed.then(async (result) => {
|
awaitDesktopDialogClosed.then(async (result) => {
|
||||||
@ -465,9 +464,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fingerprint() {
|
async fingerprint() {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(
|
const fingerprint = await this.keyService.getFingerprint(await this.stateService.getUserId());
|
||||||
await this.stateService.getUserId(),
|
|
||||||
);
|
|
||||||
|
|
||||||
const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
|
const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
|
||||||
fingerprint,
|
fingerprint,
|
||||||
|
@ -27,7 +27,6 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -52,7 +51,7 @@ import {
|
|||||||
TypographyModule,
|
TypographyModule,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BiometricErrors, BiometricErrorTypes } from "../../../models/biometricErrors";
|
import { BiometricErrors, BiometricErrorTypes } from "../../../models/biometricErrors";
|
||||||
import { BrowserApi } from "../../../platform/browser/browser-api";
|
import { BrowserApi } from "../../../platform/browser/browser-api";
|
||||||
@ -127,7 +126,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
public messagingService: MessagingService,
|
public messagingService: MessagingService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
@ -436,7 +435,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.cryptoService.refreshAdditionalKeys();
|
await this.keyService.refreshAdditionalKeys();
|
||||||
|
|
||||||
const successful = await this.trySetupBiometrics();
|
const successful = await this.trySetupBiometrics();
|
||||||
this.form.controls.biometric.setValue(successful);
|
this.form.controls.biometric.setValue(successful);
|
||||||
@ -562,8 +561,8 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
|
|||||||
const activeUserId = await firstValueFrom(
|
const activeUserId = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||||
);
|
);
|
||||||
const publicKey = await firstValueFrom(this.cryptoService.userPublicKey$(activeUserId));
|
const publicKey = await firstValueFrom(this.keyService.userPublicKey$(activeUserId));
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(activeUserId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(activeUserId, publicKey);
|
||||||
|
|
||||||
const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
|
const dialogRef = FingerprintDialogComponent.open(this.dialogService, {
|
||||||
fingerprint,
|
fingerprint,
|
||||||
|
@ -2,15 +2,15 @@ import { Subject, filter, firstValueFrom, map, merge, timeout } from "rxjs";
|
|||||||
|
|
||||||
import { CollectionService, DefaultCollectionService } from "@bitwarden/admin-console/common";
|
import { CollectionService, DefaultCollectionService } from "@bitwarden/admin-console/common";
|
||||||
import {
|
import {
|
||||||
PinServiceAbstraction,
|
|
||||||
PinService,
|
|
||||||
InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
UserDecryptionOptionsService,
|
|
||||||
AuthRequestServiceAbstraction,
|
|
||||||
AuthRequestService,
|
AuthRequestService,
|
||||||
|
AuthRequestServiceAbstraction,
|
||||||
|
DefaultLockService,
|
||||||
|
InternalUserDecryptionOptionsServiceAbstraction,
|
||||||
LoginEmailServiceAbstraction,
|
LoginEmailServiceAbstraction,
|
||||||
LogoutReason,
|
LogoutReason,
|
||||||
DefaultLockService,
|
PinService,
|
||||||
|
PinServiceAbstraction,
|
||||||
|
UserDecryptionOptionsService,
|
||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service";
|
||||||
@ -56,16 +56,16 @@ import { TokenService } from "@bitwarden/common/auth/services/token.service";
|
|||||||
import { UserVerificationApiService } from "@bitwarden/common/auth/services/user-verification/user-verification-api.service";
|
import { UserVerificationApiService } from "@bitwarden/common/auth/services/user-verification/user-verification-api.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service";
|
import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service";
|
||||||
import {
|
import {
|
||||||
AutofillSettingsServiceAbstraction,
|
|
||||||
AutofillSettingsService,
|
AutofillSettingsService,
|
||||||
|
AutofillSettingsServiceAbstraction,
|
||||||
} from "@bitwarden/common/autofill/services/autofill-settings.service";
|
} from "@bitwarden/common/autofill/services/autofill-settings.service";
|
||||||
import {
|
import {
|
||||||
BadgeSettingsServiceAbstraction,
|
|
||||||
BadgeSettingsService,
|
BadgeSettingsService,
|
||||||
|
BadgeSettingsServiceAbstraction,
|
||||||
} from "@bitwarden/common/autofill/services/badge-settings.service";
|
} from "@bitwarden/common/autofill/services/badge-settings.service";
|
||||||
import {
|
import {
|
||||||
DomainSettingsService,
|
|
||||||
DefaultDomainSettingsService,
|
DefaultDomainSettingsService,
|
||||||
|
DomainSettingsService,
|
||||||
} from "@bitwarden/common/autofill/services/domain-settings.service";
|
} from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
import {
|
import {
|
||||||
UserNotificationSettingsService,
|
UserNotificationSettingsService,
|
||||||
@ -81,7 +81,6 @@ import { AppIdService as AppIdServiceAbstraction } from "@bitwarden/common/platf
|
|||||||
import { ConfigApiServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config-api.service.abstraction";
|
import { ConfigApiServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config-api.service.abstraction";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { RegionConfig } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { RegionConfig } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { Fido2ActiveRequestManager as Fido2ActiveRequestManagerAbstraction } from "@bitwarden/common/platform/abstractions/fido2/fido2-active-request-manager.abstraction";
|
import { Fido2ActiveRequestManager as Fido2ActiveRequestManagerAbstraction } from "@bitwarden/common/platform/abstractions/fido2/fido2-active-request-manager.abstraction";
|
||||||
@ -190,10 +189,10 @@ import { FolderService } from "@bitwarden/common/vault/services/folder/folder.se
|
|||||||
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
||||||
import { VaultSettingsService } from "@bitwarden/common/vault/services/vault-settings/vault-settings.service";
|
import { VaultSettingsService } from "@bitwarden/common/vault/services/vault-settings/vault-settings.service";
|
||||||
import {
|
import {
|
||||||
legacyPasswordGenerationServiceFactory,
|
|
||||||
PasswordGenerationServiceAbstraction,
|
PasswordGenerationServiceAbstraction,
|
||||||
legacyUsernameGenerationServiceFactory,
|
|
||||||
UsernameGenerationServiceAbstraction,
|
UsernameGenerationServiceAbstraction,
|
||||||
|
legacyPasswordGenerationServiceFactory,
|
||||||
|
legacyUsernameGenerationServiceFactory,
|
||||||
} from "@bitwarden/generator-legacy";
|
} from "@bitwarden/generator-legacy";
|
||||||
import {
|
import {
|
||||||
ImportApiService,
|
ImportApiService,
|
||||||
@ -203,8 +202,9 @@ import {
|
|||||||
} from "@bitwarden/importer/core";
|
} from "@bitwarden/importer/core";
|
||||||
import {
|
import {
|
||||||
BiometricStateService,
|
BiometricStateService,
|
||||||
DefaultBiometricStateService,
|
|
||||||
BiometricsService,
|
BiometricsService,
|
||||||
|
DefaultBiometricStateService,
|
||||||
|
KeyService as KeyServiceAbstraction,
|
||||||
} from "@bitwarden/key-management";
|
} from "@bitwarden/key-management";
|
||||||
import {
|
import {
|
||||||
IndividualVaultExportService,
|
IndividualVaultExportService,
|
||||||
@ -235,6 +235,7 @@ import { AutofillService as AutofillServiceAbstraction } from "../autofill/servi
|
|||||||
import AutofillService from "../autofill/services/autofill.service";
|
import AutofillService from "../autofill/services/autofill.service";
|
||||||
import { SafariApp } from "../browser/safariApp";
|
import { SafariApp } from "../browser/safariApp";
|
||||||
import { BackgroundBrowserBiometricsService } from "../key-management/biometrics/background-browser-biometrics.service";
|
import { BackgroundBrowserBiometricsService } from "../key-management/biometrics/background-browser-biometrics.service";
|
||||||
|
import { BrowserKeyService } from "../key-management/browser-key.service";
|
||||||
import { BrowserApi } from "../platform/browser/browser-api";
|
import { BrowserApi } from "../platform/browser/browser-api";
|
||||||
import { flagEnabled } from "../platform/flags";
|
import { flagEnabled } from "../platform/flags";
|
||||||
import { UpdateBadge } from "../platform/listeners/update-badge";
|
import { UpdateBadge } from "../platform/listeners/update-badge";
|
||||||
@ -244,7 +245,6 @@ import { ChromeMessageSender } from "../platform/messaging/chrome-message.sender
|
|||||||
import { OffscreenDocumentService } from "../platform/offscreen-document/abstractions/offscreen-document";
|
import { OffscreenDocumentService } from "../platform/offscreen-document/abstractions/offscreen-document";
|
||||||
import { DefaultOffscreenDocumentService } from "../platform/offscreen-document/offscreen-document.service";
|
import { DefaultOffscreenDocumentService } from "../platform/offscreen-document/offscreen-document.service";
|
||||||
import { BrowserTaskSchedulerService } from "../platform/services/abstractions/browser-task-scheduler.service";
|
import { BrowserTaskSchedulerService } from "../platform/services/abstractions/browser-task-scheduler.service";
|
||||||
import { BrowserCryptoService } from "../platform/services/browser-crypto.service";
|
|
||||||
import { BrowserEnvironmentService } from "../platform/services/browser-environment.service";
|
import { BrowserEnvironmentService } from "../platform/services/browser-environment.service";
|
||||||
import BrowserLocalStorageService from "../platform/services/browser-local-storage.service";
|
import BrowserLocalStorageService from "../platform/services/browser-local-storage.service";
|
||||||
import BrowserMemoryStorageService from "../platform/services/browser-memory-storage.service";
|
import BrowserMemoryStorageService from "../platform/services/browser-memory-storage.service";
|
||||||
@ -284,7 +284,7 @@ export default class MainBackground {
|
|||||||
platformUtilsService: PlatformUtilsServiceAbstraction;
|
platformUtilsService: PlatformUtilsServiceAbstraction;
|
||||||
logService: LogServiceAbstraction;
|
logService: LogServiceAbstraction;
|
||||||
keyGenerationService: KeyGenerationServiceAbstraction;
|
keyGenerationService: KeyGenerationServiceAbstraction;
|
||||||
cryptoService: CryptoServiceAbstraction;
|
keyService: KeyServiceAbstraction;
|
||||||
cryptoFunctionService: CryptoFunctionServiceAbstraction;
|
cryptoFunctionService: CryptoFunctionServiceAbstraction;
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction;
|
masterPasswordService: InternalMasterPasswordServiceAbstraction;
|
||||||
tokenService: TokenServiceAbstraction;
|
tokenService: TokenServiceAbstraction;
|
||||||
@ -653,7 +653,7 @@ export default class MainBackground {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cryptoService = new BrowserCryptoService(
|
this.keyService = new BrowserKeyService(
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
@ -679,7 +679,7 @@ export default class MainBackground {
|
|||||||
this.accountService,
|
this.accountService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.userDecryptionOptionsService,
|
this.userDecryptionOptionsService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.biometricStateService,
|
this.biometricStateService,
|
||||||
@ -708,7 +708,7 @@ export default class MainBackground {
|
|||||||
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
||||||
|
|
||||||
this.collectionService = new DefaultCollectionService(
|
this.collectionService = new DefaultCollectionService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -723,7 +723,7 @@ export default class MainBackground {
|
|||||||
this.keyConnectorService = new KeyConnectorService(
|
this.keyConnectorService = new KeyConnectorService(
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.logService,
|
this.logService,
|
||||||
@ -742,7 +742,7 @@ export default class MainBackground {
|
|||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.kdfConfigService,
|
this.kdfConfigService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ export default class MainBackground {
|
|||||||
|
|
||||||
this.passwordGenerationService = legacyPasswordGenerationServiceFactory(
|
this.passwordGenerationService = legacyPasswordGenerationServiceFactory(
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -762,7 +762,7 @@ export default class MainBackground {
|
|||||||
this.deviceTrustService = new DeviceTrustService(
|
this.deviceTrustService = new DeviceTrustService(
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.devicesApiService,
|
this.devicesApiService,
|
||||||
@ -781,7 +781,7 @@ export default class MainBackground {
|
|||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -790,7 +790,7 @@ export default class MainBackground {
|
|||||||
this.authService = new AuthService(
|
this.authService = new AuthService(
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
@ -822,7 +822,7 @@ export default class MainBackground {
|
|||||||
this.bulkEncryptService = new FallbackBulkEncryptService(this.encryptService);
|
this.bulkEncryptService = new FallbackBulkEncryptService(this.encryptService);
|
||||||
|
|
||||||
this.cipherService = new CipherService(
|
this.cipherService = new CipherService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.domainSettingsService,
|
this.domainSettingsService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
@ -837,7 +837,7 @@ export default class MainBackground {
|
|||||||
this.accountService,
|
this.accountService,
|
||||||
);
|
);
|
||||||
this.folderService = new FolderService(
|
this.folderService = new FolderService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
@ -846,7 +846,7 @@ export default class MainBackground {
|
|||||||
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
||||||
|
|
||||||
this.userVerificationService = new UserVerificationService(
|
this.userVerificationService = new UserVerificationService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
@ -891,11 +891,11 @@ export default class MainBackground {
|
|||||||
logoutCallback,
|
logoutCallback,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
|
this.containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
|
|
||||||
this.sendStateProvider = new SendStateProvider(this.stateProvider);
|
this.sendStateProvider = new SendStateProvider(this.stateProvider);
|
||||||
this.sendService = new SendService(
|
this.sendService = new SendService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
this.sendStateProvider,
|
this.sendStateProvider,
|
||||||
@ -936,7 +936,7 @@ export default class MainBackground {
|
|||||||
this.domainSettingsService,
|
this.domainSettingsService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
@ -1011,7 +1011,7 @@ export default class MainBackground {
|
|||||||
this.importApiService,
|
this.importApiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
@ -1021,7 +1021,7 @@ export default class MainBackground {
|
|||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.kdfConfigService,
|
this.kdfConfigService,
|
||||||
@ -1032,7 +1032,7 @@ export default class MainBackground {
|
|||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
@ -1139,7 +1139,7 @@ export default class MainBackground {
|
|||||||
lockService,
|
lockService,
|
||||||
);
|
);
|
||||||
this.nativeMessagingBackground = new NativeMessagingBackground(
|
this.nativeMessagingBackground = new NativeMessagingBackground(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.runtimeBackground,
|
this.runtimeBackground,
|
||||||
@ -1244,7 +1244,7 @@ export default class MainBackground {
|
|||||||
this.usernameGenerationService = legacyUsernameGenerationServiceFactory(
|
this.usernameGenerationService = legacyUsernameGenerationServiceFactory(
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
@ -1276,7 +1276,7 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.cryptoService);
|
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.keyService);
|
||||||
|
|
||||||
this.cipherAuthorizationService = new DefaultCipherAuthorizationService(
|
this.cipherAuthorizationService = new DefaultCipherAuthorizationService(
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
@ -1514,7 +1514,7 @@ export default class MainBackground {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.cryptoService.clearKeys(userBeingLoggedOut),
|
this.keyService.clearKeys(userBeingLoggedOut),
|
||||||
this.cipherService.clear(userBeingLoggedOut),
|
this.cipherService.clear(userBeingLoggedOut),
|
||||||
this.folderService.clear(userBeingLoggedOut),
|
this.folderService.clear(userBeingLoggedOut),
|
||||||
this.collectionService.clear(userBeingLoggedOut),
|
this.collectionService.clear(userBeingLoggedOut),
|
||||||
|
@ -5,7 +5,6 @@ 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 { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -14,7 +13,7 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
|
|||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { UserKey } from "@bitwarden/common/types/key";
|
import { UserKey } from "@bitwarden/common/types/key";
|
||||||
import { BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BrowserApi } from "../platform/browser/browser-api";
|
import { BrowserApi } from "../platform/browser/browser-api";
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ export class NativeMessagingBackground {
|
|||||||
private validatingFingerprint: boolean;
|
private validatingFingerprint: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private runtimeBackground: RuntimeBackground,
|
private runtimeBackground: RuntimeBackground,
|
||||||
@ -318,15 +317,12 @@ export class NativeMessagingBackground {
|
|||||||
const activeUserId = await firstValueFrom(
|
const activeUserId = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||||
);
|
);
|
||||||
const isUserKeyValid = await this.cryptoService.validateUserKey(
|
const isUserKeyValid = await this.keyService.validateUserKey(userKey, activeUserId);
|
||||||
userKey,
|
|
||||||
activeUserId,
|
|
||||||
);
|
|
||||||
if (isUserKeyValid) {
|
if (isUserKeyValid) {
|
||||||
await this.cryptoService.setUserKey(userKey, activeUserId);
|
await this.keyService.setUserKey(userKey, activeUserId);
|
||||||
} else {
|
} else {
|
||||||
this.logService.error("Unable to verify biometric unlocked userkey");
|
this.logService.error("Unable to verify biometric unlocked userkey");
|
||||||
await this.cryptoService.clearKeys(activeUserId);
|
await this.keyService.clearKeys(activeUserId);
|
||||||
this.rejecter("userkey wrong");
|
this.rejecter("userkey wrong");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -342,10 +338,10 @@ export class NativeMessagingBackground {
|
|||||||
// Verify key is correct by attempting to decrypt a secret
|
// Verify key is correct by attempting to decrypt a secret
|
||||||
try {
|
try {
|
||||||
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
||||||
await this.cryptoService.getFingerprint(userId);
|
await this.keyService.getFingerprint(userId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error("Unable to verify key: " + e);
|
this.logService.error("Unable to verify key: " + e);
|
||||||
await this.cryptoService.clearKeys();
|
await this.keyService.clearKeys();
|
||||||
this.rejecter("userkey wrong");
|
this.rejecter("userkey wrong");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -398,7 +394,7 @@ export class NativeMessagingBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async showFingerprintDialog() {
|
private async showFingerprintDialog() {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(
|
const fingerprint = await this.keyService.getFingerprint(
|
||||||
(await firstValueFrom(this.accountService.activeAccount$))?.id,
|
(await firstValueFrom(this.accountService.activeAccount$))?.id,
|
||||||
this.publicKey,
|
this.publicKey,
|
||||||
);
|
);
|
||||||
|
@ -11,14 +11,17 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/services/crypto.service";
|
|
||||||
import { USER_KEY } from "@bitwarden/common/platform/services/key-state/user-key.state";
|
import { USER_KEY } from "@bitwarden/common/platform/services/key-state/user-key.state";
|
||||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey } from "@bitwarden/common/types/key";
|
import { UserKey } from "@bitwarden/common/types/key";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import {
|
||||||
|
DefaultKeyService,
|
||||||
|
BiometricsService,
|
||||||
|
BiometricStateService,
|
||||||
|
} from "@bitwarden/key-management";
|
||||||
|
|
||||||
export class BrowserCryptoService extends CryptoService {
|
export class BrowserKeyService extends DefaultKeyService {
|
||||||
constructor(
|
constructor(
|
||||||
pinService: PinServiceAbstraction,
|
pinService: PinServiceAbstraction,
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
@ -6,15 +6,15 @@ import { ViewCacheService } from "@bitwarden/angular/platform/abstractions/view-
|
|||||||
import { AngularThemingService } from "@bitwarden/angular/platform/services/theming/angular-theming.service";
|
import { AngularThemingService } from "@bitwarden/angular/platform/services/theming/angular-theming.service";
|
||||||
import { SafeProvider, safeProvider } from "@bitwarden/angular/platform/utils/safe-provider";
|
import { SafeProvider, safeProvider } from "@bitwarden/angular/platform/utils/safe-provider";
|
||||||
import {
|
import {
|
||||||
MEMORY_STORAGE,
|
CLIENT_TYPE,
|
||||||
SECURE_STORAGE,
|
|
||||||
OBSERVABLE_DISK_STORAGE,
|
|
||||||
OBSERVABLE_MEMORY_STORAGE,
|
|
||||||
SYSTEM_THEME_OBSERVABLE,
|
|
||||||
SafeInjectionToken,
|
|
||||||
DEFAULT_VAULT_TIMEOUT,
|
DEFAULT_VAULT_TIMEOUT,
|
||||||
INTRAPROCESS_MESSAGING_SUBJECT,
|
INTRAPROCESS_MESSAGING_SUBJECT,
|
||||||
CLIENT_TYPE,
|
MEMORY_STORAGE,
|
||||||
|
OBSERVABLE_DISK_STORAGE,
|
||||||
|
OBSERVABLE_MEMORY_STORAGE,
|
||||||
|
SECURE_STORAGE,
|
||||||
|
SYSTEM_THEME_OBSERVABLE,
|
||||||
|
SafeInjectionToken,
|
||||||
ENV_ADDITIONAL_REGIONS,
|
ENV_ADDITIONAL_REGIONS,
|
||||||
} from "@bitwarden/angular/services/injection-tokens";
|
} from "@bitwarden/angular/services/injection-tokens";
|
||||||
import { JslibServicesModule } from "@bitwarden/angular/services/jslib-services.module";
|
import { JslibServicesModule } from "@bitwarden/angular/services/jslib-services.module";
|
||||||
@ -50,7 +50,6 @@ import {
|
|||||||
} from "@bitwarden/common/platform/abstractions/animation-control.service";
|
} from "@bitwarden/common/platform/abstractions/animation-control.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
@ -91,7 +90,7 @@ import { FolderService as FolderServiceAbstraction } from "@bitwarden/common/vau
|
|||||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/vault/abstractions/totp.service";
|
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||||
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { BiometricStateService, BiometricsService, KeyService } from "@bitwarden/key-management";
|
||||||
import { PasswordRepromptService } from "@bitwarden/vault";
|
import { PasswordRepromptService } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { ForegroundLockService } from "../../auth/popup/accounts/foreground-lock.service";
|
import { ForegroundLockService } from "../../auth/popup/accounts/foreground-lock.service";
|
||||||
@ -100,6 +99,7 @@ import { AutofillService as AutofillServiceAbstraction } from "../../autofill/se
|
|||||||
import AutofillService from "../../autofill/services/autofill.service";
|
import AutofillService from "../../autofill/services/autofill.service";
|
||||||
import MainBackground from "../../background/main.background";
|
import MainBackground from "../../background/main.background";
|
||||||
import { ForegroundBrowserBiometricsService } from "../../key-management/biometrics/foreground-browser-biometrics";
|
import { ForegroundBrowserBiometricsService } from "../../key-management/biometrics/foreground-browser-biometrics";
|
||||||
|
import { BrowserKeyService } from "../../key-management/browser-key.service";
|
||||||
import { BrowserApi } from "../../platform/browser/browser-api";
|
import { BrowserApi } from "../../platform/browser/browser-api";
|
||||||
import { runInsideAngular } from "../../platform/browser/run-inside-angular.operator";
|
import { runInsideAngular } from "../../platform/browser/run-inside-angular.operator";
|
||||||
/* eslint-disable no-restricted-imports */
|
/* eslint-disable no-restricted-imports */
|
||||||
@ -111,7 +111,6 @@ import BrowserPopupUtils from "../../platform/popup/browser-popup-utils";
|
|||||||
import { BrowserFileDownloadService } from "../../platform/popup/services/browser-file-download.service";
|
import { BrowserFileDownloadService } from "../../platform/popup/services/browser-file-download.service";
|
||||||
import { PopupViewCacheService } from "../../platform/popup/view-cache/popup-view-cache.service";
|
import { PopupViewCacheService } from "../../platform/popup/view-cache/popup-view-cache.service";
|
||||||
import { ScriptInjectorService } from "../../platform/services/abstractions/script-injector.service";
|
import { ScriptInjectorService } from "../../platform/services/abstractions/script-injector.service";
|
||||||
import { BrowserCryptoService } from "../../platform/services/browser-crypto.service";
|
|
||||||
import { BrowserEnvironmentService } from "../../platform/services/browser-environment.service";
|
import { BrowserEnvironmentService } from "../../platform/services/browser-environment.service";
|
||||||
import BrowserLocalStorageService from "../../platform/services/browser-local-storage.service";
|
import BrowserLocalStorageService from "../../platform/services/browser-local-storage.service";
|
||||||
import { BrowserScriptInjectorService } from "../../platform/services/browser-script-injector.service";
|
import { BrowserScriptInjectorService } from "../../platform/services/browser-script-injector.service";
|
||||||
@ -212,7 +211,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
deps: [GlobalStateProvider],
|
deps: [GlobalStateProvider],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: CryptoService,
|
provide: KeyService,
|
||||||
useFactory: (
|
useFactory: (
|
||||||
pinService: PinServiceAbstraction,
|
pinService: PinServiceAbstraction,
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||||
@ -228,7 +227,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
biometricsService: BiometricsService,
|
biometricsService: BiometricsService,
|
||||||
kdfConfigService: KdfConfigService,
|
kdfConfigService: KdfConfigService,
|
||||||
) => {
|
) => {
|
||||||
const cryptoService = new BrowserCryptoService(
|
const keyService = new BrowserKeyService(
|
||||||
pinService,
|
pinService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
keyGenerationService,
|
keyGenerationService,
|
||||||
@ -243,8 +242,8 @@ const safeProviders: SafeProvider[] = [
|
|||||||
biometricsService,
|
biometricsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
);
|
);
|
||||||
new ContainerService(cryptoService, encryptService).attachToGlobal(self);
|
new ContainerService(keyService, encryptService).attachToGlobal(self);
|
||||||
return cryptoService;
|
return keyService;
|
||||||
},
|
},
|
||||||
deps: [
|
deps: [
|
||||||
PinServiceAbstraction,
|
PinServiceAbstraction,
|
||||||
|
@ -8,10 +8,9 @@ import {
|
|||||||
UserDecryptionOptionsServiceAbstraction,
|
UserDecryptionOptionsServiceAbstraction,
|
||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { BiometricsService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BrowserRouterService } from "../platform/popup/services/browser-router.service";
|
import { BrowserRouterService } from "../platform/popup/services/browser-router.service";
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ describe("ExtensionLockComponentService", () => {
|
|||||||
let biometricsService: MockProxy<BiometricsService>;
|
let biometricsService: MockProxy<BiometricsService>;
|
||||||
let pinService: MockProxy<PinServiceAbstraction>;
|
let pinService: MockProxy<PinServiceAbstraction>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let routerService: MockProxy<BrowserRouterService>;
|
let routerService: MockProxy<BrowserRouterService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -34,7 +33,7 @@ describe("ExtensionLockComponentService", () => {
|
|||||||
biometricsService = mock<BiometricsService>();
|
biometricsService = mock<BiometricsService>();
|
||||||
pinService = mock<PinServiceAbstraction>();
|
pinService = mock<PinServiceAbstraction>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
routerService = mock<BrowserRouterService>();
|
routerService = mock<BrowserRouterService>();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -61,8 +60,8 @@ describe("ExtensionLockComponentService", () => {
|
|||||||
useValue: vaultTimeoutSettingsService,
|
useValue: vaultTimeoutSettingsService,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: CryptoService,
|
provide: KeyService,
|
||||||
useValue: cryptoService,
|
useValue: keyService,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: BrowserRouterService,
|
provide: BrowserRouterService,
|
||||||
@ -307,9 +306,7 @@ describe("ExtensionLockComponentService", () => {
|
|||||||
// Biometrics
|
// Biometrics
|
||||||
biometricsService.supportsBiometric.mockResolvedValue(mockInputs.osSupportsBiometric);
|
biometricsService.supportsBiometric.mockResolvedValue(mockInputs.osSupportsBiometric);
|
||||||
vaultTimeoutSettingsService.isBiometricLockSet.mockResolvedValue(mockInputs.biometricLockSet);
|
vaultTimeoutSettingsService.isBiometricLockSet.mockResolvedValue(mockInputs.biometricLockSet);
|
||||||
cryptoService.hasUserKeyStored.mockResolvedValue(
|
keyService.hasUserKeyStored.mockResolvedValue(mockInputs.hasBiometricEncryptedUserKeyStored);
|
||||||
mockInputs.hasBiometricEncryptedUserKeyStored,
|
|
||||||
);
|
|
||||||
platformUtilsService.supportsSecureStorage.mockReturnValue(
|
platformUtilsService.supportsSecureStorage.mockReturnValue(
|
||||||
mockInputs.platformSupportsSecureStorage,
|
mockInputs.platformSupportsSecureStorage,
|
||||||
);
|
);
|
||||||
|
@ -11,11 +11,10 @@ import {
|
|||||||
UserDecryptionOptionsServiceAbstraction,
|
UserDecryptionOptionsServiceAbstraction,
|
||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { BiometricsService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BiometricErrors, BiometricErrorTypes } from "../models/biometricErrors";
|
import { BiometricErrors, BiometricErrorTypes } from "../models/biometricErrors";
|
||||||
import { BrowserRouterService } from "../platform/popup/services/browser-router.service";
|
import { BrowserRouterService } from "../platform/popup/services/browser-router.service";
|
||||||
@ -26,7 +25,7 @@ export class ExtensionLockComponentService implements LockComponentService {
|
|||||||
private readonly biometricsService = inject(BiometricsService);
|
private readonly biometricsService = inject(BiometricsService);
|
||||||
private readonly pinService = inject(PinServiceAbstraction);
|
private readonly pinService = inject(PinServiceAbstraction);
|
||||||
private readonly vaultTimeoutSettingsService = inject(VaultTimeoutSettingsService);
|
private readonly vaultTimeoutSettingsService = inject(VaultTimeoutSettingsService);
|
||||||
private readonly cryptoService = inject(CryptoService);
|
private readonly keyService = inject(KeyService);
|
||||||
private readonly routerService = inject(BrowserRouterService);
|
private readonly routerService = inject(BrowserRouterService);
|
||||||
|
|
||||||
getPreviousUrl(): string | null {
|
getPreviousUrl(): string | null {
|
||||||
@ -53,7 +52,7 @@ export class ExtensionLockComponentService implements LockComponentService {
|
|||||||
|
|
||||||
private async isBiometricLockSet(userId: UserId): Promise<boolean> {
|
private async isBiometricLockSet(userId: UserId): Promise<boolean> {
|
||||||
const biometricLockSet = await this.vaultTimeoutSettingsService.isBiometricLockSet(userId);
|
const biometricLockSet = await this.vaultTimeoutSettingsService.isBiometricLockSet(userId);
|
||||||
const hasBiometricEncryptedUserKeyStored = await this.cryptoService.hasUserKeyStored(
|
const hasBiometricEncryptedUserKeyStored = await this.keyService.hasUserKeyStored(
|
||||||
KeySuffixOptions.Biometric,
|
KeySuffixOptions.Biometric,
|
||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,6 @@ import { NoopAnimationsModule } from "@angular/platform-browser/animations";
|
|||||||
import { BehaviorSubject } from "rxjs";
|
import { BehaviorSubject } from "rxjs";
|
||||||
|
|
||||||
import { AccountInfo, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountInfo, AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
@ -13,6 +12,7 @@ import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folde
|
|||||||
import { Folder } from "@bitwarden/common/vault/models/domain/folder";
|
import { Folder } from "@bitwarden/common/vault/models/domain/folder";
|
||||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AddEditFolderDialogComponent,
|
AddEditFolderDialogComponent,
|
||||||
@ -64,7 +64,7 @@ describe("AddEditFolderDialogComponent", () => {
|
|||||||
useValue: { activeAccount$: new BehaviorSubject({ id: userId, ...accountInfo }) },
|
useValue: { activeAccount$: new BehaviorSubject({ id: userId, ...accountInfo }) },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: CryptoService,
|
provide: KeyService,
|
||||||
useValue: {
|
useValue: {
|
||||||
getUserKeyWithLegacySupport,
|
getUserKeyWithLegacySupport,
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,6 @@ import { firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
@ -32,6 +31,7 @@ import {
|
|||||||
IconButtonModule,
|
IconButtonModule,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
export type AddEditFolderDialogData = {
|
export type AddEditFolderDialogData = {
|
||||||
/** When provided, dialog will display edit folder variant */
|
/** When provided, dialog will display edit folder variant */
|
||||||
@ -72,7 +72,7 @@ export class AddEditFolderDialogComponent implements AfterViewInit, OnInit {
|
|||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private folderApiService: FolderApiServiceAbstraction,
|
private folderApiService: FolderApiServiceAbstraction,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
@ -113,7 +113,7 @@ export class AddEditFolderDialogComponent implements AfterViewInit, OnInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeUserId.id);
|
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId.id);
|
||||||
const folder = await this.folderService.encrypt(this.folder, userKey);
|
const folder = await this.folderService.encrypt(this.folder, userKey);
|
||||||
await this.folderApiService.save(folder);
|
await this.folderApiService.save(folder);
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from "@bitwarden/ang
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -16,6 +15,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-vault-attachments",
|
selector: "app-vault-attachments",
|
||||||
@ -28,7 +28,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
|
|||||||
constructor(
|
constructor(
|
||||||
cipherService: CipherService,
|
cipherService: CipherService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -45,7 +45,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
|
|||||||
super(
|
super(
|
||||||
cipherService,
|
cipherService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
apiService,
|
apiService,
|
||||||
|
@ -12,7 +12,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||||
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 { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -28,6 +27,7 @@ import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
|||||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { PasswordRepromptService } from "@bitwarden/vault";
|
import { PasswordRepromptService } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { BrowserFido2UserInterfaceSession } from "../../../../autofill/fido2/services/browser-fido2-user-interface.service";
|
import { BrowserFido2UserInterfaceSession } from "../../../../autofill/fido2/services/browser-fido2-user-interface.service";
|
||||||
@ -81,7 +81,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
|
|||||||
totpService: TotpServiceAbstraction,
|
totpService: TotpServiceAbstraction,
|
||||||
tokenService: TokenService,
|
tokenService: TokenService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
auditService: AuditService,
|
auditService: AuditService,
|
||||||
@ -111,7 +111,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
|
|||||||
totpService,
|
totpService,
|
||||||
tokenService,
|
tokenService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
auditService,
|
auditService,
|
||||||
|
@ -5,13 +5,13 @@ import { first } from "rxjs/operators";
|
|||||||
|
|
||||||
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-folder-add-edit",
|
selector: "app-folder-add-edit",
|
||||||
@ -23,7 +23,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent implement
|
|||||||
folderService: FolderService,
|
folderService: FolderService,
|
||||||
folderApiService: FolderApiServiceAbstraction,
|
folderApiService: FolderApiServiceAbstraction,
|
||||||
accountService: AccountService,
|
accountService: AccountService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@ -36,7 +36,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent implement
|
|||||||
folderService,
|
folderService,
|
||||||
folderApiService,
|
folderApiService,
|
||||||
accountService,
|
accountService,
|
||||||
cryptoService,
|
keyService,
|
||||||
i18nService,
|
i18nService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
logService,
|
logService,
|
||||||
|
@ -3,16 +3,16 @@ import {
|
|||||||
OrganizationUserConfirmRequest,
|
OrganizationUserConfirmRequest,
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { Response } from "../../models/response";
|
import { Response } from "../../models/response";
|
||||||
|
|
||||||
export class ConfirmCommand {
|
export class ConfirmCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
) {}
|
) {}
|
||||||
@ -42,7 +42,7 @@ export class ConfirmCommand {
|
|||||||
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
|
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(options.organizationId);
|
const orgKey = await this.keyService.getOrgKey(options.organizationId);
|
||||||
if (orgKey == null) {
|
if (orgKey == null) {
|
||||||
throw new Error("No encryption key for this organization.");
|
throw new Error("No encryption key for this organization.");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import { TwoFactorEmailRequest } from "@bitwarden/common/auth/models/request/two
|
|||||||
import { UpdateTempPasswordRequest } from "@bitwarden/common/auth/models/request/update-temp-password.request";
|
import { UpdateTempPasswordRequest } from "@bitwarden/common/auth/models/request/update-temp-password.request";
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@ -38,6 +37,7 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym
|
|||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { NodeUtils } from "@bitwarden/node/node-utils";
|
import { NodeUtils } from "@bitwarden/node/node-utils";
|
||||||
|
|
||||||
import { Response } from "../../models/response";
|
import { Response } from "../../models/response";
|
||||||
@ -61,7 +61,7 @@ export class LoginCommand {
|
|||||||
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||||
protected platformUtilsService: PlatformUtilsService,
|
protected platformUtilsService: PlatformUtilsService,
|
||||||
protected accountService: AccountService,
|
protected accountService: AccountService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected policyService: PolicyService,
|
protected policyService: PolicyService,
|
||||||
protected twoFactorService: TwoFactorService,
|
protected twoFactorService: TwoFactorService,
|
||||||
protected syncService: SyncService,
|
protected syncService: SyncService,
|
||||||
@ -421,7 +421,7 @@ export class LoginCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const request = new PasswordRequest();
|
const request = new PasswordRequest();
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(currentPassword, null);
|
request.masterPasswordHash = await this.keyService.hashMasterKey(currentPassword, null);
|
||||||
request.masterPasswordHint = hint;
|
request.masterPasswordHint = hint;
|
||||||
request.newMasterPasswordHash = newPasswordHash;
|
request.newMasterPasswordHash = newPasswordHash;
|
||||||
request.key = newUserKey[1].encryptedString;
|
request.key = newUserKey[1].encryptedString;
|
||||||
@ -570,21 +570,21 @@ export class LoginCommand {
|
|||||||
const kdfConfig = await this.kdfConfigService.getKdfConfig();
|
const kdfConfig = await this.kdfConfigService.getKdfConfig();
|
||||||
|
|
||||||
// Create new key and hash new password
|
// Create new key and hash new password
|
||||||
const newMasterKey = await this.cryptoService.makeMasterKey(
|
const newMasterKey = await this.keyService.makeMasterKey(
|
||||||
masterPassword,
|
masterPassword,
|
||||||
this.email.trim().toLowerCase(),
|
this.email.trim().toLowerCase(),
|
||||||
kdfConfig,
|
kdfConfig,
|
||||||
);
|
);
|
||||||
const newPasswordHash = await this.cryptoService.hashMasterKey(masterPassword, newMasterKey);
|
const newPasswordHash = await this.keyService.hashMasterKey(masterPassword, newMasterKey);
|
||||||
|
|
||||||
// Grab user key
|
// Grab user key
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
const userKey = await this.keyService.getUserKey();
|
||||||
if (!userKey) {
|
if (!userKey) {
|
||||||
throw new Error("User key not found.");
|
throw new Error("User key not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-encrypt user key with new master key
|
// Re-encrypt user key with new master key
|
||||||
const newUserKey = await this.cryptoService.encryptUserKeyWithMasterKey(newMasterKey, userKey);
|
const newUserKey = await this.keyService.encryptUserKeyWithMasterKey(newMasterKey, userKey);
|
||||||
|
|
||||||
return { newPasswordHash, newUserKey: newUserKey, hint: masterPasswordHint };
|
return { newPasswordHash, newUserKey: newUserKey, hint: masterPasswordHint };
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ import { UserVerificationService } from "@bitwarden/common/auth/abstractions/use
|
|||||||
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
|
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
|
||||||
import { MasterPasswordVerification } from "@bitwarden/common/auth/types/verification";
|
import { MasterPasswordVerification } from "@bitwarden/common/auth/types/verification";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
|
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
|
||||||
import { MasterKey } from "@bitwarden/common/types/key";
|
import { MasterKey } from "@bitwarden/common/types/key";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { ConvertToKeyConnectorCommand } from "../../commands/convert-to-key-connector.command";
|
import { ConvertToKeyConnectorCommand } from "../../commands/convert-to-key-connector.command";
|
||||||
import { Response } from "../../models/response";
|
import { Response } from "../../models/response";
|
||||||
@ -24,7 +24,7 @@ export class UnlockCommand {
|
|||||||
constructor(
|
constructor(
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
private masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private logService: ConsoleLogService,
|
private logService: ConsoleLogService,
|
||||||
@ -69,7 +69,7 @@ export class UnlockCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userKey = await this.masterPasswordService.decryptUserKeyWithMasterKey(masterKey);
|
const userKey = await this.masterPasswordService.decryptUserKeyWithMasterKey(masterKey);
|
||||||
await this.cryptoService.setUserKey(userKey, userId);
|
await this.keyService.setUserKey(userKey, userId);
|
||||||
|
|
||||||
if (await this.keyConnectorService.getConvertAccountRequired()) {
|
if (await this.keyConnectorService.getConvertAccountRequired()) {
|
||||||
const convertToKeyConnectorCommand = new ConvertToKeyConnectorCommand(
|
const convertToKeyConnectorCommand = new ConvertToKeyConnectorCommand(
|
||||||
|
@ -171,7 +171,7 @@ export abstract class BaseProgram {
|
|||||||
const command = new UnlockCommand(
|
const command = new UnlockCommand(
|
||||||
this.serviceContainer.accountService,
|
this.serviceContainer.accountService,
|
||||||
this.serviceContainer.masterPasswordService,
|
this.serviceContainer.masterPasswordService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.userVerificationService,
|
this.serviceContainer.userVerificationService,
|
||||||
this.serviceContainer.cryptoFunctionService,
|
this.serviceContainer.cryptoFunctionService,
|
||||||
this.serviceContainer.logService,
|
this.serviceContainer.logService,
|
||||||
|
@ -7,12 +7,12 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
|
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
|
||||||
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
|
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
|
||||||
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
|
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
||||||
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
||||||
@ -25,7 +25,7 @@ export class EditCommand {
|
|||||||
constructor(
|
constructor(
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private folderApiService: FolderApiServiceAbstraction,
|
private folderApiService: FolderApiServiceAbstraction,
|
||||||
@ -143,7 +143,7 @@ export class EditCommand {
|
|||||||
folderView = FolderExport.toView(req, folderView);
|
folderView = FolderExport.toView(req, folderView);
|
||||||
|
|
||||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeUserId.id);
|
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId.id);
|
||||||
const encFolder = await this.folderService.encrypt(folderView, userKey);
|
const encFolder = await this.folderService.encrypt(folderView, userKey);
|
||||||
try {
|
try {
|
||||||
await this.folderApiService.save(encFolder);
|
await this.folderApiService.save(encFolder);
|
||||||
@ -174,7 +174,7 @@ export class EditCommand {
|
|||||||
return Response.badRequest("`organizationid` option does not match request object.");
|
return Response.badRequest("`organizationid` option does not match request object.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(req.organizationId);
|
const orgKey = await this.keyService.getOrgKey(req.organizationId);
|
||||||
if (orgKey == null) {
|
if (orgKey == null) {
|
||||||
throw new Error("No encryption key for this organization.");
|
throw new Error("No encryption key for this organization.");
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import { LoginUriExport } from "@bitwarden/common/models/export/login-uri.export
|
|||||||
import { LoginExport } from "@bitwarden/common/models/export/login.export";
|
import { LoginExport } from "@bitwarden/common/models/export/login.export";
|
||||||
import { SecureNoteExport } from "@bitwarden/common/models/export/secure-note.export";
|
import { SecureNoteExport } from "@bitwarden/common/models/export/secure-note.export";
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@ -33,6 +32,7 @@ import { TotpService } from "@bitwarden/common/vault/abstractions/totp.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 { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
||||||
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
||||||
@ -56,7 +56,7 @@ export class GetCommand extends DownloadCommand {
|
|||||||
private collectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
private totpService: TotpService,
|
private totpService: TotpService,
|
||||||
private auditService: AuditService,
|
private auditService: AuditService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
@ -377,7 +377,7 @@ export class GetCommand extends DownloadCommand {
|
|||||||
const key =
|
const key =
|
||||||
attachments[0].key != null
|
attachments[0].key != null
|
||||||
? attachments[0].key
|
? attachments[0].key
|
||||||
: await this.cryptoService.getOrgKey(cipher.organizationId);
|
: await this.keyService.getOrgKey(cipher.organizationId);
|
||||||
return await this.saveAttachmentToFile(url, key, attachments[0].fileName, options.output);
|
return await this.saveAttachmentToFile(url, key, attachments[0].fileName, options.output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ export class GetCommand extends DownloadCommand {
|
|||||||
if (Utils.isGuid(id)) {
|
if (Utils.isGuid(id)) {
|
||||||
const collection = await this.collectionService.get(id);
|
const collection = await this.collectionService.get(id);
|
||||||
if (collection != null) {
|
if (collection != null) {
|
||||||
const orgKeys = await firstValueFrom(this.cryptoService.activeUserOrgKeys$);
|
const orgKeys = await firstValueFrom(this.keyService.activeUserOrgKeys$);
|
||||||
decCollection = await collection.decrypt(
|
decCollection = await collection.decrypt(
|
||||||
orgKeys[collection.organizationId as OrganizationId],
|
orgKeys[collection.organizationId as OrganizationId],
|
||||||
);
|
);
|
||||||
@ -445,7 +445,7 @@ export class GetCommand extends DownloadCommand {
|
|||||||
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
|
return Response.badRequest("`" + options.organizationId + "` is not a GUID.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(options.organizationId);
|
const orgKey = await this.keyService.getOrgKey(options.organizationId);
|
||||||
if (orgKey == null) {
|
if (orgKey == null) {
|
||||||
throw new Error("No encryption key for this organization.");
|
throw new Error("No encryption key for this organization.");
|
||||||
}
|
}
|
||||||
@ -553,13 +553,13 @@ export class GetCommand extends DownloadCommand {
|
|||||||
const activeUserId = await firstValueFrom(
|
const activeUserId = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||||
);
|
);
|
||||||
const publicKey = await firstValueFrom(this.cryptoService.userPublicKey$(activeUserId));
|
const publicKey = await firstValueFrom(this.keyService.userPublicKey$(activeUserId));
|
||||||
fingerprint = await this.cryptoService.getFingerprint(activeUserId, publicKey);
|
fingerprint = await this.keyService.getFingerprint(activeUserId, publicKey);
|
||||||
} else if (Utils.isGuid(id)) {
|
} else if (Utils.isGuid(id)) {
|
||||||
try {
|
try {
|
||||||
const response = await this.apiService.getUserPublicKey(id);
|
const response = await this.apiService.getUserPublicKey(id);
|
||||||
const pubKey = Utils.fromB64ToArray(response.publicKey);
|
const pubKey = Utils.fromB64ToArray(response.publicKey);
|
||||||
fingerprint = await this.cryptoService.getFingerprint(id, pubKey);
|
fingerprint = await this.keyService.getFingerprint(id, pubKey);
|
||||||
} catch {
|
} catch {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ export class OssServeConfigurator {
|
|||||||
this.serviceContainer.collectionService,
|
this.serviceContainer.collectionService,
|
||||||
this.serviceContainer.totpService,
|
this.serviceContainer.totpService,
|
||||||
this.serviceContainer.auditService,
|
this.serviceContainer.auditService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.stateService,
|
this.serviceContainer.stateService,
|
||||||
this.serviceContainer.searchService,
|
this.serviceContainer.searchService,
|
||||||
@ -79,7 +79,7 @@ export class OssServeConfigurator {
|
|||||||
this.createCommand = new CreateCommand(
|
this.createCommand = new CreateCommand(
|
||||||
this.serviceContainer.cipherService,
|
this.serviceContainer.cipherService,
|
||||||
this.serviceContainer.folderService,
|
this.serviceContainer.folderService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.folderApiService,
|
this.serviceContainer.folderApiService,
|
||||||
@ -90,7 +90,7 @@ export class OssServeConfigurator {
|
|||||||
this.editCommand = new EditCommand(
|
this.editCommand = new EditCommand(
|
||||||
this.serviceContainer.cipherService,
|
this.serviceContainer.cipherService,
|
||||||
this.serviceContainer.folderService,
|
this.serviceContainer.folderService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.folderApiService,
|
this.serviceContainer.folderApiService,
|
||||||
@ -117,7 +117,7 @@ export class OssServeConfigurator {
|
|||||||
);
|
);
|
||||||
this.confirmCommand = new ConfirmCommand(
|
this.confirmCommand = new ConfirmCommand(
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.organizationUserApiService,
|
this.serviceContainer.organizationUserApiService,
|
||||||
);
|
);
|
||||||
@ -130,7 +130,7 @@ export class OssServeConfigurator {
|
|||||||
this.unlockCommand = new UnlockCommand(
|
this.unlockCommand = new UnlockCommand(
|
||||||
this.serviceContainer.accountService,
|
this.serviceContainer.accountService,
|
||||||
this.serviceContainer.masterPasswordService,
|
this.serviceContainer.masterPasswordService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.userVerificationService,
|
this.serviceContainer.userVerificationService,
|
||||||
this.serviceContainer.cryptoFunctionService,
|
this.serviceContainer.cryptoFunctionService,
|
||||||
this.serviceContainer.logService,
|
this.serviceContainer.logService,
|
||||||
@ -399,7 +399,7 @@ export class OssServeConfigurator {
|
|||||||
this.processResponse(res, Response.error("You are not logged in."));
|
this.processResponse(res, Response.error("You are not logged in."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (await this.serviceContainer.cryptoService.hasUserKey()) {
|
if (await this.serviceContainer.keyService.hasUserKey()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.processResponse(res, Response.error("Vault is locked."));
|
this.processResponse(res, Response.error("Vault is locked."));
|
||||||
|
@ -150,7 +150,7 @@ export class Program extends BaseProgram {
|
|||||||
this.serviceContainer.passwordStrengthService,
|
this.serviceContainer.passwordStrengthService,
|
||||||
this.serviceContainer.platformUtilsService,
|
this.serviceContainer.platformUtilsService,
|
||||||
this.serviceContainer.accountService,
|
this.serviceContainer.accountService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.policyService,
|
this.serviceContainer.policyService,
|
||||||
this.serviceContainer.twoFactorService,
|
this.serviceContainer.twoFactorService,
|
||||||
this.serviceContainer.syncService,
|
this.serviceContainer.syncService,
|
||||||
@ -258,7 +258,7 @@ export class Program extends BaseProgram {
|
|||||||
const command = new UnlockCommand(
|
const command = new UnlockCommand(
|
||||||
this.serviceContainer.accountService,
|
this.serviceContainer.accountService,
|
||||||
this.serviceContainer.masterPasswordService,
|
this.serviceContainer.masterPasswordService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.userVerificationService,
|
this.serviceContainer.userVerificationService,
|
||||||
this.serviceContainer.cryptoFunctionService,
|
this.serviceContainer.cryptoFunctionService,
|
||||||
this.serviceContainer.logService,
|
this.serviceContainer.logService,
|
||||||
|
@ -79,7 +79,6 @@ import { AppIdService } from "@bitwarden/common/platform/services/app-id.service
|
|||||||
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
|
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
|
||||||
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
|
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
|
||||||
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
|
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/services/crypto.service";
|
|
||||||
import { EncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/encrypt.service.implementation";
|
import { EncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/encrypt.service.implementation";
|
||||||
import { FallbackBulkEncryptService } from "@bitwarden/common/platform/services/cryptography/fallback-bulk-encrypt.service";
|
import { FallbackBulkEncryptService } from "@bitwarden/common/platform/services/cryptography/fallback-bulk-encrypt.service";
|
||||||
import { DefaultEnvironmentService } from "@bitwarden/common/platform/services/default-environment.service";
|
import { DefaultEnvironmentService } from "@bitwarden/common/platform/services/default-environment.service";
|
||||||
@ -127,6 +126,7 @@ import {
|
|||||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service";
|
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service";
|
||||||
import { SendStateProvider } from "@bitwarden/common/tools/send/services/send-state.provider";
|
import { SendStateProvider } from "@bitwarden/common/tools/send/services/send-state.provider";
|
||||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service";
|
import { SendService } from "@bitwarden/common/tools/send/services/send.service";
|
||||||
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
|
import { VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
|
||||||
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import {
|
import {
|
||||||
@ -148,7 +148,11 @@ import {
|
|||||||
ImportService,
|
ImportService,
|
||||||
ImportServiceAbstraction,
|
ImportServiceAbstraction,
|
||||||
} from "@bitwarden/importer/core";
|
} from "@bitwarden/importer/core";
|
||||||
import { BiometricStateService, DefaultBiometricStateService } from "@bitwarden/key-management";
|
import {
|
||||||
|
DefaultKeyService as KeyService,
|
||||||
|
BiometricStateService,
|
||||||
|
DefaultBiometricStateService,
|
||||||
|
} from "@bitwarden/key-management";
|
||||||
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
|
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
|
||||||
import {
|
import {
|
||||||
IndividualVaultExportService,
|
IndividualVaultExportService,
|
||||||
@ -187,7 +191,7 @@ export class ServiceContainer {
|
|||||||
memoryStorageForStateProviders: MemoryStorageServiceForStateProviders;
|
memoryStorageForStateProviders: MemoryStorageServiceForStateProviders;
|
||||||
i18nService: I18nService;
|
i18nService: I18nService;
|
||||||
platformUtilsService: CliPlatformUtilsService;
|
platformUtilsService: CliPlatformUtilsService;
|
||||||
cryptoService: CryptoService;
|
keyService: KeyService;
|
||||||
tokenService: TokenService;
|
tokenService: TokenService;
|
||||||
appIdService: AppIdService;
|
appIdService: AppIdService;
|
||||||
apiService: NodeApiService;
|
apiService: NodeApiService;
|
||||||
@ -416,7 +420,7 @@ export class ServiceContainer {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cryptoService = new CryptoService(
|
this.keyService = new KeyService(
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
@ -449,7 +453,7 @@ export class ServiceContainer {
|
|||||||
this.accountService,
|
this.accountService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.userDecryptionOptionsService,
|
this.userDecryptionOptionsService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.biometricStateService,
|
this.biometricStateService,
|
||||||
@ -474,7 +478,7 @@ export class ServiceContainer {
|
|||||||
customUserAgent,
|
customUserAgent,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
|
this.containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
|
|
||||||
this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider);
|
this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider);
|
||||||
|
|
||||||
@ -483,7 +487,7 @@ export class ServiceContainer {
|
|||||||
this.sendStateProvider = new SendStateProvider(this.stateProvider);
|
this.sendStateProvider = new SendStateProvider(this.stateProvider);
|
||||||
|
|
||||||
this.sendService = new SendService(
|
this.sendService = new SendService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
this.sendStateProvider,
|
this.sendStateProvider,
|
||||||
@ -504,7 +508,7 @@ export class ServiceContainer {
|
|||||||
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
||||||
|
|
||||||
this.collectionService = new DefaultCollectionService(
|
this.collectionService = new DefaultCollectionService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -517,7 +521,7 @@ export class ServiceContainer {
|
|||||||
this.keyConnectorService = new KeyConnectorService(
|
this.keyConnectorService = new KeyConnectorService(
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.logService,
|
this.logService,
|
||||||
@ -542,7 +546,7 @@ export class ServiceContainer {
|
|||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.kdfConfigService,
|
this.kdfConfigService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
customUserAgent,
|
customUserAgent,
|
||||||
);
|
);
|
||||||
@ -551,7 +555,7 @@ export class ServiceContainer {
|
|||||||
|
|
||||||
this.passwordGenerationService = legacyPasswordGenerationServiceFactory(
|
this.passwordGenerationService = legacyPasswordGenerationServiceFactory(
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -561,7 +565,7 @@ export class ServiceContainer {
|
|||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
@ -576,7 +580,7 @@ export class ServiceContainer {
|
|||||||
this.authService = new AuthService(
|
this.authService = new AuthService(
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
@ -596,7 +600,7 @@ export class ServiceContainer {
|
|||||||
this.deviceTrustService = new DeviceTrustService(
|
this.deviceTrustService = new DeviceTrustService(
|
||||||
this.keyGenerationService,
|
this.keyGenerationService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.devicesApiService,
|
this.devicesApiService,
|
||||||
@ -612,7 +616,7 @@ export class ServiceContainer {
|
|||||||
this.loginStrategyService = new LoginStrategyService(
|
this.loginStrategyService = new LoginStrategyService(
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
@ -644,7 +648,7 @@ export class ServiceContainer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.cipherService = new CipherService(
|
this.cipherService = new CipherService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.domainSettingsService,
|
this.domainSettingsService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
@ -660,7 +664,7 @@ export class ServiceContainer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.folderService = new FolderService(
|
this.folderService = new FolderService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
@ -670,12 +674,12 @@ export class ServiceContainer {
|
|||||||
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
||||||
|
|
||||||
const lockedCallback = async (userId?: string) =>
|
const lockedCallback = async (userId?: string) =>
|
||||||
await this.cryptoService.clearStoredUserKey(KeySuffixOptions.Auto);
|
await this.keyService.clearStoredUserKey(KeySuffixOptions.Auto);
|
||||||
|
|
||||||
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
||||||
|
|
||||||
this.userVerificationService = new UserVerificationService(
|
this.userVerificationService = new UserVerificationService(
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.masterPasswordService,
|
this.masterPasswordService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
@ -716,7 +720,7 @@ export class ServiceContainer {
|
|||||||
this.domainSettingsService,
|
this.domainSettingsService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
@ -747,7 +751,7 @@ export class ServiceContainer {
|
|||||||
this.importApiService,
|
this.importApiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
@ -757,7 +761,7 @@ export class ServiceContainer {
|
|||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.kdfConfigService,
|
this.kdfConfigService,
|
||||||
@ -768,7 +772,7 @@ export class ServiceContainer {
|
|||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.pinService,
|
this.pinService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
@ -781,7 +785,7 @@ export class ServiceContainer {
|
|||||||
this.organizationExportService,
|
this.organizationExportService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.cryptoService);
|
this.userAutoUnlockKeyService = new UserAutoUnlockKeyService(this.keyService);
|
||||||
|
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
|
|
||||||
@ -823,17 +827,17 @@ export class ServiceContainer {
|
|||||||
});
|
});
|
||||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
|
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.eventUploadService.uploadEvents(userId),
|
this.eventUploadService.uploadEvents(userId as UserId),
|
||||||
this.cryptoService.clearKeys(),
|
this.keyService.clearKeys(),
|
||||||
this.cipherService.clear(userId),
|
this.cipherService.clear(userId),
|
||||||
this.folderService.clear(userId),
|
this.folderService.clear(userId),
|
||||||
this.collectionService.clear(userId),
|
this.collectionService.clear(userId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await this.stateEventRunnerService.handleEvent("logout", userId);
|
await this.stateEventRunnerService.handleEvent("logout", userId as UserId);
|
||||||
|
|
||||||
await this.stateService.clean();
|
await this.stateService.clean();
|
||||||
await this.accountService.clean(userId);
|
await this.accountService.clean(userId as UserId);
|
||||||
await this.accountService.switchAccount(null);
|
await this.accountService.switchAccount(null);
|
||||||
process.env.BW_SESSION = undefined;
|
process.env.BW_SESSION = undefined;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import { firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
@ -15,6 +14,7 @@ import { SendAccess } from "@bitwarden/common/tools/send/models/domain/send-acce
|
|||||||
import { SendAccessRequest } from "@bitwarden/common/tools/send/models/request/send-access.request";
|
import { SendAccessRequest } from "@bitwarden/common/tools/send/models/request/send-access.request";
|
||||||
import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-access.view";
|
import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-access.view";
|
||||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { NodeUtils } from "@bitwarden/node/node-utils";
|
import { NodeUtils } from "@bitwarden/node/node-utils";
|
||||||
|
|
||||||
import { DownloadCommand } from "../../../commands/download.command";
|
import { DownloadCommand } from "../../../commands/download.command";
|
||||||
@ -27,7 +27,7 @@ export class SendReceiveCommand extends DownloadCommand {
|
|||||||
private sendAccessRequest: SendAccessRequest;
|
private sendAccessRequest: SendAccessRequest;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
@ -146,7 +146,7 @@ export class SendReceiveCommand extends DownloadCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const sendAccess = new SendAccess(sendResponse);
|
const sendAccess = new SendAccess(sendResponse);
|
||||||
this.decKey = await this.cryptoService.makeSendKey(key);
|
this.decKey = await this.keyService.makeSendKey(key);
|
||||||
return await sendAccess.decrypt(this.decKey);
|
return await sendAccess.decrypt(this.decKey);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ErrorResponse) {
|
if (e instanceof ErrorResponse) {
|
||||||
|
@ -100,7 +100,7 @@ export class SendProgram extends BaseProgram {
|
|||||||
})
|
})
|
||||||
.action(async (url: string, options: OptionValues) => {
|
.action(async (url: string, options: OptionValues) => {
|
||||||
const cmd = new SendReceiveCommand(
|
const cmd = new SendReceiveCommand(
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.cryptoFunctionService,
|
this.serviceContainer.cryptoFunctionService,
|
||||||
this.serviceContainer.platformUtilsService,
|
this.serviceContainer.platformUtilsService,
|
||||||
@ -142,7 +142,7 @@ export class SendProgram extends BaseProgram {
|
|||||||
this.serviceContainer.collectionService,
|
this.serviceContainer.collectionService,
|
||||||
this.serviceContainer.totpService,
|
this.serviceContainer.totpService,
|
||||||
this.serviceContainer.auditService,
|
this.serviceContainer.auditService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.stateService,
|
this.serviceContainer.stateService,
|
||||||
this.serviceContainer.searchService,
|
this.serviceContainer.searchService,
|
||||||
|
@ -177,7 +177,7 @@ export class VaultProgram extends BaseProgram {
|
|||||||
this.serviceContainer.collectionService,
|
this.serviceContainer.collectionService,
|
||||||
this.serviceContainer.totpService,
|
this.serviceContainer.totpService,
|
||||||
this.serviceContainer.auditService,
|
this.serviceContainer.auditService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.stateService,
|
this.serviceContainer.stateService,
|
||||||
this.serviceContainer.searchService,
|
this.serviceContainer.searchService,
|
||||||
@ -224,7 +224,7 @@ export class VaultProgram extends BaseProgram {
|
|||||||
const command = new CreateCommand(
|
const command = new CreateCommand(
|
||||||
this.serviceContainer.cipherService,
|
this.serviceContainer.cipherService,
|
||||||
this.serviceContainer.folderService,
|
this.serviceContainer.folderService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.folderApiService,
|
this.serviceContainer.folderApiService,
|
||||||
@ -273,7 +273,7 @@ export class VaultProgram extends BaseProgram {
|
|||||||
const command = new EditCommand(
|
const command = new EditCommand(
|
||||||
this.serviceContainer.cipherService,
|
this.serviceContainer.cipherService,
|
||||||
this.serviceContainer.folderService,
|
this.serviceContainer.folderService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.folderApiService,
|
this.serviceContainer.folderApiService,
|
||||||
@ -415,7 +415,7 @@ export class VaultProgram extends BaseProgram {
|
|||||||
await this.exitIfLocked();
|
await this.exitIfLocked();
|
||||||
const command = new ConfirmCommand(
|
const command = new ConfirmCommand(
|
||||||
this.serviceContainer.apiService,
|
this.serviceContainer.apiService,
|
||||||
this.serviceContainer.cryptoService,
|
this.serviceContainer.keyService,
|
||||||
this.serviceContainer.encryptService,
|
this.serviceContainer.encryptService,
|
||||||
this.serviceContainer.organizationUserApiService,
|
this.serviceContainer.organizationUserApiService,
|
||||||
);
|
);
|
||||||
|
@ -12,12 +12,12 @@ import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abs
|
|||||||
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
|
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
|
||||||
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
|
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
|
||||||
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
|
import { FolderExport } from "@bitwarden/common/models/export/folder.export";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
|
||||||
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
import { OrganizationCollectionResponse } from "../admin-console/models/response/organization-collection.response";
|
||||||
@ -31,7 +31,7 @@ export class CreateCommand {
|
|||||||
constructor(
|
constructor(
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private folderApiService: FolderApiServiceAbstraction,
|
private folderApiService: FolderApiServiceAbstraction,
|
||||||
@ -141,7 +141,7 @@ export class CreateCommand {
|
|||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
const userKey = await this.keyService.getUserKey();
|
||||||
if (userKey == null) {
|
if (userKey == null) {
|
||||||
return Response.error(
|
return Response.error(
|
||||||
"You must update your encryption key before you can use this feature. " +
|
"You must update your encryption key before you can use this feature. " +
|
||||||
@ -170,7 +170,7 @@ export class CreateCommand {
|
|||||||
|
|
||||||
private async createFolder(req: FolderExport) {
|
private async createFolder(req: FolderExport) {
|
||||||
const activeAccountId = await firstValueFrom(this.accountService.activeAccount$);
|
const activeAccountId = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeAccountId.id);
|
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeAccountId.id);
|
||||||
const folder = await this.folderService.encrypt(FolderExport.toView(req), userKey);
|
const folder = await this.folderService.encrypt(FolderExport.toView(req), userKey);
|
||||||
try {
|
try {
|
||||||
await this.folderApiService.save(folder);
|
await this.folderApiService.save(folder);
|
||||||
@ -194,7 +194,7 @@ export class CreateCommand {
|
|||||||
return Response.badRequest("`organizationid` option does not match request object.");
|
return Response.badRequest("`organizationid` option does not match request object.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(req.organizationId);
|
const orgKey = await this.keyService.getOrgKey(req.organizationId);
|
||||||
if (orgKey == null) {
|
if (orgKey == null) {
|
||||||
throw new Error("No encryption key for this organization.");
|
throw new Error("No encryption key for this organization.");
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/s
|
|||||||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
import { DeviceType } from "@bitwarden/common/enums";
|
import { DeviceType } from "@bitwarden/common/enums";
|
||||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -29,7 +28,7 @@ import {
|
|||||||
VaultTimeoutStringType,
|
VaultTimeoutStringType,
|
||||||
} from "@bitwarden/common/types/vault-timeout.type";
|
} from "@bitwarden/common/types/vault-timeout.type";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { SetPinComponent } from "../../auth/components/set-pin.component";
|
import { SetPinComponent } from "../../auth/components/set-pin.component";
|
||||||
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
||||||
@ -126,7 +125,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private autofillSettingsService: AutofillSettingsServiceAbstraction,
|
private autofillSettingsService: AutofillSettingsServiceAbstraction,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private themeStateService: ThemeStateService,
|
private themeStateService: ThemeStateService,
|
||||||
private domainSettingsService: DomainSettingsService,
|
private domainSettingsService: DomainSettingsService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
@ -460,7 +459,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
if (!enabled || !this.supportsBiometric) {
|
if (!enabled || !this.supportsBiometric) {
|
||||||
this.form.controls.biometric.setValue(false, { emitEvent: false });
|
this.form.controls.biometric.setValue(false, { emitEvent: false });
|
||||||
await this.biometricStateService.setBiometricUnlockEnabled(false);
|
await this.biometricStateService.setBiometricUnlockEnabled(false);
|
||||||
await this.cryptoService.refreshAdditionalKeys();
|
await this.keyService.refreshAdditionalKeys();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,10 +498,10 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
await this.biometricStateService.setRequirePasswordOnStart(true);
|
await this.biometricStateService.setRequirePasswordOnStart(true);
|
||||||
await this.biometricStateService.setDismissedRequirePasswordOnStartCallout();
|
await this.biometricStateService.setDismissedRequirePasswordOnStartCallout();
|
||||||
}
|
}
|
||||||
await this.cryptoService.refreshAdditionalKeys();
|
await this.keyService.refreshAdditionalKeys();
|
||||||
|
|
||||||
// Validate the key is stored in case biometrics fail.
|
// Validate the key is stored in case biometrics fail.
|
||||||
const biometricSet = await this.cryptoService.hasUserKeyStored(KeySuffixOptions.Biometric);
|
const biometricSet = await this.keyService.hasUserKeyStored(KeySuffixOptions.Biometric);
|
||||||
this.form.controls.biometric.setValue(biometricSet, { emitEvent: false });
|
this.form.controls.biometric.setValue(biometricSet, { emitEvent: false });
|
||||||
if (!biometricSet) {
|
if (!biometricSet) {
|
||||||
await this.biometricStateService.setBiometricUnlockEnabled(false);
|
await this.biometricStateService.setBiometricUnlockEnabled(false);
|
||||||
@ -534,7 +533,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||||||
await this.biometricStateService.setRequirePasswordOnStart(false);
|
await this.biometricStateService.setRequirePasswordOnStart(false);
|
||||||
}
|
}
|
||||||
await this.biometricStateService.setDismissedRequirePasswordOnStartCallout();
|
await this.biometricStateService.setDismissedRequirePasswordOnStartCallout();
|
||||||
await this.cryptoService.refreshAdditionalKeys();
|
await this.keyService.refreshAdditionalKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveFavicons() {
|
async saveFavicons() {
|
||||||
|
@ -35,7 +35,6 @@ import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action
|
|||||||
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -53,7 +52,7 @@ import { InternalFolderService } from "@bitwarden/common/vault/abstractions/fold
|
|||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { DialogService, ToastOptions, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastOptions, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
import { BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { DeleteAccountComponent } from "../auth/delete-account.component";
|
import { DeleteAccountComponent } from "../auth/delete-account.component";
|
||||||
import { LoginApprovalComponent } from "../auth/login/login-approval.component";
|
import { LoginApprovalComponent } from "../auth/login/login-approval.component";
|
||||||
@ -135,7 +134,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
private ngZone: NgZone,
|
private ngZone: NgZone,
|
||||||
private vaultTimeoutService: VaultTimeoutService,
|
private vaultTimeoutService: VaultTimeoutService,
|
||||||
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private collectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
@ -303,8 +302,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
const activeUserId = await firstValueFrom(
|
const activeUserId = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||||
);
|
);
|
||||||
const publicKey = await firstValueFrom(this.cryptoService.userPublicKey$(activeUserId));
|
const publicKey = await firstValueFrom(this.keyService.userPublicKey$(activeUserId));
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(activeUserId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(activeUserId, publicKey);
|
||||||
const dialogRef = FingerprintDialogComponent.open(this.dialogService, { fingerprint });
|
const dialogRef = FingerprintDialogComponent.open(this.dialogService, { fingerprint });
|
||||||
await firstValueFrom(dialogRef.closed);
|
await firstValueFrom(dialogRef.closed);
|
||||||
break;
|
break;
|
||||||
@ -692,7 +691,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// Provide the userId of the user to upload events for
|
// Provide the userId of the user to upload events for
|
||||||
await this.eventUploadService.uploadEvents(userBeingLoggedOut);
|
await this.eventUploadService.uploadEvents(userBeingLoggedOut);
|
||||||
await this.cryptoService.clearKeys(userBeingLoggedOut);
|
await this.keyService.clearKeys(userBeingLoggedOut);
|
||||||
await this.cipherService.clear(userBeingLoggedOut);
|
await this.cipherService.clear(userBeingLoggedOut);
|
||||||
await this.folderService.clear(userBeingLoggedOut);
|
await this.folderService.clear(userBeingLoggedOut);
|
||||||
await this.collectionService.clear(userBeingLoggedOut);
|
await this.collectionService.clear(userBeingLoggedOut);
|
||||||
|
@ -8,7 +8,6 @@ import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/
|
|||||||
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
|
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
||||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
@ -19,6 +18,7 @@ import { SyncService as SyncServiceAbstraction } from "@bitwarden/common/platfor
|
|||||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||||
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { I18nRendererService } from "../../platform/services/i18n.renderer.service";
|
import { I18nRendererService } from "../../platform/services/i18n.renderer.service";
|
||||||
import { NativeMessagingService } from "../../services/native-messaging.service";
|
import { NativeMessagingService } from "../../services/native-messaging.service";
|
||||||
@ -35,7 +35,7 @@ export class InitService {
|
|||||||
private notificationsService: NotificationsServiceAbstraction,
|
private notificationsService: NotificationsServiceAbstraction,
|
||||||
private platformUtilsService: PlatformUtilsServiceAbstraction,
|
private platformUtilsService: PlatformUtilsServiceAbstraction,
|
||||||
private stateService: StateServiceAbstraction,
|
private stateService: StateServiceAbstraction,
|
||||||
private cryptoService: CryptoServiceAbstraction,
|
private keyService: KeyServiceAbstraction,
|
||||||
private nativeMessagingService: NativeMessagingService,
|
private nativeMessagingService: NativeMessagingService,
|
||||||
private themingService: AbstractThemingService,
|
private themingService: AbstractThemingService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
@ -73,7 +73,7 @@ export class InitService {
|
|||||||
htmlEl.classList.add("os_" + this.platformUtilsService.getDeviceString());
|
htmlEl.classList.add("os_" + this.platformUtilsService.getDeviceString());
|
||||||
this.themingService.applyThemeChangesTo(this.document);
|
this.themingService.applyThemeChangesTo(this.document);
|
||||||
|
|
||||||
const containerService = new ContainerService(this.cryptoService, this.encryptService);
|
const containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
containerService.attachToGlobal(this.win);
|
containerService.attachToGlobal(this.win);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,6 @@ import { ClientType } from "@bitwarden/common/enums";
|
|||||||
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
||||||
import { ProcessReloadService } from "@bitwarden/common/key-management/services/process-reload.service";
|
import { ProcessReloadService } from "@bitwarden/common/key-management/services/process-reload.service";
|
||||||
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import {
|
|
||||||
CryptoService,
|
|
||||||
CryptoService as CryptoServiceAbstraction,
|
|
||||||
} from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -74,13 +70,18 @@ import { VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.ty
|
|||||||
import { CipherService as CipherServiceAbstraction } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService as CipherServiceAbstraction } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
import { BiometricStateService, BiometricsService } from "@bitwarden/key-management";
|
import {
|
||||||
|
KeyService,
|
||||||
|
KeyService as KeyServiceAbstraction,
|
||||||
|
BiometricStateService,
|
||||||
|
BiometricsService,
|
||||||
|
} from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
import { DesktopAutofillSettingsService } from "../../autofill/services/desktop-autofill-settings.service";
|
||||||
import { ElectronBiometricsService } from "../../key-management/biometrics/electron-biometrics.service";
|
import { ElectronBiometricsService } from "../../key-management/biometrics/electron-biometrics.service";
|
||||||
import { flagEnabled } from "../../platform/flags";
|
import { flagEnabled } from "../../platform/flags";
|
||||||
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { ElectronCryptoService } from "../../platform/services/electron-crypto.service";
|
import { ElectronKeyService } from "../../platform/services/electron-key.service";
|
||||||
import { ElectronLogRendererService } from "../../platform/services/electron-log.renderer.service";
|
import { ElectronLogRendererService } from "../../platform/services/electron-log.renderer.service";
|
||||||
import {
|
import {
|
||||||
ELECTRON_SUPPORTS_SECURE_STORAGE,
|
ELECTRON_SUPPORTS_SECURE_STORAGE,
|
||||||
@ -260,8 +261,8 @@ const safeProviders: SafeProvider[] = [
|
|||||||
deps: [WINDOW],
|
deps: [WINDOW],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: CryptoServiceAbstraction,
|
provide: KeyServiceAbstraction,
|
||||||
useClass: ElectronCryptoService,
|
useClass: ElectronKeyService,
|
||||||
deps: [
|
deps: [
|
||||||
PinServiceAbstraction,
|
PinServiceAbstraction,
|
||||||
InternalMasterPasswordServiceAbstraction,
|
InternalMasterPasswordServiceAbstraction,
|
||||||
@ -304,7 +305,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
useClass: DesktopSetPasswordJitService,
|
useClass: DesktopSetPasswordJitService,
|
||||||
deps: [
|
deps: [
|
||||||
ApiService,
|
ApiService,
|
||||||
CryptoService,
|
KeyService,
|
||||||
EncryptService,
|
EncryptService,
|
||||||
I18nServiceAbstraction,
|
I18nServiceAbstraction,
|
||||||
KdfConfigService,
|
KdfConfigService,
|
||||||
|
@ -20,7 +20,6 @@ import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth
|
|||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { FakeMasterPasswordService } from "@bitwarden/common/auth/services/master-password/fake-master-password.service";
|
import { FakeMasterPasswordService } from "@bitwarden/common/auth/services/master-password/fake-master-password.service";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -34,6 +33,7 @@ import { UserId } from "@bitwarden/common/types/guid";
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import {
|
import {
|
||||||
|
KeyService,
|
||||||
BiometricsService as AbstractBiometricService,
|
BiometricsService as AbstractBiometricService,
|
||||||
BiometricStateService,
|
BiometricStateService,
|
||||||
} from "@bitwarden/key-management";
|
} from "@bitwarden/key-management";
|
||||||
@ -106,8 +106,8 @@ describe("LockComponent", () => {
|
|||||||
useValue: messagingServiceMock,
|
useValue: messagingServiceMock,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: CryptoService,
|
provide: KeyService,
|
||||||
useValue: mock<CryptoService>(),
|
useValue: mock<KeyService>(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: VaultTimeoutService,
|
provide: VaultTimeoutService,
|
||||||
|
@ -17,7 +17,6 @@ import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth
|
|||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { DeviceType } from "@bitwarden/common/enums";
|
import { DeviceType } from "@bitwarden/common/enums";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -27,7 +26,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "LockComponent";
|
const BroadcasterSubscriptionId = "LockComponent";
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ export class LockComponent extends BaseLockComponent implements OnInit, OnDestro
|
|||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
vaultTimeoutService: VaultTimeoutService,
|
vaultTimeoutService: VaultTimeoutService,
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
environmentService: EnvironmentService,
|
environmentService: EnvironmentService,
|
||||||
@ -79,7 +78,7 @@ export class LockComponent extends BaseLockComponent implements OnInit, OnDestro
|
|||||||
i18nService,
|
i18nService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
messagingService,
|
messagingService,
|
||||||
cryptoService,
|
keyService,
|
||||||
vaultTimeoutService,
|
vaultTimeoutService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
environmentService,
|
environmentService,
|
||||||
|
@ -9,7 +9,6 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@ -20,6 +19,7 @@ import {
|
|||||||
DialogService,
|
DialogService,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
const RequestTimeOut = 60000 * 15; //15 Minutes
|
const RequestTimeOut = 60000 * 15; //15 Minutes
|
||||||
const RequestTimeUpdate = 60000 * 5; //5 Minutes
|
const RequestTimeUpdate = 60000 * 5; //5 Minutes
|
||||||
@ -53,7 +53,7 @@ export class LoginApprovalComponent implements OnInit, OnDestroy {
|
|||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected apiService: ApiService,
|
protected apiService: ApiService,
|
||||||
protected appIdService: AppIdService,
|
protected appIdService: AppIdService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
private dialogRef: DialogRef,
|
private dialogRef: DialogRef,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
) {
|
) {
|
||||||
|
@ -16,7 +16,6 @@ import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
|||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -25,6 +24,7 @@ import { ValidationService } from "@bitwarden/common/platform/abstractions/valid
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { EnvironmentComponent } from "../environment.component";
|
import { EnvironmentComponent } from "../environment.component";
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
cryptoFunctionService: CryptoFunctionService,
|
cryptoFunctionService: CryptoFunctionService,
|
||||||
appIdService: AppIdService,
|
appIdService: AppIdService,
|
||||||
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
@ -63,7 +63,7 @@ export class LoginViaAuthRequestComponent extends BaseLoginWithDeviceComponent {
|
|||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
router,
|
router,
|
||||||
cryptoService,
|
keyService,
|
||||||
cryptoFunctionService,
|
cryptoFunctionService,
|
||||||
appIdService,
|
appIdService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
|
@ -8,7 +8,6 @@ import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -16,6 +15,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "RegisterComponent";
|
const BroadcasterSubscriptionId = "RegisterComponent";
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export class RegisterComponent extends BaseRegisterComponent implements OnInit,
|
|||||||
loginStrategyService: LoginStrategyServiceAbstraction,
|
loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
router: Router,
|
router: Router,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -49,7 +49,7 @@ export class RegisterComponent extends BaseRegisterComponent implements OnInit,
|
|||||||
loginStrategyService,
|
loginStrategyService,
|
||||||
router,
|
router,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
apiService,
|
apiService,
|
||||||
stateService,
|
stateService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -13,7 +13,6 @@ import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config
|
|||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
||||||
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
|
import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/sso-login.service.abstraction";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -24,6 +23,7 @@ import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "SetPasswordComponent";
|
const BroadcasterSubscriptionId = "SetPasswordComponent";
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export class SetPasswordComponent extends BaseSetPasswordComponent implements On
|
|||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -62,7 +62,7 @@ export class SetPasswordComponent extends BaseSetPasswordComponent implements On
|
|||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
messagingService,
|
messagingService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -22,10 +22,10 @@ import {
|
|||||||
mockAccountServiceWith,
|
mockAccountServiceWith,
|
||||||
} from "../../../../../libs/common/spec/fake-account-service";
|
} from "../../../../../libs/common/spec/fake-account-service";
|
||||||
|
|
||||||
import { ElectronCryptoService } from "./electron-crypto.service";
|
import { ElectronKeyService } from "./electron-key.service";
|
||||||
|
|
||||||
describe("electronCryptoService", () => {
|
describe("electronKeyService", () => {
|
||||||
let sut: ElectronCryptoService;
|
let sut: ElectronKeyService;
|
||||||
|
|
||||||
const pinService = mock<PinServiceAbstraction>();
|
const pinService = mock<PinServiceAbstraction>();
|
||||||
const keyGenerationService = mock<KeyGenerationService>();
|
const keyGenerationService = mock<KeyGenerationService>();
|
||||||
@ -47,7 +47,7 @@ describe("electronCryptoService", () => {
|
|||||||
masterPasswordService = new FakeMasterPasswordService();
|
masterPasswordService = new FakeMasterPasswordService();
|
||||||
stateProvider = new FakeStateProvider(accountService);
|
stateProvider = new FakeStateProvider(accountService);
|
||||||
|
|
||||||
sut = new ElectronCryptoService(
|
sut = new ElectronKeyService(
|
||||||
pinService,
|
pinService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
keyGenerationService,
|
keyGenerationService,
|
@ -13,14 +13,13 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/services/crypto.service";
|
|
||||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||||
import { CsprngString } from "@bitwarden/common/types/csprng";
|
import { CsprngString } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey } from "@bitwarden/common/types/key";
|
import { UserKey } from "@bitwarden/common/types/key";
|
||||||
import { BiometricStateService } from "@bitwarden/key-management";
|
import { DefaultKeyService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
export class ElectronCryptoService extends CryptoService {
|
export class ElectronKeyService extends DefaultKeyService {
|
||||||
constructor(
|
constructor(
|
||||||
pinService: PinServiceAbstraction,
|
pinService: PinServiceAbstraction,
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
@ -9,10 +9,9 @@ import {
|
|||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||||
import { DeviceType } from "@bitwarden/common/enums";
|
import { DeviceType } from "@bitwarden/common/enums";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { BiometricsService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { DesktopLockComponentService } from "./desktop-lock-component.service";
|
import { DesktopLockComponentService } from "./desktop-lock-component.service";
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ describe("DesktopLockComponentService", () => {
|
|||||||
let biometricsService: MockProxy<BiometricsService>;
|
let biometricsService: MockProxy<BiometricsService>;
|
||||||
let pinService: MockProxy<PinServiceAbstraction>;
|
let pinService: MockProxy<PinServiceAbstraction>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
userDecryptionOptionsService = mock<UserDecryptionOptionsServiceAbstraction>();
|
userDecryptionOptionsService = mock<UserDecryptionOptionsServiceAbstraction>();
|
||||||
@ -46,7 +45,7 @@ describe("DesktopLockComponentService", () => {
|
|||||||
biometricsService = mock<BiometricsService>();
|
biometricsService = mock<BiometricsService>();
|
||||||
pinService = mock<PinServiceAbstraction>();
|
pinService = mock<PinServiceAbstraction>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
@ -72,8 +71,8 @@ describe("DesktopLockComponentService", () => {
|
|||||||
useValue: vaultTimeoutSettingsService,
|
useValue: vaultTimeoutSettingsService,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: CryptoService,
|
provide: KeyService,
|
||||||
useValue: cryptoService,
|
useValue: keyService,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -358,9 +357,7 @@ describe("DesktopLockComponentService", () => {
|
|||||||
// Biometrics
|
// Biometrics
|
||||||
biometricsService.supportsBiometric.mockResolvedValue(mockInputs.osSupportsBiometric);
|
biometricsService.supportsBiometric.mockResolvedValue(mockInputs.osSupportsBiometric);
|
||||||
vaultTimeoutSettingsService.isBiometricLockSet.mockResolvedValue(mockInputs.biometricLockSet);
|
vaultTimeoutSettingsService.isBiometricLockSet.mockResolvedValue(mockInputs.biometricLockSet);
|
||||||
cryptoService.hasUserKeyStored.mockResolvedValue(
|
keyService.hasUserKeyStored.mockResolvedValue(mockInputs.hasBiometricEncryptedUserKeyStored);
|
||||||
mockInputs.hasBiometricEncryptedUserKeyStored,
|
|
||||||
);
|
|
||||||
platformUtilsService.supportsSecureStorage.mockReturnValue(
|
platformUtilsService.supportsSecureStorage.mockReturnValue(
|
||||||
mockInputs.platformSupportsSecureStorage,
|
mockInputs.platformSupportsSecureStorage,
|
||||||
);
|
);
|
||||||
|
@ -12,11 +12,10 @@ import {
|
|||||||
} from "@bitwarden/auth/common";
|
} from "@bitwarden/auth/common";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||||
import { DeviceType } from "@bitwarden/common/enums";
|
import { DeviceType } from "@bitwarden/common/enums";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { BiometricsService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
export class DesktopLockComponentService implements LockComponentService {
|
export class DesktopLockComponentService implements LockComponentService {
|
||||||
private readonly userDecryptionOptionsService = inject(UserDecryptionOptionsServiceAbstraction);
|
private readonly userDecryptionOptionsService = inject(UserDecryptionOptionsServiceAbstraction);
|
||||||
@ -24,7 +23,7 @@ export class DesktopLockComponentService implements LockComponentService {
|
|||||||
private readonly biometricsService = inject(BiometricsService);
|
private readonly biometricsService = inject(BiometricsService);
|
||||||
private readonly pinService = inject(PinServiceAbstraction);
|
private readonly pinService = inject(PinServiceAbstraction);
|
||||||
private readonly vaultTimeoutSettingsService = inject(VaultTimeoutSettingsService);
|
private readonly vaultTimeoutSettingsService = inject(VaultTimeoutSettingsService);
|
||||||
private readonly cryptoService = inject(CryptoService);
|
private readonly keyService = inject(KeyService);
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ export class DesktopLockComponentService implements LockComponentService {
|
|||||||
|
|
||||||
private async isBiometricLockSet(userId: UserId): Promise<boolean> {
|
private async isBiometricLockSet(userId: UserId): Promise<boolean> {
|
||||||
const biometricLockSet = await this.vaultTimeoutSettingsService.isBiometricLockSet(userId);
|
const biometricLockSet = await this.vaultTimeoutSettingsService.isBiometricLockSet(userId);
|
||||||
const hasBiometricEncryptedUserKeyStored = await this.cryptoService.hasUserKeyStored(
|
const hasBiometricEncryptedUserKeyStored = await this.keyService.hasUserKeyStored(
|
||||||
KeySuffixOptions.Biometric,
|
KeySuffixOptions.Biometric,
|
||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
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 { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -15,7 +14,7 @@ import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
|||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricsService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BrowserSyncVerificationDialogComponent } from "../app/components/browser-sync-verification-dialog.component";
|
import { BrowserSyncVerificationDialogComponent } from "../app/components/browser-sync-verification-dialog.component";
|
||||||
import { LegacyMessage } from "../models/native-messaging/legacy-message";
|
import { LegacyMessage } from "../models/native-messaging/legacy-message";
|
||||||
@ -32,7 +31,7 @@ const HashAlgorithmForAsymmetricEncryption = "sha1";
|
|||||||
export class NativeMessagingService {
|
export class NativeMessagingService {
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
@ -81,7 +80,7 @@ export class NativeMessagingService {
|
|||||||
appId: appId,
|
appId: appId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(
|
const fingerprint = await this.keyService.getFingerprint(
|
||||||
rawMessage.userId,
|
rawMessage.userId,
|
||||||
remotePublicKey,
|
remotePublicKey,
|
||||||
);
|
);
|
||||||
@ -172,7 +171,7 @@ export class NativeMessagingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const userKey = await this.cryptoService.getUserKeyFromStorage(
|
const userKey = await this.keyService.getUserKeyFromStorage(
|
||||||
KeySuffixOptions.Biometric,
|
KeySuffixOptions.Biometric,
|
||||||
message.userId,
|
message.userId,
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,6 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from "@bitwarden/ang
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -13,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-vault-attachments",
|
selector: "app-vault-attachments",
|
||||||
@ -22,7 +22,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
cipherService: CipherService,
|
cipherService: CipherService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -37,7 +37,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
|||||||
super(
|
super(
|
||||||
cipherService,
|
cipherService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
apiService,
|
apiService,
|
||||||
|
@ -3,13 +3,13 @@ import { FormBuilder } from "@angular/forms";
|
|||||||
|
|
||||||
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-folder-add-edit",
|
selector: "app-folder-add-edit",
|
||||||
@ -20,7 +20,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
folderService: FolderService,
|
folderService: FolderService,
|
||||||
folderApiService: FolderApiServiceAbstraction,
|
folderApiService: FolderApiServiceAbstraction,
|
||||||
accountService: AccountService,
|
accountService: AccountService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
@ -31,7 +31,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
folderService,
|
folderService,
|
||||||
folderApiService,
|
folderApiService,
|
||||||
accountService,
|
accountService,
|
||||||
cryptoService,
|
keyService,
|
||||||
i18nService,
|
i18nService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
logService,
|
logService,
|
||||||
|
@ -18,7 +18,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||||
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 { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -32,6 +31,7 @@ import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
|||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { PasswordRepromptService } from "@bitwarden/vault";
|
import { PasswordRepromptService } from "@bitwarden/vault";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "ViewComponent";
|
const BroadcasterSubscriptionId = "ViewComponent";
|
||||||
@ -49,7 +49,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
|
|||||||
totpService: TotpService,
|
totpService: TotpService,
|
||||||
tokenService: TokenService,
|
tokenService: TokenService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
auditService: AuditService,
|
auditService: AuditService,
|
||||||
@ -75,7 +75,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
|
|||||||
totpService,
|
totpService,
|
||||||
tokenService,
|
tokenService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
auditService,
|
auditService,
|
||||||
|
@ -14,12 +14,12 @@ import {
|
|||||||
} from "@bitwarden/common/admin-console/enums";
|
} from "@bitwarden/common/admin-console/enums";
|
||||||
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationUserView } from "../organizations/core/views/organization-user.view";
|
import { OrganizationUserView } from "../organizations/core/views/organization-user.view";
|
||||||
import { UserConfirmComponent } from "../organizations/manage/user-confirm.component";
|
import { UserConfirmComponent } from "../organizations/manage/user-confirm.component";
|
||||||
@ -78,7 +78,7 @@ export abstract class BaseMembersComponent<UserView extends UserViewTypes> {
|
|||||||
constructor(
|
constructor(
|
||||||
protected apiService: ApiService,
|
protected apiService: ApiService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected validationService: ValidationService,
|
protected validationService: ValidationService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
protected userNamePipe: UserNamePipe,
|
protected userNamePipe: UserNamePipe,
|
||||||
@ -213,7 +213,7 @@ export abstract class BaseMembersComponent<UserView extends UserViewTypes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(user.userId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(user.userId, publicKey);
|
||||||
this.logService.info(`User's fingerprint: ${fingerprint.join("-")}`);
|
this.logService.info(`User's fingerprint: ${fingerprint.join("-")}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error(e);
|
this.logService.error(e);
|
||||||
|
@ -16,13 +16,13 @@ import {
|
|||||||
} from "@bitwarden/common/admin-console/enums";
|
} from "@bitwarden/common/admin-console/enums";
|
||||||
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationUserView } from "../organizations/core/views/organization-user.view";
|
import { OrganizationUserView } from "../organizations/core/views/organization-user.view";
|
||||||
import { UserConfirmComponent } from "../organizations/manage/user-confirm.component";
|
import { UserConfirmComponent } from "../organizations/manage/user-confirm.component";
|
||||||
@ -119,7 +119,7 @@ export abstract class BasePeopleComponent<
|
|||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected platformUtilsService: PlatformUtilsService,
|
protected platformUtilsService: PlatformUtilsService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected validationService: ValidationService,
|
protected validationService: ValidationService,
|
||||||
protected modalService: ModalService,
|
protected modalService: ModalService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
@ -384,7 +384,7 @@ export abstract class BasePeopleComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(user.userId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(user.userId, publicKey);
|
||||||
this.logService.info(`User's fingerprint: ${fingerprint.join("-")}`);
|
this.logService.info(`User's fingerprint: ${fingerprint.join("-")}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logService.error(e);
|
this.logService.error(e);
|
||||||
|
@ -3,9 +3,9 @@ import { Component, Inject, OnInit } from "@angular/core";
|
|||||||
import { FormControl, FormGroup } from "@angular/forms";
|
import { FormControl, FormGroup } from "@angular/forms";
|
||||||
|
|
||||||
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
|
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
export type UserConfirmDialogData = {
|
export type UserConfirmDialogData = {
|
||||||
name: string;
|
name: string;
|
||||||
@ -34,7 +34,7 @@ export class UserConfirmComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(DIALOG_DATA) protected data: UserConfirmDialogData,
|
@Inject(DIALOG_DATA) protected data: UserConfirmDialogData,
|
||||||
private dialogRef: DialogRef,
|
private dialogRef: DialogRef,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
private organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
||||||
) {
|
) {
|
||||||
@ -46,7 +46,7 @@ export class UserConfirmComponent implements OnInit {
|
|||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
try {
|
try {
|
||||||
if (this.publicKey != null) {
|
if (this.publicKey != null) {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(this.userId, this.publicKey);
|
const fingerprint = await this.keyService.getFingerprint(this.userId, this.publicKey);
|
||||||
if (fingerprint != null) {
|
if (fingerprint != null) {
|
||||||
this.fingerprint = fingerprint.join("-");
|
this.fingerprint = fingerprint.join("-");
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ import {
|
|||||||
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
||||||
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BulkUserDetails } from "./bulk-status.component";
|
import { BulkUserDetails } from "./bulk-status.component";
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ export abstract class BaseBulkConfirmComponent implements OnInit {
|
|||||||
protected error: string;
|
protected error: string;
|
||||||
|
|
||||||
protected constructor(
|
protected constructor(
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected encryptService: EncryptService,
|
protected encryptService: EncryptService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
) {}
|
) {}
|
||||||
@ -48,7 +48,7 @@ export abstract class BaseBulkConfirmComponent implements OnInit {
|
|||||||
|
|
||||||
for (const entry of publicKeysResponse.data) {
|
for (const entry of publicKeysResponse.data) {
|
||||||
const publicKey = Utils.fromB64ToArray(entry.key);
|
const publicKey = Utils.fromB64ToArray(entry.key);
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(entry.userId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(entry.userId, publicKey);
|
||||||
if (fingerprint != null) {
|
if (fingerprint != null) {
|
||||||
this.publicKeys.set(entry.id, publicKey);
|
this.publicKeys.set(entry.id, publicKey);
|
||||||
this.fingerprints.set(entry.id, fingerprint.join("-"));
|
this.fingerprints.set(entry.id, fingerprint.join("-"));
|
||||||
|
@ -13,7 +13,6 @@ import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enum
|
|||||||
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
||||||
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
@ -21,6 +20,7 @@ import { StateProvider } from "@bitwarden/common/platform/state";
|
|||||||
import { OrganizationId } from "@bitwarden/common/types/guid";
|
import { OrganizationId } from "@bitwarden/common/types/guid";
|
||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { BaseBulkConfirmComponent } from "./base-bulk-confirm.component";
|
import { BaseBulkConfirmComponent } from "./base-bulk-confirm.component";
|
||||||
import { BulkUserDetails } from "./bulk-status.component";
|
import { BulkUserDetails } from "./bulk-status.component";
|
||||||
@ -39,18 +39,18 @@ export class BulkConfirmDialogComponent extends BaseBulkConfirmComponent {
|
|||||||
users: BulkUserDetails[];
|
users: BulkUserDetails[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
@Inject(DIALOG_DATA) protected dialogParams: BulkConfirmDialogParams,
|
@Inject(DIALOG_DATA) protected dialogParams: BulkConfirmDialogParams,
|
||||||
protected encryptService: EncryptService,
|
protected encryptService: EncryptService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
private stateProvider: StateProvider,
|
private stateProvider: StateProvider,
|
||||||
) {
|
) {
|
||||||
super(cryptoService, encryptService, i18nService);
|
super(keyService, encryptService, i18nService);
|
||||||
|
|
||||||
this.organizationId = dialogParams.organizationId;
|
this.organizationId = dialogParams.organizationId;
|
||||||
this.organizationKey$ = this.stateProvider.activeUserId$.pipe(
|
this.organizationKey$ = this.stateProvider.activeUserId$.pipe(
|
||||||
switchMap((userId) => this.cryptoService.orgKeys$(userId)),
|
switchMap((userId) => this.keyService.orgKeys$(userId)),
|
||||||
map((organizationKeysById) => organizationKeysById[this.organizationId as OrganizationId]),
|
map((organizationKeysById) => organizationKeysById[this.organizationId as OrganizationId]),
|
||||||
takeUntilDestroyed(),
|
takeUntilDestroyed(),
|
||||||
);
|
);
|
||||||
|
@ -42,13 +42,13 @@ import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstract
|
|||||||
import { isNotSelfUpgradable, ProductTierType } from "@bitwarden/common/billing/enums";
|
import { isNotSelfUpgradable, ProductTierType } from "@bitwarden/common/billing/enums";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.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 { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, SimpleDialogOptions, ToastService } from "@bitwarden/components";
|
import { DialogService, SimpleDialogOptions, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChangePlanDialogResultType,
|
ChangePlanDialogResultType,
|
||||||
@ -110,7 +110,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
validationService: ValidationService,
|
validationService: ValidationService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
@ -134,7 +134,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
super(
|
super(
|
||||||
apiService,
|
apiService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
validationService,
|
validationService,
|
||||||
logService,
|
logService,
|
||||||
userNamePipe,
|
userNamePipe,
|
||||||
@ -172,8 +172,8 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
this.organization.canManageUsersPassword &&
|
this.organization.canManageUsersPassword &&
|
||||||
!this.organization.hasPublicAndPrivateKeys
|
!this.organization.hasPublicAndPrivateKeys
|
||||||
) {
|
) {
|
||||||
const orgShareKey = await this.cryptoService.getOrgKey(this.organization.id);
|
const orgShareKey = await this.keyService.getOrgKey(this.organization.id);
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);
|
const orgKeys = await this.keyService.makeKeyPair(orgShareKey);
|
||||||
const request = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
const request = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||||
const response = await this.organizationApiService.updateKeys(
|
const response = await this.organizationApiService.updateKeys(
|
||||||
this.organization.id,
|
this.organization.id,
|
||||||
@ -293,7 +293,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
async confirmUser(user: OrganizationUserView, publicKey: Uint8Array): Promise<void> {
|
async confirmUser(user: OrganizationUserView, publicKey: Uint8Array): Promise<void> {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(this.organization.id);
|
const orgKey = await this.keyService.getOrgKey(this.organization.id);
|
||||||
const key = await this.encryptService.rsaEncrypt(orgKey.key, publicKey);
|
const key = await this.encryptService.rsaEncrypt(orgKey.key, publicKey);
|
||||||
const request = new OrganizationUserConfirmRequest();
|
const request = new OrganizationUserConfirmRequest();
|
||||||
request.key = key.encryptedString;
|
request.key = key.encryptedString;
|
||||||
|
@ -8,7 +8,6 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
|
|||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { OrganizationKeysResponse } from "@bitwarden/common/admin-console/models/response/organization-keys.response";
|
import { OrganizationKeysResponse } from "@bitwarden/common/admin-console/models/response/organization-keys.response";
|
||||||
import { OrganizationApiService } from "@bitwarden/common/admin-console/services/organization/organization-api.service";
|
import { OrganizationApiService } from "@bitwarden/common/admin-console/services/organization/organization-api.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { EncryptionType, KdfType } from "@bitwarden/common/platform/enums";
|
import { EncryptionType, KdfType } from "@bitwarden/common/platform/enums";
|
||||||
@ -17,13 +16,14 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym
|
|||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey, OrgKey, MasterKey } from "@bitwarden/common/types/key";
|
import { UserKey, OrgKey, MasterKey } from "@bitwarden/common/types/key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationUserResetPasswordService } from "./organization-user-reset-password.service";
|
import { OrganizationUserResetPasswordService } from "./organization-user-reset-password.service";
|
||||||
|
|
||||||
describe("OrganizationUserResetPasswordService", () => {
|
describe("OrganizationUserResetPasswordService", () => {
|
||||||
let sut: OrganizationUserResetPasswordService;
|
let sut: OrganizationUserResetPasswordService;
|
||||||
|
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let encryptService: MockProxy<EncryptService>;
|
let encryptService: MockProxy<EncryptService>;
|
||||||
let organizationService: MockProxy<OrganizationService>;
|
let organizationService: MockProxy<OrganizationService>;
|
||||||
let organizationUserApiService: MockProxy<OrganizationUserApiService>;
|
let organizationUserApiService: MockProxy<OrganizationUserApiService>;
|
||||||
@ -31,7 +31,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
let i18nService: MockProxy<I18nService>;
|
let i18nService: MockProxy<I18nService>;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
encryptService = mock<EncryptService>();
|
encryptService = mock<EncryptService>();
|
||||||
organizationService = mock<OrganizationService>();
|
organizationService = mock<OrganizationService>();
|
||||||
organizationUserApiService = mock<OrganizationUserApiService>();
|
organizationUserApiService = mock<OrganizationUserApiService>();
|
||||||
@ -39,7 +39,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
i18nService = mock<I18nService>();
|
i18nService = mock<I18nService>();
|
||||||
|
|
||||||
sut = new OrganizationUserResetPasswordService(
|
sut = new OrganizationUserResetPasswordService(
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
organizationService,
|
organizationService,
|
||||||
organizationUserApiService,
|
organizationUserApiService,
|
||||||
@ -69,7 +69,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
|
|
||||||
const mockRandomBytes = new Uint8Array(64) as CsprngArray;
|
const mockRandomBytes = new Uint8Array(64) as CsprngArray;
|
||||||
const mockUserKey = new SymmetricCryptoKey(mockRandomBytes) as UserKey;
|
const mockUserKey = new SymmetricCryptoKey(mockRandomBytes) as UserKey;
|
||||||
cryptoService.getUserKey.mockResolvedValue(mockUserKey);
|
keyService.getUserKey.mockResolvedValue(mockUserKey);
|
||||||
|
|
||||||
encryptService.rsaEncrypt.mockResolvedValue(
|
encryptService.rsaEncrypt.mockResolvedValue(
|
||||||
new EncString(EncryptionType.Rsa2048_OaepSha1_B64, "mockEncryptedUserKey"),
|
new EncString(EncryptionType.Rsa2048_OaepSha1_B64, "mockEncryptedUserKey"),
|
||||||
@ -87,7 +87,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
|
|
||||||
await sut.buildRecoveryKey(mockOrgId, mockUserKey);
|
await sut.buildRecoveryKey(mockOrgId, mockUserKey);
|
||||||
|
|
||||||
expect(cryptoService.getUserKey).not.toHaveBeenCalled();
|
expect(keyService.getUserKey).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an error if the organization keys are null", async () => {
|
it("should throw an error if the organization keys are null", async () => {
|
||||||
@ -96,7 +96,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an error if the user key can't be found", async () => {
|
it("should throw an error if the user key can't be found", async () => {
|
||||||
cryptoService.getUserKey.mockResolvedValue(null);
|
keyService.getUserKey.mockResolvedValue(null);
|
||||||
await expect(sut.buildRecoveryKey(mockOrgId)).rejects.toThrow();
|
await expect(sut.buildRecoveryKey(mockOrgId)).rejects.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -125,16 +125,16 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
|
|
||||||
const mockRandomBytes = new Uint8Array(64) as CsprngArray;
|
const mockRandomBytes = new Uint8Array(64) as CsprngArray;
|
||||||
const mockOrgKey = new SymmetricCryptoKey(mockRandomBytes) as OrgKey;
|
const mockOrgKey = new SymmetricCryptoKey(mockRandomBytes) as OrgKey;
|
||||||
cryptoService.getOrgKey.mockResolvedValue(mockOrgKey);
|
keyService.getOrgKey.mockResolvedValue(mockOrgKey);
|
||||||
encryptService.decryptToBytes.mockResolvedValue(mockRandomBytes);
|
encryptService.decryptToBytes.mockResolvedValue(mockRandomBytes);
|
||||||
|
|
||||||
encryptService.rsaDecrypt.mockResolvedValue(mockRandomBytes);
|
encryptService.rsaDecrypt.mockResolvedValue(mockRandomBytes);
|
||||||
const mockMasterKey = new SymmetricCryptoKey(mockRandomBytes) as MasterKey;
|
const mockMasterKey = new SymmetricCryptoKey(mockRandomBytes) as MasterKey;
|
||||||
cryptoService.makeMasterKey.mockResolvedValue(mockMasterKey);
|
keyService.makeMasterKey.mockResolvedValue(mockMasterKey);
|
||||||
cryptoService.hashMasterKey.mockResolvedValue("test-master-key-hash");
|
keyService.hashMasterKey.mockResolvedValue("test-master-key-hash");
|
||||||
|
|
||||||
const mockUserKey = new SymmetricCryptoKey(mockRandomBytes) as UserKey;
|
const mockUserKey = new SymmetricCryptoKey(mockRandomBytes) as UserKey;
|
||||||
cryptoService.encryptUserKeyWithMasterKey.mockResolvedValue([
|
keyService.encryptUserKeyWithMasterKey.mockResolvedValue([
|
||||||
mockUserKey,
|
mockUserKey,
|
||||||
new EncString(EncryptionType.AesCbc256_HmacSha256_B64, "test-encrypted-user-key"),
|
new EncString(EncryptionType.AesCbc256_HmacSha256_B64, "test-encrypted-user-key"),
|
||||||
]);
|
]);
|
||||||
@ -153,7 +153,7 @@ describe("OrganizationUserResetPasswordService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an error if the org key is null", async () => {
|
it("should throw an error if the org key is null", async () => {
|
||||||
cryptoService.getOrgKey.mockResolvedValue(null);
|
keyService.getOrgKey.mockResolvedValue(null);
|
||||||
await expect(
|
await expect(
|
||||||
sut.resetMasterPassword(mockNewMP, mockEmail, mockOrgUserId, mockOrgId),
|
sut.resetMasterPassword(mockNewMP, mockEmail, mockOrgUserId, mockOrgId),
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
|
@ -13,7 +13,6 @@ import {
|
|||||||
KdfConfig,
|
KdfConfig,
|
||||||
PBKDF2KdfConfig,
|
PBKDF2KdfConfig,
|
||||||
} from "@bitwarden/common/auth/models/domain/kdf-config";
|
} from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { KdfType } from "@bitwarden/common/platform/enums";
|
import { KdfType } from "@bitwarden/common/platform/enums";
|
||||||
@ -22,6 +21,7 @@ import { EncryptedString, EncString } from "@bitwarden/common/platform/models/do
|
|||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey } from "@bitwarden/common/types/key";
|
import { UserKey } from "@bitwarden/common/types/key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: "root",
|
providedIn: "root",
|
||||||
@ -30,7 +30,7 @@ export class OrganizationUserResetPasswordService
|
|||||||
implements UserKeyRotationDataProvider<OrganizationUserResetPasswordWithIdRequest>
|
implements UserKeyRotationDataProvider<OrganizationUserResetPasswordWithIdRequest>
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
@ -53,7 +53,7 @@ export class OrganizationUserResetPasswordService
|
|||||||
const publicKey = Utils.fromB64ToArray(orgKeys.publicKey);
|
const publicKey = Utils.fromB64ToArray(orgKeys.publicKey);
|
||||||
|
|
||||||
// RSA Encrypt user key with organization's public key
|
// RSA Encrypt user key with organization's public key
|
||||||
userKey ??= await this.cryptoService.getUserKey();
|
userKey ??= await this.keyService.getUserKey();
|
||||||
if (userKey == null) {
|
if (userKey == null) {
|
||||||
throw new Error("No user key found");
|
throw new Error("No user key found");
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ export class OrganizationUserResetPasswordService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt Organization's encrypted Private Key with org key
|
// Decrypt Organization's encrypted Private Key with org key
|
||||||
const orgSymKey = await this.cryptoService.getOrgKey(orgId);
|
const orgSymKey = await this.keyService.getOrgKey(orgId);
|
||||||
if (orgSymKey == null) {
|
if (orgSymKey == null) {
|
||||||
throw new Error("No org key found");
|
throw new Error("No org key found");
|
||||||
}
|
}
|
||||||
@ -109,18 +109,15 @@ export class OrganizationUserResetPasswordService
|
|||||||
: new Argon2KdfConfig(response.kdfIterations, response.kdfMemory, response.kdfParallelism);
|
: new Argon2KdfConfig(response.kdfIterations, response.kdfMemory, response.kdfParallelism);
|
||||||
|
|
||||||
// Create new master key and hash new password
|
// Create new master key and hash new password
|
||||||
const newMasterKey = await this.cryptoService.makeMasterKey(
|
const newMasterKey = await this.keyService.makeMasterKey(
|
||||||
newMasterPassword,
|
newMasterPassword,
|
||||||
email.trim().toLowerCase(),
|
email.trim().toLowerCase(),
|
||||||
kdfConfig,
|
kdfConfig,
|
||||||
);
|
);
|
||||||
const newMasterKeyHash = await this.cryptoService.hashMasterKey(
|
const newMasterKeyHash = await this.keyService.hashMasterKey(newMasterPassword, newMasterKey);
|
||||||
newMasterPassword,
|
|
||||||
newMasterKey,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create new encrypted user key for the User
|
// Create new encrypted user key for the User
|
||||||
const newUserKey = await this.cryptoService.encryptUserKeyWithMasterKey(
|
const newUserKey = await this.keyService.encryptUserKeyWithMasterKey(
|
||||||
newMasterKey,
|
newMasterKey,
|
||||||
existingUserKey,
|
existingUserKey,
|
||||||
);
|
);
|
||||||
|
@ -12,11 +12,11 @@ import { OrganizationUpdateRequest } from "@bitwarden/common/admin-console/model
|
|||||||
import { OrganizationResponse } from "@bitwarden/common/admin-console/models/response/organization.response";
|
import { OrganizationResponse } from "@bitwarden/common/admin-console/models/response/organization.response";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { ApiKeyComponent } from "../../../auth/settings/security/api-key.component";
|
import { ApiKeyComponent } from "../../../auth/settings/security/api-key.component";
|
||||||
import { PurgeVaultComponent } from "../../../vault/settings/purge-vault.component";
|
import { PurgeVaultComponent } from "../../../vault/settings/purge-vault.component";
|
||||||
@ -85,7 +85,7 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||||
@ -194,8 +194,8 @@ export class AccountComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// Backfill pub/priv key if necessary
|
// Backfill pub/priv key if necessary
|
||||||
if (!this.org.hasPublicAndPrivateKeys) {
|
if (!this.org.hasPublicAndPrivateKeys) {
|
||||||
const orgShareKey = await this.cryptoService.getOrgKey(this.organizationId);
|
const orgShareKey = await this.keyService.getOrgKey(this.organizationId);
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);
|
const orgKeys = await this.keyService.makeKeyPair(orgShareKey);
|
||||||
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-con
|
|||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
@ -31,7 +30,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
|
|||||||
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { InternalFolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { DialogService, ToastOptions, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastOptions, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
import { BiometricStateService } from "@bitwarden/key-management";
|
import { KeyService, BiometricStateService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { flagEnabled } from "../utils/flags";
|
import { flagEnabled } from "../utils/flags";
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private ngZone: NgZone,
|
private ngZone: NgZone,
|
||||||
private vaultTimeoutService: VaultTimeoutService,
|
private vaultTimeoutService: VaultTimeoutService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private collectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
@ -317,7 +316,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.cryptoService.clearKeys(),
|
this.keyService.clearKeys(),
|
||||||
this.cipherService.clear(userId),
|
this.cipherService.clear(userId),
|
||||||
this.folderService.clear(userId),
|
this.folderService.clear(userId),
|
||||||
this.collectionService.clear(userId),
|
this.collectionService.clear(userId),
|
||||||
|
@ -8,12 +8,12 @@ import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/mod
|
|||||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||||
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
||||||
import { DEFAULT_KDF_CONFIG } from "@bitwarden/common/auth/models/domain/kdf-config";
|
import { DEFAULT_KDF_CONFIG } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
|
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
|
||||||
import { OrganizationInvite } from "../../../organization-invite/organization-invite";
|
import { OrganizationInvite } from "../../../organization-invite/organization-invite";
|
||||||
@ -23,7 +23,7 @@ import { WebRegistrationFinishService } from "./web-registration-finish.service"
|
|||||||
describe("DefaultRegistrationFinishService", () => {
|
describe("DefaultRegistrationFinishService", () => {
|
||||||
let service: WebRegistrationFinishService;
|
let service: WebRegistrationFinishService;
|
||||||
|
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let accountApiService: MockProxy<AccountApiService>;
|
let accountApiService: MockProxy<AccountApiService>;
|
||||||
let acceptOrgInviteService: MockProxy<AcceptOrganizationInviteService>;
|
let acceptOrgInviteService: MockProxy<AcceptOrganizationInviteService>;
|
||||||
let policyApiService: MockProxy<PolicyApiServiceAbstraction>;
|
let policyApiService: MockProxy<PolicyApiServiceAbstraction>;
|
||||||
@ -31,7 +31,7 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
let policyService: MockProxy<PolicyService>;
|
let policyService: MockProxy<PolicyService>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
accountApiService = mock<AccountApiService>();
|
accountApiService = mock<AccountApiService>();
|
||||||
acceptOrgInviteService = mock<AcceptOrganizationInviteService>();
|
acceptOrgInviteService = mock<AcceptOrganizationInviteService>();
|
||||||
policyApiService = mock<PolicyApiServiceAbstraction>();
|
policyApiService = mock<PolicyApiServiceAbstraction>();
|
||||||
@ -39,7 +39,7 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
policyService = mock<PolicyService>();
|
policyService = mock<PolicyService>();
|
||||||
|
|
||||||
service = new WebRegistrationFinishService(
|
service = new WebRegistrationFinishService(
|
||||||
cryptoService,
|
keyService,
|
||||||
accountApiService,
|
accountApiService,
|
||||||
acceptOrgInviteService,
|
acceptOrgInviteService,
|
||||||
policyApiService,
|
policyApiService,
|
||||||
@ -193,7 +193,7 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error if the user key cannot be created", async () => {
|
it("throws an error if the user key cannot be created", async () => {
|
||||||
cryptoService.makeUserKey.mockResolvedValue([null, null]);
|
keyService.makeUserKey.mockResolvedValue([null, null]);
|
||||||
|
|
||||||
await expect(service.finishRegistration(email, passwordInputResult)).rejects.toThrow(
|
await expect(service.finishRegistration(email, passwordInputResult)).rejects.toThrow(
|
||||||
"User key could not be created",
|
"User key could not be created",
|
||||||
@ -201,8 +201,8 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("registers the user and returns a captcha bypass token when given valid email verification input", async () => {
|
it("registers the user and returns a captcha bypass token when given valid email verification input", async () => {
|
||||||
cryptoService.makeUserKey.mockResolvedValue([userKey, userKeyEncString]);
|
keyService.makeUserKey.mockResolvedValue([userKey, userKeyEncString]);
|
||||||
cryptoService.makeKeyPair.mockResolvedValue(userKeyPair);
|
keyService.makeKeyPair.mockResolvedValue(userKeyPair);
|
||||||
accountApiService.registerFinish.mockResolvedValue(capchaBypassToken);
|
accountApiService.registerFinish.mockResolvedValue(capchaBypassToken);
|
||||||
acceptOrgInviteService.getOrganizationInvite.mockResolvedValue(null);
|
acceptOrgInviteService.getOrganizationInvite.mockResolvedValue(null);
|
||||||
|
|
||||||
@ -214,8 +214,8 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(capchaBypassToken);
|
expect(result).toEqual(capchaBypassToken);
|
||||||
|
|
||||||
expect(cryptoService.makeUserKey).toHaveBeenCalledWith(masterKey);
|
expect(keyService.makeUserKey).toHaveBeenCalledWith(masterKey);
|
||||||
expect(cryptoService.makeKeyPair).toHaveBeenCalledWith(userKey);
|
expect(keyService.makeKeyPair).toHaveBeenCalledWith(userKey);
|
||||||
expect(accountApiService.registerFinish).toHaveBeenCalledWith(
|
expect(accountApiService.registerFinish).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
email,
|
email,
|
||||||
@ -238,8 +238,8 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("it registers the user and returns a captcha bypass token when given an org invite", async () => {
|
it("it registers the user and returns a captcha bypass token when given an org invite", async () => {
|
||||||
cryptoService.makeUserKey.mockResolvedValue([userKey, userKeyEncString]);
|
keyService.makeUserKey.mockResolvedValue([userKey, userKeyEncString]);
|
||||||
cryptoService.makeKeyPair.mockResolvedValue(userKeyPair);
|
keyService.makeKeyPair.mockResolvedValue(userKeyPair);
|
||||||
accountApiService.registerFinish.mockResolvedValue(capchaBypassToken);
|
accountApiService.registerFinish.mockResolvedValue(capchaBypassToken);
|
||||||
acceptOrgInviteService.getOrganizationInvite.mockResolvedValue(orgInvite);
|
acceptOrgInviteService.getOrganizationInvite.mockResolvedValue(orgInvite);
|
||||||
|
|
||||||
@ -247,8 +247,8 @@ describe("DefaultRegistrationFinishService", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(capchaBypassToken);
|
expect(result).toEqual(capchaBypassToken);
|
||||||
|
|
||||||
expect(cryptoService.makeUserKey).toHaveBeenCalledWith(masterKey);
|
expect(keyService.makeUserKey).toHaveBeenCalledWith(masterKey);
|
||||||
expect(cryptoService.makeKeyPair).toHaveBeenCalledWith(userKey);
|
expect(keyService.makeKeyPair).toHaveBeenCalledWith(userKey);
|
||||||
expect(accountApiService.registerFinish).toHaveBeenCalledWith(
|
expect(accountApiService.registerFinish).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
email,
|
email,
|
||||||
|
@ -11,9 +11,9 @@ import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/mod
|
|||||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||||
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service";
|
||||||
import { RegisterFinishRequest } from "@bitwarden/common/auth/models/request/registration/register-finish.request";
|
import { RegisterFinishRequest } from "@bitwarden/common/auth/models/request/registration/register-finish.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { EncryptedString, EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncryptedString, EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
|
import { AcceptOrganizationInviteService } from "../../../organization-invite/accept-organization.service";
|
||||||
|
|
||||||
@ -22,14 +22,14 @@ export class WebRegistrationFinishService
|
|||||||
implements RegistrationFinishService
|
implements RegistrationFinishService
|
||||||
{
|
{
|
||||||
constructor(
|
constructor(
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected accountApiService: AccountApiService,
|
protected accountApiService: AccountApiService,
|
||||||
private acceptOrgInviteService: AcceptOrganizationInviteService,
|
private acceptOrgInviteService: AcceptOrganizationInviteService,
|
||||||
private policyApiService: PolicyApiServiceAbstraction,
|
private policyApiService: PolicyApiServiceAbstraction,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
) {
|
) {
|
||||||
super(cryptoService, accountApiService);
|
super(keyService, accountApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async getOrgNameFromOrgInvite(): Promise<string | null> {
|
override async getOrgNameFromOrgInvite(): Promise<string | null> {
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import { TestBed } from "@angular/core/testing";
|
import { TestBed } from "@angular/core/testing";
|
||||||
import { mock, MockProxy } from "jest-mock-extended";
|
import { mock, MockProxy } from "jest-mock-extended";
|
||||||
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { RotateableKeySetService } from "./rotateable-key-set.service";
|
import { RotateableKeySetService } from "./rotateable-key-set.service";
|
||||||
|
|
||||||
describe("RotateableKeySetService", () => {
|
describe("RotateableKeySetService", () => {
|
||||||
let testBed!: TestBed;
|
let testBed!: TestBed;
|
||||||
let cryptoService!: MockProxy<CryptoService>;
|
let keyService!: MockProxy<KeyService>;
|
||||||
let encryptService!: MockProxy<EncryptService>;
|
let encryptService!: MockProxy<EncryptService>;
|
||||||
let service!: RotateableKeySetService;
|
let service!: RotateableKeySetService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
encryptService = mock<EncryptService>();
|
encryptService = mock<EncryptService>();
|
||||||
testBed = TestBed.configureTestingModule({
|
testBed = TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: CryptoService, useValue: cryptoService },
|
{ provide: KeyService, useValue: keyService },
|
||||||
{ provide: EncryptService, useValue: encryptService },
|
{ provide: EncryptService, useValue: encryptService },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -33,8 +33,8 @@ describe("RotateableKeySetService", () => {
|
|||||||
const encryptedUserKey = Symbol();
|
const encryptedUserKey = Symbol();
|
||||||
const encryptedPublicKey = Symbol();
|
const encryptedPublicKey = Symbol();
|
||||||
const encryptedPrivateKey = Symbol();
|
const encryptedPrivateKey = Symbol();
|
||||||
cryptoService.makeKeyPair.mockResolvedValue(["publicKey", encryptedPrivateKey as any]);
|
keyService.makeKeyPair.mockResolvedValue(["publicKey", encryptedPrivateKey as any]);
|
||||||
cryptoService.getUserKey.mockResolvedValue({ key: userKey.key } as any);
|
keyService.getUserKey.mockResolvedValue({ key: userKey.key } as any);
|
||||||
encryptService.rsaEncrypt.mockResolvedValue(encryptedUserKey as any);
|
encryptService.rsaEncrypt.mockResolvedValue(encryptedUserKey as any);
|
||||||
encryptService.encrypt.mockResolvedValue(encryptedPublicKey as any);
|
encryptService.encrypt.mockResolvedValue(encryptedPublicKey as any);
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { inject, Injectable } from "@angular/core";
|
import { inject, Injectable } from "@angular/core";
|
||||||
|
|
||||||
import { RotateableKeySet } from "@bitwarden/auth/common";
|
import { RotateableKeySet } from "@bitwarden/auth/common";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Injectable({ providedIn: "root" })
|
@Injectable({ providedIn: "root" })
|
||||||
export class RotateableKeySetService {
|
export class RotateableKeySetService {
|
||||||
private readonly cryptoService = inject(CryptoService);
|
private readonly keyService = inject(KeyService);
|
||||||
private readonly encryptService = inject(EncryptService);
|
private readonly encryptService = inject(EncryptService);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,9 +21,9 @@ export class RotateableKeySetService {
|
|||||||
async createKeySet<ExternalKey extends SymmetricCryptoKey>(
|
async createKeySet<ExternalKey extends SymmetricCryptoKey>(
|
||||||
externalKey: ExternalKey,
|
externalKey: ExternalKey,
|
||||||
): Promise<RotateableKeySet<ExternalKey>> {
|
): Promise<RotateableKeySet<ExternalKey>> {
|
||||||
const [publicKey, encryptedPrivateKey] = await this.cryptoService.makeKeyPair(externalKey);
|
const [publicKey, encryptedPrivateKey] = await this.keyService.makeKeyPair(externalKey);
|
||||||
|
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
const userKey = await this.keyService.getUserKey();
|
||||||
const rawPublicKey = Utils.fromB64ToArray(publicKey);
|
const rawPublicKey = Utils.fromB64ToArray(publicKey);
|
||||||
const encryptedUserKey = await this.encryptService.rsaEncrypt(userKey.key, rawPublicKey);
|
const encryptedUserKey = await this.encryptService.rsaEncrypt(userKey.key, rawPublicKey);
|
||||||
const encryptedPublicKey = await this.encryptService.encrypt(rawPublicKey, userKey);
|
const encryptedPublicKey = await this.encryptService.encrypt(rawPublicKey, userKey);
|
||||||
|
@ -4,7 +4,7 @@ import { mock, MockProxy } from "jest-mock-extended";
|
|||||||
|
|
||||||
import { RotateableKeySet } from "@bitwarden/auth/common";
|
import { RotateableKeySet } from "@bitwarden/auth/common";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { WebAuthnLoginPrfCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-prf-crypto.service.abstraction";
|
import { WebAuthnLoginPrfKeyServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-prf-key.service.abstraction";
|
||||||
import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view";
|
import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view";
|
||||||
import { WebAuthnLoginAssertionResponseRequest } from "@bitwarden/common/auth/services/webauthn-login/request/webauthn-login-assertion-response.request";
|
import { WebAuthnLoginAssertionResponseRequest } from "@bitwarden/common/auth/services/webauthn-login/request/webauthn-login-assertion-response.request";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@ -24,7 +24,7 @@ describe("WebauthnAdminService", () => {
|
|||||||
let apiService!: MockProxy<WebAuthnLoginAdminApiService>;
|
let apiService!: MockProxy<WebAuthnLoginAdminApiService>;
|
||||||
let userVerificationService!: MockProxy<UserVerificationService>;
|
let userVerificationService!: MockProxy<UserVerificationService>;
|
||||||
let rotateableKeySetService!: MockProxy<RotateableKeySetService>;
|
let rotateableKeySetService!: MockProxy<RotateableKeySetService>;
|
||||||
let webAuthnLoginPrfCryptoService!: MockProxy<WebAuthnLoginPrfCryptoServiceAbstraction>;
|
let webAuthnLoginPrfKeyService!: MockProxy<WebAuthnLoginPrfKeyServiceAbstraction>;
|
||||||
let credentials: MockProxy<CredentialsContainer>;
|
let credentials: MockProxy<CredentialsContainer>;
|
||||||
let service!: WebauthnLoginAdminService;
|
let service!: WebauthnLoginAdminService;
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ describe("WebauthnAdminService", () => {
|
|||||||
apiService = mock<WebAuthnLoginAdminApiService>();
|
apiService = mock<WebAuthnLoginAdminApiService>();
|
||||||
userVerificationService = mock<UserVerificationService>();
|
userVerificationService = mock<UserVerificationService>();
|
||||||
rotateableKeySetService = mock<RotateableKeySetService>();
|
rotateableKeySetService = mock<RotateableKeySetService>();
|
||||||
webAuthnLoginPrfCryptoService = mock<WebAuthnLoginPrfCryptoServiceAbstraction>();
|
webAuthnLoginPrfKeyService = mock<WebAuthnLoginPrfKeyServiceAbstraction>();
|
||||||
credentials = mock<CredentialsContainer>();
|
credentials = mock<CredentialsContainer>();
|
||||||
service = new WebauthnLoginAdminService(
|
service = new WebauthnLoginAdminService(
|
||||||
apiService,
|
apiService,
|
||||||
userVerificationService,
|
userVerificationService,
|
||||||
rotateableKeySetService,
|
rotateableKeySetService,
|
||||||
webAuthnLoginPrfCryptoService,
|
webAuthnLoginPrfKeyService,
|
||||||
credentials,
|
credentials,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { BehaviorSubject, filter, from, map, Observable, shareReplay, switchMap,
|
|||||||
|
|
||||||
import { PrfKeySet, UserKeyRotationDataProvider } from "@bitwarden/auth/common";
|
import { PrfKeySet, UserKeyRotationDataProvider } from "@bitwarden/auth/common";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { WebAuthnLoginPrfCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-prf-crypto.service.abstraction";
|
import { WebAuthnLoginPrfKeyServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-prf-key.service.abstraction";
|
||||||
import { WebauthnRotateCredentialRequest } from "@bitwarden/common/auth/models/request/webauthn-rotate-credential.request";
|
import { WebauthnRotateCredentialRequest } from "@bitwarden/common/auth/models/request/webauthn-rotate-credential.request";
|
||||||
import { WebAuthnLoginCredentialAssertionOptionsView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion-options.view";
|
import { WebAuthnLoginCredentialAssertionOptionsView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion-options.view";
|
||||||
import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view";
|
import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view";
|
||||||
@ -51,7 +51,7 @@ export class WebauthnLoginAdminService
|
|||||||
private apiService: WebAuthnLoginAdminApiService,
|
private apiService: WebAuthnLoginAdminApiService,
|
||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
private rotateableKeySetService: RotateableKeySetService,
|
private rotateableKeySetService: RotateableKeySetService,
|
||||||
private webAuthnLoginPrfCryptoService: WebAuthnLoginPrfCryptoServiceAbstraction,
|
private webAuthnLoginPrfKeyService: WebAuthnLoginPrfKeyServiceAbstraction,
|
||||||
@Optional() navigatorCredentials?: CredentialsContainer,
|
@Optional() navigatorCredentials?: CredentialsContainer,
|
||||||
@Optional() private logService?: LogService,
|
@Optional() private logService?: LogService,
|
||||||
) {
|
) {
|
||||||
@ -143,7 +143,7 @@ export class WebauthnLoginAdminService
|
|||||||
pendingCredential.createOptions.options.authenticatorSelection.userVerification,
|
pendingCredential.createOptions.options.authenticatorSelection.userVerification,
|
||||||
// TODO: Remove `any` when typescript typings add support for PRF
|
// TODO: Remove `any` when typescript typings add support for PRF
|
||||||
extensions: {
|
extensions: {
|
||||||
prf: { eval: { first: await this.webAuthnLoginPrfCryptoService.getLoginWithPrfSalt() } },
|
prf: { eval: { first: await this.webAuthnLoginPrfKeyService.getLoginWithPrfSalt() } },
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -162,7 +162,7 @@ export class WebauthnLoginAdminService
|
|||||||
}
|
}
|
||||||
|
|
||||||
const symmetricPrfKey =
|
const symmetricPrfKey =
|
||||||
await this.webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf(prfResult);
|
await this.webAuthnLoginPrfKeyService.createSymmetricKeyFromPrf(prfResult);
|
||||||
return await this.rotateableKeySetService.createKeySet(symmetricPrfKey);
|
return await this.rotateableKeySetService.createKeySet(symmetricPrfKey);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logService?.error(error);
|
this.logService?.error(error);
|
||||||
|
@ -6,7 +6,6 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
|||||||
import { UserKeyResponse } from "@bitwarden/common/models/response/user-key.response";
|
import { UserKeyResponse } from "@bitwarden/common/models/response/user-key.response";
|
||||||
import { BulkEncryptService } from "@bitwarden/common/platform/abstractions/bulk-encrypt.service";
|
import { BulkEncryptService } from "@bitwarden/common/platform/abstractions/bulk-encrypt.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { EncryptionType, KdfType } from "@bitwarden/common/platform/enums";
|
import { EncryptionType, KdfType } from "@bitwarden/common/platform/enums";
|
||||||
@ -16,6 +15,7 @@ import { CsprngArray } from "@bitwarden/common/types/csprng";
|
|||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { EmergencyAccessStatusType } from "../enums/emergency-access-status-type";
|
import { EmergencyAccessStatusType } from "../enums/emergency-access-status-type";
|
||||||
import { EmergencyAccessType } from "../enums/emergency-access-type";
|
import { EmergencyAccessType } from "../enums/emergency-access-type";
|
||||||
@ -31,7 +31,7 @@ import { EmergencyAccessService } from "./emergency-access.service";
|
|||||||
describe("EmergencyAccessService", () => {
|
describe("EmergencyAccessService", () => {
|
||||||
let emergencyAccessApiService: MockProxy<EmergencyAccessApiService>;
|
let emergencyAccessApiService: MockProxy<EmergencyAccessApiService>;
|
||||||
let apiService: MockProxy<ApiService>;
|
let apiService: MockProxy<ApiService>;
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let encryptService: MockProxy<EncryptService>;
|
let encryptService: MockProxy<EncryptService>;
|
||||||
let bulkEncryptService: MockProxy<BulkEncryptService>;
|
let bulkEncryptService: MockProxy<BulkEncryptService>;
|
||||||
let cipherService: MockProxy<CipherService>;
|
let cipherService: MockProxy<CipherService>;
|
||||||
@ -42,7 +42,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
emergencyAccessApiService = mock<EmergencyAccessApiService>();
|
emergencyAccessApiService = mock<EmergencyAccessApiService>();
|
||||||
apiService = mock<ApiService>();
|
apiService = mock<ApiService>();
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
encryptService = mock<EncryptService>();
|
encryptService = mock<EncryptService>();
|
||||||
bulkEncryptService = mock<BulkEncryptService>();
|
bulkEncryptService = mock<BulkEncryptService>();
|
||||||
cipherService = mock<CipherService>();
|
cipherService = mock<CipherService>();
|
||||||
@ -51,7 +51,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
emergencyAccessService = new EmergencyAccessService(
|
emergencyAccessService = new EmergencyAccessService(
|
||||||
emergencyAccessApiService,
|
emergencyAccessApiService,
|
||||||
apiService,
|
apiService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
bulkEncryptService,
|
bulkEncryptService,
|
||||||
cipherService,
|
cipherService,
|
||||||
@ -129,7 +129,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
"mockUserPublicKeyEncryptedUserKey",
|
"mockUserPublicKeyEncryptedUserKey",
|
||||||
);
|
);
|
||||||
|
|
||||||
cryptoService.getUserKey.mockResolvedValueOnce(mockUserKey);
|
keyService.getUserKey.mockResolvedValueOnce(mockUserKey);
|
||||||
apiService.getUserPublicKey.mockResolvedValueOnce(mockUserPublicKeyResponse);
|
apiService.getUserPublicKey.mockResolvedValueOnce(mockUserPublicKeyResponse);
|
||||||
|
|
||||||
encryptService.rsaEncrypt.mockResolvedValueOnce(mockUserPublicKeyEncryptedUserKey);
|
encryptService.rsaEncrypt.mockResolvedValueOnce(mockUserPublicKeyEncryptedUserKey);
|
||||||
@ -161,17 +161,17 @@ describe("EmergencyAccessService", () => {
|
|||||||
} as EmergencyAccessTakeoverResponse);
|
} as EmergencyAccessTakeoverResponse);
|
||||||
|
|
||||||
const mockDecryptedGrantorUserKey = new Uint8Array(64);
|
const mockDecryptedGrantorUserKey = new Uint8Array(64);
|
||||||
cryptoService.getPrivateKey.mockResolvedValue(new Uint8Array(64));
|
keyService.getPrivateKey.mockResolvedValue(new Uint8Array(64));
|
||||||
encryptService.rsaDecrypt.mockResolvedValueOnce(mockDecryptedGrantorUserKey);
|
encryptService.rsaDecrypt.mockResolvedValueOnce(mockDecryptedGrantorUserKey);
|
||||||
|
|
||||||
const mockMasterKey = new SymmetricCryptoKey(new Uint8Array(64) as CsprngArray) as MasterKey;
|
const mockMasterKey = new SymmetricCryptoKey(new Uint8Array(64) as CsprngArray) as MasterKey;
|
||||||
|
|
||||||
cryptoService.makeMasterKey.mockResolvedValueOnce(mockMasterKey);
|
keyService.makeMasterKey.mockResolvedValueOnce(mockMasterKey);
|
||||||
|
|
||||||
const mockMasterKeyHash = "mockMasterKeyHash";
|
const mockMasterKeyHash = "mockMasterKeyHash";
|
||||||
cryptoService.hashMasterKey.mockResolvedValueOnce(mockMasterKeyHash);
|
keyService.hashMasterKey.mockResolvedValueOnce(mockMasterKeyHash);
|
||||||
|
|
||||||
// must mock [UserKey, EncString] return from cryptoService.encryptUserKeyWithMasterKey
|
// must mock [UserKey, EncString] return from keyService.encryptUserKeyWithMasterKey
|
||||||
// where UserKey is the decrypted grantor user key
|
// where UserKey is the decrypted grantor user key
|
||||||
const mockMasterKeyEncryptedUserKey = new EncString(
|
const mockMasterKeyEncryptedUserKey = new EncString(
|
||||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||||
@ -180,7 +180,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
|
|
||||||
const mockUserKey = new SymmetricCryptoKey(mockDecryptedGrantorUserKey) as UserKey;
|
const mockUserKey = new SymmetricCryptoKey(mockDecryptedGrantorUserKey) as UserKey;
|
||||||
|
|
||||||
cryptoService.encryptUserKeyWithMasterKey.mockResolvedValueOnce([
|
keyService.encryptUserKeyWithMasterKey.mockResolvedValueOnce([
|
||||||
mockUserKey,
|
mockUserKey,
|
||||||
mockMasterKeyEncryptedUserKey,
|
mockMasterKeyEncryptedUserKey,
|
||||||
]);
|
]);
|
||||||
@ -206,7 +206,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
kdf: KdfType.PBKDF2_SHA256,
|
kdf: KdfType.PBKDF2_SHA256,
|
||||||
kdfIterations: 500,
|
kdfIterations: 500,
|
||||||
} as EmergencyAccessTakeoverResponse);
|
} as EmergencyAccessTakeoverResponse);
|
||||||
cryptoService.getPrivateKey.mockResolvedValue(new Uint8Array(64));
|
keyService.getPrivateKey.mockResolvedValue(new Uint8Array(64));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
emergencyAccessService.takeover(mockId, mockEmail, mockName),
|
emergencyAccessService.takeover(mockId, mockEmail, mockName),
|
||||||
@ -221,7 +221,7 @@ describe("EmergencyAccessService", () => {
|
|||||||
kdf: KdfType.PBKDF2_SHA256,
|
kdf: KdfType.PBKDF2_SHA256,
|
||||||
kdfIterations: 500,
|
kdfIterations: 500,
|
||||||
} as EmergencyAccessTakeoverResponse);
|
} as EmergencyAccessTakeoverResponse);
|
||||||
cryptoService.getPrivateKey.mockResolvedValue(null);
|
keyService.getPrivateKey.mockResolvedValue(null);
|
||||||
|
|
||||||
await expect(emergencyAccessService.takeover(mockId, mockEmail, mockName)).rejects.toThrow(
|
await expect(emergencyAccessService.takeover(mockId, mockEmail, mockName)).rejects.toThrow(
|
||||||
"user does not have a private key",
|
"user does not have a private key",
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { BulkEncryptService } from "@bitwarden/common/platform/abstractions/bulk-encrypt.service";
|
import { BulkEncryptService } from "@bitwarden/common/platform/abstractions/bulk-encrypt.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { KdfType } from "@bitwarden/common/platform/enums";
|
import { KdfType } from "@bitwarden/common/platform/enums";
|
||||||
@ -24,6 +23,7 @@ import { UserKey } from "@bitwarden/common/types/key";
|
|||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { EmergencyAccessStatusType } from "../enums/emergency-access-status-type";
|
import { EmergencyAccessStatusType } from "../enums/emergency-access-status-type";
|
||||||
import { EmergencyAccessType } from "../enums/emergency-access-type";
|
import { EmergencyAccessType } from "../enums/emergency-access-type";
|
||||||
@ -46,7 +46,7 @@ export class EmergencyAccessService
|
|||||||
constructor(
|
constructor(
|
||||||
private emergencyAccessApiService: EmergencyAccessApiService,
|
private emergencyAccessApiService: EmergencyAccessApiService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private bulkEncryptService: BulkEncryptService,
|
private bulkEncryptService: BulkEncryptService,
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
@ -153,7 +153,7 @@ export class EmergencyAccessService
|
|||||||
* @param token secret token provided in email
|
* @param token secret token provided in email
|
||||||
*/
|
*/
|
||||||
async confirm(id: string, granteeId: string) {
|
async confirm(id: string, granteeId: string) {
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
const userKey = await this.keyService.getUserKey();
|
||||||
if (!userKey) {
|
if (!userKey) {
|
||||||
throw new Error("No user key found");
|
throw new Error("No user key found");
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ export class EmergencyAccessService
|
|||||||
try {
|
try {
|
||||||
this.logService.debug(
|
this.logService.debug(
|
||||||
"User's fingerprint: " +
|
"User's fingerprint: " +
|
||||||
(await this.cryptoService.getFingerprint(granteeId, publicKey)).join("-"),
|
(await this.keyService.getFingerprint(granteeId, publicKey)).join("-"),
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors since it's just a debug message
|
// Ignore errors since it's just a debug message
|
||||||
@ -218,7 +218,7 @@ export class EmergencyAccessService
|
|||||||
async getViewOnlyCiphers(id: string): Promise<CipherView[]> {
|
async getViewOnlyCiphers(id: string): Promise<CipherView[]> {
|
||||||
const response = await this.emergencyAccessApiService.postEmergencyAccessView(id);
|
const response = await this.emergencyAccessApiService.postEmergencyAccessView(id);
|
||||||
|
|
||||||
const activeUserPrivateKey = await this.cryptoService.getPrivateKey();
|
const activeUserPrivateKey = await this.keyService.getPrivateKey();
|
||||||
|
|
||||||
if (activeUserPrivateKey == null) {
|
if (activeUserPrivateKey == null) {
|
||||||
throw new Error("Active user does not have a private key, cannot get view only ciphers.");
|
throw new Error("Active user does not have a private key, cannot get view only ciphers.");
|
||||||
@ -255,7 +255,7 @@ export class EmergencyAccessService
|
|||||||
async takeover(id: string, masterPassword: string, email: string) {
|
async takeover(id: string, masterPassword: string, email: string) {
|
||||||
const takeoverResponse = await this.emergencyAccessApiService.postEmergencyAccessTakeover(id);
|
const takeoverResponse = await this.emergencyAccessApiService.postEmergencyAccessTakeover(id);
|
||||||
|
|
||||||
const activeUserPrivateKey = await this.cryptoService.getPrivateKey();
|
const activeUserPrivateKey = await this.keyService.getPrivateKey();
|
||||||
|
|
||||||
if (activeUserPrivateKey == null) {
|
if (activeUserPrivateKey == null) {
|
||||||
throw new Error("Active user does not have a private key, cannot complete a takeover.");
|
throw new Error("Active user does not have a private key, cannot complete a takeover.");
|
||||||
@ -286,10 +286,10 @@ export class EmergencyAccessService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const masterKey = await this.cryptoService.makeMasterKey(masterPassword, email, config);
|
const masterKey = await this.keyService.makeMasterKey(masterPassword, email, config);
|
||||||
const masterKeyHash = await this.cryptoService.hashMasterKey(masterPassword, masterKey);
|
const masterKeyHash = await this.keyService.hashMasterKey(masterPassword, masterKey);
|
||||||
|
|
||||||
const encKey = await this.cryptoService.encryptUserKeyWithMasterKey(masterKey, grantorUserKey);
|
const encKey = await this.keyService.encryptUserKeyWithMasterKey(masterKey, grantorUserKey);
|
||||||
|
|
||||||
const request = new EmergencyAccessPasswordRequest();
|
const request = new EmergencyAccessPasswordRequest();
|
||||||
request.newMasterPasswordHash = masterKeyHash;
|
request.newMasterPasswordHash = masterKeyHash;
|
||||||
|
@ -6,7 +6,6 @@ import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractio
|
|||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { WebauthnRotateCredentialRequest } from "@bitwarden/common/auth/models/request/webauthn-rotate-credential.request";
|
import { WebauthnRotateCredentialRequest } from "@bitwarden/common/auth/models/request/webauthn-rotate-credential.request";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { SendWithIdRequest } from "@bitwarden/common/tools/send/models/request/send-with-id.request";
|
import { SendWithIdRequest } from "@bitwarden/common/tools/send/models/request/send-with-id.request";
|
||||||
@ -19,6 +18,7 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
|
|||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
import { CipherWithIdRequest } from "@bitwarden/common/vault/models/request/cipher-with-id.request";
|
import { CipherWithIdRequest } from "@bitwarden/common/vault/models/request/cipher-with-id.request";
|
||||||
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
|
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationUserResetPasswordService } from "../../admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service";
|
import { OrganizationUserResetPasswordService } from "../../admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service";
|
||||||
import { WebauthnLoginAdminService } from "../core";
|
import { WebauthnLoginAdminService } from "../core";
|
||||||
@ -39,7 +39,7 @@ describe("KeyRotationService", () => {
|
|||||||
let mockEmergencyAccessService: MockProxy<EmergencyAccessService>;
|
let mockEmergencyAccessService: MockProxy<EmergencyAccessService>;
|
||||||
let mockResetPasswordService: MockProxy<OrganizationUserResetPasswordService>;
|
let mockResetPasswordService: MockProxy<OrganizationUserResetPasswordService>;
|
||||||
let mockDeviceTrustService: MockProxy<DeviceTrustServiceAbstraction>;
|
let mockDeviceTrustService: MockProxy<DeviceTrustServiceAbstraction>;
|
||||||
let mockCryptoService: MockProxy<CryptoService>;
|
let mockKeyService: MockProxy<KeyService>;
|
||||||
let mockEncryptService: MockProxy<EncryptService>;
|
let mockEncryptService: MockProxy<EncryptService>;
|
||||||
let mockConfigService: MockProxy<ConfigService>;
|
let mockConfigService: MockProxy<ConfigService>;
|
||||||
let mockSyncService: MockProxy<SyncService>;
|
let mockSyncService: MockProxy<SyncService>;
|
||||||
@ -61,7 +61,7 @@ describe("KeyRotationService", () => {
|
|||||||
mockEmergencyAccessService = mock<EmergencyAccessService>();
|
mockEmergencyAccessService = mock<EmergencyAccessService>();
|
||||||
mockResetPasswordService = mock<OrganizationUserResetPasswordService>();
|
mockResetPasswordService = mock<OrganizationUserResetPasswordService>();
|
||||||
mockDeviceTrustService = mock<DeviceTrustServiceAbstraction>();
|
mockDeviceTrustService = mock<DeviceTrustServiceAbstraction>();
|
||||||
mockCryptoService = mock<CryptoService>();
|
mockKeyService = mock<KeyService>();
|
||||||
mockEncryptService = mock<EncryptService>();
|
mockEncryptService = mock<EncryptService>();
|
||||||
mockConfigService = mock<ConfigService>();
|
mockConfigService = mock<ConfigService>();
|
||||||
mockSyncService = mock<SyncService>();
|
mockSyncService = mock<SyncService>();
|
||||||
@ -76,7 +76,7 @@ describe("KeyRotationService", () => {
|
|||||||
mockEmergencyAccessService,
|
mockEmergencyAccessService,
|
||||||
mockResetPasswordService,
|
mockResetPasswordService,
|
||||||
mockDeviceTrustService,
|
mockDeviceTrustService,
|
||||||
mockCryptoService,
|
mockKeyService,
|
||||||
mockEncryptService,
|
mockEncryptService,
|
||||||
mockSyncService,
|
mockSyncService,
|
||||||
mockWebauthnLoginAdminService,
|
mockWebauthnLoginAdminService,
|
||||||
@ -91,13 +91,13 @@ describe("KeyRotationService", () => {
|
|||||||
let privateKey: BehaviorSubject<UserPrivateKey>;
|
let privateKey: BehaviorSubject<UserPrivateKey>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockCryptoService.makeUserKey.mockResolvedValue([
|
mockKeyService.makeUserKey.mockResolvedValue([
|
||||||
new SymmetricCryptoKey(new Uint8Array(64)) as UserKey,
|
new SymmetricCryptoKey(new Uint8Array(64)) as UserKey,
|
||||||
{
|
{
|
||||||
encryptedString: "mockNewUserKey",
|
encryptedString: "mockNewUserKey",
|
||||||
} as any,
|
} as any,
|
||||||
]);
|
]);
|
||||||
mockCryptoService.hashMasterKey.mockResolvedValue("mockMasterPasswordHash");
|
mockKeyService.hashMasterKey.mockResolvedValue("mockMasterPasswordHash");
|
||||||
mockConfigService.getFeatureFlag.mockResolvedValue(true);
|
mockConfigService.getFeatureFlag.mockResolvedValue(true);
|
||||||
|
|
||||||
mockEncryptService.encrypt.mockResolvedValue({
|
mockEncryptService.encrypt.mockResolvedValue({
|
||||||
@ -111,11 +111,11 @@ describe("KeyRotationService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mock user key
|
// Mock user key
|
||||||
mockCryptoService.userKey$.mockReturnValue(new BehaviorSubject("mockOriginalUserKey" as any));
|
mockKeyService.userKey$.mockReturnValue(new BehaviorSubject("mockOriginalUserKey" as any));
|
||||||
|
|
||||||
// Mock private key
|
// Mock private key
|
||||||
privateKey = new BehaviorSubject("mockPrivateKey" as any);
|
privateKey = new BehaviorSubject("mockPrivateKey" as any);
|
||||||
mockCryptoService.userPrivateKeyWithLegacySupport$.mockReturnValue(privateKey);
|
mockKeyService.userPrivateKeyWithLegacySupport$.mockReturnValue(privateKey);
|
||||||
|
|
||||||
// Mock ciphers
|
// Mock ciphers
|
||||||
const mockCiphers = [createMockCipher("1", "Cipher 1"), createMockCipher("2", "Cipher 2")];
|
const mockCiphers = [createMockCipher("1", "Cipher 1"), createMockCipher("2", "Cipher 2")];
|
||||||
@ -164,7 +164,7 @@ describe("KeyRotationService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws if user key creation fails", async () => {
|
it("throws if user key creation fails", async () => {
|
||||||
mockCryptoService.makeUserKey.mockResolvedValueOnce([null, null]);
|
mockKeyService.makeUserKey.mockResolvedValueOnce([null, null]);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
keyRotationService.rotateUserKeyAndEncryptedData("mockMasterPassword", mockUser),
|
keyRotationService.rotateUserKeyAndEncryptedData("mockMasterPassword", mockUser),
|
||||||
|
@ -6,7 +6,6 @@ import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractio
|
|||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
|
import { VerificationType } from "@bitwarden/common/auth/enums/verification-type";
|
||||||
import { MasterPasswordVerification } from "@bitwarden/common/auth/types/verification";
|
import { MasterPasswordVerification } from "@bitwarden/common/auth/types/verification";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EncryptedString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncryptedString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
||||||
@ -15,6 +14,7 @@ import { UserKey } from "@bitwarden/common/types/key";
|
|||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationUserResetPasswordService } from "../../admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service";
|
import { OrganizationUserResetPasswordService } from "../../admin-console/organizations/members/services/organization-user-reset-password/organization-user-reset-password.service";
|
||||||
import { WebauthnLoginAdminService } from "../core";
|
import { WebauthnLoginAdminService } from "../core";
|
||||||
@ -34,7 +34,7 @@ export class UserKeyRotationService {
|
|||||||
private emergencyAccessService: EmergencyAccessService,
|
private emergencyAccessService: EmergencyAccessService,
|
||||||
private resetPasswordService: OrganizationUserResetPasswordService,
|
private resetPasswordService: OrganizationUserResetPasswordService,
|
||||||
private deviceTrustService: DeviceTrustServiceAbstraction,
|
private deviceTrustService: DeviceTrustServiceAbstraction,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private webauthnLoginAdminService: WebauthnLoginAdminService,
|
private webauthnLoginAdminService: WebauthnLoginAdminService,
|
||||||
@ -71,7 +71,7 @@ export class UserKeyRotationService {
|
|||||||
user.email,
|
user.email,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [newUserKey, newEncUserKey] = await this.cryptoService.makeUserKey(masterKey);
|
const [newUserKey, newEncUserKey] = await this.keyService.makeUserKey(masterKey);
|
||||||
|
|
||||||
if (!newUserKey || !newEncUserKey) {
|
if (!newUserKey || !newEncUserKey) {
|
||||||
throw new Error("User key could not be created");
|
throw new Error("User key could not be created");
|
||||||
@ -84,13 +84,13 @@ export class UserKeyRotationService {
|
|||||||
request.key = newEncUserKey.encryptedString;
|
request.key = newEncUserKey.encryptedString;
|
||||||
|
|
||||||
// Add master key hash
|
// Add master key hash
|
||||||
const masterPasswordHash = await this.cryptoService.hashMasterKey(masterPassword, masterKey);
|
const masterPasswordHash = await this.keyService.hashMasterKey(masterPassword, masterKey);
|
||||||
request.masterPasswordHash = masterPasswordHash;
|
request.masterPasswordHash = masterPasswordHash;
|
||||||
|
|
||||||
// Get original user key
|
// Get original user key
|
||||||
// Note: We distribute the legacy key, but not all domains actually use it. If any of those
|
// Note: We distribute the legacy key, but not all domains actually use it. If any of those
|
||||||
// domains break their legacy support it will break the migration process for legacy users.
|
// domains break their legacy support it will break the migration process for legacy users.
|
||||||
const originalUserKey = await this.cryptoService.getUserKeyWithLegacySupport(user.id);
|
const originalUserKey = await this.keyService.getUserKeyWithLegacySupport(user.id);
|
||||||
|
|
||||||
// Add re-encrypted data
|
// Add re-encrypted data
|
||||||
request.privateKey = await this.encryptPrivateKey(newUserKey, user.id);
|
request.privateKey = await this.encryptPrivateKey(newUserKey, user.id);
|
||||||
@ -162,7 +162,7 @@ export class UserKeyRotationService {
|
|||||||
userId: UserId,
|
userId: UserId,
|
||||||
): Promise<EncryptedString | null> {
|
): Promise<EncryptedString | null> {
|
||||||
const privateKey = await firstValueFrom(
|
const privateKey = await firstValueFrom(
|
||||||
this.cryptoService.userPrivateKeyWithLegacySupport$(userId),
|
this.keyService.userPrivateKeyWithLegacySupport$(userId),
|
||||||
);
|
);
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
throw new Error("No private key found for user key rotation");
|
throw new Error("No private key found for user key rotation");
|
||||||
|
@ -3,13 +3,13 @@ import { FormControl, FormGroup, Validators } from "@angular/forms";
|
|||||||
import { firstValueFrom } from "rxjs";
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { SharedModule } from "../../shared";
|
import { SharedModule } from "../../shared";
|
||||||
import { UserKeyRotationModule } from "../key-rotation/user-key-rotation.module";
|
import { UserKeyRotationModule } from "../key-rotation/user-key-rotation.module";
|
||||||
@ -31,7 +31,7 @@ export class MigrateFromLegacyEncryptionComponent {
|
|||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private keyRotationService: UserKeyRotationService,
|
private keyRotationService: UserKeyRotationService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
@ -49,7 +49,7 @@ export class MigrateFromLegacyEncryptionComponent {
|
|||||||
|
|
||||||
const activeUser = await firstValueFrom(this.accountService.activeAccount$);
|
const activeUser = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
|
|
||||||
const hasUserKey = await this.cryptoService.hasUserKey(activeUser.id);
|
const hasUserKey = await this.keyService.hasUserKey(activeUser.id);
|
||||||
if (hasUserKey) {
|
if (hasUserKey) {
|
||||||
this.messagingService.send("logout");
|
this.messagingService.send("logout");
|
||||||
throw new Error("User key already exists, cannot migrate legacy encryption.");
|
throw new Error("User key already exists, cannot migrate legacy encryption.");
|
||||||
|
@ -10,12 +10,12 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
|||||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||||
import { ResetPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/reset-password-policy-options";
|
import { ResetPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/reset-password-policy-options";
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { FakeGlobalState } from "@bitwarden/common/spec/fake-state";
|
import { FakeGlobalState } from "@bitwarden/common/spec/fake-state";
|
||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { I18nService } from "../../core/i18n.service";
|
import { I18nService } from "../../core/i18n.service";
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ describe("AcceptOrganizationInviteService", () => {
|
|||||||
let sut: AcceptOrganizationInviteService;
|
let sut: AcceptOrganizationInviteService;
|
||||||
let apiService: MockProxy<ApiService>;
|
let apiService: MockProxy<ApiService>;
|
||||||
let authService: MockProxy<AuthService>;
|
let authService: MockProxy<AuthService>;
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let encryptService: MockProxy<EncryptService>;
|
let encryptService: MockProxy<EncryptService>;
|
||||||
let policyApiService: MockProxy<PolicyApiServiceAbstraction>;
|
let policyApiService: MockProxy<PolicyApiServiceAbstraction>;
|
||||||
let policyService: MockProxy<PolicyService>;
|
let policyService: MockProxy<PolicyService>;
|
||||||
@ -43,7 +43,7 @@ describe("AcceptOrganizationInviteService", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
apiService = mock();
|
apiService = mock();
|
||||||
authService = mock();
|
authService = mock();
|
||||||
cryptoService = mock();
|
keyService = mock();
|
||||||
encryptService = mock();
|
encryptService = mock();
|
||||||
policyApiService = mock();
|
policyApiService = mock();
|
||||||
policyService = mock();
|
policyService = mock();
|
||||||
@ -57,7 +57,7 @@ describe("AcceptOrganizationInviteService", () => {
|
|||||||
sut = new AcceptOrganizationInviteService(
|
sut = new AcceptOrganizationInviteService(
|
||||||
apiService,
|
apiService,
|
||||||
authService,
|
authService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
policyApiService,
|
policyApiService,
|
||||||
policyService,
|
policyService,
|
||||||
@ -71,11 +71,11 @@ describe("AcceptOrganizationInviteService", () => {
|
|||||||
|
|
||||||
describe("validateAndAcceptInvite", () => {
|
describe("validateAndAcceptInvite", () => {
|
||||||
it("initializes an organization when given an invite where initOrganization is true", async () => {
|
it("initializes an organization when given an invite where initOrganization is true", async () => {
|
||||||
cryptoService.makeOrgKey.mockResolvedValue([
|
keyService.makeOrgKey.mockResolvedValue([
|
||||||
{ encryptedString: "string" } as EncString,
|
{ encryptedString: "string" } as EncString,
|
||||||
"orgPrivateKey" as unknown as OrgKey,
|
"orgPrivateKey" as unknown as OrgKey,
|
||||||
]);
|
]);
|
||||||
cryptoService.makeKeyPair.mockResolvedValue([
|
keyService.makeKeyPair.mockResolvedValue([
|
||||||
"orgPublicKey",
|
"orgPublicKey",
|
||||||
{ encryptedString: "string" } as EncString,
|
{ encryptedString: "string" } as EncString,
|
||||||
]);
|
]);
|
||||||
|
@ -14,7 +14,6 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
|||||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||||
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
|
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
|
||||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.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";
|
||||||
@ -26,6 +25,7 @@ import {
|
|||||||
ORGANIZATION_INVITE_DISK,
|
ORGANIZATION_INVITE_DISK,
|
||||||
} from "@bitwarden/common/platform/state";
|
} from "@bitwarden/common/platform/state";
|
||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationInvite } from "./organization-invite";
|
import { OrganizationInvite } from "./organization-invite";
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ export class AcceptOrganizationInviteService {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly apiService: ApiService,
|
private readonly apiService: ApiService,
|
||||||
private readonly authService: AuthService,
|
private readonly authService: AuthService,
|
||||||
private readonly cryptoService: CryptoService,
|
private readonly keyService: KeyService,
|
||||||
private readonly encryptService: EncryptService,
|
private readonly encryptService: EncryptService,
|
||||||
private readonly policyApiService: PolicyApiServiceAbstraction,
|
private readonly policyApiService: PolicyApiServiceAbstraction,
|
||||||
private readonly policyService: PolicyService,
|
private readonly policyService: PolicyService,
|
||||||
@ -137,8 +137,8 @@ export class AcceptOrganizationInviteService {
|
|||||||
const request = new OrganizationUserAcceptInitRequest();
|
const request = new OrganizationUserAcceptInitRequest();
|
||||||
request.token = invite.token;
|
request.token = invite.token;
|
||||||
|
|
||||||
const [encryptedOrgKey, orgKey] = await this.cryptoService.makeOrgKey<OrgKey>();
|
const [encryptedOrgKey, orgKey] = await this.keyService.makeOrgKey<OrgKey>();
|
||||||
const [orgPublicKey, encryptedOrgPrivateKey] = await this.cryptoService.makeKeyPair(orgKey);
|
const [orgPublicKey, encryptedOrgPrivateKey] = await this.keyService.makeKeyPair(orgKey);
|
||||||
const collection = await this.encryptService.encrypt(
|
const collection = await this.encryptService.encrypt(
|
||||||
this.i18nService.t("defaultCollection"),
|
this.i18nService.t("defaultCollection"),
|
||||||
orgKey,
|
orgKey,
|
||||||
@ -183,7 +183,7 @@ export class AcceptOrganizationInviteService {
|
|||||||
const publicKey = Utils.fromB64ToArray(response.publicKey);
|
const publicKey = Utils.fromB64ToArray(response.publicKey);
|
||||||
|
|
||||||
// RSA Encrypt user's encKey.key with organization public key
|
// RSA Encrypt user's encKey.key with organization public key
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
const userKey = await this.keyService.getUserKey();
|
||||||
const encryptedKey = await this.encryptService.rsaEncrypt(userKey.key, publicKey);
|
const encryptedKey = await this.encryptService.rsaEncrypt(userKey.key, publicKey);
|
||||||
|
|
||||||
// Add reset password key to accept request
|
// Add reset password key to accept request
|
||||||
|
@ -5,10 +5,10 @@ import { Router } from "@angular/router";
|
|||||||
import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { TwoFactorRecoveryRequest } from "@bitwarden/common/auth/models/request/two-factor-recovery.request";
|
import { TwoFactorRecoveryRequest } from "@bitwarden/common/auth/models/request/two-factor-recovery.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-recover-two-factor",
|
selector: "app-recover-two-factor",
|
||||||
@ -26,7 +26,7 @@ export class RecoverTwoFactorComponent {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private loginStrategyService: LoginStrategyServiceAbstraction,
|
private loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
) {}
|
) {}
|
||||||
@ -53,7 +53,7 @@ export class RecoverTwoFactorComponent {
|
|||||||
request.recoveryCode = this.recoveryCode.replace(/\s/g, "").toLowerCase();
|
request.recoveryCode = this.recoveryCode.replace(/\s/g, "").toLowerCase();
|
||||||
request.email = this.email.trim().toLowerCase();
|
request.email = this.email.trim().toLowerCase();
|
||||||
const key = await this.loginStrategyService.makePreloginKey(this.masterPassword, request.email);
|
const key = await this.loginStrategyService.makePreloginKey(this.masterPassword, request.email);
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(this.masterPassword, key);
|
request.masterPasswordHash = await this.keyService.hashMasterKey(this.masterPassword, key);
|
||||||
await this.apiService.postTwoFactorRecover(request);
|
await this.apiService.postTwoFactorRecover(request);
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
variant: "success",
|
variant: "success",
|
||||||
|
@ -11,7 +11,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
||||||
import { ReferenceEventRequest } from "@bitwarden/common/models/request/reference-event.request";
|
import { ReferenceEventRequest } from "@bitwarden/common/models/request/reference-event.request";
|
||||||
import { RegisterRequest } from "@bitwarden/common/models/request/register.request";
|
import { RegisterRequest } from "@bitwarden/common/models/request/register.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@ -19,6 +18,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { AcceptOrganizationInviteService } from "../organization-invite/accept-organization.service";
|
import { AcceptOrganizationInviteService } from "../organization-invite/accept-organization.service";
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export class RegisterFormComponent extends BaseRegisterComponent implements OnIn
|
|||||||
loginStrategyService: LoginStrategyServiceAbstraction,
|
loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
router: Router,
|
router: Router,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -60,7 +60,7 @@ export class RegisterFormComponent extends BaseRegisterComponent implements OnIn
|
|||||||
loginStrategyService,
|
loginStrategyService,
|
||||||
router,
|
router,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
apiService,
|
apiService,
|
||||||
stateService,
|
stateService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -6,13 +6,13 @@ import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config
|
|||||||
import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type";
|
import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-provider-type";
|
||||||
import { EmailTokenRequest } from "@bitwarden/common/auth/models/request/email-token.request";
|
import { EmailTokenRequest } from "@bitwarden/common/auth/models/request/email-token.request";
|
||||||
import { EmailRequest } from "@bitwarden/common/auth/models/request/email.request";
|
import { EmailRequest } from "@bitwarden/common/auth/models/request/email.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-change-email",
|
selector: "app-change-email",
|
||||||
@ -34,7 +34,7 @@ export class ChangeEmailComponent implements OnInit {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
@ -69,9 +69,9 @@ export class ChangeEmailComponent implements OnInit {
|
|||||||
if (!this.tokenSent) {
|
if (!this.tokenSent) {
|
||||||
const request = new EmailTokenRequest();
|
const request = new EmailTokenRequest();
|
||||||
request.newEmail = newEmail;
|
request.newEmail = newEmail;
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(
|
request.masterPasswordHash = await this.keyService.hashMasterKey(
|
||||||
step1Value.masterPassword,
|
step1Value.masterPassword,
|
||||||
await this.cryptoService.getOrDeriveMasterKey(step1Value.masterPassword),
|
await this.keyService.getOrDeriveMasterKey(step1Value.masterPassword),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await this.apiService.postEmailToken(request);
|
await this.apiService.postEmailToken(request);
|
||||||
@ -83,21 +83,21 @@ export class ChangeEmailComponent implements OnInit {
|
|||||||
const request = new EmailRequest();
|
const request = new EmailRequest();
|
||||||
request.token = this.formGroup.value.token;
|
request.token = this.formGroup.value.token;
|
||||||
request.newEmail = newEmail;
|
request.newEmail = newEmail;
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(
|
request.masterPasswordHash = await this.keyService.hashMasterKey(
|
||||||
step1Value.masterPassword,
|
step1Value.masterPassword,
|
||||||
await this.cryptoService.getOrDeriveMasterKey(step1Value.masterPassword),
|
await this.keyService.getOrDeriveMasterKey(step1Value.masterPassword),
|
||||||
);
|
);
|
||||||
const kdfConfig = await this.kdfConfigService.getKdfConfig();
|
const kdfConfig = await this.kdfConfigService.getKdfConfig();
|
||||||
const newMasterKey = await this.cryptoService.makeMasterKey(
|
const newMasterKey = await this.keyService.makeMasterKey(
|
||||||
step1Value.masterPassword,
|
step1Value.masterPassword,
|
||||||
newEmail,
|
newEmail,
|
||||||
kdfConfig,
|
kdfConfig,
|
||||||
);
|
);
|
||||||
request.newMasterPasswordHash = await this.cryptoService.hashMasterKey(
|
request.newMasterPasswordHash = await this.keyService.hashMasterKey(
|
||||||
step1Value.masterPassword,
|
step1Value.masterPassword,
|
||||||
newMasterKey,
|
newMasterKey,
|
||||||
);
|
);
|
||||||
const newUserKey = await this.cryptoService.encryptUserKeyWithMasterKey(newMasterKey);
|
const newUserKey = await this.keyService.encryptUserKeyWithMasterKey(newMasterKey);
|
||||||
request.key = newUserKey[1].encryptedString;
|
request.key = newUserKey[1].encryptedString;
|
||||||
try {
|
try {
|
||||||
await this.apiService.postEmail(request);
|
await this.apiService.postEmail(request);
|
||||||
|
@ -11,7 +11,6 @@ import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config
|
|||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||||
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
|
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
@ -24,6 +23,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
|
|||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { UserKeyRotationService } from "../key-rotation/user-key-rotation.service";
|
import { UserKeyRotationService } from "../key-rotation/user-key-rotation.service";
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export class ChangePasswordComponent
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
@ -64,7 +64,7 @@ export class ChangePasswordComponent
|
|||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
messagingService,
|
messagingService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
@ -181,14 +181,14 @@ export class ChangePasswordComponent
|
|||||||
newMasterKey: MasterKey,
|
newMasterKey: MasterKey,
|
||||||
newUserKey: [UserKey, EncString],
|
newUserKey: [UserKey, EncString],
|
||||||
) {
|
) {
|
||||||
const masterKey = await this.cryptoService.makeMasterKey(
|
const masterKey = await this.keyService.makeMasterKey(
|
||||||
this.currentMasterPassword,
|
this.currentMasterPassword,
|
||||||
await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email))),
|
await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.email))),
|
||||||
await this.kdfConfigService.getKdfConfig(),
|
await this.kdfConfigService.getKdfConfig(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
|
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
|
||||||
const newLocalKeyHash = await this.cryptoService.hashMasterKey(
|
const newLocalKeyHash = await this.keyService.hashMasterKey(
|
||||||
this.masterPassword,
|
this.masterPassword,
|
||||||
newMasterKey,
|
newMasterKey,
|
||||||
HashPurpose.LocalAuthorization,
|
HashPurpose.LocalAuthorization,
|
||||||
@ -205,7 +205,7 @@ export class ChangePasswordComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
const request = new PasswordRequest();
|
const request = new PasswordRequest();
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(
|
request.masterPasswordHash = await this.keyService.hashMasterKey(
|
||||||
this.currentMasterPassword,
|
this.currentMasterPassword,
|
||||||
masterKey,
|
masterKey,
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,6 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from "@bitwarden/ang
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -14,6 +13,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "emergency-access-attachments",
|
selector: "emergency-access-attachments",
|
||||||
@ -26,7 +26,7 @@ export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponen
|
|||||||
constructor(
|
constructor(
|
||||||
cipherService: CipherService,
|
cipherService: CipherService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -41,7 +41,7 @@ export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponen
|
|||||||
super(
|
super(
|
||||||
cipherService,
|
cipherService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
apiService,
|
apiService,
|
||||||
|
@ -4,10 +4,10 @@ import { FormBuilder } from "@angular/forms";
|
|||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
|
import { OrganizationManagementPreferencesService } from "@bitwarden/common/admin-console/abstractions/organization-management-preferences/organization-management-preferences.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
export enum EmergencyAccessConfirmDialogResult {
|
export enum EmergencyAccessConfirmDialogResult {
|
||||||
Confirmed = "confirmed",
|
Confirmed = "confirmed",
|
||||||
@ -35,7 +35,7 @@ export class EmergencyAccessConfirmComponent implements OnInit {
|
|||||||
@Inject(DIALOG_DATA) protected params: EmergencyAccessConfirmDialogData,
|
@Inject(DIALOG_DATA) protected params: EmergencyAccessConfirmDialogData,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
protected organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
protected organizationManagementPreferencesService: OrganizationManagementPreferencesService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private dialogRef: DialogRef<EmergencyAccessConfirmDialogResult>,
|
private dialogRef: DialogRef<EmergencyAccessConfirmDialogResult>,
|
||||||
@ -46,7 +46,7 @@ export class EmergencyAccessConfirmComponent implements OnInit {
|
|||||||
const publicKeyResponse = await this.apiService.getUserPublicKey(this.params.userId);
|
const publicKeyResponse = await this.apiService.getUserPublicKey(this.params.userId);
|
||||||
if (publicKeyResponse != null) {
|
if (publicKeyResponse != null) {
|
||||||
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(this.params.userId, publicKey);
|
const fingerprint = await this.keyService.getFingerprint(this.params.userId, publicKey);
|
||||||
if (fingerprint != null) {
|
if (fingerprint != null) {
|
||||||
this.fingerprint = fingerprint.join("-");
|
this.fingerprint = fingerprint.join("-");
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -17,6 +16,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { KdfType } from "@bitwarden/common/platform/enums";
|
import { KdfType } from "@bitwarden/common/platform/enums";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { EmergencyAccessService } from "../../../emergency-access";
|
import { EmergencyAccessService } from "../../../emergency-access";
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ export class EmergencyAccessTakeoverComponent
|
|||||||
@Inject(DIALOG_DATA) protected params: EmergencyAccessTakeoverDialogData,
|
@Inject(DIALOG_DATA) protected params: EmergencyAccessTakeoverDialogData,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
@ -68,7 +68,7 @@ export class EmergencyAccessTakeoverComponent
|
|||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
messagingService,
|
messagingService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -7,12 +7,12 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||||
import { KdfRequest } from "@bitwarden/common/models/request/kdf.request";
|
import { KdfRequest } from "@bitwarden/common/models/request/kdf.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { KdfType } from "@bitwarden/common/platform/enums";
|
import { KdfType } from "@bitwarden/common/platform/enums";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-change-kdf-confirmation",
|
selector: "app-change-kdf-confirmation",
|
||||||
@ -32,7 +32,7 @@ export class ChangeKdfConfirmationComponent {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
@Inject(DIALOG_DATA) params: { kdf: KdfType; kdfConfig: KdfConfig },
|
@Inject(DIALOG_DATA) params: { kdf: KdfType; kdfConfig: KdfConfig },
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
@ -70,22 +70,18 @@ export class ChangeKdfConfirmationComponent {
|
|||||||
request.kdfMemory = this.kdfConfig.memory;
|
request.kdfMemory = this.kdfConfig.memory;
|
||||||
request.kdfParallelism = this.kdfConfig.parallelism;
|
request.kdfParallelism = this.kdfConfig.parallelism;
|
||||||
}
|
}
|
||||||
const masterKey = await this.cryptoService.getOrDeriveMasterKey(masterPassword);
|
const masterKey = await this.keyService.getOrDeriveMasterKey(masterPassword);
|
||||||
request.masterPasswordHash = await this.cryptoService.hashMasterKey(masterPassword, masterKey);
|
request.masterPasswordHash = await this.keyService.hashMasterKey(masterPassword, masterKey);
|
||||||
const email = await firstValueFrom(
|
const email = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.email)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.email)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const newMasterKey = await this.cryptoService.makeMasterKey(
|
const newMasterKey = await this.keyService.makeMasterKey(masterPassword, email, this.kdfConfig);
|
||||||
masterPassword,
|
request.newMasterPasswordHash = await this.keyService.hashMasterKey(
|
||||||
email,
|
|
||||||
this.kdfConfig,
|
|
||||||
);
|
|
||||||
request.newMasterPasswordHash = await this.cryptoService.hashMasterKey(
|
|
||||||
masterPassword,
|
masterPassword,
|
||||||
newMasterKey,
|
newMasterKey,
|
||||||
);
|
);
|
||||||
const newUserKey = await this.cryptoService.encryptUserKeyWithMasterKey(newMasterKey);
|
const newUserKey = await this.keyService.encryptUserKeyWithMasterKey(newMasterKey);
|
||||||
request.key = newUserKey[1].encryptedString;
|
request.key = newUserKey[1].encryptedString;
|
||||||
|
|
||||||
await this.apiService.postAccountKdf(request);
|
await this.apiService.postAccountKdf(request);
|
||||||
|
@ -36,11 +36,11 @@ import { PaymentSourceResponse } from "@bitwarden/common/billing/models/response
|
|||||||
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { PaymentV2Component } from "../shared/payment/payment-v2.component";
|
import { PaymentV2Component } from "../shared/payment/payment-v2.component";
|
||||||
import { PaymentComponent } from "../shared/payment/payment.component";
|
import { PaymentComponent } from "../shared/payment/payment.component";
|
||||||
@ -177,7 +177,7 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
|
|||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
@ -755,8 +755,8 @@ export class ChangePlanDialogComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// Backfill pub/priv key if necessary
|
// Backfill pub/priv key if necessary
|
||||||
if (!this.organization.hasPublicAndPrivateKeys) {
|
if (!this.organization.hasPublicAndPrivateKeys) {
|
||||||
const orgShareKey = await this.cryptoService.getOrgKey(this.organizationId);
|
const orgShareKey = await this.keyService.getOrgKey(this.organizationId);
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);
|
const orgKeys = await this.keyService.makeKeyPair(orgShareKey);
|
||||||
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import { OrganizationSubscriptionResponse } from "@bitwarden/common/billing/mode
|
|||||||
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -43,6 +42,7 @@ import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/sym
|
|||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationCreateModule } from "../../admin-console/organizations/create/organization-create.module";
|
import { OrganizationCreateModule } from "../../admin-console/organizations/create/organization-create.module";
|
||||||
import { BillingSharedModule, secretsManagerSubscribeFormFactory } from "../shared";
|
import { BillingSharedModule, secretsManagerSubscribeFormFactory } from "../shared";
|
||||||
@ -153,7 +153,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
@ -596,14 +596,14 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||||||
const doSubmit = async (): Promise<string> => {
|
const doSubmit = async (): Promise<string> => {
|
||||||
let orgId: string = null;
|
let orgId: string = null;
|
||||||
if (this.createOrganization) {
|
if (this.createOrganization) {
|
||||||
const orgKey = await this.cryptoService.makeOrgKey<OrgKey>();
|
const orgKey = await this.keyService.makeOrgKey<OrgKey>();
|
||||||
const key = orgKey[0].encryptedString;
|
const key = orgKey[0].encryptedString;
|
||||||
const collection = await this.encryptService.encrypt(
|
const collection = await this.encryptService.encrypt(
|
||||||
this.i18nService.t("defaultCollection"),
|
this.i18nService.t("defaultCollection"),
|
||||||
orgKey[1],
|
orgKey[1],
|
||||||
);
|
);
|
||||||
const collectionCt = collection.encryptedString;
|
const collectionCt = collection.encryptedString;
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgKey[1]);
|
const orgKeys = await this.keyService.makeKeyPair(orgKey[1]);
|
||||||
|
|
||||||
if (this.selfHosted) {
|
if (this.selfHosted) {
|
||||||
orgId = await this.createSelfHosted(key, collectionCt, orgKeys);
|
orgId = await this.createSelfHosted(key, collectionCt, orgKeys);
|
||||||
@ -690,8 +690,8 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// Backfill pub/priv key if necessary
|
// Backfill pub/priv key if necessary
|
||||||
if (!this.organization.hasPublicAndPrivateKeys) {
|
if (!this.organization.hasPublicAndPrivateKeys) {
|
||||||
const orgShareKey = await this.cryptoService.getOrgKey(this.organizationId);
|
const orgShareKey = await this.keyService.getOrgKey(this.organizationId);
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);
|
const orgKeys = await this.keyService.makeKeyPair(orgShareKey);
|
||||||
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,7 +755,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||||||
this.formGroup.controls.clientOwnerEmail.value,
|
this.formGroup.controls.clientOwnerEmail.value,
|
||||||
request,
|
request,
|
||||||
);
|
);
|
||||||
const providerKey = await this.cryptoService.getProviderKey(this.providerId);
|
const providerKey = await this.keyService.getProviderKey(this.providerId);
|
||||||
providerRequest.organizationCreateRequest.key = (
|
providerRequest.organizationCreateRequest.key = (
|
||||||
await this.encryptService.encrypt(orgKey.key, providerKey)
|
await this.encryptService.encrypt(orgKey.key, providerKey)
|
||||||
).encryptedString;
|
).encryptedString;
|
||||||
|
@ -5,13 +5,13 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
|
||||||
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
|
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { SyncService } from "@bitwarden/common/platform/sync";
|
import { SyncService } from "@bitwarden/common/platform/sync";
|
||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { AbstractSelfHostingLicenseUploaderComponent } from "../../shared/self-hosting-license-uploader/abstract-self-hosting-license-uploader.component";
|
import { AbstractSelfHostingLicenseUploaderComponent } from "../../shared/self-hosting-license-uploader/abstract-self-hosting-license-uploader.component";
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ export class OrganizationSelfHostingLicenseUploaderComponent extends AbstractSel
|
|||||||
protected readonly tokenService: TokenService,
|
protected readonly tokenService: TokenService,
|
||||||
private readonly apiService: ApiService,
|
private readonly apiService: ApiService,
|
||||||
private readonly encryptService: EncryptService,
|
private readonly encryptService: EncryptService,
|
||||||
private readonly cryptoService: CryptoService,
|
private readonly keyService: KeyService,
|
||||||
private readonly organizationApiService: OrganizationApiServiceAbstraction,
|
private readonly organizationApiService: OrganizationApiServiceAbstraction,
|
||||||
private readonly syncService: SyncService,
|
private readonly syncService: SyncService,
|
||||||
) {
|
) {
|
||||||
@ -47,14 +47,14 @@ export class OrganizationSelfHostingLicenseUploaderComponent extends AbstractSel
|
|||||||
protected async submit(): Promise<void> {
|
protected async submit(): Promise<void> {
|
||||||
await super.submit();
|
await super.submit();
|
||||||
|
|
||||||
const orgKey = await this.cryptoService.makeOrgKey<OrgKey>();
|
const orgKey = await this.keyService.makeOrgKey<OrgKey>();
|
||||||
const key = orgKey[0].encryptedString;
|
const key = orgKey[0].encryptedString;
|
||||||
const collection = await this.encryptService.encrypt(
|
const collection = await this.encryptService.encrypt(
|
||||||
this.i18nService.t("defaultCollection"),
|
this.i18nService.t("defaultCollection"),
|
||||||
orgKey[1],
|
orgKey[1],
|
||||||
);
|
);
|
||||||
const collectionCt = collection.encryptedString;
|
const collectionCt = collection.encryptedString;
|
||||||
const orgKeys = await this.cryptoService.makeKeyPair(orgKey[1]);
|
const orgKeys = await this.keyService.makeKeyPair(orgKey[1]);
|
||||||
|
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append("license", this.formValue.file);
|
fd.append("license", this.formValue.file);
|
||||||
|
@ -42,7 +42,6 @@ import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth
|
|||||||
import { ClientType } from "@bitwarden/common/enums";
|
import { ClientType } from "@bitwarden/common/enums";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import {
|
import {
|
||||||
EnvironmentService,
|
EnvironmentService,
|
||||||
@ -72,7 +71,7 @@ import {
|
|||||||
ThemeStateService,
|
ThemeStateService,
|
||||||
} from "@bitwarden/common/platform/theming/theme-state.service";
|
} from "@bitwarden/common/platform/theming/theme-state.service";
|
||||||
import { VaultTimeout, VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
|
import { VaultTimeout, VaultTimeoutStringType } from "@bitwarden/common/types/vault-timeout.type";
|
||||||
import { BiometricsService } from "@bitwarden/key-management";
|
import { KeyService as KeyServiceAbstraction, BiometricsService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { flagEnabled } from "../../utils/flags";
|
import { flagEnabled } from "../../utils/flags";
|
||||||
import { PolicyListService } from "../admin-console/core/policy-list.service";
|
import { PolicyListService } from "../admin-console/core/policy-list.service";
|
||||||
@ -211,7 +210,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
provide: RegistrationFinishServiceAbstraction,
|
provide: RegistrationFinishServiceAbstraction,
|
||||||
useClass: WebRegistrationFinishService,
|
useClass: WebRegistrationFinishService,
|
||||||
deps: [
|
deps: [
|
||||||
CryptoServiceAbstraction,
|
KeyServiceAbstraction,
|
||||||
AccountApiServiceAbstraction,
|
AccountApiServiceAbstraction,
|
||||||
AcceptOrganizationInviteService,
|
AcceptOrganizationInviteService,
|
||||||
PolicyApiServiceAbstraction,
|
PolicyApiServiceAbstraction,
|
||||||
@ -229,7 +228,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
useClass: WebSetPasswordJitService,
|
useClass: WebSetPasswordJitService,
|
||||||
deps: [
|
deps: [
|
||||||
ApiService,
|
ApiService,
|
||||||
CryptoServiceAbstraction,
|
KeyServiceAbstraction,
|
||||||
EncryptService,
|
EncryptService,
|
||||||
I18nServiceAbstraction,
|
I18nServiceAbstraction,
|
||||||
KdfConfigService,
|
KdfConfigService,
|
||||||
@ -247,7 +246,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
safeProvider({
|
safeProvider({
|
||||||
provide: CollectionAdminService,
|
provide: CollectionAdminService,
|
||||||
useClass: DefaultCollectionAdminService,
|
useClass: DefaultCollectionAdminService,
|
||||||
deps: [ApiService, CryptoServiceAbstraction, EncryptService, CollectionService],
|
deps: [ApiService, KeyServiceAbstraction, EncryptService, CollectionService],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: SdkClientFactory,
|
provide: SdkClientFactory,
|
||||||
|
@ -8,7 +8,6 @@ import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/
|
|||||||
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
|
import { NotificationsService as NotificationsServiceAbstraction } from "@bitwarden/common/abstractions/notifications.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
||||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
@ -16,6 +15,7 @@ import { ContainerService } from "@bitwarden/common/platform/services/container.
|
|||||||
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
|
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
|
||||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||||
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
||||||
|
import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InitService {
|
export class InitService {
|
||||||
@ -27,7 +27,7 @@ export class InitService {
|
|||||||
private eventUploadService: EventUploadServiceAbstraction,
|
private eventUploadService: EventUploadServiceAbstraction,
|
||||||
private twoFactorService: TwoFactorServiceAbstraction,
|
private twoFactorService: TwoFactorServiceAbstraction,
|
||||||
private stateService: StateServiceAbstraction,
|
private stateService: StateServiceAbstraction,
|
||||||
private cryptoService: CryptoServiceAbstraction,
|
private keyService: KeyServiceAbstraction,
|
||||||
private themingService: AbstractThemingService,
|
private themingService: AbstractThemingService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
||||||
@ -54,7 +54,7 @@ export class InitService {
|
|||||||
const htmlEl = this.win.document.documentElement;
|
const htmlEl = this.win.document.documentElement;
|
||||||
htmlEl.classList.add("locale_" + this.i18nService.translationLocale);
|
htmlEl.classList.add("locale_" + this.i18nService.translationLocale);
|
||||||
this.themingService.applyThemeChangesTo(this.document);
|
this.themingService.applyThemeChangesTo(this.document);
|
||||||
const containerService = new ContainerService(this.cryptoService, this.encryptService);
|
const containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
containerService.attachToGlobal(this.win);
|
containerService.attachToGlobal(this.win);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, Input, OnInit } from "@angular/core";
|
import { Component, Input, OnInit } from "@angular/core";
|
||||||
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { SharedModule } from "../../shared.module";
|
import { SharedModule } from "../../shared.module";
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ export class AccountFingerprintComponent implements OnInit {
|
|||||||
|
|
||||||
protected fingerprint: string;
|
protected fingerprint: string;
|
||||||
|
|
||||||
constructor(private cryptoService: CryptoService) {}
|
constructor(private keyService: KeyService) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
// TODO - In the future, remove this code and use the fingerprint pipe once merged
|
// TODO - In the future, remove this code and use the fingerprint pipe once merged
|
||||||
const generatedFingerprint = await this.cryptoService.getFingerprint(
|
const generatedFingerprint = await this.keyService.getFingerprint(
|
||||||
this.fingerprintMaterial,
|
this.fingerprintMaterial,
|
||||||
this.publicKeyBuffer,
|
this.publicKeyBuffer,
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,6 @@ import { RegisterRouteService } from "@bitwarden/auth/common";
|
|||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
@ -19,6 +18,7 @@ import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-ac
|
|||||||
import { SEND_KDF_ITERATIONS } from "@bitwarden/common/tools/send/send-kdf";
|
import { SEND_KDF_ITERATIONS } from "@bitwarden/common/tools/send/send-kdf";
|
||||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||||
import { NoItemsModule, ToastService } from "@bitwarden/components";
|
import { NoItemsModule, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { ExpiredSendIcon } from "@bitwarden/send-ui";
|
import { ExpiredSendIcon } from "@bitwarden/send-ui";
|
||||||
|
|
||||||
import { SharedModule } from "../../shared";
|
import { SharedModule } from "../../shared";
|
||||||
@ -65,7 +65,7 @@ export class AccessComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private sendApiService: SendApiService,
|
private sendApiService: SendApiService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
@ -126,7 +126,7 @@ export class AccessComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.passwordRequired = false;
|
this.passwordRequired = false;
|
||||||
const sendAccess = new SendAccess(sendResponse);
|
const sendAccess = new SendAccess(sendResponse);
|
||||||
this.decKey = await this.cryptoService.makeSendKey(keyArray);
|
this.decKey = await this.keyService.makeSendKey(keyArray);
|
||||||
this.send = await sendAccess.decrypt(this.decKey);
|
this.send = await sendAccess.decrypt(this.decKey);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ErrorResponse) {
|
if (e instanceof ErrorResponse) {
|
||||||
|
@ -10,13 +10,13 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { CipherFormConfig, DefaultCipherFormConfigService } from "@bitwarden/vault";
|
import { CipherFormConfig, DefaultCipherFormConfigService } from "@bitwarden/vault";
|
||||||
|
|
||||||
import { AddEditComponentV2 } from "./add-edit-v2.component";
|
import { AddEditComponentV2 } from "./add-edit-v2.component";
|
||||||
@ -89,7 +89,7 @@ describe("AddEditComponentV2", () => {
|
|||||||
{ provide: ActivatedRoute, useValue: activatedRoute },
|
{ provide: ActivatedRoute, useValue: activatedRoute },
|
||||||
{ provide: CollectionService, useValue: collectionService },
|
{ provide: CollectionService, useValue: collectionService },
|
||||||
{ provide: FolderService, useValue: folderService },
|
{ provide: FolderService, useValue: folderService },
|
||||||
{ provide: CryptoService, useValue: mock<CryptoService>() },
|
{ provide: KeyService, useValue: mock<KeyService>() },
|
||||||
{ provide: BillingAccountProfileStateService, useValue: billingAccountProfileStateService },
|
{ provide: BillingAccountProfileStateService, useValue: billingAccountProfileStateService },
|
||||||
{ provide: PolicyService, useValue: policyService },
|
{ provide: PolicyService, useValue: policyService },
|
||||||
{ provide: DefaultCipherFormConfigService, useValue: mockDefaultCipherFormConfigService },
|
{ provide: DefaultCipherFormConfigService, useValue: mockDefaultCipherFormConfigService },
|
||||||
|
@ -4,7 +4,6 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from "@bitwarden/ang
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -14,6 +13,7 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
|
|||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-vault-attachments",
|
selector: "app-vault-attachments",
|
||||||
@ -25,7 +25,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
cipherService: CipherService,
|
cipherService: CipherService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -40,7 +40,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
|
|||||||
super(
|
super(
|
||||||
cipherService,
|
cipherService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
apiService,
|
apiService,
|
||||||
|
@ -5,13 +5,13 @@ import { firstValueFrom } from "rxjs";
|
|||||||
|
|
||||||
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
import { FolderAddEditComponent as BaseFolderAddEditComponent } from "@bitwarden/angular/vault/components/folder-add-edit.component";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
|
||||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-folder-add-edit",
|
selector: "app-folder-add-edit",
|
||||||
@ -23,7 +23,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
folderService: FolderService,
|
folderService: FolderService,
|
||||||
folderApiService: FolderApiServiceAbstraction,
|
folderApiService: FolderApiServiceAbstraction,
|
||||||
protected accountSerivce: AccountService,
|
protected accountSerivce: AccountService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
@ -37,7 +37,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
folderService,
|
folderService,
|
||||||
folderApiService,
|
folderApiService,
|
||||||
accountSerivce,
|
accountSerivce,
|
||||||
cryptoService,
|
keyService,
|
||||||
i18nService,
|
i18nService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
logService,
|
logService,
|
||||||
@ -81,7 +81,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const activeAccountId = (await firstValueFrom(this.accountSerivce.activeAccount$)).id;
|
const activeAccountId = (await firstValueFrom(this.accountSerivce.activeAccount$)).id;
|
||||||
const userKey = await this.cryptoService.getUserKeyWithLegacySupport(activeAccountId);
|
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeAccountId);
|
||||||
const folder = await this.folderService.encrypt(this.folder, userKey);
|
const folder = await this.folderService.encrypt(this.folder, userKey);
|
||||||
this.formPromise = this.folderApiService.save(folder);
|
this.formPromise = this.folderApiService.save(folder);
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
|
@ -7,7 +7,6 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
|
|||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
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 { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
@ -16,6 +15,7 @@ import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folde
|
|||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { ViewCipherDialogParams, ViewCipherDialogResult, ViewComponent } from "./view.component";
|
import { ViewCipherDialogParams, ViewCipherDialogResult, ViewComponent } from "./view.component";
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ describe("ViewComponent", () => {
|
|||||||
},
|
},
|
||||||
{ provide: CollectionService, useValue: mock<CollectionService>() },
|
{ provide: CollectionService, useValue: mock<CollectionService>() },
|
||||||
{ provide: FolderService, useValue: mock<FolderService>() },
|
{ provide: FolderService, useValue: mock<FolderService>() },
|
||||||
{ provide: CryptoService, useValue: mock<CryptoService>() },
|
{ provide: KeyService, useValue: mock<KeyService>() },
|
||||||
{
|
{
|
||||||
provide: BillingAccountProfileStateService,
|
provide: BillingAccountProfileStateService,
|
||||||
useValue: mock<BillingAccountProfileStateService>(),
|
useValue: mock<BillingAccountProfileStateService>(),
|
||||||
|
@ -4,7 +4,6 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
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 { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -17,6 +16,7 @@ import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
|
|||||||
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
||||||
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.view";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { AttachmentsComponent as BaseAttachmentsComponent } from "../individual-vault/attachments.component";
|
import { AttachmentsComponent as BaseAttachmentsComponent } from "../individual-vault/attachments.component";
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
|
|||||||
constructor(
|
constructor(
|
||||||
cipherService: CipherService,
|
cipherService: CipherService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
encryptService: EncryptService,
|
encryptService: EncryptService,
|
||||||
stateService: StateService,
|
stateService: StateService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
@ -46,7 +46,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
|
|||||||
super(
|
super(
|
||||||
cipherService,
|
cipherService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
stateService,
|
stateService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
|
@ -17,7 +17,7 @@ export class ServiceContainer extends OssServiceContainer {
|
|||||||
this.organizationAuthRequestApiService = new OrganizationAuthRequestApiService(this.apiService);
|
this.organizationAuthRequestApiService = new OrganizationAuthRequestApiService(this.apiService);
|
||||||
this.organizationAuthRequestService = new OrganizationAuthRequestService(
|
this.organizationAuthRequestService = new OrganizationAuthRequestService(
|
||||||
this.organizationAuthRequestApiService,
|
this.organizationAuthRequestApiService,
|
||||||
this.cryptoService,
|
this.keyService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.organizationUserApiService,
|
this.organizationUserApiService,
|
||||||
);
|
);
|
||||||
|
@ -5,9 +5,9 @@ import {
|
|||||||
OrganizationUserResetPasswordDetailsResponse,
|
OrganizationUserResetPasswordDetailsResponse,
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationAuthRequestApiService } from "./organization-auth-request-api.service";
|
import { OrganizationAuthRequestApiService } from "./organization-auth-request-api.service";
|
||||||
import { OrganizationAuthRequestUpdateRequest } from "./organization-auth-request-update.request";
|
import { OrganizationAuthRequestUpdateRequest } from "./organization-auth-request-update.request";
|
||||||
@ -16,19 +16,19 @@ import { PendingAuthRequestView } from "./pending-auth-request.view";
|
|||||||
|
|
||||||
describe("OrganizationAuthRequestService", () => {
|
describe("OrganizationAuthRequestService", () => {
|
||||||
let organizationAuthRequestApiService: MockProxy<OrganizationAuthRequestApiService>;
|
let organizationAuthRequestApiService: MockProxy<OrganizationAuthRequestApiService>;
|
||||||
let cryptoService: MockProxy<CryptoService>;
|
let keyService: MockProxy<KeyService>;
|
||||||
let encryptService: MockProxy<EncryptService>;
|
let encryptService: MockProxy<EncryptService>;
|
||||||
let organizationUserApiService: MockProxy<OrganizationUserApiService>;
|
let organizationUserApiService: MockProxy<OrganizationUserApiService>;
|
||||||
let organizationAuthRequestService: OrganizationAuthRequestService;
|
let organizationAuthRequestService: OrganizationAuthRequestService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
organizationAuthRequestApiService = mock<OrganizationAuthRequestApiService>();
|
organizationAuthRequestApiService = mock<OrganizationAuthRequestApiService>();
|
||||||
cryptoService = mock<CryptoService>();
|
keyService = mock<KeyService>();
|
||||||
encryptService = mock<EncryptService>();
|
encryptService = mock<EncryptService>();
|
||||||
organizationUserApiService = mock<OrganizationUserApiService>();
|
organizationUserApiService = mock<OrganizationUserApiService>();
|
||||||
organizationAuthRequestService = new OrganizationAuthRequestService(
|
organizationAuthRequestService = new OrganizationAuthRequestService(
|
||||||
organizationAuthRequestApiService,
|
organizationAuthRequestApiService,
|
||||||
cryptoService,
|
keyService,
|
||||||
encryptService,
|
encryptService,
|
||||||
organizationUserApiService,
|
organizationUserApiService,
|
||||||
);
|
);
|
||||||
|
@ -2,11 +2,11 @@ import {
|
|||||||
OrganizationUserApiService,
|
OrganizationUserApiService,
|
||||||
OrganizationUserResetPasswordDetailsResponse,
|
OrganizationUserResetPasswordDetailsResponse,
|
||||||
} from "@bitwarden/admin-console/common";
|
} from "@bitwarden/admin-console/common";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { OrganizationAuthRequestApiService } from "./organization-auth-request-api.service";
|
import { OrganizationAuthRequestApiService } from "./organization-auth-request-api.service";
|
||||||
import { OrganizationAuthRequestUpdateRequest } from "./organization-auth-request-update.request";
|
import { OrganizationAuthRequestUpdateRequest } from "./organization-auth-request-update.request";
|
||||||
@ -15,7 +15,7 @@ import { PendingAuthRequestView } from "./pending-auth-request.view";
|
|||||||
export class OrganizationAuthRequestService {
|
export class OrganizationAuthRequestService {
|
||||||
constructor(
|
constructor(
|
||||||
private organizationAuthRequestApiService: OrganizationAuthRequestApiService,
|
private organizationAuthRequestApiService: OrganizationAuthRequestApiService,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
) {}
|
) {}
|
||||||
@ -110,7 +110,7 @@ export class OrganizationAuthRequestService {
|
|||||||
const devicePubKey = Utils.fromB64ToArray(devicePublicKey);
|
const devicePubKey = Utils.fromB64ToArray(devicePublicKey);
|
||||||
|
|
||||||
// Decrypt Organization's encrypted Private Key with org key
|
// Decrypt Organization's encrypted Private Key with org key
|
||||||
const orgSymKey = await this.cryptoService.getOrgKey(organizationId);
|
const orgSymKey = await this.keyService.getOrgKey(organizationId);
|
||||||
const decOrgPrivateKey = await this.encryptService.decryptToBytes(
|
const decOrgPrivateKey = await this.encryptService.decryptToBytes(
|
||||||
new EncString(encryptedOrgPrivateKey),
|
new EncString(encryptedOrgPrivateKey),
|
||||||
orgSymKey,
|
orgSymKey,
|
||||||
|
@ -9,13 +9,13 @@ import { OrganizationAuthRequestService } from "@bitwarden/bit-common/admin-cons
|
|||||||
import { PendingAuthRequestView } from "@bitwarden/bit-common/admin-console/auth-requests/pending-auth-request.view";
|
import { PendingAuthRequestView } from "@bitwarden/bit-common/admin-console/auth-requests/pending-auth-request.view";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { TableDataSource, NoItemsModule, ToastService } from "@bitwarden/components";
|
import { TableDataSource, NoItemsModule, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { Devices } from "@bitwarden/web-vault/app/admin-console/icons";
|
import { Devices } from "@bitwarden/web-vault/app/admin-console/icons";
|
||||||
import { LooseComponentsModule } from "@bitwarden/web-vault/app/shared";
|
import { LooseComponentsModule } from "@bitwarden/web-vault/app/shared";
|
||||||
import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module";
|
import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module";
|
||||||
@ -33,7 +33,7 @@ import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module";
|
|||||||
provide: OrganizationAuthRequestService,
|
provide: OrganizationAuthRequestService,
|
||||||
deps: [
|
deps: [
|
||||||
OrganizationAuthRequestApiService,
|
OrganizationAuthRequestApiService,
|
||||||
CryptoService,
|
KeyService,
|
||||||
EncryptService,
|
EncryptService,
|
||||||
OrganizationUserApiService,
|
OrganizationUserApiService,
|
||||||
],
|
],
|
||||||
|
@ -12,11 +12,11 @@ import { ProviderUserBulkRequest } from "@bitwarden/common/admin-console/models/
|
|||||||
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
|
||||||
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { BaseBulkConfirmComponent } from "@bitwarden/web-vault/app/admin-console/organizations/members/components/bulk/base-bulk-confirm.component";
|
import { BaseBulkConfirmComponent } from "@bitwarden/web-vault/app/admin-console/organizations/members/components/bulk/base-bulk-confirm.component";
|
||||||
import { BulkUserDetails } from "@bitwarden/web-vault/app/admin-console/organizations/members/components/bulk/bulk-status.component";
|
import { BulkUserDetails } from "@bitwarden/web-vault/app/admin-console/organizations/members/components/bulk/bulk-status.component";
|
||||||
|
|
||||||
@ -34,19 +34,19 @@ export class BulkConfirmDialogComponent extends BaseBulkConfirmComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
protected cryptoService: CryptoService,
|
protected keyService: KeyService,
|
||||||
protected encryptService: EncryptService,
|
protected encryptService: EncryptService,
|
||||||
@Inject(DIALOG_DATA) protected dialogParams: BulkConfirmDialogParams,
|
@Inject(DIALOG_DATA) protected dialogParams: BulkConfirmDialogParams,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
) {
|
) {
|
||||||
super(cryptoService, encryptService, i18nService);
|
super(keyService, encryptService, i18nService);
|
||||||
|
|
||||||
this.providerId = dialogParams.providerId;
|
this.providerId = dialogParams.providerId;
|
||||||
this.users = dialogParams.users;
|
this.users = dialogParams.users;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getCryptoKey = (): Promise<SymmetricCryptoKey> =>
|
protected getCryptoKey = (): Promise<SymmetricCryptoKey> =>
|
||||||
this.cryptoService.getProviderKey(this.providerId);
|
this.keyService.getProviderKey(this.providerId);
|
||||||
|
|
||||||
protected getPublicKeys = async (): Promise<
|
protected getPublicKeys = async (): Promise<
|
||||||
ListResponse<OrganizationUserBulkPublicKeyResponse | ProviderUserBulkPublicKeyResponse>
|
ListResponse<OrganizationUserBulkPublicKeyResponse | ProviderUserBulkPublicKeyResponse>
|
||||||
|
@ -14,12 +14,12 @@ import { ProviderUserBulkRequest } from "@bitwarden/common/admin-console/models/
|
|||||||
import { ProviderUserConfirmRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-user-confirm.request";
|
import { ProviderUserConfirmRequest } from "@bitwarden/common/admin-console/models/request/provider/provider-user-confirm.request";
|
||||||
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
import { ProviderUserUserDetailsResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user.response";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.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 { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { DialogService, ToastService } from "@bitwarden/components";
|
import { DialogService, ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
import { BaseMembersComponent } from "@bitwarden/web-vault/app/admin-console/common/base-members.component";
|
import { BaseMembersComponent } from "@bitwarden/web-vault/app/admin-console/common/base-members.component";
|
||||||
import {
|
import {
|
||||||
peopleFilter,
|
peopleFilter,
|
||||||
@ -59,7 +59,7 @@ export class MembersComponent extends BaseMembersComponent<ProviderUser> {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
cryptoService: CryptoService,
|
keyService: KeyService,
|
||||||
dialogService: DialogService,
|
dialogService: DialogService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
@ -75,7 +75,7 @@ export class MembersComponent extends BaseMembersComponent<ProviderUser> {
|
|||||||
super(
|
super(
|
||||||
apiService,
|
apiService,
|
||||||
i18nService,
|
i18nService,
|
||||||
cryptoService,
|
keyService,
|
||||||
validationService,
|
validationService,
|
||||||
logService,
|
logService,
|
||||||
userNamePipe,
|
userNamePipe,
|
||||||
@ -185,7 +185,7 @@ export class MembersComponent extends BaseMembersComponent<ProviderUser> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async confirmUser(user: ProviderUser, publicKey: Uint8Array): Promise<void> {
|
async confirmUser(user: ProviderUser, publicKey: Uint8Array): Promise<void> {
|
||||||
const providerKey = await this.cryptoService.getProviderKey(this.providerId);
|
const providerKey = await this.keyService.getProviderKey(this.providerId);
|
||||||
const key = await this.encryptService.rsaEncrypt(providerKey.key, publicKey);
|
const key = await this.encryptService.rsaEncrypt(providerKey.key, publicKey);
|
||||||
const request = new ProviderUserConfirmRequest();
|
const request = new ProviderUserConfirmRequest();
|
||||||
request.key = key.encryptedString;
|
request.key = key.encryptedString;
|
||||||
|
@ -6,16 +6,16 @@ import { ProviderAddOrganizationRequest } from "@bitwarden/common/admin-console/
|
|||||||
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/billing-api.service.abstraction";
|
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/billing-api.service.abstraction";
|
||||||
import { PlanType } from "@bitwarden/common/billing/enums";
|
import { PlanType } from "@bitwarden/common/billing/enums";
|
||||||
import { CreateClientOrganizationRequest } from "@bitwarden/common/billing/models/request/create-client-organization.request";
|
import { CreateClientOrganizationRequest } from "@bitwarden/common/billing/models/request/create-client-organization.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { OrgKey } from "@bitwarden/common/types/key";
|
import { OrgKey } from "@bitwarden/common/types/key";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WebProviderService {
|
export class WebProviderService {
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
@ -24,8 +24,8 @@ export class WebProviderService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async addOrganizationToProvider(providerId: string, organizationId: string) {
|
async addOrganizationToProvider(providerId: string, organizationId: string) {
|
||||||
const orgKey = await this.cryptoService.getOrgKey(organizationId);
|
const orgKey = await this.keyService.getOrgKey(organizationId);
|
||||||
const providerKey = await this.cryptoService.getProviderKey(providerId);
|
const providerKey = await this.keyService.getProviderKey(providerId);
|
||||||
|
|
||||||
const encryptedOrgKey = await this.encryptService.encrypt(orgKey.key, providerKey);
|
const encryptedOrgKey = await this.encryptService.encrypt(orgKey.key, providerKey);
|
||||||
|
|
||||||
@ -45,16 +45,16 @@ export class WebProviderService {
|
|||||||
planType: PlanType,
|
planType: PlanType,
|
||||||
seats: number,
|
seats: number,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const organizationKey = (await this.cryptoService.makeOrgKey<OrgKey>())[1];
|
const organizationKey = (await this.keyService.makeOrgKey<OrgKey>())[1];
|
||||||
|
|
||||||
const [publicKey, encryptedPrivateKey] = await this.cryptoService.makeKeyPair(organizationKey);
|
const [publicKey, encryptedPrivateKey] = await this.keyService.makeKeyPair(organizationKey);
|
||||||
|
|
||||||
const encryptedCollectionName = await this.encryptService.encrypt(
|
const encryptedCollectionName = await this.encryptService.encrypt(
|
||||||
this.i18nService.t("defaultCollection"),
|
this.i18nService.t("defaultCollection"),
|
||||||
organizationKey,
|
organizationKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
const providerKey = await this.cryptoService.getProviderKey(providerId);
|
const providerKey = await this.keyService.getProviderKey(providerId);
|
||||||
|
|
||||||
const encryptedProviderKey = await this.encryptService.encrypt(
|
const encryptedProviderKey = await this.encryptService.encrypt(
|
||||||
organizationKey.key,
|
organizationKey.key,
|
||||||
|
@ -10,12 +10,12 @@ import { ProviderSetupRequest } from "@bitwarden/common/admin-console/models/req
|
|||||||
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
|
import { ExpandedTaxInfoUpdateRequest } from "@bitwarden/common/billing/models/request/expanded-tax-info-update.request";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { ProviderKey } from "@bitwarden/common/types/key";
|
import { ProviderKey } from "@bitwarden/common/types/key";
|
||||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "provider-setup",
|
selector: "provider-setup",
|
||||||
@ -44,7 +44,7 @@ export class SetupComponent implements OnInit, OnDestroy {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private validationService: ValidationService,
|
private validationService: ValidationService,
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
@ -124,7 +124,7 @@ export class SetupComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const providerKey = await this.cryptoService.makeOrgKey<ProviderKey>();
|
const providerKey = await this.keyService.makeOrgKey<ProviderKey>();
|
||||||
const key = providerKey[0].encryptedString;
|
const key = providerKey[0].encryptedString;
|
||||||
|
|
||||||
const request = new ProviderSetupRequest();
|
const request = new ProviderSetupRequest();
|
||||||
|
@ -3,10 +3,10 @@ import { Subject } from "rxjs";
|
|||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { ProjectListView } from "../models/view/project-list.view";
|
import { ProjectListView } from "../models/view/project-list.view";
|
||||||
import { ProjectView } from "../models/view/project.view";
|
import { ProjectView } from "../models/view/project.view";
|
||||||
@ -24,7 +24,7 @@ export class ProjectService {
|
|||||||
project$ = this._project.asObservable();
|
project$ = this._project.asObservable();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private keyService: KeyService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
) {}
|
) {}
|
||||||
@ -82,7 +82,7 @@ export class ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getOrganizationKey(organizationId: string): Promise<SymmetricCryptoKey> {
|
private async getOrganizationKey(organizationId: string): Promise<SymmetricCryptoKey> {
|
||||||
return await this.cryptoService.getOrgKey(organizationId);
|
return await this.keyService.getOrgKey(organizationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getProjectRequest(
|
private async getProjectRequest(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { mock } from "jest-mock-extended";
|
import { mock } from "jest-mock-extended";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||||
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { SecretAccessPoliciesView } from "../models/view/access-policies/secret-access-policies.view";
|
import { SecretAccessPoliciesView } from "../models/view/access-policies/secret-access-policies.view";
|
||||||
import { SecretView } from "../models/view/secret.view";
|
import { SecretView } from "../models/view/secret.view";
|
||||||
@ -14,7 +14,7 @@ import { SecretService } from "./secret.service";
|
|||||||
describe("SecretService", () => {
|
describe("SecretService", () => {
|
||||||
let sut: SecretService;
|
let sut: SecretService;
|
||||||
|
|
||||||
const cryptoService = mock<CryptoService>();
|
const keyService = mock<KeyService>();
|
||||||
const apiService = mock<ApiService>();
|
const apiService = mock<ApiService>();
|
||||||
const encryptService = mock<EncryptService>();
|
const encryptService = mock<EncryptService>();
|
||||||
const accessPolicyService = mock<AccessPolicyService>();
|
const accessPolicyService = mock<AccessPolicyService>();
|
||||||
@ -22,7 +22,7 @@ describe("SecretService", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
|
|
||||||
sut = new SecretService(cryptoService, apiService, encryptService, accessPolicyService);
|
sut = new SecretService(keyService, apiService, encryptService, accessPolicyService);
|
||||||
|
|
||||||
encryptService.encrypt.mockResolvedValue({
|
encryptService.encrypt.mockResolvedValue({
|
||||||
encryptedString: "mockEncryptedString",
|
encryptedString: "mockEncryptedString",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user