@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.
Files changed (102) hide show
  1. package/README.md +16 -0
  2. package/out/commands/add/add.const.js +6 -0
  3. package/out/commands/add/add.types.js +2 -0
  4. package/out/commands/add/add.util.js +35 -0
  5. package/out/commands/download/download.const.js +6 -0
  6. package/out/commands/download/download.types.js +2 -0
  7. package/out/commands/download/download.utils.js +35 -0
  8. package/out/commands/generate-password/generate-password.const.js +12 -0
  9. package/out/commands/generate-password/generate-password.types.js +2 -0
  10. package/out/commands/generate-password/generate-password.utils.js +58 -0
  11. package/out/commands/generate-template/generate-template.const.js +7 -0
  12. package/out/commands/generate-template/generate-template.types.js +2 -0
  13. package/out/commands/generate-template/generate-template.util.js +37 -0
  14. package/out/commands/get/get.const.js +8 -0
  15. package/out/commands/get/get.types.js +2 -0
  16. package/out/commands/get/get.utils.js +45 -0
  17. package/out/commands/get-default/get-default.const.js +5 -0
  18. package/out/commands/get-default/get-default.types.js +2 -0
  19. package/out/commands/get-default/get-default.utils.js +33 -0
  20. package/out/commands/list/list.const.js +7 -0
  21. package/out/commands/list/list.types.js +2 -0
  22. package/out/commands/list/list.utils.js +43 -0
  23. package/out/commands/lock/lock.action.js +13 -0
  24. package/out/commands/lock/lock.js +10 -0
  25. package/out/commands/lock/lock.utils.js +52 -0
  26. package/out/commands/login/login.action.js +22 -0
  27. package/out/commands/login/login.const.js +10 -0
  28. package/out/commands/login/login.help.js +12 -0
  29. package/out/commands/login/login.js +17 -0
  30. package/out/commands/login/login.types.js +5 -0
  31. package/out/commands/login/login.utils.js +307 -0
  32. package/out/commands/reset/reset.action.js +28 -0
  33. package/out/commands/reset/reset.help.js +8 -0
  34. package/out/commands/reset/reset.js +14 -0
  35. package/out/commands/reset/reset.utils.js +2 -0
  36. package/out/commands/search/search.action.js +30 -0
  37. package/out/commands/search/search.constants.js +14 -0
  38. package/out/commands/search/search.help.js +6 -0
  39. package/out/commands/search/search.js +26 -0
  40. package/out/commands/search/search.types.js +16 -0
  41. package/out/commands/search/search.utils.js +61 -0
  42. package/out/commands/set-default/set-default.const.js +6 -0
  43. package/out/commands/set-default/set-default.types.js +2 -0
  44. package/out/commands/set-default/set-default.utils.js +39 -0
  45. package/out/commands/unlock/unlock.action.js +23 -0
  46. package/out/commands/unlock/unlock.help.js +2 -0
  47. package/out/commands/unlock/unlock.js +12 -0
  48. package/out/commands/unlock/unlock.type.js +2 -0
  49. package/out/commands/unlock/unlock.utils.js +133 -0
  50. package/out/js/I18n/index.js +80 -0
  51. package/out/js/I18n/resources/CLI_I18N_en.js +173 -0
  52. package/out/js/I18n/resources/CLI_I18N_es.js +3 -0
  53. package/out/js/I18n/resources/CLI_I18N_fr.js +3 -0
  54. package/out/js/I18n/resources/CLI_I18N_nl.js +3 -0
  55. package/out/js/I18n/resources/CLI_I18N_pt.js +3 -0
  56. package/out/js/I18n/resources/CLI_I18N_zh.js +3 -0
  57. package/out/js/crypto/aes.js +225 -0
  58. package/out/js/crypto/index.js +139 -0
  59. package/out/js/crypto/rsa.js +1945 -0
  60. package/out/js/crypto/zohovault.js +671 -0
  61. package/out/js/logger/index.js +10 -0
  62. package/out/old/Add.js +590 -0
  63. package/out/old/Default.js +209 -0
  64. package/out/old/Download.js +69 -0
  65. package/out/old/Generate.js +171 -0
  66. package/out/old/Get.js +225 -0
  67. package/out/old/List.js +197 -0
  68. package/out/old/Login.js +287 -0
  69. package/out/old/Logout.js +21 -0
  70. package/out/old/PasswordGenerator.js +718 -0
  71. package/out/old/PasswordPolicies.js +21 -0
  72. package/out/old/PasswordTypes.js +33 -0
  73. package/out/old/Update.js +682 -0
  74. package/out/old/cmd/addcmd.js +59 -0
  75. package/out/old/cmd/downloadcmd.js +76 -0
  76. package/out/old/cmd/generate-passwordcmd.js +127 -0
  77. package/out/old/cmd/generate-templatecmd.js +59 -0
  78. package/out/old/cmd/get-defaultcmd.js +48 -0
  79. package/out/old/cmd/getcmd.js +57 -0
  80. package/out/old/cmd/listcmd.js +54 -0
  81. package/out/old/cmd/logoutcmd.js +31 -0
  82. package/out/old/cmd/set-default.js +75 -0
  83. package/out/old/cmd/updatecmd.js +44 -0
  84. package/out/old/index.js +580 -0
  85. package/out/util/configuration.util.js +103 -0
  86. package/out/util/consts.util.js +97 -0
  87. package/out/util/dbutils/db.types.js +2 -0
  88. package/out/util/dbutils/db.utils.js +164 -0
  89. package/out/util/dbutils/dbtable.utils.js +19 -0
  90. package/out/util/dev.utils.js +14 -0
  91. package/out/util/encryptionutil/encryption.uitl.js +108 -0
  92. package/out/util/index.util.js +341 -0
  93. package/out/util/keyringutil/keyring.util.js +57 -0
  94. package/out/util/loader/loader.interface.js +2 -0
  95. package/out/util/loader/transfer.loader.js +28 -0
  96. package/out/util/login.util.js +352 -0
  97. package/out/util/passwordtypes.util.js +91 -0
  98. package/out/util/print.util.js +4 -0
  99. package/out/util/search.util.js +359 -0
  100. package/out/util/types.util.js +7 -0
  101. package/out/zv.js +41 -0
  102. package/package.json +96 -0
