abstract password generation service

This commit is contained in:
Kyle Spearrin 2018-01-29 17:59:57 -05:00
parent e160b97497
commit 15f254879f
4 changed files with 15 additions and 18 deletions

View File

@ -1,12 +1,10 @@
import { PasswordHistory } from '../models/domain/passwordHistory';
export interface PasswordGenerationService {
optionsCache: any;
history: PasswordHistory[];
generatePassword(options: any): string;
getOptions(): any;
saveOptions(options: any): Promise<any>;
getHistory(): Promise<PasswordHistory[]>;
addHistory(password: string): Promise<any>;
clear(): Promise<any>;
export abstract class PasswordGenerationService {
generatePassword: (options: any) => string;
getOptions: () => any;
saveOptions: (options: any) => Promise<any>;
getHistory: () => Promise<PasswordHistory[]>;
addHistory: (password: string) => Promise<any>;
clear: () => Promise<any>;
}

View File

@ -3,7 +3,7 @@ import { View } from './view';
import { Folder } from '../domain/folder';
export class FolderView implements View {
id: string;
id: string = null;
name: string;
constructor(f?: Folder) {

View File

@ -67,10 +67,9 @@ export class FolderService implements FolderServiceAbstraction {
return this.decryptedFolderCache;
}
const decFolders: FolderView[] = [{
id: null,
name: this.noneFolder(),
}];
const noneFolder = new FolderView();
noneFolder.name = this.noneFolder();
const decFolders: FolderView[] = [noneFolder];
const key = await this.cryptoService.getKey();
if (key == null) {

View File

@ -5,7 +5,7 @@ import { UtilsService } from './utils.service';
import { CryptoService } from '../abstractions/crypto.service';
import {
PasswordGenerationService as PasswordGenerationServiceInterface,
PasswordGenerationService as PasswordGenerationServiceAbstraction,
} from '../abstractions/passwordGeneration.service';
import { StorageService } from '../abstractions/storage.service';
@ -29,7 +29,7 @@ const Keys = {
const MaxPasswordsInHistory = 100;
export class PasswordGenerationService implements PasswordGenerationServiceInterface {
export class PasswordGenerationService implements PasswordGenerationServiceAbstraction {
static generatePassword(options: any): string {
// overload defaults with given options
const o = Object.assign({}, DefaultOptions, options);
@ -147,8 +147,8 @@ export class PasswordGenerationService implements PasswordGenerationServiceInter
return password;
}
optionsCache: any;
history: PasswordHistory[] = [];
private optionsCache: any;
private history: PasswordHistory[] = [];
constructor(private cryptoService: CryptoService, private storageService: StorageService) {
}