@sebastienrousseau/crypto-cli 0.0.8 → 0.0.24
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 +685 -3
- package/dist/cli.js +37 -196
- package/dist/commands/decrypt.command.js +2 -2
- package/dist/commands/encrypt.command.js +2 -2
- package/dist/commands/generate.command.js +2 -2
- package/dist/commands/modern/cbom.command.d.ts +2 -1
- package/dist/commands/modern/cbom.command.d.ts.map +1 -1
- package/dist/commands/modern/cbom.command.js +99 -146
- package/dist/commands/modern/cbom.core.d.ts +5 -0
- package/dist/commands/modern/cbom.core.d.ts.map +1 -0
- package/dist/commands/modern/cbom.core.js +57 -0
- package/dist/commands/modern/encrypt.command.d.ts.map +1 -1
- package/dist/commands/modern/encrypt.command.js +42 -63
- package/dist/commands/modern/hash.command.d.ts.map +1 -1
- package/dist/commands/modern/hash.command.js +1 -1
- package/dist/commands/modern/keygen.command.js +1 -1
- package/dist/commands/modern/password-hash.command.d.ts.map +1 -1
- package/dist/commands/modern/password-hash.command.js +28 -27
- package/dist/commands/modern/sign.command.d.ts.map +1 -1
- package/dist/commands/modern/sign.command.js +83 -73
- package/dist/commands/reformat.command.js +2 -2
- package/dist/commands/revoke.command.js +2 -2
- package/dist/commands/session.command.js +2 -2
- package/dist/commands/sign.command.js +2 -2
- package/dist/commands/verify.command.js +2 -2
- package/dist/menu.d.ts +12 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +107 -0
- package/dist/program/cbom.d.ts +4 -0
- package/dist/program/cbom.d.ts.map +1 -0
- package/dist/program/cbom.js +49 -0
- package/dist/program/encrypt.d.ts +6 -0
- package/dist/program/encrypt.d.ts.map +1 -0
- package/dist/program/encrypt.js +73 -0
- package/dist/program/hash.d.ts +4 -0
- package/dist/program/hash.d.ts.map +1 -0
- package/dist/program/hash.js +21 -0
- package/dist/program/hpke.d.ts +4 -0
- package/dist/program/hpke.d.ts.map +1 -0
- package/dist/program/hpke.js +111 -0
- package/dist/program/index.d.ts +7 -0
- package/dist/program/index.d.ts.map +1 -0
- package/dist/program/index.js +77 -0
- package/dist/program/io.d.ts +35 -0
- package/dist/program/io.d.ts.map +1 -0
- package/dist/program/io.js +65 -0
- package/dist/program/keygen.d.ts +4 -0
- package/dist/program/keygen.d.ts.map +1 -0
- package/dist/program/keygen.js +32 -0
- package/dist/program/kms.d.ts +8 -0
- package/dist/program/kms.d.ts.map +1 -0
- package/dist/program/kms.js +247 -0
- package/dist/program/opaque.d.ts +4 -0
- package/dist/program/opaque.d.ts.map +1 -0
- package/dist/program/opaque.js +209 -0
- package/dist/program/password.d.ts +4 -0
- package/dist/program/password.d.ts.map +1 -0
- package/dist/program/password.js +73 -0
- package/dist/program/secrets.d.ts +30 -0
- package/dist/program/secrets.d.ts.map +1 -0
- package/dist/program/secrets.js +70 -0
- package/dist/program/sign.d.ts +18 -0
- package/dist/program/sign.d.ts.map +1 -0
- package/dist/program/sign.js +130 -0
- package/dist/program/stream-multi.d.ts +7 -0
- package/dist/program/stream-multi.d.ts.map +1 -0
- package/dist/program/stream-multi.js +163 -0
- package/dist/program/stream.d.ts +6 -0
- package/dist/program/stream.d.ts.map +1 -0
- package/dist/program/stream.js +102 -0
- package/dist/program/usage.d.ts +7 -0
- package/dist/program/usage.d.ts.map +1 -0
- package/dist/program/usage.js +36 -0
- package/package.json +21 -34
package/dist/cli.js
CHANGED
|
@@ -1,201 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const banner_1 = require("./helpers/banner");
|
|
9
|
-
const index_2 = require("./constants/index");
|
|
10
|
-
const write_utils_1 = require("./utils/write.utils");
|
|
11
|
-
const kleur_1 = __importDefault(require("kleur"));
|
|
12
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
13
|
-
(0, index_2.language)(index_2.locale);
|
|
14
|
-
console.clear();
|
|
15
|
-
(0, banner_1.welcome)(index_2.constants.CLI_TITLE);
|
|
16
|
-
write_utils_1.writeUtils.writeLn(index_2.constants.CLI_TITLE);
|
|
17
|
-
write_utils_1.writeUtils.writeLn("");
|
|
18
|
-
write_utils_1.writeUtils.writeLn(index_2.constants.CLI_DESCRIPTION);
|
|
19
|
-
write_utils_1.writeUtils.writeLn("");
|
|
20
|
-
(async () => {
|
|
21
|
-
const response = await (0, prompts_1.default)({
|
|
22
|
-
type: "select",
|
|
23
|
-
name: index_2.constants.PROMPT_SELECT_TTL,
|
|
24
|
-
message: index_2.constants.PROMPT_SELECT_DES + "\n\n",
|
|
25
|
-
choices: [
|
|
26
|
-
{
|
|
27
|
-
title: index_2.constants.CLI_FN_1_TTL,
|
|
28
|
-
description: index_2.constants.CLI_FN_1_DES,
|
|
29
|
-
value: index_2.constants.CLI_FN_1_TTL,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
title: index_2.constants.CLI_FN_2_TTL,
|
|
33
|
-
description: index_2.constants.CLI_FN_2_DES,
|
|
34
|
-
value: index_2.constants.CLI_FN_2_TTL,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
title: index_2.constants.CLI_FN_3_TTL,
|
|
38
|
-
description: index_2.constants.CLI_FN_3_DES,
|
|
39
|
-
value: index_2.constants.CLI_FN_3_TTL,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: index_2.constants.CLI_FN_4_TTL,
|
|
43
|
-
description: index_2.constants.CLI_FN_4_DES,
|
|
44
|
-
value: index_2.constants.CLI_FN_4_TTL,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title: index_2.constants.CLI_FN_5_TTL,
|
|
48
|
-
description: index_2.constants.CLI_FN_5_DES,
|
|
49
|
-
value: index_2.constants.CLI_FN_5_TTL,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: index_2.constants.CLI_FN_6_TTL,
|
|
53
|
-
description: index_2.constants.CLI_FN_6_DES,
|
|
54
|
-
value: index_2.constants.CLI_FN_6_TTL,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
title: index_2.constants.CLI_FN_7_TTL,
|
|
58
|
-
description: index_2.constants.CLI_FN_7_DES,
|
|
59
|
-
value: index_2.constants.CLI_FN_7_TTL,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
title: index_2.constants.CLI_FN_8_TTL,
|
|
63
|
-
description: index_2.constants.CLI_FN_8_DES,
|
|
64
|
-
value: index_2.constants.CLI_FN_8_TTL,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
title: "Modern Keygen",
|
|
68
|
-
description: "Generate keys (Ed25519, ML-DSA, ML-KEM, P-256, etc.)",
|
|
69
|
-
value: "Modern Keygen",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
title: "Modern Hash",
|
|
73
|
-
description: "Hash data (SHA-2, SHA-3, BLAKE2b, BLAKE3)",
|
|
74
|
-
value: "Modern Hash",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
title: "Modern Encrypt",
|
|
78
|
-
description: "Encrypt (XChaCha20, AES-GCM, AES-GCM-SIV)",
|
|
79
|
-
value: "Modern Encrypt",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
title: "Modern Sign",
|
|
83
|
-
description: "Sign/verify (Ed25519, ECDSA, Schnorr, ML-DSA)",
|
|
84
|
-
value: "Modern Sign",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
title: "Password Hash",
|
|
88
|
-
description: "Hash/verify passwords (Argon2id/i/d)",
|
|
89
|
-
value: "Password Hash",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
title: "CBOM",
|
|
93
|
-
description: "Generate or audit Cryptographic Bill of Materials",
|
|
94
|
-
value: "CBOM",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
title: index_2.constants.CLI_FN_9_TTL,
|
|
98
|
-
description: index_2.constants.CLI_FN_9_DES,
|
|
99
|
-
value: index_2.constants.CLI_FN_9_TTL,
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
});
|
|
103
|
-
switch (response.Selection) {
|
|
104
|
-
case index_2.constants.CLI_FN_1_TTL: {
|
|
105
|
-
write_utils_1.writeUtils.writeLn("");
|
|
106
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
107
|
-
index_1.Command.handleGenerate();
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
case index_2.constants.CLI_FN_2_TTL: {
|
|
111
|
-
write_utils_1.writeUtils.writeLn("");
|
|
112
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
113
|
-
index_1.Command.handleEncrypt();
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case index_2.constants.CLI_FN_3_TTL: {
|
|
117
|
-
write_utils_1.writeUtils.writeLn("");
|
|
118
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
119
|
-
index_1.Command.handleDecrypt();
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case index_2.constants.CLI_FN_4_TTL: {
|
|
123
|
-
write_utils_1.writeUtils.writeLn("");
|
|
124
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
125
|
-
index_1.Command.handleReformat();
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
case index_2.constants.CLI_FN_5_TTL: {
|
|
129
|
-
write_utils_1.writeUtils.writeLn("");
|
|
130
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
131
|
-
index_1.Command.handleRevoke();
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
case index_2.constants.CLI_FN_6_TTL: {
|
|
135
|
-
write_utils_1.writeUtils.writeLn("");
|
|
136
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
137
|
-
index_1.Command.handleSession();
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case index_2.constants.CLI_FN_7_TTL: {
|
|
141
|
-
write_utils_1.writeUtils.writeLn("");
|
|
142
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
143
|
-
index_1.Command.handleSign();
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case index_2.constants.CLI_FN_8_TTL: {
|
|
147
|
-
write_utils_1.writeUtils.writeLn("");
|
|
148
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_HDL_1_DES));
|
|
149
|
-
index_1.Command.handleVerify();
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case "Modern Keygen": {
|
|
153
|
-
write_utils_1.writeUtils.writeLn("");
|
|
154
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Modern Key Generation"));
|
|
155
|
-
index_1.Command.handleModernKeygen();
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
case "Modern Hash": {
|
|
159
|
-
write_utils_1.writeUtils.writeLn("");
|
|
160
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Modern Hashing"));
|
|
161
|
-
index_1.Command.handleModernHash();
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case "Modern Encrypt": {
|
|
165
|
-
write_utils_1.writeUtils.writeLn("");
|
|
166
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Modern Encryption"));
|
|
167
|
-
index_1.Command.handleModernEncrypt();
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
case "Modern Sign": {
|
|
171
|
-
write_utils_1.writeUtils.writeLn("");
|
|
172
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Modern Signing"));
|
|
173
|
-
index_1.Command.handleModernSign();
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
case "Password Hash": {
|
|
177
|
-
write_utils_1.writeUtils.writeLn("");
|
|
178
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Password Hashing (Argon2)"));
|
|
179
|
-
index_1.Command.handlePasswordHash();
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
case "CBOM": {
|
|
183
|
-
write_utils_1.writeUtils.writeLn("");
|
|
184
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green("Cryptographic Bill of Materials (CBOM)"));
|
|
185
|
-
index_1.Command.handleModernCbom();
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case index_2.constants.CLI_FN_9_TTL: {
|
|
189
|
-
write_utils_1.writeUtils.writeLn("");
|
|
190
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.green(index_2.constants.CLI_FN_9_TTL));
|
|
191
|
-
index_1.Command.handleHelp();
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
default: {
|
|
195
|
-
write_utils_1.writeUtils.writeLn("");
|
|
196
|
-
write_utils_1.writeUtils.writeLn(kleur_1.default.red(index_2.constants.CLI_ERR_1));
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
199
8
|
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
200
35
|
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const index_1 = require("./program/index");
|
|
38
|
+
(0, index_1.exitOnClosedPipe)(process.stdout, (code) => process.exit(code));
|
|
39
|
+
(0, index_1.main)(process.argv.slice(2), (0, index_1.processIO)(), () => Promise.resolve().then(() => __importStar(require("./menu"))).then((menu) => menu.runMenu())).then((code) => {
|
|
40
|
+
process.exitCode = code;
|
|
41
|
+
});
|
|
201
42
|
//# sourceMappingURL=cli.js.map
|
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleDecrypt = async () => {
|
|
9
9
|
const responseDecrypt = await (0, prompts_1.default)([
|
|
@@ -34,7 +34,7 @@ const handleDecrypt = async () => {
|
|
|
34
34
|
console.error("\n🔔 You must provide a value for each of the properties.\n");
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
await (0,
|
|
37
|
+
await (0, pgp_1.decrypt)(data);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
exports.default = handleDecrypt;
|
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleEncrypt = async () => {
|
|
9
9
|
const responseEncrypt = await (0, prompts_1.default)([
|
|
@@ -34,7 +34,7 @@ const handleEncrypt = async () => {
|
|
|
34
34
|
console.error("\n🔔 You must provide a value for each of the properties.\n");
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
await (0,
|
|
37
|
+
await (0, pgp_1.encrypt)(data);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
exports.default = handleEncrypt;
|
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
const pgp_1 = require("@sebastienrousseau/crypto-lib/pgp");
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const handleGenerate = async () => {
|
|
9
9
|
const responseGenerate = await (0, prompts_1.default)([
|
|
@@ -60,7 +60,7 @@ const handleGenerate = async () => {
|
|
|
60
60
|
keyExpirationTime: responseGenerate.expiration,
|
|
61
61
|
format: responseGenerate.format,
|
|
62
62
|
};
|
|
63
|
-
await (0,
|
|
63
|
+
await (0, pgp_1.generate)(data);
|
|
64
64
|
};
|
|
65
65
|
exports.default = handleGenerate;
|
|
66
66
|
//# sourceMappingURL=generate.command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cbom.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/cbom.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cbom.command.d.ts","sourceRoot":"","sources":["../../../src/commands/modern/cbom.command.ts"],"names":[],"mappings":"AASA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAGxE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA8HD,QAAA,MAAM,gBAAgB,GAAU,UAAS,iBAAsB,kBAO9D,CAAC;AAGF,eAAe,gBAAgB,CAAC"}
|
|
@@ -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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
63
|
+
directory = scanResponse.directory;
|
|
64
|
+
cbomFormat = scanResponse.format;
|
|
65
|
+
output = scanResponse.output;
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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":"
|
|
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"}
|