@zohocorporation/vault-cli 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/out/commands/add/add.const.js +6 -0
- package/out/commands/add/add.types.js +2 -0
- package/out/commands/add/add.util.js +35 -0
- package/out/commands/download/download.const.js +6 -0
- package/out/commands/download/download.types.js +2 -0
- package/out/commands/download/download.utils.js +35 -0
- package/out/commands/generate-password/generate-password.const.js +12 -0
- package/out/commands/generate-password/generate-password.types.js +2 -0
- package/out/commands/generate-password/generate-password.utils.js +58 -0
- package/out/commands/generate-template/generate-template.const.js +7 -0
- package/out/commands/generate-template/generate-template.types.js +2 -0
- package/out/commands/generate-template/generate-template.util.js +37 -0
- package/out/commands/get/get.const.js +8 -0
- package/out/commands/get/get.types.js +2 -0
- package/out/commands/get/get.utils.js +45 -0
- package/out/commands/get-default/get-default.const.js +5 -0
- package/out/commands/get-default/get-default.types.js +2 -0
- package/out/commands/get-default/get-default.utils.js +33 -0
- package/out/commands/list/list.const.js +7 -0
- package/out/commands/list/list.types.js +2 -0
- package/out/commands/list/list.utils.js +43 -0
- package/out/commands/lock/lock.action.js +13 -0
- package/out/commands/lock/lock.js +10 -0
- package/out/commands/lock/lock.utils.js +52 -0
- package/out/commands/login/login.action.js +22 -0
- package/out/commands/login/login.const.js +10 -0
- package/out/commands/login/login.help.js +12 -0
- package/out/commands/login/login.js +17 -0
- package/out/commands/login/login.types.js +5 -0
- package/out/commands/login/login.utils.js +307 -0
- package/out/commands/reset/reset.action.js +28 -0
- package/out/commands/reset/reset.help.js +8 -0
- package/out/commands/reset/reset.js +14 -0
- package/out/commands/reset/reset.utils.js +2 -0
- package/out/commands/search/search.action.js +30 -0
- package/out/commands/search/search.constants.js +14 -0
- package/out/commands/search/search.help.js +6 -0
- package/out/commands/search/search.js +26 -0
- package/out/commands/search/search.types.js +16 -0
- package/out/commands/search/search.utils.js +61 -0
- package/out/commands/set-default/set-default.const.js +6 -0
- package/out/commands/set-default/set-default.types.js +2 -0
- package/out/commands/set-default/set-default.utils.js +39 -0
- package/out/commands/unlock/unlock.action.js +23 -0
- package/out/commands/unlock/unlock.help.js +2 -0
- package/out/commands/unlock/unlock.js +12 -0
- package/out/commands/unlock/unlock.type.js +2 -0
- package/out/commands/unlock/unlock.utils.js +133 -0
- package/out/js/I18n/index.js +80 -0
- package/out/js/I18n/resources/CLI_I18N_en.js +173 -0
- package/out/js/I18n/resources/CLI_I18N_es.js +3 -0
- package/out/js/I18n/resources/CLI_I18N_fr.js +3 -0
- package/out/js/I18n/resources/CLI_I18N_nl.js +3 -0
- package/out/js/I18n/resources/CLI_I18N_pt.js +3 -0
- package/out/js/I18n/resources/CLI_I18N_zh.js +3 -0
- package/out/js/crypto/aes.js +225 -0
- package/out/js/crypto/index.js +139 -0
- package/out/js/crypto/rsa.js +1945 -0
- package/out/js/crypto/zohovault.js +671 -0
- package/out/js/logger/index.js +10 -0
- package/out/old/Add.js +590 -0
- package/out/old/Default.js +209 -0
- package/out/old/Download.js +69 -0
- package/out/old/Generate.js +171 -0
- package/out/old/Get.js +225 -0
- package/out/old/List.js +197 -0
- package/out/old/Login.js +287 -0
- package/out/old/Logout.js +21 -0
- package/out/old/PasswordGenerator.js +718 -0
- package/out/old/PasswordPolicies.js +21 -0
- package/out/old/PasswordTypes.js +33 -0
- package/out/old/Update.js +682 -0
- package/out/old/cmd/addcmd.js +59 -0
- package/out/old/cmd/downloadcmd.js +76 -0
- package/out/old/cmd/generate-passwordcmd.js +127 -0
- package/out/old/cmd/generate-templatecmd.js +59 -0
- package/out/old/cmd/get-defaultcmd.js +48 -0
- package/out/old/cmd/getcmd.js +57 -0
- package/out/old/cmd/listcmd.js +54 -0
- package/out/old/cmd/logoutcmd.js +31 -0
- package/out/old/cmd/set-default.js +75 -0
- package/out/old/cmd/updatecmd.js +44 -0
- package/out/old/index.js +580 -0
- package/out/util/configuration.util.js +103 -0
- package/out/util/consts.util.js +97 -0
- package/out/util/dbutils/db.types.js +2 -0
- package/out/util/dbutils/db.utils.js +164 -0
- package/out/util/dbutils/dbtable.utils.js +19 -0
- package/out/util/dev.utils.js +14 -0
- package/out/util/encryptionutil/encryption.uitl.js +108 -0
- package/out/util/index.util.js +341 -0
- package/out/util/keyringutil/keyring.util.js +57 -0
- package/out/util/loader/loader.interface.js +2 -0
- package/out/util/loader/transfer.loader.js +28 -0
- package/out/util/login.util.js +352 -0
- package/out/util/passwordtypes.util.js +91 -0
- package/out/util/print.util.js +4 -0
- package/out/util/search.util.js +359 -0
- package/out/util/types.util.js +7 -0
- package/out/zv.js +41 -0
- package/package.json +96 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { Login } from "./login.util.js";
|
|
2
|
+
import { SEARCH } from "../commands/search/search.constants.js";
|
|
3
|
+
import { I18N } from "../js/I18n/index.js";
|
|
4
|
+
import { Utilities, _pull } from "./index.util.js";
|
|
5
|
+
import { header } from "../commands/login/login.utils.js";
|
|
6
|
+
import { OPTIONS, VAULT_ENDPOINTS } from "./consts.util.js";
|
|
7
|
+
import { OUTPUT } from "../commands/search/search.constants.js";
|
|
8
|
+
import { PasswordTypes } from "./passwordtypes.util.js";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import chalk from "chalk";
|
|
12
|
+
import wrap from "word-wrap";
|
|
13
|
+
export class Search extends Login {
|
|
14
|
+
key;
|
|
15
|
+
strict;
|
|
16
|
+
tags;
|
|
17
|
+
description;
|
|
18
|
+
name;
|
|
19
|
+
verbose;
|
|
20
|
+
output;
|
|
21
|
+
outFile;
|
|
22
|
+
notSafe;
|
|
23
|
+
fields;
|
|
24
|
+
// private masterKey: string | undefined;
|
|
25
|
+
i18nText = new I18N();
|
|
26
|
+
constructor(key, strict, tags, description, name, verbose, output, outFile, notSafe, passphrase, dc) {
|
|
27
|
+
super(passphrase, dc);
|
|
28
|
+
this.key = !strict ? key : `"${key}"`;
|
|
29
|
+
this.strict = strict;
|
|
30
|
+
this.tags = tags;
|
|
31
|
+
this.description = description;
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.verbose = verbose;
|
|
34
|
+
this.output = output;
|
|
35
|
+
this.outFile = outFile;
|
|
36
|
+
this.notSafe = notSafe;
|
|
37
|
+
// super. = undefined;
|
|
38
|
+
if (outFile !== undefined && typeof outFile === "string") {
|
|
39
|
+
const dirPath = path.parse(outFile).dir;
|
|
40
|
+
if ((outFile === undefined || outFile === '' || fs.existsSync(dirPath) || dirPath === '')) {
|
|
41
|
+
this.outFile = outFile;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(chalk.red('Invalid File Path provided'));
|
|
45
|
+
this.outFile = undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.outFile = undefined;
|
|
50
|
+
}
|
|
51
|
+
this.fields = this.constructFields(tags, description, name);
|
|
52
|
+
}
|
|
53
|
+
constructFields(tags, description, name) {
|
|
54
|
+
const result = [];
|
|
55
|
+
if (!tags && !description && !name) {
|
|
56
|
+
return [SEARCH.TAGS, SEARCH.DESCRIPTION, SEARCH.SECRETNAME];
|
|
57
|
+
}
|
|
58
|
+
if (tags) {
|
|
59
|
+
result.push(SEARCH.TAGS);
|
|
60
|
+
}
|
|
61
|
+
;
|
|
62
|
+
if (description) {
|
|
63
|
+
result.push(SEARCH.DESCRIPTION);
|
|
64
|
+
}
|
|
65
|
+
if (name) {
|
|
66
|
+
result.push(SEARCH.SECRETNAME);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
async getValutRespForSearchSecrets() {
|
|
71
|
+
return new Promise(async (reslove, reject) => {
|
|
72
|
+
try {
|
|
73
|
+
reslove(await _pull(header, Utilities.getVaultUrl(this.getDC()) + VAULT_ENDPOINTS.URL_SEARCH_SECRETS, {
|
|
74
|
+
searchIn: JSON.stringify(this.fields),
|
|
75
|
+
key: this.key,
|
|
76
|
+
pageNum: 0,
|
|
77
|
+
rowPerPage: -1
|
|
78
|
+
}, undefined));
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
reject(new Error("Error while getting secrets"));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
formatSearchArrayForVerbose(serachArr) {
|
|
86
|
+
const arr = [];
|
|
87
|
+
serachArr.forEach((secret) => {
|
|
88
|
+
arr.push({
|
|
89
|
+
secretid: secret.secretid,
|
|
90
|
+
secretname: secret.secretname,
|
|
91
|
+
description: secret.description,
|
|
92
|
+
ownername: secret.ownerdetails.USERNAME,
|
|
93
|
+
owneremail: secret.ownerdetails.EMAIL
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
return arr;
|
|
97
|
+
}
|
|
98
|
+
outForXML(secret) {
|
|
99
|
+
if (!this.verbose) {
|
|
100
|
+
const secData = this.formatSearchArrayForVerbose(secret);
|
|
101
|
+
Utilities.printAsXML({ secrets: { secret: secData } }, this.outFile, this.output);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
Utilities.printAsXML({ secrets: { secret: secret } }, this.outFile, this.output);
|
|
105
|
+
}
|
|
106
|
+
outForYAML(secret) {
|
|
107
|
+
if (!this.verbose) {
|
|
108
|
+
const secData = this.formatSearchArrayForVerbose(secret);
|
|
109
|
+
Utilities.printAsYAML({ secrets: { secret: secData } }, this.outFile, this.output);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
Utilities.printAsYAML({ secrets: { secret: secret } }, this.outFile, this.output);
|
|
113
|
+
}
|
|
114
|
+
outForJSON(secret) {
|
|
115
|
+
if (!this.verbose) {
|
|
116
|
+
const secData = this.formatSearchArrayForVerbose(secret);
|
|
117
|
+
Utilities.printAsJSON({ secrets: { secret: secData } }, this.outFile, this.output);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
Utilities.printAsJSON({ secrets: { secret: secret } }, this.outFile, this.output);
|
|
121
|
+
}
|
|
122
|
+
getAccountType(accountType, secretTypes) {
|
|
123
|
+
const secretType = secretTypes.find((element) => element.secret_type_id === accountType);
|
|
124
|
+
return secretType.secret_type_name;
|
|
125
|
+
}
|
|
126
|
+
async constructTableDataForNonVerbose(groupedSecrets, secretTypes) {
|
|
127
|
+
const result = [];
|
|
128
|
+
for (const secType in groupedSecrets) {
|
|
129
|
+
const secArray = groupedSecrets[secType];
|
|
130
|
+
for (const secret of secArray) {
|
|
131
|
+
// secArray.forEach((secret: Secret) => {
|
|
132
|
+
const secObj = {};
|
|
133
|
+
// const key: string = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_passwordId");
|
|
134
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_passwordId")] = wrap(secret.secretid);
|
|
135
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_passwordName")] = wrap(secret.secretname, {
|
|
136
|
+
width: 10,
|
|
137
|
+
});
|
|
138
|
+
if (secret.description != '') {
|
|
139
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_Description")] = wrap(secret.description, {
|
|
140
|
+
width: 10,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const description = await this.decrypt(secret.encdescription, secret.isshared);
|
|
145
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_Description")] = wrap(description, {
|
|
146
|
+
width: 10,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// const description = await this.decrypt(secret.encdescription, secret.isshared) as string;
|
|
150
|
+
// secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_Description")] = wrap(description, {
|
|
151
|
+
// width: 10,
|
|
152
|
+
// })
|
|
153
|
+
// }
|
|
154
|
+
const accountType = secretTypes[secType]?.secret_type_name;
|
|
155
|
+
if (accountType) {
|
|
156
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_type")] = wrap(accountType);
|
|
157
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_ownerName")] = wrap(secret.ownerdetails.USERNAME);
|
|
158
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_owneremail")] = wrap(secret.ownerdetails.EMAIL);
|
|
159
|
+
result.push(secObj);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
formatFilesArr(files) {
|
|
166
|
+
if (files === undefined) {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
const filesArr = JSON.parse(files);
|
|
170
|
+
let filesObj = {};
|
|
171
|
+
for (let i = 0; i < filesArr.length; i++) {
|
|
172
|
+
const file = filesArr[i];
|
|
173
|
+
filesObj[file.column] = file.name;
|
|
174
|
+
}
|
|
175
|
+
return filesObj;
|
|
176
|
+
}
|
|
177
|
+
async formatSecObj(secData, secObj) {
|
|
178
|
+
let fileArr = this.formatFilesArr(secData.files);
|
|
179
|
+
delete secData.files;
|
|
180
|
+
for (const attr in secData) {
|
|
181
|
+
let label = attr;
|
|
182
|
+
if (attr === "username") {
|
|
183
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_username"); //No I18N
|
|
184
|
+
}
|
|
185
|
+
else if (attr === "password") {
|
|
186
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_password"); //No I18N
|
|
187
|
+
}
|
|
188
|
+
else if (attr === "file") { //File Attachments
|
|
189
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_file"); //No I18N
|
|
190
|
+
}
|
|
191
|
+
else if (attr === "agency") { //Health Care Agency
|
|
192
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_agency"); //No I18N
|
|
193
|
+
}
|
|
194
|
+
else if (attr === "policyno") { //Health Care Agency
|
|
195
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_policyno"); //No I18N
|
|
196
|
+
}
|
|
197
|
+
else if (attr === "groupno") { //Health care Agency
|
|
198
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_groupno"); //No I18N
|
|
199
|
+
}
|
|
200
|
+
else if (attr === "name") { //category :- Social Security Account
|
|
201
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_name"); //No I18N
|
|
202
|
+
}
|
|
203
|
+
else if (attr === "ssno") { // Social Security Account
|
|
204
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_ssno"); //No I18N
|
|
205
|
+
}
|
|
206
|
+
else if (attr === "accno") { //Bank Account
|
|
207
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_accno"); //No I18N
|
|
208
|
+
}
|
|
209
|
+
else if (attr === "bankid") { //Bank Account
|
|
210
|
+
label = this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_bankid"); //No I18N
|
|
211
|
+
}
|
|
212
|
+
if (attr.toLocaleLowerCase() === "file" || attr.toLocaleLowerCase() === "file attachment") {
|
|
213
|
+
const name = !!secData[attr] ? secData[attr] : '';
|
|
214
|
+
const fileArrName = fileArr[name];
|
|
215
|
+
secObj[label] = wrap(fileArrName, { width: 10 });
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (secObj.hasOwnProperty(label)) {
|
|
219
|
+
secObj[wrap(`${label}(${attr})`)] = wrap(secData[attr], { width: 10 });
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
secObj[label] = wrap(secData[attr], { width: 10 });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async getTableData(secretArr, secretData) {
|
|
228
|
+
try {
|
|
229
|
+
let result = [];
|
|
230
|
+
const { secret_type_fields: secretTypeFields } = secretData;
|
|
231
|
+
for (const secret of secretArr) {
|
|
232
|
+
let secObj = {};
|
|
233
|
+
await this.decryptSecretObject(secret, secretTypeFields, this.notSafe);
|
|
234
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_passwordId")] = wrap(secret.secretid);
|
|
235
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_passwordName")] = wrap(secret.secretname, {
|
|
236
|
+
width: 10,
|
|
237
|
+
});
|
|
238
|
+
if (secret.description != '') {
|
|
239
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_Description")] = wrap(secret.description, {
|
|
240
|
+
width: 10,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
const description = await this.decrypt(secret.encdescription, secret.isshared);
|
|
245
|
+
secObj[this.i18nText.getI18nMsg("vault.search.formatDataForTable_head_Description")] = wrap(description, {
|
|
246
|
+
width: 10,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const { secretData: secData, files } = secret;
|
|
250
|
+
const sec = secData;
|
|
251
|
+
if (secData) {
|
|
252
|
+
await this.formatSecObj({ ...sec, files }, secObj);
|
|
253
|
+
}
|
|
254
|
+
result.push(secObj);
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
constructTableDataVerbose(groupedSecrets, secretTypes) {
|
|
262
|
+
return new Promise(async (resolve, reject) => {
|
|
263
|
+
try {
|
|
264
|
+
const result = [];
|
|
265
|
+
for (const secTypeId in groupedSecrets) {
|
|
266
|
+
result.length = 0;
|
|
267
|
+
console.log(this.i18nText.getI18nMsg("vault.list.listsecrets_category") + secretTypes[secTypeId]?.secret_type_name);
|
|
268
|
+
const secretArr = groupedSecrets[secTypeId];
|
|
269
|
+
const secretData = secretTypes[secTypeId];
|
|
270
|
+
let tableData = await this.getTableData(secretArr, secretData);
|
|
271
|
+
result.push(...tableData);
|
|
272
|
+
Utilities.printTable(result);
|
|
273
|
+
console.log(`\nTotal: ${result.length} password(s) retrieved\n`);
|
|
274
|
+
}
|
|
275
|
+
resolve(result);
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
outForTable(groupedSecrets, secretTypes) {
|
|
282
|
+
return new Promise(async (resolve, reject) => {
|
|
283
|
+
try {
|
|
284
|
+
if (!this.verbose) {
|
|
285
|
+
const tableData = await this.constructTableDataForNonVerbose(groupedSecrets, secretTypes);
|
|
286
|
+
Utilities.printTable(tableData);
|
|
287
|
+
console.log(`\nTotal: ${tableData.length} password(s) retrieved\n`);
|
|
288
|
+
resolve(true);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
await this.constructTableDataVerbose(groupedSecrets, secretTypes);
|
|
292
|
+
// Utilities.printTable(tableData) ;
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
reject("Error while printing table");
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
outSearchResult(output, secrets) {
|
|
300
|
+
return new Promise(async (resolve, reject) => {
|
|
301
|
+
try {
|
|
302
|
+
switch (output) {
|
|
303
|
+
case OUTPUT.XML:
|
|
304
|
+
this.outForXML(secrets);
|
|
305
|
+
break;
|
|
306
|
+
case OUTPUT.YAML:
|
|
307
|
+
case OUTPUT.YML:
|
|
308
|
+
this.outForYAML(secrets);
|
|
309
|
+
break;
|
|
310
|
+
case OUTPUT.JSON:
|
|
311
|
+
this.outForJSON(secrets);
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
const groupedSecrets = Utilities.groupBy(secrets, "accounttype");
|
|
315
|
+
let secretTypes = await PasswordTypes.getPasswordTypes(this.getDC(), undefined, OPTIONS.SEARCH, false);
|
|
316
|
+
await this.outForTable(groupedSecrets, secretTypes);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
reject(new Error("Problem displaying password"));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
// simplfySecret(secrets: Secret[]) {
|
|
325
|
+
// for (let i = 0; i < secrets.length; i++) {
|
|
326
|
+
// let secretData = secrets[i]?.secretData;
|
|
327
|
+
// const secretsLength = !!secretData ? secretData.length
|
|
328
|
+
// for (i = 0; i < secretData.length; i++) {
|
|
329
|
+
// let secretDataField = secretData[i];
|
|
330
|
+
// delete secretDataField.pii;
|
|
331
|
+
// delete secretDataField.columnOrder;
|
|
332
|
+
// delete secretDataField.isDeleted;
|
|
333
|
+
// delete secretDataField.isMandatory;
|
|
334
|
+
// }
|
|
335
|
+
// }
|
|
336
|
+
// }
|
|
337
|
+
async getSecrets() {
|
|
338
|
+
try {
|
|
339
|
+
await this.getDcAndSetHeader();
|
|
340
|
+
const masterKey = await this.getMasterKeyAfterConfiguration();
|
|
341
|
+
this.setMasterKey(masterKey);
|
|
342
|
+
const resp = await this.getValutRespForSearchSecrets();
|
|
343
|
+
const { data: { operation: { Details: secrets, result: { status, message } } } } = resp;
|
|
344
|
+
if (status !== "Success") {
|
|
345
|
+
throw new Error(message);
|
|
346
|
+
}
|
|
347
|
+
if (secrets.length === 0) {
|
|
348
|
+
throw new Error(this.i18nText.getI18nMsg("vault.search.getSecrets_noPasswordFound"));
|
|
349
|
+
}
|
|
350
|
+
await this.outSearchResult(this.output, secrets);
|
|
351
|
+
}
|
|
352
|
+
catch (err) {
|
|
353
|
+
if (err instanceof Error) {
|
|
354
|
+
console.log(err.message);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=search.util.js.map
|
package/out/zv.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { login } from "./commands/login/login.js";
|
|
4
|
+
import { unlock } from "./commands/unlock/unlock.js";
|
|
5
|
+
import { lock } from "./commands/lock/lock.js";
|
|
6
|
+
import { search } from "./commands/search/search.js";
|
|
7
|
+
import { list } from "./old/cmd/listcmd.js";
|
|
8
|
+
import { get } from "./old/cmd/getcmd.js";
|
|
9
|
+
import { generateTemplate } from "./old/cmd/generate-templatecmd.js";
|
|
10
|
+
import { add } from "./old/cmd/addcmd.js";
|
|
11
|
+
import { updateCmd } from "./old/cmd/updatecmd.js";
|
|
12
|
+
import { downloadCmd } from "./old/cmd/downloadcmd.js";
|
|
13
|
+
import { generatePassword } from "./old/cmd/generate-passwordcmd.js";
|
|
14
|
+
import { logoutCmd } from "./old/cmd/logoutcmd.js";
|
|
15
|
+
import { getDefaultCmd } from "./old/cmd/get-defaultcmd.js";
|
|
16
|
+
import { setDefaultCmd } from "./old/cmd/set-default.js";
|
|
17
|
+
import { reset } from "./commands/reset/reset.js";
|
|
18
|
+
import('source-map-support').then((module) => {
|
|
19
|
+
module.install();
|
|
20
|
+
}).catch((error) => { });
|
|
21
|
+
const program = new Command();
|
|
22
|
+
login(program);
|
|
23
|
+
unlock(program);
|
|
24
|
+
lock(program);
|
|
25
|
+
search(program);
|
|
26
|
+
list(program);
|
|
27
|
+
get(program);
|
|
28
|
+
add(program);
|
|
29
|
+
generateTemplate(program);
|
|
30
|
+
updateCmd(program);
|
|
31
|
+
downloadCmd(program);
|
|
32
|
+
generatePassword(program);
|
|
33
|
+
logoutCmd(program);
|
|
34
|
+
getDefaultCmd(program);
|
|
35
|
+
setDefaultCmd(program);
|
|
36
|
+
reset(program);
|
|
37
|
+
program
|
|
38
|
+
.version('1.1.2', '-v --version', 'Display the CLI version')
|
|
39
|
+
.description('Zoho Vault Command Line Interface');
|
|
40
|
+
program.parse(process.argv);
|
|
41
|
+
//# sourceMappingURL=zv.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zohocorporation/vault-cli",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Zoho Vault Command Line Interface",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"./out/**/*.js"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"tscdev": "tsc -w",
|
|
12
|
+
"dev": "node ./scripts/watch.js",
|
|
13
|
+
"build": "node ./scripts/build.js",
|
|
14
|
+
"build:install": "npm install --registry http://cm-npmregistry && node ./scripts/build.js",
|
|
15
|
+
"prepack": "npm install --registry http://cm-npmregistry && tsc",
|
|
16
|
+
"test": "mocha",
|
|
17
|
+
"pkg:lin": "pkg . -t node18-linux-x64 -o bundle/linux/zv -C GZip",
|
|
18
|
+
"pkg:lin-arm": "pkg . -t node18-linux-arm64 -o bundle/linarm/zv -C GZip",
|
|
19
|
+
"pkg:mac": "pkg . -t node18-macos-x64 -o bundle/macos/zv -C GZip ",
|
|
20
|
+
"pkg:mac-arm": "pkg . -t node18-macos-arm64 -o bundle/macarm/zv -C GZip",
|
|
21
|
+
"pkg:win": "pkg . -t node18-win-x64 -o bundle/win/zv.exe -C GZip",
|
|
22
|
+
"pkg": "npm run pkg:lin && npm run pkg:mac && npm run pkg:win",
|
|
23
|
+
"lint-staged": "lint-staged",
|
|
24
|
+
"eslint": "eslint",
|
|
25
|
+
"setup": "npm install --registry http://cm-npmregistry && cd .. && husky jsapps/.husky && cd jsapps && husky init && node ./scripts/setup.js",
|
|
26
|
+
"link-err-stk": "alias zv=\"node -r source-map-support/register dist/zv.cjs\"",
|
|
27
|
+
"prepare": "husky"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"zv": "./out/zv.js"
|
|
31
|
+
},
|
|
32
|
+
"pkg": {
|
|
33
|
+
"assets": [
|
|
34
|
+
"./build/**/*",
|
|
35
|
+
"./node_modules/better-sqlite3/build/Release/better_sqlite3.node"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"nativeDependencies": {
|
|
39
|
+
"better-sqlite3": "*",
|
|
40
|
+
"@napi-rs/keyring": "*"
|
|
41
|
+
},
|
|
42
|
+
"author": "Zoho Vault",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@napi-rs/keyring": "1.1.6",
|
|
45
|
+
"atob": "2.1.2",
|
|
46
|
+
"axios": "1.7.7",
|
|
47
|
+
"better-sqlite3": "9.4.3",
|
|
48
|
+
"chalk": "5.3.0",
|
|
49
|
+
"cli-highlight": "2.1.11",
|
|
50
|
+
"cli-progress": "3.11.2",
|
|
51
|
+
"cli-table3": "0.6.4",
|
|
52
|
+
"commander": "12.1.0",
|
|
53
|
+
"inquirer": "10.2.2",
|
|
54
|
+
"js-yaml": "4.1.0",
|
|
55
|
+
"log4js": "6.9.1",
|
|
56
|
+
"mime-types": "2.1.35",
|
|
57
|
+
"string-similarity": "4.0.4",
|
|
58
|
+
"word-wrap": "1.2.5",
|
|
59
|
+
"xml-js": "1.6.11"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/atob": "2.1.2",
|
|
63
|
+
"@types/better-sqlite3": "7.6.11",
|
|
64
|
+
"@types/chai": "4.3.16",
|
|
65
|
+
"@types/cli-table": "0.3.0",
|
|
66
|
+
"@types/inquirer": "8.2.1",
|
|
67
|
+
"@types/jest": "29.5.12",
|
|
68
|
+
"@types/js-yaml": "4.0.9",
|
|
69
|
+
"@types/mocha": "10.0.1",
|
|
70
|
+
"@types/node": "22.7.2",
|
|
71
|
+
"@types/source-map-support": "0.5.4",
|
|
72
|
+
"@typescript-eslint/parser": "8.2.0",
|
|
73
|
+
"chai": "4.3.10",
|
|
74
|
+
"dotenv": "16.4.5",
|
|
75
|
+
"esbuild": "0.23.1",
|
|
76
|
+
"eslint": "9.11.1",
|
|
77
|
+
"file-loader": "6.2.0",
|
|
78
|
+
"husky": "9.0.11",
|
|
79
|
+
"lint-staged": "15.2.7",
|
|
80
|
+
"mocha": "10.2.0",
|
|
81
|
+
"pkg": "5.8.1",
|
|
82
|
+
"source-map-support": "0.5.21",
|
|
83
|
+
"ts-node": "10.9.2",
|
|
84
|
+
"typescript": "^5.4.5",
|
|
85
|
+
"typescript-eslint": "8.0.0"
|
|
86
|
+
},
|
|
87
|
+
"lint-staged": {
|
|
88
|
+
"*.{js,ts}": [
|
|
89
|
+
"eslint"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"engines": {
|
|
93
|
+
"node": ">=18",
|
|
94
|
+
"npm": ">=5.0.0"
|
|
95
|
+
}
|
|
96
|
+
}
|