@sebastienrousseau/crypto-cli 0.0.7 → 0.0.9

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 (59) hide show
  1. package/README.md +325 -3
  2. package/dist/cli.js +37 -196
  3. package/dist/commands/decrypt.command.js +2 -2
  4. package/dist/commands/encrypt.command.js +2 -2
  5. package/dist/commands/generate.command.js +2 -2
  6. package/dist/commands/modern/cbom.command.d.ts +2 -1
  7. package/dist/commands/modern/cbom.command.d.ts.map +1 -1
  8. package/dist/commands/modern/cbom.command.js +99 -146
  9. package/dist/commands/modern/cbom.core.d.ts +5 -0
  10. package/dist/commands/modern/cbom.core.d.ts.map +1 -0
  11. package/dist/commands/modern/cbom.core.js +57 -0
  12. package/dist/commands/modern/encrypt.command.d.ts.map +1 -1
  13. package/dist/commands/modern/encrypt.command.js +42 -63
  14. package/dist/commands/modern/hash.command.d.ts.map +1 -1
  15. package/dist/commands/modern/hash.command.js +1 -1
  16. package/dist/commands/modern/keygen.command.js +1 -1
  17. package/dist/commands/modern/password-hash.command.d.ts.map +1 -1
  18. package/dist/commands/modern/password-hash.command.js +28 -27
  19. package/dist/commands/modern/sign.command.d.ts.map +1 -1
  20. package/dist/commands/modern/sign.command.js +83 -73
  21. package/dist/commands/reformat.command.js +2 -2
  22. package/dist/commands/revoke.command.js +2 -2
  23. package/dist/commands/session.command.js +2 -2
  24. package/dist/commands/sign.command.js +2 -2
  25. package/dist/commands/verify.command.js +2 -2
  26. package/dist/menu.d.ts +12 -0
  27. package/dist/menu.d.ts.map +1 -0
  28. package/dist/menu.js +107 -0
  29. package/dist/program/cbom.d.ts +4 -0
  30. package/dist/program/cbom.d.ts.map +1 -0
  31. package/dist/program/cbom.js +49 -0
  32. package/dist/program/encrypt.d.ts +6 -0
  33. package/dist/program/encrypt.d.ts.map +1 -0
  34. package/dist/program/encrypt.js +73 -0
  35. package/dist/program/hash.d.ts +4 -0
  36. package/dist/program/hash.d.ts.map +1 -0
  37. package/dist/program/hash.js +21 -0
  38. package/dist/program/index.d.ts +7 -0
  39. package/dist/program/index.d.ts.map +1 -0
  40. package/dist/program/index.js +69 -0
  41. package/dist/program/io.d.ts +35 -0
  42. package/dist/program/io.d.ts.map +1 -0
  43. package/dist/program/io.js +65 -0
  44. package/dist/program/keygen.d.ts +4 -0
  45. package/dist/program/keygen.d.ts.map +1 -0
  46. package/dist/program/keygen.js +32 -0
  47. package/dist/program/password.d.ts +4 -0
  48. package/dist/program/password.d.ts.map +1 -0
  49. package/dist/program/password.js +73 -0
  50. package/dist/program/secrets.d.ts +30 -0
  51. package/dist/program/secrets.d.ts.map +1 -0
  52. package/dist/program/secrets.js +70 -0
  53. package/dist/program/sign.d.ts +18 -0
  54. package/dist/program/sign.d.ts.map +1 -0
  55. package/dist/program/sign.js +130 -0
  56. package/dist/program/usage.d.ts +7 -0
  57. package/dist/program/usage.d.ts.map +1 -0
  58. package/dist/program/usage.js +36 -0
  59. package/package.json +28 -36
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -40,124 +7,110 @@ const node_fs_1 = __importDefault(require("node:fs"));
40
7
  const prompts_1 = __importDefault(require("prompts"));
41
8
  const write_utils_1 = require("../../utils/write.utils");
42
9
  const kleur_1 = __importDefault(require("kleur"));
