mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[PM-19469] Add logs for unlock time (#13972)
* Add logs for unlock time * Undo local flag override * Update message * Update messages * Fix build on chrome
This commit is contained in:
@@ -858,6 +858,7 @@ export default class MainBackground {
|
|||||||
this.configService,
|
this.configService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
|
this.logService,
|
||||||
);
|
);
|
||||||
this.folderService = new FolderService(
|
this.folderService = new FolderService(
|
||||||
this.keyService,
|
this.keyService,
|
||||||
|
|||||||
@@ -693,6 +693,7 @@ export class ServiceContainer {
|
|||||||
this.configService,
|
this.configService,
|
||||||
this.stateProvider,
|
this.stateProvider,
|
||||||
this.accountService,
|
this.accountService,
|
||||||
|
this.logService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.folderService = new FolderService(
|
this.folderService = new FolderService(
|
||||||
|
|||||||
@@ -505,6 +505,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
configService: ConfigService,
|
configService: ConfigService,
|
||||||
stateProvider: StateProvider,
|
stateProvider: StateProvider,
|
||||||
accountService: AccountServiceAbstraction,
|
accountService: AccountServiceAbstraction,
|
||||||
|
logService: LogService,
|
||||||
) =>
|
) =>
|
||||||
new CipherService(
|
new CipherService(
|
||||||
keyService,
|
keyService,
|
||||||
@@ -520,6 +521,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
configService,
|
configService,
|
||||||
stateProvider,
|
stateProvider,
|
||||||
accountService,
|
accountService,
|
||||||
|
logService,
|
||||||
),
|
),
|
||||||
deps: [
|
deps: [
|
||||||
KeyService,
|
KeyService,
|
||||||
@@ -535,6 +537,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
ConfigService,
|
ConfigService,
|
||||||
StateProvider,
|
StateProvider,
|
||||||
AccountServiceAbstraction,
|
AccountServiceAbstraction,
|
||||||
|
LogService,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
|
|||||||
@@ -224,7 +224,10 @@ export class PinService implements PinServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async makePinKey(pin: string, salt: string, kdfConfig: KdfConfig): Promise<PinKey> {
|
async makePinKey(pin: string, salt: string, kdfConfig: KdfConfig): Promise<PinKey> {
|
||||||
|
const start = Date.now();
|
||||||
const pinKey = await this.keyGenerationService.deriveKeyFromPassword(pin, salt, kdfConfig);
|
const pinKey = await this.keyGenerationService.deriveKeyFromPassword(pin, salt, kdfConfig);
|
||||||
|
this.logService.info(`[Pin Service] deriving pin key took ${Date.now() - start}ms`);
|
||||||
|
|
||||||
return (await this.keyGenerationService.stretchKey(pinKey)) as PinKey;
|
return (await this.keyGenerationService.stretchKey(pinKey)) as PinKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const indexingStartTime = new Date().getTime();
|
||||||
await this.setIsIndexing(userId, true);
|
await this.setIsIndexing(userId, true);
|
||||||
await this.setIndexedEntityIdForSearch(userId, indexedEntityId as IndexedEntityId);
|
await this.setIndexedEntityIdForSearch(userId, indexedEntityId as IndexedEntityId);
|
||||||
const builder = new lunr.Builder();
|
const builder = new lunr.Builder();
|
||||||
@@ -187,8 +188,11 @@ export class SearchService implements SearchServiceAbstraction {
|
|||||||
await this.setIndexForSearch(userId, index.toJSON() as SerializedLunrIndex);
|
await this.setIndexForSearch(userId, index.toJSON() as SerializedLunrIndex);
|
||||||
|
|
||||||
await this.setIsIndexing(userId, false);
|
await this.setIsIndexing(userId, false);
|
||||||
|
this.logService.info(
|
||||||
this.logService.info("Finished search indexing");
|
`[SearchService] Building search index of ${ciphers.length} ciphers took ${
|
||||||
|
new Date().getTime() - indexingStartTime
|
||||||
|
}ms`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchCiphers(
|
async searchCiphers(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { mock } from "jest-mock-extended";
|
import { mock } from "jest-mock-extended";
|
||||||
import { BehaviorSubject, map, of } from "rxjs";
|
import { BehaviorSubject, map, of } from "rxjs";
|
||||||
|
|
||||||
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { CipherDecryptionKeys, KeyService } from "@bitwarden/key-management";
|
import { CipherDecryptionKeys, KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { FakeAccountService, mockAccountServiceWith } from "../../../spec/fake-account-service";
|
import { FakeAccountService, mockAccountServiceWith } from "../../../spec/fake-account-service";
|
||||||
@@ -121,6 +122,7 @@ describe("Cipher Service", () => {
|
|||||||
const bulkEncryptService = mock<BulkEncryptService>();
|
const bulkEncryptService = mock<BulkEncryptService>();
|
||||||
const configService = mock<ConfigService>();
|
const configService = mock<ConfigService>();
|
||||||
accountService = mockAccountServiceWith(mockUserId);
|
accountService = mockAccountServiceWith(mockUserId);
|
||||||
|
const logService = mock<LogService>();
|
||||||
const stateProvider = new FakeStateProvider(accountService);
|
const stateProvider = new FakeStateProvider(accountService);
|
||||||
|
|
||||||
const userId = "TestUserId" as UserId;
|
const userId = "TestUserId" as UserId;
|
||||||
@@ -148,6 +150,7 @@ describe("Cipher Service", () => {
|
|||||||
configService,
|
configService,
|
||||||
stateProvider,
|
stateProvider,
|
||||||
accountService,
|
accountService,
|
||||||
|
logService,
|
||||||
);
|
);
|
||||||
|
|
||||||
cipherObj = new Cipher(cipherData);
|
cipherObj = new Cipher(cipherData);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
|
|
||||||
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { ApiService } from "../../abstractions/api.service";
|
import { ApiService } from "../../abstractions/api.service";
|
||||||
@@ -110,6 +111,7 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
private stateProvider: StateProvider,
|
private stateProvider: StateProvider,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
|
private logService: LogService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
localData$(userId: UserId): Observable<Record<CipherId, LocalData>> {
|
localData$(userId: UserId): Observable<Record<CipherId, LocalData>> {
|
||||||
@@ -445,6 +447,7 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
{} as Record<string, Cipher[]>,
|
{} as Record<string, Cipher[]>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const decryptStartTime = new Date().getTime();
|
||||||
const allCipherViews = (
|
const allCipherViews = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.entries(grouped).map(async ([orgId, groupedCiphers]) => {
|
Object.entries(grouped).map(async ([orgId, groupedCiphers]) => {
|
||||||
@@ -464,6 +467,9 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
)
|
)
|
||||||
.flat()
|
.flat()
|
||||||
.sort(this.getLocaleSortingFunction());
|
.sort(this.getLocaleSortingFunction());
|
||||||
|
this.logService.info(
|
||||||
|
`[CipherService] Decrypting ${allCipherViews.length} ciphers took ${new Date().getTime() - decryptStartTime}ms`,
|
||||||
|
);
|
||||||
|
|
||||||
// Split ciphers into two arrays, one for successfully decrypted ciphers and one for ciphers that failed to decrypt
|
// Split ciphers into two arrays, one for successfully decrypted ciphers and one for ciphers that failed to decrypt
|
||||||
return allCipherViews.reduce(
|
return allCipherViews.reduce(
|
||||||
|
|||||||
@@ -607,9 +607,17 @@ export class LockComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
|
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
|
||||||
|
const startSync = new Date().getTime();
|
||||||
|
// TODO: This should probably not be blocking
|
||||||
await this.syncService.fullSync(false);
|
await this.syncService.fullSync(false);
|
||||||
|
this.logService.info(`[LockComponent] Sync took ${new Date().getTime() - startSync}ms`);
|
||||||
|
|
||||||
|
const startRegeneration = new Date().getTime();
|
||||||
|
// TODO: This should probably not be blocking
|
||||||
await this.userAsymmetricKeysRegenerationService.regenerateIfNeeded(this.activeAccount.id);
|
await this.userAsymmetricKeysRegenerationService.regenerateIfNeeded(this.activeAccount.id);
|
||||||
|
this.logService.info(
|
||||||
|
`[LockComponent] Private key regeneration took ${new Date().getTime() - startRegeneration}ms`,
|
||||||
|
);
|
||||||
|
|
||||||
if (this.clientType === "browser") {
|
if (this.clientType === "browser") {
|
||||||
const previousUrl = this.lockComponentService.getPreviousUrl();
|
const previousUrl = this.lockComponentService.getPreviousUrl();
|
||||||
|
|||||||
@@ -306,11 +306,16 @@ export class DefaultKeyService implements KeyServiceAbstraction {
|
|||||||
* TODO: Move to MasterPasswordService
|
* TODO: Move to MasterPasswordService
|
||||||
*/
|
*/
|
||||||
async makeMasterKey(password: string, email: string, KdfConfig: KdfConfig): Promise<MasterKey> {
|
async makeMasterKey(password: string, email: string, KdfConfig: KdfConfig): Promise<MasterKey> {
|
||||||
return (await this.keyGenerationService.deriveKeyFromPassword(
|
const start = new Date().getTime();
|
||||||
|
const masterKey = (await this.keyGenerationService.deriveKeyFromPassword(
|
||||||
password,
|
password,
|
||||||
email,
|
email,
|
||||||
KdfConfig,
|
KdfConfig,
|
||||||
)) as MasterKey;
|
)) as MasterKey;
|
||||||
|
const end = new Date().getTime();
|
||||||
|
this.logService.info(`[KeyService] Deriving master key took ${end - start}ms`);
|
||||||
|
|
||||||
|
return masterKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
async encryptUserKeyWithMasterKey(
|
async encryptUserKeyWithMasterKey(
|
||||||
|
|||||||
Reference in New Issue
Block a user