diff --git a/jslib b/jslib index a7bbdf9c93..9f26f9f377 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit a7bbdf9c9391c8d58fee0231e1d4cfe34af55cdb +Subproject commit 9f26f9f37771f8f450b380b4c05ffd5d9164f099 diff --git a/src/app/accounts/recover-two-factor.component.ts b/src/app/accounts/recover-two-factor.component.ts index 72da951d83..6c86cda69e 100644 --- a/src/app/accounts/recover-two-factor.component.ts +++ b/src/app/accounts/recover-two-factor.component.ts @@ -5,6 +5,7 @@ import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; +import { AuthService } from 'jslib/abstractions/auth.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -22,15 +23,15 @@ export class RecoverTwoFactorComponent { constructor(private router: Router, private apiService: ApiService, private analytics: Angulartics2, private toasterService: ToasterService, - private i18nService: I18nService, private cryptoService: CryptoService) { - } + private i18nService: I18nService, private cryptoService: CryptoService, + private authService: AuthService) { } async submit() { try { const request = new TwoFactorRecoveryRequest(); request.recoveryCode = this.recoveryCode.replace(/\s/g, '').toLowerCase(); request.email = this.email.toLowerCase(); - const key = await this.cryptoService.makeKey(this.masterPassword, request.email); + const key = await this.authService.makePreloginKey(this.masterPassword, request.email); request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key); this.formPromise = this.apiService.postTwoFactorRecover(request); await this.formPromise; diff --git a/src/app/organizations/tools/export.component.ts b/src/app/organizations/tools/export.component.ts index 454c067e29..b071baa7f2 100644 --- a/src/app/organizations/tools/export.component.ts +++ b/src/app/organizations/tools/export.component.ts @@ -8,7 +8,6 @@ import { CryptoService } from 'jslib/abstractions/crypto.service'; import { ExportService } from 'jslib/abstractions/export.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; -import { UserService } from 'jslib/abstractions/user.service'; import { ExportComponent as BaseExportComponent } from '../../tools/export.component'; @@ -20,11 +19,10 @@ export class ExportComponent extends BaseExportComponent { organizationId: string; constructor(analytics: Angulartics2, toasterService: ToasterService, - cryptoService: CryptoService, userService: UserService, - i18nService: I18nService, platformUtilsService: PlatformUtilsService, - exportService: ExportService, private route: ActivatedRoute) { - super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService, - exportService); + cryptoService: CryptoService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, exportService: ExportService, + private route: ActivatedRoute) { + super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, exportService); } ngOnInit() { diff --git a/src/app/settings/change-email.component.ts b/src/app/settings/change-email.component.ts index f2db2cbe93..889c05a395 100644 --- a/src/app/settings/change-email.component.ts +++ b/src/app/settings/change-email.component.ts @@ -9,6 +9,7 @@ import { ApiService } from 'jslib/abstractions/api.service'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { EmailRequest } from 'jslib/models/request/emailRequest'; import { EmailTokenRequest } from 'jslib/models/request/emailTokenRequest'; @@ -27,7 +28,8 @@ export class ChangeEmailComponent { constructor(private apiService: ApiService, private i18nService: I18nService, private analytics: Angulartics2, private toasterService: ToasterService, - private cryptoService: CryptoService, private messagingService: MessagingService) { } + private cryptoService: CryptoService, private messagingService: MessagingService, + private userService: UserService) { } async submit() { const hasEncKey = await this.cryptoService.hasEncKey(); @@ -51,7 +53,9 @@ export class ChangeEmailComponent { request.token = this.token; request.newEmail = this.newEmail; request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null); - const newKey = await this.cryptoService.makeKey(this.masterPassword, this.newEmail); + const kdf = await this.userService.getKdf(); + const kdfIterations = await this.userService.getKdfIterations(); + const newKey = await this.cryptoService.makeKey(this.masterPassword, this.newEmail, kdf, kdfIterations); request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, newKey); const encKey = await this.cryptoService.getEncKey(); const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey); diff --git a/src/app/settings/change-password.component.ts b/src/app/settings/change-password.component.ts index 75ffcfda28..d6209978fd 100644 --- a/src/app/settings/change-password.component.ts +++ b/src/app/settings/change-password.component.ts @@ -54,7 +54,9 @@ export class ChangePasswordComponent { const request = new PasswordRequest(); request.masterPasswordHash = await this.cryptoService.hashPassword(this.currentMasterPassword, null); const email = await this.userService.getEmail(); - const newKey = await this.cryptoService.makeKey(this.newMasterPassword, email); + const kdf = await this.userService.getKdf(); + const kdfIterations = await this.userService.getKdfIterations(); + const newKey = await this.cryptoService.makeKey(this.newMasterPassword, email, kdf, kdfIterations); request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.newMasterPassword, newKey); const encKey = await this.cryptoService.getEncKey(); const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey); diff --git a/src/app/tools/export.component.ts b/src/app/tools/export.component.ts index 5575088a17..c378465f64 100644 --- a/src/app/tools/export.component.ts +++ b/src/app/tools/export.component.ts @@ -7,7 +7,6 @@ import { CryptoService } from 'jslib/abstractions/crypto.service'; import { ExportService } from 'jslib/abstractions/export.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; -import { UserService } from 'jslib/abstractions/user.service'; import { ExportComponent as BaseExportComponent } from 'jslib/angular/components/export.component'; @@ -17,10 +16,9 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components }) export class ExportComponent extends BaseExportComponent { constructor(analytics: Angulartics2, toasterService: ToasterService, - cryptoService: CryptoService, userService: UserService, - i18nService: I18nService, platformUtilsService: PlatformUtilsService, - exportService: ExportService) { - super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService, + cryptoService: CryptoService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, exportService: ExportService) { + super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, exportService, window); }