@sebastienrousseau/crypto-cli 0.0.1 → 0.0.7

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 (91) hide show
  1. package/README.md +228 -235
  2. package/dist/cli.js +67 -1
  3. package/dist/commands/decrypt.command.d.ts.map +1 -1
  4. package/dist/commands/decrypt.command.js +3 -4
  5. package/dist/commands/encrypt.command.d.ts.map +1 -1
  6. package/dist/commands/encrypt.command.js +2 -3
  7. package/dist/commands/generate.command.d.ts.map +1 -1
  8. package/dist/commands/generate.command.js +24 -25
  9. package/dist/commands/help.command.d.ts.map +1 -1
  10. package/dist/commands/index.d.ts +6 -0
  11. package/dist/commands/index.d.ts.map +1 -1
  12. package/dist/commands/index.js +7 -0
  13. package/dist/commands/modern/cbom.command.d.ts +10 -0
  14. package/dist/commands/modern/cbom.command.d.ts.map +1 -0
  15. package/dist/commands/modern/cbom.command.js +164 -0
  16. package/dist/commands/modern/encrypt.command.d.ts +3 -0
  17. package/dist/commands/modern/encrypt.command.d.ts.map +1 -0
  18. package/dist/commands/modern/encrypt.command.js +125 -0
  19. package/dist/commands/modern/hash.command.d.ts +3 -0
  20. package/dist/commands/modern/hash.command.d.ts.map +1 -0
  21. package/dist/commands/modern/hash.command.js +91 -0
  22. package/dist/commands/modern/index.d.ts +9 -0
  23. package/dist/commands/modern/index.d.ts.map +1 -0
  24. package/dist/commands/modern/index.js +21 -0
  25. package/dist/commands/modern/keygen.command.d.ts +3 -0
  26. package/dist/commands/modern/keygen.command.d.ts.map +1 -0
  27. package/dist/commands/modern/keygen.command.js +113 -0
  28. package/dist/commands/modern/password-hash.command.d.ts +3 -0
  29. package/dist/commands/modern/password-hash.command.d.ts.map +1 -0
  30. package/dist/commands/modern/password-hash.command.js +106 -0
  31. package/dist/commands/modern/sign.command.d.ts +3 -0
  32. package/dist/commands/modern/sign.command.d.ts.map +1 -0
  33. package/dist/commands/modern/sign.command.js +135 -0
  34. package/dist/commands/reformat.command.d.ts.map +1 -1
  35. package/dist/commands/reformat.command.js +2 -3
  36. package/dist/commands/revoke.command.d.ts.map +1 -1
  37. package/dist/commands/revoke.command.js +2 -3
  38. package/dist/commands/session.command.d.ts.map +1 -1
  39. package/dist/commands/session.command.js +2 -3
  40. package/dist/commands/sign.command.d.ts.map +1 -1
  41. package/dist/commands/sign.command.js +2 -3
  42. package/dist/commands/verify.command.d.ts.map +1 -1
  43. package/dist/commands/verify.command.js +12 -13
  44. package/dist/constants/en.d.ts.map +1 -1
  45. package/dist/constants/en.js +87 -87
  46. package/dist/constants/fr.d.ts +1 -1
  47. package/dist/constants/fr.d.ts.map +1 -1
  48. package/dist/constants/fr.js +24 -24
  49. package/dist/constants/index.d.ts +4 -2
  50. package/dist/constants/index.d.ts.map +1 -1
  51. package/dist/constants/index.js +25 -20
  52. package/dist/helpers/banner.d.ts +1 -1
  53. package/dist/helpers/banner.d.ts.map +1 -1
  54. package/dist/utils/version.utils.d.ts.map +1 -1
  55. package/dist/utils/write.utils.d.ts.map +1 -1
  56. package/dist/utils/write.utils.js +1 -1
  57. package/package.json +123 -126
  58. package/dist/.DS_Store +0 -0
  59. package/dist/COPYRIGHT +0 -15
  60. package/dist/Makefile +0 -122
  61. package/dist/Report.txt +0 -176
  62. package/dist/cli.js.map +0 -1
  63. package/dist/commands/decrypt.command.js.map +0 -1
  64. package/dist/commands/encrypt.command.js.map +0 -1
  65. package/dist/commands/generate.command.js.map +0 -1
  66. package/dist/commands/help.command.js.map +0 -1
  67. package/dist/commands/index.js.map +0 -1
  68. package/dist/commands/reformat.command.js.map +0 -1
  69. package/dist/commands/revoke.command.js.map +0 -1
  70. package/dist/commands/session.command.js.map +0 -1
  71. package/dist/commands/sign.command.js.map +0 -1
  72. package/dist/commands/verify.command.js.map +0 -1
  73. package/dist/constants/en.js.map +0 -1
  74. package/dist/constants/fr.js.map +0 -1
  75. package/dist/constants/index.js.map +0 -1
  76. package/dist/helpers/banner.js.map +0 -1
  77. package/dist/key/key.d.ts +0 -17
  78. package/dist/key/key.d.ts.map +0 -1
  79. package/dist/key/key.js +0 -19
  80. package/dist/key/key.js.map +0 -1
  81. package/dist/key/rsa-reformat.cert +0 -1
  82. package/dist/key/rsa-reformat.key +0 -1
  83. package/dist/key/rsa-reformat.pub +0 -1
  84. package/dist/key/rsa-revoke.key +0 -1
  85. package/dist/key/rsa-revoke.pub +0 -1
  86. package/dist/key/rsa.cert +0 -1
  87. package/dist/key/rsa.key +0 -1
  88. package/dist/key/rsa.pub +0 -1
  89. package/dist/package.json +0 -129
  90. package/dist/utils/version.utils.js.map +0 -1
  91. package/dist/utils/write.utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"generate.command.d.ts","sourceRoot":"","sources":["../../src/commands/generate.command.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,cAAc,qBA4DnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"generate.command.d.ts","sourceRoot":"","sources":["../../src/commands/generate.command.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,cAAc,qBA6DnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const crypto_lib_1 = __importDefault(require("@sebastienrousseau/crypto-lib"));
6
+ const generate_1 = __importDefault(require("@sebastienrousseau/crypto-lib/dist/lib/generate"));
7
7
  const prompts_1 = __importDefault(require("prompts"));
8
8
  const handleGenerate = async () => {
9
9
  const responseGenerate = await (0, prompts_1.default)([
10
10
  {
11
11
  type: "text",
12
- name: "curve",
13
- message: 'Curve name (e.g. "curve25519")',
12
+ name: "name",
13
+ message: "Provide a first and last name",
14
14
  },
15
15
  {
16
16
  type: "text",
@@ -19,18 +19,8 @@ const handleGenerate = async () => {
19
19
  },
20
20
  {
21
21
  type: "text",
22
- name: "format",
23
- message: 'Provide a format (e.g. "armored")',
24
- },
25
- {
26
- type: "text",
27
- name: "expiration",
28
- message: 'Provide a key expiration time (e.g. "1y")',
29
- },
30
- {
31
- type: "text",
32
- name: "name",
33
- message: "Provide a first and last name",
22
+ name: "type",
23
+ message: 'Provide a key type (e.g. "rsa or ecc")',
34
24
  },
35
25
  {
36
26
  type: "password",
@@ -44,24 +34,33 @@ const handleGenerate = async () => {
44
34
  },
45
35
  {
46
36
  type: "text",
47
- name: "type",
48
- message: 'Provide a key type (e.g. "rsa or ecc")',
37
+ name: "curve",
38
+ message: 'Curve name (e.g. "curve25519")',
39
+ },
40
+ {
41
+ type: "text",
42
+ name: "expiration",
43
+ message: 'Provide a key expiration time (e.g. "1y")',
44
+ },
45
+ {
46
+ type: "text",
47
+ name: "format",
48
+ message: 'Provide a format (e.g. "armored")',
49
49
  },
50
50
  ]);
51
- console.log(responseGenerate);
52
51
  const data = {
53
- curve: responseGenerate.curve,
54
52
  date: new Date(),
55
- email: responseGenerate.email,
56
- format: responseGenerate.format,
57
- keyExpirationTime: responseGenerate.expiration,
58
53
  name: responseGenerate.name,
54
+ email: responseGenerate.email,
55
+ userIDs: [{ name: responseGenerate.name, email: responseGenerate.email }],
56
+ type: responseGenerate.type,
59
57
  passphrase: responseGenerate.passphrase,
60
58
  rsaBits: responseGenerate.rsaBits,
61
- type: responseGenerate.type,
62
- userIDs: [{ name: responseGenerate.name, email: responseGenerate.email }],
59
+ curve: responseGenerate.curve,
60
+ keyExpirationTime: responseGenerate.expiration,
61
+ format: responseGenerate.format,
63
62
  };
64
- await crypto_lib_1.default.generate(data);
63
+ await (0, generate_1.default)(data);
65
64
  };
66
65
  exports.default = handleGenerate;
67
66
  //# sourceMappingURL=generate.command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"help.command.d.ts","sourceRoot":"","sources":["../../src/commands/help.command.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,UAAU,qBA0Mf,CAAC;AACF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"help.command.d.ts","sourceRoot":"","sources":["../../src/commands/help.command.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,UAAU,qBAyMf,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -8,5 +8,11 @@ export declare const Command: {
8
8
  handleSession: () => Promise<void>;
9
9
  handleSign: () => Promise<void>;
10
10
  handleVerify: () => Promise<void>;
11
+ handleModernKeygen: () => Promise<void>;
12
+ handleModernHash: () => Promise<void>;
13
+ handleModernEncrypt: () => Promise<void>;
14
+ handleModernSign: () => Promise<void>;
15
+ handlePasswordHash: () => Promise<void>;
16
+ handleModernCbom: (options?: import("./modern/cbom.command").ModernCbomOptions) => Promise<void>;
11
17
  };
12
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,OAAO;;;;;;;;;;CAUnB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;CA+BnB,CAAC"}
@@ -13,6 +13,7 @@ const revoke_command_1 = __importDefault(require("./revoke.command"));
13
13
  const session_command_1 = __importDefault(require("./session.command"));
14
14
  const sign_command_1 = __importDefault(require("./sign.command"));
15
15
  const verify_command_1 = __importDefault(require("./verify.command"));
16
+ const modern_1 = require("./modern");
16
17
  exports.Command = {
17
18
  handleDecrypt: decrypt_command_1.default,
18
19
  handleEncrypt: encrypt_command_1.default,
@@ -23,5 +24,11 @@ exports.Command = {
23
24
  handleSession: session_command_1.default,
24
25
  handleSign: sign_command_1.default,
25
26
  handleVerify: verify_command_1.default,
27
+ handleModernKeygen: modern_1.ModernCommand.handleModernKeygen,
28
+ handleModernHash: modern_1.ModernCommand.handleModernHash,
29
+ handleModernEncrypt: modern_1.ModernCommand.handleModernEncrypt,
30
+ handleModernSign: modern_1.ModernCommand.handleModernSign,
31
+ handlePasswordHash: modern_1.ModernCommand.handlePasswordHash,
32
+ handleModernCbom: modern_1.ModernCommand.handleModernCbom,
26
33
  };
27
34
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ export interface ModernCbomOptions {
2
+ action?: "scan" | "audit";
3
+ directory?: string;
4
+ format?: "cyclonedx" | "spdx";
5
+ output?: string;
6
+ filePath?: string;
7
+ }
8
+ declare const handleModernCbom: (options?: ModernCbomOptions) => Promise<void>;
9
+ export default handleModernCbom;
10
+ //# sourceMappingURL=cbom.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cbom.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/cbom.command.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAWD,QAAA,MAAM,gBAAgB,GAAU,UAAU,iBAAiB,kBAuI1D,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,164 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const node_fs_1 = __importDefault(require("node:fs"));
40
+ const prompts_1 = __importDefault(require("prompts"));
41
+ const write_utils_1 = require("../../utils/write.utils");
42
+ 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)
63
+ return;
64
+ action = actionResponse.action;
65
+ }
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}`));
113
+ }
114
+ }
115
+ 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
+ }
161
+ }
162
+ };
163
+ exports.default = handleModernCbom;
164
+ //# sourceMappingURL=cbom.command.js.map
@@ -0,0 +1,3 @@
1
+ declare const handleModernEncrypt: () => Promise<void>;
2
+ export default handleModernEncrypt;
3
+ //# sourceMappingURL=encrypt.command.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,125 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const prompts_1 = __importDefault(require("prompts"));
40
+ const write_utils_1 = require("../../utils/write.utils");
41
+ const kleur_1 = __importDefault(require("kleur"));
42
+ const ALGORITHMS = [
43
+ "xchacha20-poly1305",
44
+ "aes-256-gcm",
45
+ "aes-128-gcm",
46
+ "aes-256-gcm-siv",
47
+ "aes-128-gcm-siv",
48
+ ];
49
+ 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
+ ]);
77
+ if (!response.algorithm || !response.key || !response.plaintext)
78
+ return;
79
+ 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
+ }
105
+ }
106
+ 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
+ }
118
+ }
119
+ }
120
+ catch (err) {
121
+ write_utils_1.writeUtils.writeLn(kleur_1.default.red(`Encryption failed: ${err.message}`));
122
+ }
123
+ };
124
+ exports.default = handleModernEncrypt;
125
+ //# sourceMappingURL=encrypt.command.js.map
@@ -0,0 +1,3 @@
1
+ declare const handleModernHash: () => Promise<void>;
2
+ export default handleModernHash;
3
+ //# sourceMappingURL=hash.command.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,91 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const prompts_1 = __importDefault(require("prompts"));
40
+ const write_utils_1 = require("../../utils/write.utils");
41
+ const kleur_1 = __importDefault(require("kleur"));
42
+ const ALGORITHMS = [
43
+ "sha256",
44
+ "sha384",
45
+ "sha512",
46
+ "sha3-256",
47
+ "sha3-512",
48
+ "blake2b",
49
+ "blake3",
50
+ ];
51
+ const handleModernHash = async () => {
52
+ const response = await (0, prompts_1.default)([
53
+ {
54
+ type: "select",
55
+ name: "algorithm",
56
+ message: "Select hash algorithm",
57
+ choices: ALGORITHMS.map((a) => ({ title: a, value: a })),
58
+ },
59
+ {
60
+ type: "text",
61
+ name: "data",
62
+ message: "Data to hash",
63
+ },
64
+ {
65
+ type: "select",
66
+ name: "outputFormat",
67
+ message: "Output format",
68
+ choices: [
69
+ { title: "JSON", value: "json" },
70
+ { title: "Plain", value: "plain" },
71
+ ],
72
+ },
73
+ ]);
74
+ if (!response.algorithm || !response.data)
75
+ return;
76
+ try {
77
+ const { hash } = await Promise.resolve().then(() => __importStar(require("@sebastienrousseau/crypto-lib/dist/modern/hash")));
78
+ const result = hash({ algorithm: response.algorithm, data: response.data });
79
+ if (response.outputFormat === "json") {
80
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(JSON.stringify(result, null, 2)));
81
+ }
82
+ else {
83
+ write_utils_1.writeUtils.writeLn(kleur_1.default.green(result.digest));
84
+ }
85
+ }
86
+ catch (err) {
87
+ write_utils_1.writeUtils.writeLn(kleur_1.default.red(`Hashing failed: ${err.message}`));
88
+ }
89
+ };
90
+ exports.default = handleModernHash;
91
+ //# sourceMappingURL=hash.command.js.map
@@ -0,0 +1,9 @@
1
+ export declare const ModernCommand: {
2
+ handleModernKeygen: () => Promise<void>;
3
+ handleModernHash: () => Promise<void>;
4
+ handleModernEncrypt: () => Promise<void>;
5
+ handleModernSign: () => Promise<void>;
6
+ handlePasswordHash: () => Promise<void>;
7
+ handleModernCbom: (options?: import("./cbom.command").ModernCbomOptions) => Promise<void>;
8
+ };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa;;;;;;;CAazB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModernCommand = void 0;
7
+ const keygen_command_1 = __importDefault(require("./keygen.command"));
8
+ const hash_command_1 = __importDefault(require("./hash.command"));
9
+ const encrypt_command_1 = __importDefault(require("./encrypt.command"));
10
+ const sign_command_1 = __importDefault(require("./sign.command"));
11
+ const password_hash_command_1 = __importDefault(require("./password-hash.command"));
12
+ const cbom_command_1 = __importDefault(require("./cbom.command"));
13
+ exports.ModernCommand = {
14
+ handleModernKeygen: keygen_command_1.default,
15
+ handleModernHash: hash_command_1.default,
16
+ handleModernEncrypt: encrypt_command_1.default,
17
+ handleModernSign: sign_command_1.default,
18
+ handlePasswordHash: password_hash_command_1.default,
19
+ handleModernCbom: cbom_command_1.default,
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ declare const handleModernKeygen: () => Promise<void>;
2
+ export default handleModernKeygen;
3
+ //# sourceMappingURL=keygen.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keygen.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/keygen.command.ts"],"names":[],"mappings":"AAiCA,QAAA,MAAM,kBAAkB,qBA0DvB,CAAC;AAGF,eAAe,kBAAkB,CAAC"}