@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,59 @@
|
|
|
1
|
+
import { Logger } from "../../js/logger/index.js";
|
|
2
|
+
import { Utilities, isMasterKeyExist } from "../../util/index.util.js";
|
|
3
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
4
|
+
import { Add } from "../Add.js";
|
|
5
|
+
import { getAddDefaults } from "../../commands/add/add.util.js";
|
|
6
|
+
import { validReadablePathCheck } from "../index.js";
|
|
7
|
+
const i18nText = new I18N();
|
|
8
|
+
export const add = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("add") //NO I18N
|
|
11
|
+
.description(i18nText.getI18nMsg("vault.add.desc"))
|
|
12
|
+
.option("-id, --category-id <key>", i18nText.getI18nMsg("vault.add.option_passType"))
|
|
13
|
+
.option("-f, --file <key>", i18nText.getI18nMsg("vault.add.option_templateFile"))
|
|
14
|
+
.option("--use-default", "uses default options for add", false)
|
|
15
|
+
//TODO get the default value from some config file
|
|
16
|
+
.on("--help", () => {
|
|
17
|
+
console.log(`
|
|
18
|
+
Example :
|
|
19
|
+
zv add
|
|
20
|
+
zv add -id 2000001954220
|
|
21
|
+
zv add -f ~/facebook_pass.json
|
|
22
|
+
|
|
23
|
+
`
|
|
24
|
+
+ i18nText.getI18nMsg("vault.add.example_note")); //NO I18N
|
|
25
|
+
})
|
|
26
|
+
.action(async (comObj) => {
|
|
27
|
+
/*
|
|
28
|
+
* Get Details based the option
|
|
29
|
+
*/
|
|
30
|
+
const isConfigured = Utilities.isConfigured();
|
|
31
|
+
if (!isConfigured) {
|
|
32
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!await isMasterKeyExist()) {
|
|
36
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { useDefault } = comObj;
|
|
40
|
+
if (useDefault) {
|
|
41
|
+
const addDef = await getAddDefaults();
|
|
42
|
+
comObj = { ...comObj, ...addDef };
|
|
43
|
+
}
|
|
44
|
+
const { categoryId, file } = comObj;
|
|
45
|
+
if (file !== undefined && !validReadablePathCheck(file)) {
|
|
46
|
+
console.log(i18nText.getI18nMsg("vault.add.templateFile_invalid"));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const addAction = new Add(categoryId, file);
|
|
51
|
+
await addAction.add();
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.log(i18nText.getI18nMsg("vault.add.secrets_errorAdding"));
|
|
55
|
+
Logger.error(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=addcmd.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { Logger } from "../../js/logger/index.js";
|
|
4
|
+
import { Download } from "../Download.js";
|
|
5
|
+
import { Utilities, isMasterKeyExist } from "../../util/index.util.js";
|
|
6
|
+
import { getDownloadDefaults } from "../../commands/download/download.utils.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
const i18nText = new I18N();
|
|
9
|
+
export const downloadCmd = (program) => {
|
|
10
|
+
program
|
|
11
|
+
.command("download") //No I18N
|
|
12
|
+
.description(i18nText.getI18nMsg("vault.download.desc"))
|
|
13
|
+
.option("-id, --password-id <id>", //No I18N
|
|
14
|
+
i18nText.getI18nMsg("vault.download.option_passId") //No I18N
|
|
15
|
+
)
|
|
16
|
+
.option("-d,--dir <path>", i18nText.getI18nMsg("vault.download.option_dir"))
|
|
17
|
+
.option("--use-default", "uses default options for download", false)
|
|
18
|
+
.on("--help", () => {
|
|
19
|
+
console.log(`
|
|
20
|
+
Example :
|
|
21
|
+
zv download -id 2000000000015
|
|
22
|
+
zv download -id 2000000000015 -d ~/Desktop
|
|
23
|
+
|
|
24
|
+
`);
|
|
25
|
+
})
|
|
26
|
+
.action(async (comObj) => {
|
|
27
|
+
/*
|
|
28
|
+
* Generate Passwords and template
|
|
29
|
+
*/
|
|
30
|
+
const isConfigured = Utilities.isConfigured();
|
|
31
|
+
if (!isConfigured) {
|
|
32
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!await isMasterKeyExist()) {
|
|
36
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { useDefault } = comObj;
|
|
40
|
+
if (useDefault) {
|
|
41
|
+
const def = await getDownloadDefaults();
|
|
42
|
+
comObj = { ...comObj, ...def };
|
|
43
|
+
}
|
|
44
|
+
let { passwordId, dir } = comObj;
|
|
45
|
+
if (dir) {
|
|
46
|
+
dir = path.resolve(dir);
|
|
47
|
+
}
|
|
48
|
+
if (!passwordId) {
|
|
49
|
+
console.log("error: required field password-id not mentioned");
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
if (dir !== undefined && dir !== "") {
|
|
53
|
+
try {
|
|
54
|
+
const stats = fs.statSync(dir);
|
|
55
|
+
if (!stats.isDirectory()) {
|
|
56
|
+
console.log(i18nText.getI18nMsg("vault.download.dir_expectedDirectory"));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
console.log(i18nText.getI18nMsg("vault.download.dir_notWritable"), dir);
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const downloadActions = new Download(passwordId, dir);
|
|
68
|
+
await downloadActions.download();
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.log(i18nText.getI18nMsg("vault.download.errorDownloading"));
|
|
72
|
+
Logger.error(e);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=downloadcmd.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Utilities, isMasterKeyExist } from "../../util/index.util.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { Generate } from "../Generate.js";
|
|
4
|
+
import { PasswordOptions, PasswordGenerator, getComplexityOf } from "../PasswordGenerator.js";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import progress from "cli-progress";
|
|
7
|
+
import { getGenPassDefaults } from "../../commands/generate-password/generate-password.utils.js";
|
|
8
|
+
import { Logger } from "../../js/logger/index.js";
|
|
9
|
+
const _progress = progress;
|
|
10
|
+
export const generatePassword = (program) => {
|
|
11
|
+
program
|
|
12
|
+
.command('generate-password') //No I18N
|
|
13
|
+
.description('Password Generator')
|
|
14
|
+
.option('-g --use-password-policy', 'Generate a password based on the password policy', false)
|
|
15
|
+
.option('-p --policy-id <id>', 'Password Policy ID')
|
|
16
|
+
.option('-len --max-length <length>', 'Length of the password to be generated')
|
|
17
|
+
.option('-upper --include-upper-case', 'Include upper case characters', false)
|
|
18
|
+
.option('-lower --include-lower-case', 'Include lower case characters', false)
|
|
19
|
+
.option('-spl --special-character-count <count>', 'Include Special Characters')
|
|
20
|
+
.option('-number --include-numbers', 'Include numbers', false)
|
|
21
|
+
.option('-exclude --exclude-character <character>', 'Characters to be excluded', '')
|
|
22
|
+
.option("--use-default", "uses default options for generate-password", false)
|
|
23
|
+
.on('--help', () => {
|
|
24
|
+
console.log(`
|
|
25
|
+
Example:
|
|
26
|
+
zv generate-password --use-password-policy
|
|
27
|
+
zv generate-password --use-password-policy --policy-id 2000000000063
|
|
28
|
+
zv generate-password -len 10 -upper -lower -number -spl 3
|
|
29
|
+
zv generate-password -len 10 -lower -number -spl 0 -exclude 123
|
|
30
|
+
`);
|
|
31
|
+
})
|
|
32
|
+
.action(async (ComObj) => {
|
|
33
|
+
try {
|
|
34
|
+
const isConfigured = Utilities.isConfigured();
|
|
35
|
+
if (!isConfigured) {
|
|
36
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!await isMasterKeyExist()) {
|
|
40
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { useDefault } = ComObj;
|
|
44
|
+
if (useDefault) {
|
|
45
|
+
const def = await getGenPassDefaults();
|
|
46
|
+
ComObj = { ...ComObj, ...def };
|
|
47
|
+
}
|
|
48
|
+
var { usePasswordPolicy, policyId, includeUpperCase, includeLowerCase, specialCharacterCount, includeNumbers, excludeCharacter, maxLength } = ComObj;
|
|
49
|
+
var startWithLetter = undefined;
|
|
50
|
+
if (!maxLength && usePasswordPolicy === false && includeUpperCase === false && includeLowerCase === false && includeNumbers === false && (specialCharacterCount === undefined || specialCharacterCount === 0)) {
|
|
51
|
+
var generatepassword = new Generate();
|
|
52
|
+
var defaultpolicy = await generatepassword.getDefaultPasswordPloicy();
|
|
53
|
+
maxLength = defaultpolicy.max_length;
|
|
54
|
+
specialCharacterCount = defaultpolicy.no_of_special_characters;
|
|
55
|
+
startWithLetter = defaultpolicy.start_with_alphabet;
|
|
56
|
+
includeNumbers = defaultpolicy.enforce_numerals;
|
|
57
|
+
excludeCharacter = defaultpolicy.characters_not_allowed;
|
|
58
|
+
if (defaultpolicy.enforce_mixed_case) {
|
|
59
|
+
includeLowerCase = true;
|
|
60
|
+
includeUpperCase = true;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
includeUpperCase = true;
|
|
64
|
+
includeLowerCase = false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (usePasswordPolicy === true) {
|
|
68
|
+
var generatePassword = new Generate(policyId);
|
|
69
|
+
var policyDetails = await generatePassword.getPolicyDetails();
|
|
70
|
+
const { characters_not_allowed, min_length, enforce_mixed_case, no_of_special_characters, start_with_alphabet, enforce_numerals, enforce_special_characters, max_length } = policyDetails;
|
|
71
|
+
maxLength = max_length;
|
|
72
|
+
specialCharacterCount = no_of_special_characters;
|
|
73
|
+
startWithLetter = start_with_alphabet;
|
|
74
|
+
includeNumbers = enforce_numerals;
|
|
75
|
+
excludeCharacter = characters_not_allowed;
|
|
76
|
+
if (enforce_mixed_case) {
|
|
77
|
+
includeLowerCase = true;
|
|
78
|
+
includeUpperCase = true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
includeUpperCase = true;
|
|
82
|
+
includeLowerCase = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (!(includeLowerCase || includeUpperCase || parseInt(specialCharacterCount) == 0 || includeNumbers)) {
|
|
87
|
+
includeUpperCase = true;
|
|
88
|
+
includeLowerCase = true;
|
|
89
|
+
includeNumbers = true;
|
|
90
|
+
specialCharacterCount = (specialCharacterCount == 0 ? 1 : specialCharacterCount);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var option = new PasswordOptions(parseInt(maxLength), parseInt(specialCharacterCount), includeUpperCase, includeLowerCase, excludeCharacter, includeNumbers, startWithLetter);
|
|
94
|
+
const password = PasswordGenerator.generatePassword(option);
|
|
95
|
+
var complexity = getComplexityOf(password);
|
|
96
|
+
complexity = Math.round(complexity * 10) / 10;
|
|
97
|
+
console.log();
|
|
98
|
+
console.log('Password: ' + password);
|
|
99
|
+
console.log();
|
|
100
|
+
let meter = 'Password Strength: [' + chalk.green(' {bar} ') + ']' + ' {percentage}% '; //No I18N
|
|
101
|
+
if (complexity <= 45) {
|
|
102
|
+
meter = 'Password Strength: [' + chalk.red(' {bar} ') + ']' + ' {percentage}% '; //No I18N
|
|
103
|
+
}
|
|
104
|
+
else if (complexity <= 60) {
|
|
105
|
+
meter = 'Password Strength: [' + chalk.rgb(255, 165, 0)(' {bar} ') + ']' + ' {percentage}% '; //No I18N
|
|
106
|
+
}
|
|
107
|
+
else if (complexity <= 75) {
|
|
108
|
+
meter = 'Password Strength: [' + chalk.blue(' {bar} ') + ']' + ' {percentage}% '; //No I18N
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
meter = 'Password Strength: [' + chalk.green(' {bar} ') + ']' + ' {percentage}% '; //No I18N
|
|
112
|
+
}
|
|
113
|
+
const bar = new _progress.Bar({
|
|
114
|
+
format: meter,
|
|
115
|
+
barCompleteChar: '=',
|
|
116
|
+
barIncompleteChar: ' '
|
|
117
|
+
});
|
|
118
|
+
bar.start(100, 0);
|
|
119
|
+
bar.update(complexity);
|
|
120
|
+
bar.stop();
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
Logger.error(e);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=generate-passwordcmd.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
2
|
+
import { Utilities } from "../../util/index.util.js";
|
|
3
|
+
import { Logger } from "../../js/logger/index.js";
|
|
4
|
+
import { Generate } from "../Generate.js";
|
|
5
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
6
|
+
import { getGenTempDefaults } from "../../commands/generate-template/generate-template.util.js";
|
|
7
|
+
const i18nText = new I18N();
|
|
8
|
+
export const generateTemplate = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("generate-template") //No I18N
|
|
11
|
+
.description(i18nText.getI18nMsg("vault.generate.desc"))
|
|
12
|
+
.option("-c, --category-id <id>", i18nText.getI18nMsg("vault.generate.option_templateId")) //No I18N
|
|
13
|
+
.option("-w, --out-file [path]", i18nText.getI18nMsg("vault.generate.option_outFile")) //No I18N
|
|
14
|
+
.option("--use-default", "uses default options for generate-template", false)
|
|
15
|
+
.option("-o , --output [type]", i18nText.getI18nMsg("vault.generate.option_output"), //No I18N
|
|
16
|
+
"json" //No I18N
|
|
17
|
+
) //TODO get the default value from some config file
|
|
18
|
+
.on("--help", () => {
|
|
19
|
+
console.log(`
|
|
20
|
+
Example :
|
|
21
|
+
zv generate-template
|
|
22
|
+
zv generate-template -c 2000002716908
|
|
23
|
+
zv generate-template -c 2000000000015 -w D:/web-template.json
|
|
24
|
+
zv generate-template -c 2000000000015 -o xml -w D:/web-template.xml
|
|
25
|
+
zv generate-template -c 2000000000015 -o yaml -w D:/web-template.yaml
|
|
26
|
+
`
|
|
27
|
+
+ i18nText.getI18nMsg("vault.generate.example_note")); //No I18N
|
|
28
|
+
})
|
|
29
|
+
.action(async (comObj) => {
|
|
30
|
+
/*
|
|
31
|
+
* Generate Passwords and template
|
|
32
|
+
*/
|
|
33
|
+
const isConfigured = Utilities.isConfigured();
|
|
34
|
+
if (!isConfigured) {
|
|
35
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!await isMasterKeyExist()) {
|
|
39
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const { useDefault } = comObj;
|
|
43
|
+
if (useDefault) {
|
|
44
|
+
const def = await getGenTempDefaults();
|
|
45
|
+
comObj = { ...comObj, ...def };
|
|
46
|
+
}
|
|
47
|
+
const { categoryId, output, outFile } = comObj;
|
|
48
|
+
try {
|
|
49
|
+
const GenerateAction = new Generate(undefined, categoryId, 'template', //No I18N
|
|
50
|
+
output, outFile);
|
|
51
|
+
await GenerateAction.generate();
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.log(i18nText.getI18nMsg("vault.generate.templates_errorGenerating"));
|
|
55
|
+
Logger.error(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=generate-templatecmd.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Utilities } from "../../util/index.util.js";
|
|
2
|
+
import { Default } from "../Default.js";
|
|
3
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
4
|
+
import { getDefaults } from "../../commands/get-default/get-default.utils.js";
|
|
5
|
+
import { Logger } from "../../js/logger/index.js";
|
|
6
|
+
export const getDefaultCmd = (program) => {
|
|
7
|
+
program
|
|
8
|
+
.command("get-default") //No I18N
|
|
9
|
+
.description("Display default values of the commands")
|
|
10
|
+
.option("-c --command <command>", //No I18N
|
|
11
|
+
"Command to display values of specific defaults" //No I18N
|
|
12
|
+
)
|
|
13
|
+
.option("--use-default", "uses default options for get-default", false)
|
|
14
|
+
.on("--help", () => {
|
|
15
|
+
console.log(`
|
|
16
|
+
Example:
|
|
17
|
+
zv get-default
|
|
18
|
+
zv get-default --command get,search`);
|
|
19
|
+
})
|
|
20
|
+
.action(async (ComObj) => {
|
|
21
|
+
try {
|
|
22
|
+
const isConfigured = Utilities.isConfigured();
|
|
23
|
+
if (!isConfigured) {
|
|
24
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock" //No I18N
|
|
25
|
+
);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!(await isMasterKeyExist())) {
|
|
29
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands" //No I18N
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { useDefault } = ComObj;
|
|
34
|
+
if (useDefault) {
|
|
35
|
+
const def = await getDefaults();
|
|
36
|
+
ComObj = { ...ComObj, ...def };
|
|
37
|
+
}
|
|
38
|
+
const command = ComObj.command;
|
|
39
|
+
let getDefault = new Default(undefined, command);
|
|
40
|
+
await getDefault.getDefaults();
|
|
41
|
+
getDefault.formatDefaultasTable();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
Logger.error(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=get-defaultcmd.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
2
|
+
import { Logger } from "../../js/logger/index.js";
|
|
3
|
+
import { Utilities } from "../../util/index.util.js";
|
|
4
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
5
|
+
import { Get } from "../Get.js";
|
|
6
|
+
import { getGetDefaults } from "../../commands/get/get.utils.js";
|
|
7
|
+
const i18nText = new I18N();
|
|
8
|
+
export const get = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("get") // NO I18N
|
|
11
|
+
.description(i18nText.getI18nMsg("vault.get.desc"))
|
|
12
|
+
.option("-id, --password-id [key]", i18nText.getI18nMsg("vault.get.option_secretId"))
|
|
13
|
+
.option("--not-safe", i18nText.getI18nMsg("vault.get.option_notSafe"), false)
|
|
14
|
+
.option("-w, --out-file [path]", i18nText.getI18nMsg("vault.get.option_outFile"))
|
|
15
|
+
.option("--use-default", "uses default options for get", false)
|
|
16
|
+
.option("-o , --output [type]", i18nText.getI18nMsg("vault.get.option_output"), //No I18N
|
|
17
|
+
"table" //NO I18N
|
|
18
|
+
) //TODO get the default value from some config file
|
|
19
|
+
.on("--help", () => {
|
|
20
|
+
console.log(`
|
|
21
|
+
Example :
|
|
22
|
+
zv get -id 2000002716908
|
|
23
|
+
zv get -id 2000002716908 --not-safe
|
|
24
|
+
zv get -id 2000002716908 --output json
|
|
25
|
+
zv get -id 2000003713122 --output json -w D:/put.json
|
|
26
|
+
`);
|
|
27
|
+
})
|
|
28
|
+
.action(async (comObj) => {
|
|
29
|
+
/*
|
|
30
|
+
* Get Details based the option
|
|
31
|
+
*/
|
|
32
|
+
const isConfigured = Utilities.isConfigured();
|
|
33
|
+
if (!isConfigured) {
|
|
34
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!await isMasterKeyExist()) {
|
|
38
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { useDefault } = comObj;
|
|
42
|
+
if (useDefault) {
|
|
43
|
+
const getDef = await getGetDefaults();
|
|
44
|
+
comObj = { ...comObj, ...getDef };
|
|
45
|
+
}
|
|
46
|
+
const { passwordId, outFile, output, notSafe } = comObj;
|
|
47
|
+
try {
|
|
48
|
+
const getAction = new Get(passwordId, outFile, output, notSafe);
|
|
49
|
+
await getAction.get();
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.log(i18nText.getI18nMsg("vault.get.secrets_errorFetching"));
|
|
53
|
+
Logger.error(e);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=getcmd.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
2
|
+
import { Utilities } from "../../util/index.util.js";
|
|
3
|
+
import { Logger } from "../../js/logger/index.js";
|
|
4
|
+
import { List } from "../List.js";
|
|
5
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
6
|
+
import { getListDefaults } from "../../commands/list/list.utils.js";
|
|
7
|
+
const i18nText = new I18N();
|
|
8
|
+
export const list = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("list <category>", {
|
|
11
|
+
category: i18nText.getI18nMsg("vault.list.category") //NO I18N
|
|
12
|
+
})
|
|
13
|
+
.option("-c --category-id <key>", i18nText.getI18nMsg("vault.list.option_type"))
|
|
14
|
+
.option("-show --not-safe", i18nText.getI18nMsg("vault.list.option_showPassword"), false)
|
|
15
|
+
.option("-V --verbose", i18nText.getI18nMsg("vault.list.option_verbose"), false)
|
|
16
|
+
.option("--use-default", "uses default options for list", false)
|
|
17
|
+
.description(i18nText.getI18nMsg("vault.list.desc"))
|
|
18
|
+
.on('--help', () => {
|
|
19
|
+
console.log(`
|
|
20
|
+
Example:
|
|
21
|
+
zv list password
|
|
22
|
+
zv list category
|
|
23
|
+
zv list password -c 2000000000015
|
|
24
|
+
zv list password -c 2000000000015 -V
|
|
25
|
+
zv list password -c 2000000000015 -V --not-safe
|
|
26
|
+
`);
|
|
27
|
+
})
|
|
28
|
+
.action(async (category, comObj) => {
|
|
29
|
+
const isConfigured = Utilities.isConfigured();
|
|
30
|
+
if (!isConfigured) {
|
|
31
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!await isMasterKeyExist()) {
|
|
35
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { useDefault } = comObj;
|
|
39
|
+
if (useDefault) {
|
|
40
|
+
const listDef = await getListDefaults();
|
|
41
|
+
comObj = { ...comObj, ...listDef };
|
|
42
|
+
}
|
|
43
|
+
const { categoryId, notSafe, verbose } = comObj;
|
|
44
|
+
try {
|
|
45
|
+
const listPassword = new List(categoryId, notSafe, category, verbose);
|
|
46
|
+
await listPassword.listSecrets();
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
console.log(i18nText.getI18nMsg("vault.list.secrets_errorListing"));
|
|
50
|
+
Logger.error(e);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=listcmd.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
2
|
+
import { Logout } from "../Logout.js";
|
|
3
|
+
import { Utilities } from "../../util/index.util.js";
|
|
4
|
+
import { Logger } from "../../js/logger/index.js";
|
|
5
|
+
const i18nText = new I18N();
|
|
6
|
+
export const logoutCmd = (program) => {
|
|
7
|
+
program
|
|
8
|
+
.command("logout") //No I18N
|
|
9
|
+
.description(i18nText.getI18nMsg("vault.logout.desc"))
|
|
10
|
+
.on("--help", () => {
|
|
11
|
+
console.log(`
|
|
12
|
+
Example :
|
|
13
|
+
zv logout
|
|
14
|
+
`);
|
|
15
|
+
})
|
|
16
|
+
.action(async () => {
|
|
17
|
+
try {
|
|
18
|
+
const isConfigured = Utilities.isConfigured();
|
|
19
|
+
if (!isConfigured) {
|
|
20
|
+
console.log("You are already logged out of Zoho Vault account");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var logout = new Logout();
|
|
24
|
+
await logout.clearAllFiles();
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
Logger.error(e);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=logoutcmd.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Utilities } from "../../util/index.util.js";
|
|
2
|
+
import { Default } from "../Default.js";
|
|
3
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
4
|
+
import { getDefaults } from "../../commands/set-default/set-default.utils.js";
|
|
5
|
+
import { getDecryptedCredentials, insertToDB } from "../../util/dbutils/db.utils.js";
|
|
6
|
+
import { generateWorkspaceHash } from "../../commands/login/login.utils.js";
|
|
7
|
+
import { Logger } from "../../js/logger/index.js";
|
|
8
|
+
export const setDefaultCmd = (program) => {
|
|
9
|
+
program
|
|
10
|
+
.command("set-default") //No I18N
|
|
11
|
+
.description("Set default values for commands")
|
|
12
|
+
.option('-c --command <command>', "Set default values for multiple commands (Comma Separated)")
|
|
13
|
+
.option('-clr --clear-old-defaults', 'Clear all current default values')
|
|
14
|
+
.on('--help', () => {
|
|
15
|
+
console.log(`
|
|
16
|
+
Example :
|
|
17
|
+
zv set-default
|
|
18
|
+
zv set-default -c add,get,list
|
|
19
|
+
`);
|
|
20
|
+
})
|
|
21
|
+
.action(async (ComObj) => {
|
|
22
|
+
const isConfigured = Utilities.isConfigured();
|
|
23
|
+
if (!isConfigured) {
|
|
24
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!await isMasterKeyExist()) {
|
|
28
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { clearOldDefaults } = ComObj;
|
|
32
|
+
if (clearOldDefaults) {
|
|
33
|
+
const data = await getDecryptedCredentials(generateWorkspaceHash());
|
|
34
|
+
data.defaults = {};
|
|
35
|
+
await insertToDB(data);
|
|
36
|
+
console.log("Cleared all old default values successfully");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// console.log(data);
|
|
40
|
+
const { useDefault } = ComObj;
|
|
41
|
+
if (useDefault) {
|
|
42
|
+
const def = await getDefaults();
|
|
43
|
+
ComObj = { ...ComObj, ...def };
|
|
44
|
+
}
|
|
45
|
+
const optionCommand = {};
|
|
46
|
+
for (let opt in program.commands) {
|
|
47
|
+
let flags = {};
|
|
48
|
+
const containsUseDeafult = program.commands[opt].options.some(flag => flag.long.includes("use-default"));
|
|
49
|
+
if (!containsUseDeafult) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
for (let flag in program.commands[opt].options) {
|
|
53
|
+
const fladg = program.commands[opt].options[flag];
|
|
54
|
+
if (fladg.long === "--use-default") {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
flags[program.commands[opt].options[flag].long.slice(2)] = {
|
|
58
|
+
'flag': program.commands[opt].options[flag].long,
|
|
59
|
+
description: program.commands[opt].options[flag].description
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (Object.keys(flags).length > 0) {
|
|
63
|
+
optionCommand[program.commands[opt]._name] = flags;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let setDefault = new Default(optionCommand, ComObj.command, !ComObj.clearOldDefaults);
|
|
67
|
+
try {
|
|
68
|
+
await setDefault.setDefaults();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
Logger.error(err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=set-default.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { I18N } from "../../js/I18n/index.js";
|
|
2
|
+
import { Update } from "../Update.js";
|
|
3
|
+
import { Utilities } from "../../util/index.util.js";
|
|
4
|
+
import { Logger } from "../../js/logger/index.js";
|
|
5
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
6
|
+
const i18nText = new I18N();
|
|
7
|
+
export const updateCmd = (program) => {
|
|
8
|
+
program
|
|
9
|
+
.command("update") //No I18N
|
|
10
|
+
.description(i18nText.getI18nMsg("vault.update.desc"))
|
|
11
|
+
.requiredOption("-id, --password-id <id>", i18nText.getI18nMsg("vault.update.option_passwordId"))
|
|
12
|
+
.on("--help", () => {
|
|
13
|
+
console.log(`
|
|
14
|
+
Example :
|
|
15
|
+
zv update -id 2000001954220
|
|
16
|
+
|
|
17
|
+
`
|
|
18
|
+
+ i18nText.getI18nMsg("vault.update.example_note")); //No I18N
|
|
19
|
+
})
|
|
20
|
+
.action(async (comObj) => {
|
|
21
|
+
/*
|
|
22
|
+
* Generate Passwords and template
|
|
23
|
+
*/
|
|
24
|
+
const isConfigured = Utilities.isConfigured();
|
|
25
|
+
if (!isConfigured) {
|
|
26
|
+
console.log("You are not logged in to your Zoho account yet. Please log in to your Zoho account using zv login, then access your account using zv unlock");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!await isMasterKeyExist()) {
|
|
30
|
+
console.log("Please unlock your Zoho Vault account using 'zv unlock' before using other commands");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { passwordId: id } = comObj;
|
|
34
|
+
try {
|
|
35
|
+
const updateActions = new Update(id);
|
|
36
|
+
await updateActions.interactiveUpdate();
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
Logger.error(e);
|
|
40
|
+
console.log(i18nText.getI18nMsg("vault.update.secrets_errorUpdating"));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=updatecmd.js.map
|