43
- const handleModernCbom = async (options) => {
44
- let action = options?.action;
45
- let directory = options?.directory;
46
- let cbomFormat = options?.format;
47
- let output = options?.output;
48
- let filePath = options?.filePath;
49
- if (!action) {
50
- const actionResponse = await (0, prompts_1.default)({
51
- type: "select",
52
- name: "action",
53
- message: "Select CBOM operation",
54
- choices: [
55
- { title: "Scan directory for cryptographic assets", value: "scan" },
56
- {
57
- title: "Audit CBOM report for post-quantum & DORA compliance",
58
- value: "audit",
59
- },
60
- ],
61
- });
62
- if (!actionResponse.action)
10
+ const cbom_core_1 = require("./cbom.core");
11
+ const emit = (json, output, label) => {
12
+ if (output && output.trim()) {
13
+ node_fs_1.default.writeFileSync(output.trim(), json, "utf8");
14
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(`${label} written to ${output.trim()}`));
15
+ }
16
+ else {
17
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(json));
18
+ }
19
+ };
20
+ const fail = (err) => {
21
+ write_utils_1.writeUtils.writeLn(kleur_1.default.red(`CBOM operation failed: ${err.message}`));
22
+ };
23
+ const promptAction = async () => {
24
+ const actionResponse = await (0, prompts_1.default)({
25
+ type: "select",
26
+ name: "action",
27
+ message: "Select CBOM operation",
28
+ choices: [
29
+ { title: "Scan directory for cryptographic assets", value: "scan" },
30
+ {
31
+ title: "Audit CBOM report for post-quantum & DORA compliance",
32
+ value: "audit",
33
+ },
34
+ ],
35
+ });
36
+ return actionResponse.action;
37
+ };
38
+ const runScan = async (directory, cbomFormat, output) => {
39
+ if (directory === undefined && cbomFormat === undefined) {
40
+ const scanResponse = await (0, prompts_1.default)([
41
+ {
42
+ type: "text",
43
+ name: "directory",
44
+ message: "Directory to scan (default: .)",
45
+ },
46
+ {
47
+ type: "select",
48
+ name: "format",
49
+ message: "CBOM standard format",
50
+ choices: [
51
+ { title: "CycloneDX (1.6)", value: "cyclonedx" },
52
+ { title: "SPDX (3.0)", value: "spdx" },
53
+ ],
54
+ },
55
+ {
56
+ type: "text",
57
+ name: "output",
58
+ message: "Output file path (leave empty for stdout)",
59
+ },
60
+ ]);
61
+ if (scanResponse.directory === undefined)
63
62
  return;
64
- action = actionResponse.action;
63
+ directory = scanResponse.directory;
64
+ cbomFormat = scanResponse.format;
65
+ output = scanResponse.output;
65
66
  }
66
- if (action === "scan") {
67
- if (directory === undefined && cbomFormat === undefined) {
68
- const scanResponse = await (0, prompts_1.default)([
69
- {
70
- type: "text",
71
- name: "directory",
72
- message: "Directory to scan (default: .)",
73
- },
74
- {
75
- type: "select",
76
- name: "format",
77
- message: "CBOM standard format",
78
- choices: [
79
- { title: "CycloneDX (1.6)", value: "cyclonedx" },
80
- { title: "SPDX (3.0)", value: "spdx" },
81
- ],
82
- },
83
- {
84
- type: "text",
85
- name: "output",
86
- message: "Output file path (leave empty for stdout)",
87
- },
88
- ]);
89
- if (scanResponse.directory === undefined)
90
- return;
91
- directory = scanResponse.directory;
92
- cbomFormat = scanResponse.format;
93
- output = scanResponse.output;
94
- }
95
- try {
96
- const { scanDirectory, generateCycloneDxCbom, generateSpdxCbom } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-cbom")));
97
- const targetDir = directory && directory.trim() ? directory.trim() : ".";
98
- const assets = scanDirectory(targetDir);
99
- const cbom = cbomFormat === "spdx"
100
- ? generateSpdxCbom(assets)
101
- : generateCycloneDxCbom(assets);
102
- const json = JSON.stringify(cbom, null, 2);
103
- if (output && output.trim()) {
104
- node_fs_1.default.writeFileSync(output.trim(), json, "utf8");
105
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(`CBOM written to ${output.trim()}`));
106
- }
107
- else {
108
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(json));
109
- }
110
- }
111
- catch (err) {
112
- write_utils_1.writeUtils.writeLn(kleur_1.default.red(`CBOM operation failed: ${err.message}`));
67
+ try {
68
+ const cbom = await (0, cbom_core_1.buildCbom)(directory, cbomFormat);
69
+ emit(JSON.stringify(cbom, null, 2), output, "CBOM");
70
+ }
71
+ catch (err) {
72
+ fail(err);
73
+ }
74
+ };
75
+ const runAudit = async (filePath, output) => {
76
+ if (!filePath) {
77
+ const auditResponse = await (0, prompts_1.default)([
78
+ {
79
+ type: "text",
80
+ name: "filePath",
81
+ message: "Path to CBOM JSON file",
82
+ },
83
+ {
84
+ type: "text",
85
+ name: "output",
86
+ message: "Output file path (leave empty for stdout)",
87
+ },
88
+ ]);
89
+ if (!auditResponse.filePath)
90
+ return;
91
+ filePath = auditResponse.filePath;
92
+ output = auditResponse.output;
93
+ }
94
+ try {
95
+ const pathStr = filePath.trim();
96
+ if (!node_fs_1.default.existsSync(pathStr)) {
97
+ write_utils_1.writeUtils.writeLn(kleur_1.default.red(`File not found: ${pathStr}`));
98
+ return;
113
99
  }
100
+ const result = await (0, cbom_core_1.auditCbomJson)(node_fs_1.default.readFileSync(pathStr, "utf8"));
101
+ emit(JSON.stringify(result, null, 2), output, "Audit report");
102
+ }
103
+ catch (err) {
104
+ fail(err);
105
+ }
106
+ };
107
+ const handleModernCbom = async (options = {}) => {
108
+ const action = options.action ?? (await promptAction());
109
+ if (action === "scan") {
110
+ await runScan(options.directory, options.format, options.output);
114
111
  }
115
112
  else if (action === "audit") {
116
- if (!filePath) {
117
- const auditResponse = await (0, prompts_1.default)([
118
- {
119
- type: "text",
120
- name: "filePath",
121
- message: "Path to CBOM JSON file",
122
- },
123
- {
124
- type: "text",
125
- name: "output",
126
- message: "Output file path (leave empty for stdout)",
127
- },
128
- ]);
129
- if (!auditResponse.filePath)
130
- return;
131
- filePath = auditResponse.filePath;
132
- output = auditResponse.output;
133
- }
134
- try {
135
- const pathStr = filePath.trim();
136
- if (!node_fs_1.default.existsSync(pathStr)) {
137
- write_utils_1.writeUtils.writeLn(kleur_1.default.red(`File not found: ${pathStr}`));
138
- return;
139
- }
140
- const { validateCbom, auditCbom } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-cbom")));
141
- const raw = node_fs_1.default.readFileSync(pathStr, "utf8");
142
- const parsed = JSON.parse(raw);
143
- const val = validateCbom(parsed);
144
- if (!val.valid) {
145
- write_utils_1.writeUtils.writeLn(kleur_1.default.red(`Validation failed: ${val.errors.join(", ")}`));
146
- return;
147
- }
148
- const result = auditCbom(parsed);
149
- const json = JSON.stringify(result, null, 2);
150
- if (output && output.trim()) {
151
- node_fs_1.default.writeFileSync(output.trim(), json, "utf8");
152
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(`Audit report written to ${output.trim()}`));
153
- }
154
- else {
155
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(json));
156
- }
157
- }
158
- catch (err) {
159
- write_utils_1.writeUtils.writeLn(kleur_1.default.red(`CBOM operation failed: ${err.message}`));
160
- }
113
+ await runAudit(options.filePath, options.output);
161
114
  }
