1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

fixes to generation service

This commit is contained in:
Kyle Spearrin 2017-12-05 12:14:45 -05:00
parent 184a3db7c8
commit eab83a9756

View File

@ -179,7 +179,7 @@ export default class PasswordGenerationService {
return this.history || new Array<PasswordHistory>(); return this.history || new Array<PasswordHistory>();
} }
async addHistory(password: string) { async addHistory(password: string): Promise<any> {
// Prevent duplicates // Prevent duplicates
if (this.matchesPrevious(password)) { if (this.matchesPrevious(password)) {
return; return;
@ -193,12 +193,12 @@ export default class PasswordGenerationService {
} }
const newHistory = await this.encryptHistory(); const newHistory = await this.encryptHistory();
await UtilsService.saveObjToStorage(Keys.history, newHistory); return await UtilsService.saveObjToStorage(Keys.history, newHistory);
} }
async clear(): Promise<any> { async clear(): Promise<any> {
this.history = []; this.history = [];
await UtilsService.removeFromStorage(Keys.history); return await UtilsService.removeFromStorage(Keys.history);
} }
private async encryptHistory(): Promise<PasswordHistory[]> { private async encryptHistory(): Promise<PasswordHistory[]> {
@ -211,11 +211,11 @@ export default class PasswordGenerationService {
return new PasswordHistory(encrypted.encryptedString, item.date); return new PasswordHistory(encrypted.encryptedString, item.date);
}); });
await Promise.all(promises); return await Promise.all(promises);
} }
private async decryptHistory(history: PasswordHistory[]): Promise<PasswordHistory[]> { private async decryptHistory(history: PasswordHistory[]): Promise<PasswordHistory[]> {
if (history == null || this.history.length === 0) { if (history == null || history.length === 0) {
return Promise.resolve([]); return Promise.resolve([]);
} }
@ -224,7 +224,7 @@ export default class PasswordGenerationService {
return new PasswordHistory(decrypted, item.date); return new PasswordHistory(decrypted, item.date);
}); });
await Promise.all(promises); return await Promise.all(promises);
} }
private matchesPrevious(password: string): boolean { private matchesPrevious(password: string): boolean {