abstract password generation service
This commit is contained in:
parent
e160b97497
commit
15f254879f
|
@ -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>;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue