mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
get exposed
This commit is contained in:
parent
36421c9144
commit
05535cc134
@ -89,6 +89,7 @@ export class Main {
|
||||
this.exportService = new ExportService(this.folderService, this.cipherService);
|
||||
this.authService = new AuthService(this.cryptoService, this.apiService, this.userService, this.tokenService,
|
||||
this.appIdService, this.i18nService, this.platformUtilsService, this.messagingService, true);
|
||||
this.auditService = new AuditService(this.cryptoFunctionService);
|
||||
this.program = new Program(this);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import * as program from 'commander';
|
||||
|
||||
import { CipherType } from 'jslib/enums/cipherType';
|
||||
|
||||
import { AuditService } from 'jslib/abstractions/audit.service';
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
import { CollectionService } from 'jslib/abstractions/collection.service';
|
||||
import { FolderService } from 'jslib/abstractions/folder.service';
|
||||
@ -32,7 +33,8 @@ import { CliUtils } from '../utils';
|
||||
|
||||
export class GetCommand {
|
||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||
private collectionService: CollectionService, private totpService: TotpService) { }
|
||||
private collectionService: CollectionService, private totpService: TotpService,
|
||||
private auditService: AuditService) { }
|
||||
|
||||
async run(object: string, id: string, cmd: program.Command): Promise<Response> {
|
||||
if (id != null) {
|
||||
@ -50,6 +52,8 @@ export class GetCommand {
|
||||
return await this.getUri(id);
|
||||
case 'totp':
|
||||
return await this.getTotp(id);
|
||||
case 'exposed':
|
||||
return await this.getExposed(id);
|
||||
case 'folder':
|
||||
return await this.getFolder(id);
|
||||
case 'collection':
|
||||
@ -167,6 +171,17 @@ export class GetCommand {
|
||||
return Response.success(res);
|
||||
}
|
||||
|
||||
private async getExposed(id: string) {
|
||||
const passwordResponse = await this.getPassword(id);
|
||||
if (!passwordResponse.success) {
|
||||
return passwordResponse;
|
||||
}
|
||||
|
||||
const exposedNumber = await this.auditService.passwordLeaked((passwordResponse.data as StringResponse).data);
|
||||
const res = new StringResponse(exposedNumber.toString());
|
||||
return Response.success(res);
|
||||
}
|
||||
|
||||
private async getFolder(id: string) {
|
||||
let decFolder: FolderView = null;
|
||||
if (this.isGuid(id)) {
|
||||
|
@ -233,6 +233,7 @@ export class Program {
|
||||
writeLn(' password');
|
||||
writeLn(' uri');
|
||||
writeLn(' totp');
|
||||
writeLn(' exposed');
|
||||
writeLn(' folder');
|
||||
writeLn(' collection');
|
||||
writeLn(' template');
|
||||
@ -246,6 +247,7 @@ export class Program {
|
||||
writeLn(' bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412');
|
||||
writeLn(' bw get password https://google.com');
|
||||
writeLn(' bw get totp google.com');
|
||||
writeLn(' bw get exposed yahoo.com');
|
||||
writeLn(' bw get folder email');
|
||||
writeLn(' bw get template folder');
|
||||
writeLn('');
|
||||
@ -253,7 +255,7 @@ export class Program {
|
||||
.action(async (object, id, cmd) => {
|
||||
await this.exitIfLocked();
|
||||
const command = new GetCommand(this.main.cipherService, this.main.folderService,
|
||||
this.main.collectionService, this.main.totpService);
|
||||
this.main.collectionService, this.main.totpService, this.main.auditService);
|
||||
const response = await command.run(object, id, cmd);
|
||||
this.processResponse(response);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user