@@ -0,0 +1,139 @@
1
+ import Zohovault from "./zohovault.js";
2
+ import CryptoJS from "./aes.js";
3
+ // import sjcl from "./sjcl.js";
4
+ import crypto from "crypto";
5
+ import RSAKey from "./rsa.js";
6
+ import { Logger } from "../logger/index.js";
7
+ import { JsEncodingUtilImpl, Utilites } from "../../old/index.js";
8
+ var Vault = {
9
+ encrypt: function (plaintext, password) {
10
+ if (!plaintext || !password) {
11
+ return;
12
+ }
13
+ return Zohovault.AES.encrypt(plaintext, password, 256);
14
+ },
15
+ decrypt: function (ciphertext, password) {
16
+ if (!ciphertext || !password) {
17
+ return;
18
+ }
19
+ return Zohovault.AES.decrypt(ciphertext, password, 256);
20
+ },
21
+ fileEncrypt: function (plaintext, password) {
22
+ if (!plaintext || !password) {
23
+ return;
24
+ }
25
+ return CryptoJS.AES.encrypt(plaintext, password).toString();
26
+ },
27
+ fileDecrypt: function (ciphertext, password) {
28
+ if (!ciphertext || !password) {
29
+ return;
30
+ }
31
+ return CryptoJS.AES.decrypt(ciphertext, password).toString(CryptoJS.enc.Latin1);
32
+ },
33
+ hash: function (plaintext) {
34
+ if (!plaintext) {
35
+ return;
36
+ }
37
+ return Zohovault.hash(plaintext);
38
+ },
39
+ Base64_encode: function (input) {
40
+ if (!input) {
41
+ return;
42
+ }
43
+ return Zohovault.Base64.encode(input);
44
+ },
45
+ Base64_decode: function (input) {
46
+ if (!input) {
47
+ return;
48
+ }
49
+ return Zohovault.Base64.decode(input);
50
+ },
51
+ // RSA_encrypt: function (plaintext, publicKey) {
52
+ // if(!plaintext || !publicKey) {
53
+ // return
54
+ // }
55
+ // var rsa = new RSAKey();
56
+ // rsa.setPublic(publicKey, "10001");
57
+ // var res = rsa.encrypt(plaintext);
58
+ // if (res) {
59
+ // let ciphertext = res;
60
+ // return ciphertext;
61
+ // }
62
+ // },
63
+ RSA_decrypt: async function (ciphertext, privateKey, keytype) {
64
+ if (!ciphertext || !privateKey) {
65
+ return;
66
+ }
67
+ switch (keytype) {
68
+ case "RSA_1024":
69
+ {
70
+ privateKey = privateKey.split(",");
71
+ var rsa = new RSAKey();
72
+ rsa.setPrivateEx(privateKey[0], privateKey[1], privateKey[2], privateKey[3], privateKey[4], privateKey[5], privateKey[6], privateKey[7]);
73
+ if (ciphertext.length === 0) {
74
+ return;
75
+ }
76
+ var plaintext = rsa.decrypt(ciphertext);
77
+ return plaintext;
78
+ }
79
+ case "RSA_4096":
80
+ {
81
+ const textDecoder = new TextDecoder();
82
+ const encodingUtil = new JsEncodingUtilImpl();
83
+ const cipherBuffer = encodingUtil.base64ToBytes(ciphertext);
84
+ const decryptedBuffer = await crypto.webcrypto.subtle.decrypt({ name: "RSA-OAEP" }, privateKey, cipherBuffer); //No I18N
85
+ return textDecoder.decode(decryptedBuffer);
86
+ }
87
+ default:
88
+ Logger.error("Invalid RSA Key Type"); //No I18N
89
+ return;
90
+ }
91
+ },
92
+ // PBKDF2_key: function (password, salt, iteration) {
93
+ // if(!password || !salt || !iteration) {
94
+ // return;
95
+ // }
96
+ // /** SJCL and Crypto-js output compatibility changes
97
+ // * SJCL <SALT> converting toHex() value.
98
+ // */
99
+ // function toHex(str) {
100
+ // var hex = "";
101
+ // for (var i = 0; i < str.length; i++) {
102
+ // hex += "" + str.charCodeAt(i).toString(16);
103
+ // }
104
+ // return hex;
105
+ // }
106
+ // var hmacSHA256 = function (key) {
107
+ // var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha256);
108
+ // this.encrypt = function () {
109
+ // return hasher.encrypt.apply(hasher, arguments);
110
+ // };
111
+ // };
112
+ // var passwordSalt = sjcl.codec.hex.toBits(toHex(salt));
113
+ // var derivedKey = sjcl.misc.pbkdf2(
114
+ // password,
115
+ // passwordSalt,
116
+ // iteration,
117
+ // 256,
118
+ // hmacSHA256
119
+ // );
120
+ // return sjcl.codec.hex.fromBits(derivedKey);
121
+ // }
122
+ PBKDF2_key: async function (password, salt, iterations) {
123
+ try {
124
+ const saltBuffer = new Uint8Array(salt.split("").map(x => x.charCodeAt(0)));
125
+ const keyMaterial = await crypto.webcrypto.subtle.importKey("raw", new TextEncoder().encode(password), { name: "PBKDF2" }, false, ["deriveBits", "deriveKey"]); //No I18N
126
+ const derivedBits = await crypto.webcrypto.subtle.deriveBits({
127
+ name: "PBKDF2", salt: saltBuffer, iterations, //No I18N
128
+ hash: "SHA-256" //No I18N
129
+ }, keyMaterial, 256);
130
+ return Utilites.bytesToHex(derivedBits);
131
+ }
132
+ catch (e) {
133
+ console.log(e);
134
+ return "";
135
+ }
136
+ }
137
+ };
138
+ export default Vault;
139
+ //# sourceMappingURL=index.js.map