@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
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# ZohoVault CLI
|
|
2
|
+
|
|
3
|
+
Steps to get CLI locally
|
|
4
|
+
|
|
5
|
+
- Run `npm install --registry http://cm-npmregistry` to get dependency packages in package.json. The npm packages present in cm-npmregistry are approved, and others should be approved by legal team.
|
|
6
|
+
- Run `npm run setup` to set up the developer environment.
|
|
7
|
+
- Run `npm run dev` to compile the code and watch for current changes
|
|
8
|
+
- Run `npm run build` to build zv.cjs file
|
|
9
|
+
- For generating binaries based on the os, run one of the following commands:
|
|
10
|
+
- Windows: `npm run pkg:win`
|
|
11
|
+
- Linux: `npm run pkg:lin`
|
|
12
|
+
- MacOS: `npm run pkg:mac`
|
|
13
|
+
- Linux-arm: `npm run pkg:lin-arm`
|
|
14
|
+
- Mac-arm: `npm run pkg:mac-arm`
|
|
15
|
+
The binary will be present in `bundle/<os>/`
|
|
16
|
+
- For generating all five binaries run `npm run pkg`.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AddOpts } from "./add.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case AddOpts.CATEGORY_ID:
|
|
7
|
+
return "categoryId";
|
|
8
|
+
case AddOpts.FILE:
|
|
9
|
+
return "file";
|
|
10
|
+
default:
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const constructDefaultOpts = (opts) => {
|
|
15
|
+
if (!(OPTIONS.ADD in opts)) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const res = {};
|
|
19
|
+
const { add } = opts;
|
|
20
|
+
for (const key in add) {
|
|
21
|
+
const tKey = key;
|
|
22
|
+
const mkey = getKey(tKey);
|
|
23
|
+
if (add.hasOwnProperty(tKey)) {
|
|
24
|
+
res[mkey] = add[tKey];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
};
|
|
29
|
+
export const getAddDefaults = async () => {
|
|
30
|
+
const def = new Default(undefined, undefined);
|
|
31
|
+
const options = await def.getDefaults();
|
|
32
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
33
|
+
return defaultOpts;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=add.util.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DownloadOpts } from "./download.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case DownloadOpts.PASSWORD_ID:
|
|
7
|
+
return "passwordId";
|
|
8
|
+
case DownloadOpts.DIR:
|
|
9
|
+
return "dir";
|
|
10
|
+
default:
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const constructDefaultOpts = (opts) => {
|
|
15
|
+
if (!(OPTIONS.DOWNLOAD in opts)) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const res = {};
|
|
19
|
+
const { download } = opts;
|
|
20
|
+
for (const key in download) {
|
|
21
|
+
const tKey = key;
|
|
22
|
+
const mkey = getKey(tKey);
|
|
23
|
+
if (download.hasOwnProperty(tKey)) {
|
|
24
|
+
res[mkey] = download[tKey];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
};
|
|
29
|
+
export const getDownloadDefaults = async () => {
|
|
30
|
+
const def = new Default(undefined, undefined);
|
|
31
|
+
const options = await def.getDefaults();
|
|
32
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
33
|
+
return defaultOpts;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=download.utils.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var GeneratePasswordOpts;
|
|
2
|
+
(function (GeneratePasswordOpts) {
|
|
3
|
+
GeneratePasswordOpts["USE_PASSWORD_POLICY"] = "--use-password-policy";
|
|
4
|
+
GeneratePasswordOpts["POLICY_ID"] = "--policy-id";
|
|
5
|
+
GeneratePasswordOpts["MAX_LENGTH"] = "--max-length";
|
|
6
|
+
GeneratePasswordOpts["INCLUDE_UPPER_CASE"] = "--include-upper-case";
|
|
7
|
+
GeneratePasswordOpts["INCLUDE_LOWER_CASE"] = "--include-lower-case";
|
|
8
|
+
GeneratePasswordOpts["SPECIAL_CHARACTER_COUNT"] = "--special-character-count";
|
|
9
|
+
GeneratePasswordOpts["INCLUDE_NUMBERS"] = "--include-numbers";
|
|
10
|
+
GeneratePasswordOpts["EXCLUDE_CHARACTER"] = "--exclude-character";
|
|
11
|
+
})(GeneratePasswordOpts || (GeneratePasswordOpts = {}));
|
|
12
|
+
//# sourceMappingURL=generate-password.const.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { GeneratePasswordOpts } from "./generate-password.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case GeneratePasswordOpts.USE_PASSWORD_POLICY:
|
|
7
|
+
return "usePasswordPolicy";
|
|
8
|
+
case GeneratePasswordOpts.POLICY_ID:
|
|
9
|
+
return "policyId";
|
|
10
|
+
case GeneratePasswordOpts.MAX_LENGTH:
|
|
11
|
+
return "maxLength";
|
|
12
|
+
case GeneratePasswordOpts.INCLUDE_UPPER_CASE:
|
|
13
|
+
return "includeUpperCase";
|
|
14
|
+
case GeneratePasswordOpts.INCLUDE_LOWER_CASE:
|
|
15
|
+
return "includeLowerCase";
|
|
16
|
+
case GeneratePasswordOpts.SPECIAL_CHARACTER_COUNT:
|
|
17
|
+
return "specialCharacterCount";
|
|
18
|
+
case GeneratePasswordOpts.INCLUDE_NUMBERS:
|
|
19
|
+
return "includeNumbers";
|
|
20
|
+
case GeneratePasswordOpts.EXCLUDE_CHARACTER:
|
|
21
|
+
return "excludeCharacter";
|
|
22
|
+
default:
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const getVal = (key, generatePassword) => {
|
|
27
|
+
if ([
|
|
28
|
+
GeneratePasswordOpts.USE_PASSWORD_POLICY,
|
|
29
|
+
GeneratePasswordOpts.INCLUDE_LOWER_CASE,
|
|
30
|
+
GeneratePasswordOpts.INCLUDE_UPPER_CASE,
|
|
31
|
+
GeneratePasswordOpts.INCLUDE_NUMBERS
|
|
32
|
+
].includes(key)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return generatePassword[key];
|
|
36
|
+
};
|
|
37
|
+
export const constructDefaultOpts = (opts) => {
|
|
38
|
+
if (!(OPTIONS.GENERATE_PASSWORD in opts)) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
const res = {};
|
|
42
|
+
const { "generate-password": generatePassword } = opts;
|
|
43
|
+
for (const key in generatePassword) {
|
|
44
|
+
const tKey = key;
|
|
45
|
+
const mkey = getKey(tKey);
|
|
46
|
+
if (generatePassword.hasOwnProperty(tKey)) {
|
|
47
|
+
res[mkey] = getVal(tKey, generatePassword);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return res;
|
|
51
|
+
};
|
|
52
|
+
export const getGenPassDefaults = async () => {
|
|
53
|
+
const def = new Default(undefined, undefined);
|
|
54
|
+
const options = await def.getDefaults();
|
|
55
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
56
|
+
return defaultOpts;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=generate-password.utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var GenerateTemplateOpts;
|
|
2
|
+
(function (GenerateTemplateOpts) {
|
|
3
|
+
GenerateTemplateOpts["CATEGORY_ID"] = "--category-id";
|
|
4
|
+
GenerateTemplateOpts["OUT_FILE"] = "--out-file";
|
|
5
|
+
GenerateTemplateOpts["OUTPUT"] = "--output";
|
|
6
|
+
})(GenerateTemplateOpts || (GenerateTemplateOpts = {}));
|
|
7
|
+
//# sourceMappingURL=generate-template.const.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GenerateTemplateOpts } from "./generate-template.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case GenerateTemplateOpts.CATEGORY_ID:
|
|
7
|
+
return "categoryId";
|
|
8
|
+
case GenerateTemplateOpts.OUT_FILE:
|
|
9
|
+
return "outFile";
|
|
10
|
+
case GenerateTemplateOpts.OUTPUT:
|
|
11
|
+
return "output";
|
|
12
|
+
default:
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const constructDefaultOpts = (opts) => {
|
|
17
|
+
if (!(OPTIONS.GENERATE_TEMPLATE in opts)) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const res = {};
|
|
21
|
+
const { "generate-template": generateTemplate } = opts;
|
|
22
|
+
for (const key in generateTemplate) {
|
|
23
|
+
const tKey = key;
|
|
24
|
+
const mkey = getKey(tKey);
|
|
25
|
+
if (generateTemplate.hasOwnProperty(tKey)) {
|
|
26
|
+
res[mkey] = generateTemplate[tKey];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return res;
|
|
30
|
+
};
|
|
31
|
+
export const getGenTempDefaults = async () => {
|
|
32
|
+
const def = new Default(undefined, undefined);
|
|
33
|
+
const options = await def.getDefaults();
|
|
34
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
35
|
+
return defaultOpts;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=generate-template.util.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GetOpts } from "./get.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case GetOpts.ID:
|
|
7
|
+
return "passwordId";
|
|
8
|
+
case GetOpts.NOT_SAFE:
|
|
9
|
+
return "notSafe";
|
|
10
|
+
case GetOpts.OUT_FILE:
|
|
11
|
+
return "outFile";
|
|
12
|
+
case GetOpts.OUTPUT:
|
|
13
|
+
return "output";
|
|
14
|
+
default:
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const getValue = (key, get) => {
|
|
19
|
+
if ([GetOpts.NOT_SAFE].includes(key)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return get[key];
|
|
23
|
+
};
|
|
24
|
+
export const constructDefaultOpts = (opts) => {
|
|
25
|
+
if (!(OPTIONS.GET in opts)) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
const res = {};
|
|
29
|
+
const { get } = opts;
|
|
30
|
+
for (const key in get) {
|
|
31
|
+
const tKey = key;
|
|
32
|
+
const mkey = getKey(tKey);
|
|
33
|
+
if (get.hasOwnProperty(tKey)) {
|
|
34
|
+
res[mkey] = getValue(tKey, get);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return res;
|
|
38
|
+
};
|
|
39
|
+
export const getGetDefaults = async () => {
|
|
40
|
+
const def = new Default(undefined, undefined);
|
|
41
|
+
const options = await def.getDefaults();
|
|
42
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
43
|
+
return defaultOpts;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=get.utils.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GetDefaultOpts } from "./get-default.const.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { Default } from "../../old/Default.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case GetDefaultOpts.COMMAND:
|
|
7
|
+
return "command";
|
|
8
|
+
default:
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const constructDefaultOpts = (opts) => {
|
|
13
|
+
if (!(OPTIONS.GET_DEFAULT in opts)) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const res = {};
|
|
17
|
+
const { "get-default": getDefault } = opts;
|
|
18
|
+
for (const key in getDefault) {
|
|
19
|
+
const tKey = key;
|
|
20
|
+
const mkey = getKey(tKey);
|
|
21
|
+
if (getDefault.hasOwnProperty(tKey)) {
|
|
22
|
+
res[mkey] = getDefault[tKey];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return res;
|
|
26
|
+
};
|
|
27
|
+
export const getDefaults = async () => {
|
|
28
|
+
const def = new Default(undefined, undefined);
|
|
29
|
+
const options = await def.getDefaults();
|
|
30
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
31
|
+
return defaultOpts;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=get-default.utils.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Default } from "../../old/Default.js";
|
|
2
|
+
import { OPTIONS } from "../../util/consts.util.js";
|
|
3
|
+
import { ListOpts } from "./list.const.js";
|
|
4
|
+
export const getKey = (key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case ListOpts.CATEGORY_ID:
|
|
7
|
+
return "categoryId";
|
|
8
|
+
case ListOpts.NOT_SAFE:
|
|
9
|
+
return "notSafe";
|
|
10
|
+
case ListOpts.VERBOSE:
|
|
11
|
+
return "verbose";
|
|
12
|
+
default:
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const getValue = (key, list) => {
|
|
17
|
+
if ([ListOpts.NOT_SAFE, ListOpts.VERBOSE].includes(key)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return list[key];
|
|
21
|
+
};
|
|
22
|
+
export const constructDefaultOpts = (opts) => {
|
|
23
|
+
if (!(OPTIONS.LIST in opts)) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
const res = {};
|
|
27
|
+
const { list } = opts;
|
|
28
|
+
for (const key in list) {
|
|
29
|
+
const tKey = key;
|
|
30
|
+
const mkey = getKey(tKey);
|
|
31
|
+
if (list.hasOwnProperty(tKey)) {
|
|
32
|
+
res[mkey] = getValue(tKey, list);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return res;
|
|
36
|
+
};
|
|
37
|
+
export const getListDefaults = async () => {
|
|
38
|
+
const def = new Default(undefined, undefined);
|
|
39
|
+
const options = await def.getDefaults();
|
|
40
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
41
|
+
return defaultOpts;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=list.utils.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { showError } from "../../util/print.util.js";
|
|
2
|
+
import { removeMasterKey } from "./lock.utils.js";
|
|
3
|
+
export const lockAction = async () => {
|
|
4
|
+
try {
|
|
5
|
+
await removeMasterKey();
|
|
6
|
+
}
|
|
7
|
+
catch (err) {
|
|
8
|
+
if (err instanceof Error) {
|
|
9
|
+
showError(err.message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=lock.action.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isMasterKeyExist } from "../../util/index.util.js";
|
|
2
|
+
import { getCredentials, getZvDB, insertToTable } from "../../util/dbutils/db.utils.js";
|
|
3
|
+
import { generateWorkspaceHash } from "../login/login.utils.js";
|
|
4
|
+
import { decryptString, encryptString } from "../../util/encryptionutil/encryption.uitl.js";
|
|
5
|
+
export const removeMasterKeyFromDB = async () => {
|
|
6
|
+
const db = getZvDB();
|
|
7
|
+
return new Promise(async (resolve, reject) => {
|
|
8
|
+
try {
|
|
9
|
+
const data = getCredentials(generateWorkspaceHash());
|
|
10
|
+
if (!data) {
|
|
11
|
+
resolve(true);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const { credentials, hasmasterkey } = data;
|
|
15
|
+
if (hasmasterkey === "false") {
|
|
16
|
+
resolve(true);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const decryptedCredentials = JSON.parse(await decryptString(credentials));
|
|
20
|
+
if (!decryptedCredentials) {
|
|
21
|
+
resolve(true);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
decryptedCredentials.masterkey = "";
|
|
25
|
+
data.credentials = await encryptString(JSON.stringify(decryptedCredentials));
|
|
26
|
+
data.hasmasterkey = "false";
|
|
27
|
+
insertToTable(db, data);
|
|
28
|
+
resolve(true);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
reject(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const removeMasterKey = () => {
|
|
36
|
+
return new Promise(async (resolve, reject) => {
|
|
37
|
+
try {
|
|
38
|
+
const doesMasterKeyExist = await isMasterKeyExist();
|
|
39
|
+
if (!doesMasterKeyExist) {
|
|
40
|
+
console.log("Your Zoho Vault session has already been ended.");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await removeMasterKeyFromDB();
|
|
44
|
+
console.log("Your Zoho Vault account is locked");
|
|
45
|
+
resolve(true);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=lock.utils.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { checkValidDC, getUserConsentAndCreateConfig } from "./login.utils.js";
|
|
2
|
+
import { Default } from "../../old/Default.js";
|
|
3
|
+
import { constructDefaultOpts } from "./login.utils.js";
|
|
4
|
+
export const loginAction = async (option) => {
|
|
5
|
+
try {
|
|
6
|
+
const { useDefault } = option;
|
|
7
|
+
if (useDefault) {
|
|
8
|
+
const def = new Default(undefined, undefined);
|
|
9
|
+
const options = await def.getDefaults();
|
|
10
|
+
const defaultOpts = constructDefaultOpts(options);
|
|
11
|
+
option = { ...option, ...defaultOpts };
|
|
12
|
+
}
|
|
13
|
+
const { dc } = option;
|
|
14
|
+
const dcLowerCase = dc.toLocaleLowerCase();
|
|
15
|
+
await checkValidDC(dcLowerCase);
|
|
16
|
+
await getUserConsentAndCreateConfig(dcLowerCase);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.log("Operation ended unexpectedly while logging in");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=login.action.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DC } from "../../util/consts.util.js";
|
|
2
|
+
export const API_DOMAIN = {
|
|
3
|
+
[DC.US]: "https://www.zohoapis.com",
|
|
4
|
+
[DC.EU]: "https://www.zohoapis.eu",
|
|
5
|
+
[DC.AU]: "https://www.zohoapis.com.au",
|
|
6
|
+
[DC.IN]: "https://www.zohoapis.in",
|
|
7
|
+
[DC.CN]: "https://www.zohoapis.com.cn",
|
|
8
|
+
};
|
|
9
|
+
export const API_DOMAIN_TO_DC = Object.fromEntries(Object.entries(API_DOMAIN).map(([dc, domain]) => [domain, dc]));
|
|
10
|
+
//# sourceMappingURL=login.const.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const loginHelp = () => {
|
|
2
|
+
console.log(`
|
|
3
|
+
Example :
|
|
4
|
+
zv login
|
|
5
|
+
zv login --dc eu
|
|
6
|
+
Note:
|
|
7
|
+
- You can identify DC from the domain you login.
|
|
8
|
+
- If you login to vault.zoho.eu then you domain is eu.
|
|
9
|
+
`);
|
|
10
|
+
};
|
|
11
|
+
export default loginHelp;
|
|
12
|
+
//# sourceMappingURL=login.help.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import loginHelp from "./login.help.js";
|
|
2
|
+
import { loginAction } from "./login.action.js";
|
|
3
|
+
export const login = (program) => {
|
|
4
|
+
program
|
|
5
|
+
.command("login")
|
|
6
|
+
.description("Log in to your Zoho Vault account") //No I18N
|
|
7
|
+
// .option("-p, --config-path [path]", "Path where your configuration details will be stored") //No I18N
|
|
8
|
+
.option("--dc [loc]", "DC in which your account is located eg: US | EU | IN | AU | COM.CN ", //No I18N
|
|
9
|
+
"us")
|
|
10
|
+
.on('--help', () => {
|
|
11
|
+
loginHelp();
|
|
12
|
+
})
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
await loginAction(options);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=login.js.map
|