1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

add list items --url <url> command. resolves #32

This commit is contained in:
Kyle Spearrin
2018-10-13 22:27:33 -04:00
parent 4639aa613e
commit 73c597f649
7 changed files with 35 additions and 24 deletions

2
jslib

Submodule jslib updated: 9fa99f3a6e...ad97afc590

31
package-lock.json generated
View File

@@ -243,6 +243,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/tldjs": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@types/tldjs/-/tldjs-2.3.0.tgz",
"integrity": "sha512-+gqspH/N6YjpApp96/XzM2AZK4R0Bk2qb4e5o16indSvgblfFaAIxNV8BdJmbqfSAYUyZubLzvrmpvdVEmBq3A==",
"dev": true
},
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
"version": "1.7.6", "version": "1.7.6",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.6.tgz", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.6.tgz",
@@ -2055,8 +2061,7 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
@@ -2066,8 +2071,7 @@
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@@ -2184,8 +2188,7 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@@ -2197,7 +2200,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@@ -2323,8 +2325,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@@ -2457,7 +2458,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@@ -3988,8 +3988,7 @@
"punycode": { "punycode": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
"dev": true
}, },
"qs": { "qs": {
"version": "6.5.2", "version": "6.5.2",
@@ -4727,6 +4726,14 @@
"setimmediate": "^1.0.4" "setimmediate": "^1.0.4"
} }
}, },
"tldjs": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tldjs/-/tldjs-2.3.1.tgz",
"integrity": "sha512-W/YVH/QczLUxVjnQhFC61Iq232NWu3TqDdO0S/MtXVz4xybejBov4ud+CIwN9aYqjOecEqIy0PscGkwpG9ZyTw==",
"requires": {
"punycode": "^1.4.1"
}
},
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",

View File

@@ -53,6 +53,7 @@
"@types/node-fetch": "^2.1.2", "@types/node-fetch": "^2.1.2",
"@types/node-forge": "^0.7.5", "@types/node-forge": "^0.7.5",
"@types/papaparse": "^4.5.3", "@types/papaparse": "^4.5.3",
"@types/tldjs": "^2.3.0",
"clean-webpack-plugin": "^0.1.19", "clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.2", "copy-webpack-plugin": "^4.5.2",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
@@ -73,6 +74,7 @@
"lunr": "2.3.3", "lunr": "2.3.3",
"node-fetch": "2.2.0", "node-fetch": "2.2.0",
"node-forge": "0.7.6", "node-forge": "0.7.6",
"papaparse": "4.6.0" "papaparse": "4.6.0",
"tldjs": "2.3.1"
} }
} }

View File

@@ -88,10 +88,10 @@ export class Main {
async (expired: boolean) => await this.logout()); async (expired: boolean) => await this.logout());
this.environmentService = new EnvironmentService(this.apiService, this.storageService, null); this.environmentService = new EnvironmentService(this.apiService, this.storageService, null);
this.userService = new UserService(this.tokenService, this.storageService); this.userService = new UserService(this.tokenService, this.storageService);
this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService); this.containerService = new ContainerService(this.cryptoService);
this.settingsService = new SettingsService(this.userService, this.storageService); this.settingsService = new SettingsService(this.userService, this.storageService);
this.cipherService = new CipherService(this.cryptoService, this.userService, this.settingsService, this.cipherService = new CipherService(this.cryptoService, this.userService, this.settingsService,
this.apiService, this.storageService, this.i18nService, this.platformUtilsService, null); this.apiService, this.storageService, this.i18nService, null);
this.folderService = new FolderService(this.cryptoService, this.userService, this.apiService, this.folderService = new FolderService(this.cryptoService, this.userService, this.apiService,
this.storageService, this.i18nService, this.cipherService); this.storageService, this.i18nService, this.cipherService);
this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService, this.collectionService = new CollectionService(this.cryptoService, this.userService, this.storageService,

View File

@@ -1,5 +1,7 @@
import * as program from 'commander'; import * as program from 'commander';
import { CipherView } from 'jslib/models/view/cipherView';
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';
@@ -36,7 +38,12 @@ export class ListCommand {
} }
private async listCiphers(cmd: program.Command) { private async listCiphers(cmd: program.Command) {
let ciphers = await this.cipherService.getAllDecrypted(); let ciphers: CipherView[];
if (cmd.url != null && cmd.url.trim() !== '') {
ciphers = await this.cipherService.getAllDecryptedForUrl(cmd.url);
} else {
ciphers = await this.cipherService.getAllDecrypted();
}
if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) { if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) {
ciphers = ciphers.filter((c) => { ciphers = ciphers.filter((c) => {

View File

@@ -194,6 +194,7 @@ export class Program {
.command('list <object>') .command('list <object>')
.description('List an array of objects from the vault.') .description('List an array of objects from the vault.')
.option('--search <search>', 'Perform a search on the listed objects.') .option('--search <search>', 'Perform a search on the listed objects.')
.option('--url <url>', 'Filter items of type login with a url-match search.')
.option('--folderid <folderid>', 'Filter items by folder id.') .option('--folderid <folderid>', 'Filter items by folder id.')
.option('--collectionid <collectionid>', 'Filter items by collection id.') .option('--collectionid <collectionid>', 'Filter items by collection id.')
.option('--organizationid <organizationid>', 'Filter items or collections by organization id.') .option('--organizationid <organizationid>', 'Filter items or collections by organization id.')
@@ -216,6 +217,7 @@ export class Program {
writeLn(' bw list items'); writeLn(' bw list items');
writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2'); writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
writeLn(' bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2'); writeLn(' bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2');
writeLn(' bw list items --url https://google.com');
writeLn(' bw list items --folderid null'); writeLn(' bw list items --folderid null');
writeLn(' bw list items --organizationid notnull'); writeLn(' bw list items --organizationid notnull');
writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull'); writeLn(' bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull');

View File

@@ -1,11 +1,8 @@
import { DeviceType } from 'jslib/enums/deviceType'; import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { Utils } from 'jslib/misc/utils';
// tslint:disable-next-line // tslint:disable-next-line
const pjson = require('../../package.json'); const pjson = require('../../package.json');
@@ -78,10 +75,6 @@ export class NodePlatformUtilsService implements PlatformUtilsService {
return null as string; return null as string;
} }
getDomain(uriString: string): string {
return Utils.getHostname(uriString);
}
isViewOpen() { isViewOpen() {
return false; return false;
} }