162
115
  };
163
116
  exports.default = handleModernCbom;
@@ -0,0 +1,5 @@
1
+ export declare const CBOM_FORMATS: readonly ["cyclonedx", "spdx"];
2
+ export type CbomFormat = (typeof CBOM_FORMATS)[number];
3
+ export declare const buildCbom: (directory: string | undefined, cbomFormat: CbomFormat | undefined) => Promise<object>;
4
+ export declare const auditCbomJson: (raw: string) => Promise<import("@sebastienrousseau/crypto-cbom").CbomAuditResult>;
5
+ //# sourceMappingURL=cbom.core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbom.core.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/cbom.core.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,gCAAiC,CAAC;AAG3D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AASvD,eAAO,MAAM,SAAS,GACpB,WAAW,MAAM,GAAG,SAAS,EAC7B,YAAY,UAAU,GAAG,SAAS,KACjC,OAAO,CAAC,MAAM,CAQhB,CAAC;AASF,eAAO,MAAM,aAAa,GAAU,KAAK,MAAM,sEAS9C,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.auditCbomJson = exports.buildCbom = exports.CBOM_FORMATS = void 0;
37
+ exports.CBOM_FORMATS = ["cyclonedx", "spdx"];
38
+ const buildCbom = async (directory, cbomFormat) => {
39
+ const { scanDirectory, generateCycloneDxCbom, generateSpdxCbom } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-cbom")));
40
+ const targetDir = directory && directory.trim() ? directory.trim() : ".";
41
+ const assets = scanDirectory(targetDir);
42
+ return cbomFormat === "spdx"
43
+ ? generateSpdxCbom(assets)
44
+ : generateCycloneDxCbom(assets);
45
+ };
46
+ exports.buildCbom = buildCbom;
47
+ const auditCbomJson = async (raw) => {
48
+ const { validateCbom, auditCbom } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-cbom")));
49
+ const parsed = JSON.parse(raw);
50
+ const validation = validateCbom(parsed);
51
+ if (!validation.valid) {
52
+ throw new Error(`Validation failed: ${validation.errors.join(", ")}`);
53
+ }
54
+ return auditCbom(parsed);
55
+ };
56
+ exports.auditCbomJson = auditCbomJson;
57
+ //# sourceMappingURL=cbom.core.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"encrypt.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/encrypt.command.ts"],"names":[],"mappings":"AA0BA,QAAA,MAAM,mBAAmB,qBA0ExB,CAAC;AAGF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"encrypt.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/encrypt.command.ts"],"names":[],"mappings":"AAmEA,QAAA,MAAM,mBAAmB,qBAqBxB,CAAC;AAGF,eAAe,mBAAmB,CAAC"}
@@ -46,75 +46,54 @@ const ALGORITHMS = [
46
46
  "aes-256-gcm-siv",
47
47
  "aes-128-gcm-siv",
48
48
  ];
