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