49
+ const QUESTIONS = [
50
+ {
51
+ type: "select",
52
+ name: "algorithm",
53
+ message: "Select encryption algorithm",
54
+ choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
55
+ },
56
+ {
57
+ type: "password",
58
+ name: "key",
59
+ message: "Encryption key (hex, 32 bytes / 64 hex chars)",
60
+ },
61
+ {
62
+ type: "text",
63
+ name: "plaintext",
64
+ message: "Plaintext to encrypt",
65
+ },
66
+ {
67
+ type: "select",
68
+ name: "outputFormat",
69
+ message: "Output format",
70
+ choices: [
71
+ { title: "JSON", value: "json" },
72
+ { title: "Hex ciphertext only", value: "hex" },
73
+ ],
74
+ },
75
+ ];
76
+ async function encryptWith(algorithm, key, plaintext) {
77
+ const lib = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
78
+ if (algorithm === "xchacha20-poly1305") {
79
+ return lib.aeadEncrypt({ key, plaintext });
80
+ }
81
+ if (algorithm.includes("siv")) {
82
+ return lib.aesGcmSivEncrypt({ key, plaintext });
83
+ }
84
+ return lib.aesGcmEncrypt({ key, plaintext });
85
+ }
49
86
  const handleModernEncrypt = async () => {
50
- const response = await (0, prompts_1.default)([
51
- {
52
- type: "select",
53
- name: "algorithm",
54
- message: "Select encryption algorithm",
55
- choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
56
- },
57
- {
58
- type: "password",
59
- name: "key",
60
- message: "Encryption key (hex, 32 bytes / 64 hex chars)",
61
- },
62
- {
63
- type: "text",
64
- name: "plaintext",
65
- message: "Plaintext to encrypt",
66
- },
67
- {
68
- type: "select",
69
- name: "outputFormat",
70
- message: "Output format",
71
- choices: [
72
- { title: "JSON", value: "json" },
73
- { title: "Hex ciphertext only", value: "hex" },
74
- ],
75
- },
76
- ]);
87
+ const response = await (0, prompts_1.default)(QUESTIONS);
77
88
  if (!response.algorithm || !response.key || !response.plaintext)
78
89
  return;
79
90
  try {
80
- if (response.algorithm === "xchacha20-poly1305") {
81
- const { aeadEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/aead")));
82
- const result = aeadEncrypt({
83
- key: response.key,
84
- plaintext: response.plaintext,
85
- });
86
- if (response.outputFormat === "json") {
87
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
88
- }
89
- else {
90
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
91
- }
92
- }
93
- else if (response.algorithm.includes("siv")) {
94
- const { aesGcmSivEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/aes")));
95
- const result = aesGcmSivEncrypt({
96
- key: response.key,
97
- plaintext: response.plaintext,
98
- });
99
- if (response.outputFormat === "json") {
100
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
101
- }
102
- else {
103
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
104
- }
91
+ const result = await encryptWith(response.algorithm, response.key, response.plaintext);
92
+ if (response.outputFormat === "json") {
93
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
105
94
  }
106
95
  else {
107
- const { aesGcmEncrypt } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/aes")));
108
- const result = aesGcmEncrypt({
109
- key: response.key,
110
- plaintext: response.plaintext,
111
- });
112
- if (response.outputFormat === "json") {
113
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
114
- }
115
- else {
116
- write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
117
- }
96
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.ciphertext));
118
97
  }
119
98
  }
120
99
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/hash.command.ts"],"names":[],"mappings":"AA4BA,QAAA,MAAM,gBAAgB,qBAwCrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/hash.command.ts"],"names":[],"mappings":"AA4BA,QAAA,MAAM,gBAAgB,qBAuCrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -74,7 +74,7 @@ const handleModernHash = async () => {
74
74
  if (!response.algorithm || !response.data)
75
75
  return;
76
76
  try {
77
- const { hash } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/hash")));
77
+ const { hash } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
78
78
  const result = hash({ algorithm: response.algorithm, data: response.data });
79
79
  if (response.outputFormat === "json") {
80
80
  write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
@@ -88,7 +88,7 @@ const handleModernKeygen = async () => {
88
88
  if (!response.algorithm)
89
89
  return;
90
90
  try {
91
- const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/keys/keygen")));
91
+ const { generateKeyPair } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/keys")));
92
92
  const metadata = {};
93
93
  if (response.kid)
94
94
  metadata.kid = response.kid;
@@ -1 +1 @@
1
- {"version":3,"file":"password-hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/password-hash.command.ts"],"names":[],"mappings":"AAiBA,QAAA,MAAM,kBAAkB,qBA0EvB,CAAC;AAGF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"password-hash.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/password-hash.command.ts"],"names":[],"mappings":"AA6CA,QAAA,MAAM,kBAAkB,qBAiDvB,CAAC;AAGF,eAAe,kBAAkB,CAAC"}
@@ -39,37 +39,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const prompts_1 = __importDefault(require("prompts"));
40
40
  const write_utils_1 = require("../../utils/write.utils");
41
41
  const kleur_1 = __importDefault(require("kleur"));
42
+ const QUESTIONS = [
43
+ {
44
+ type: "select",
45
+ name: "action",
46
+ message: "Action",
47
+ choices: [
48
+ { title: "Hash password", value: "hash" },
49
+ { title: "Verify password", value: "verify" },
50
+ ],
51
+ },
52
+ {
53
+ type: "password",
54
+ name: "password",
55
+ message: "Password",
56
+ },
57
+ {
58
+ type: "select",
59
+ name: "variant",
60
+ message: "Argon2 variant",
61
+ choices: [
62
+ { title: "argon2id (recommended)", value: "argon2id" },
63
+ { title: "argon2i (side-channel resistant)", value: "argon2i" },
64
+ { title: "argon2d (GPU resistant)", value: "argon2d" },
65
+ ],
66
+ },
67
+ ];
42
68
  const handlePasswordHash = async () => {
43
- const response = await (0, prompts_1.default)([
44
- {
45
- type: "select",
46
- name: "action",
47
- message: "Action",
48
- choices: [
49
- { title: "Hash password", value: "hash" },
50
- { title: "Verify password", value: "verify" },
51
- ],
52
- },
53
- {
54
- type: "password",
55
- name: "password",
56
- message: "Password",
57
- },
58
- {
59
- type: "select",
60
- name: "variant",
61
- message: "Argon2 variant",
62
- choices: [
63
- { title: "argon2id (recommended)", value: "argon2id" },
64
- { title: "argon2i (side-channel resistant)", value: "argon2i" },
65
- { title: "argon2d (GPU resistant)", value: "argon2d" },
66
- ],
67
- },
68
- ]);
69
+ const response = await (0, prompts_1.default)(QUESTIONS);
69
70
  if (!response.action || !response.password)
70
71
  return;
71
72
  try {
72
- const { hashPassword, verifyPasswordPhc } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/password")));
73
+ const { hashPassword, verifyPasswordPhc } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/modern")));
73
74
  if (response.action === "hash") {
74
75
  const result = hashPassword({
75
76
  password: response.password,
@@ -1 +1 @@
1
- {"version":3,"file":"sign.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/sign.command.ts"],"names":[],"mappings":"AA8BA,QAAA,MAAM,gBAAgB,qBA8HrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"sign.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/sign.command.ts"],"names":[],"mappings":"AAyIA,QAAA,MAAM,gBAAgB,qBAgBrB,CAAC;AAGF,eAAe,gBAAgB,CAAC"}