crewx 0.8.6-rc.1 β 0.8.6-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/bootstrap/tls.js +111 -26
- package/package.json +8 -7
- package/packages/cli/package.json +1 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CERT_PATH = void 0;
|
|
4
7
|
exports.resolveHttpsOptions = resolveHttpsOptions;
|
|
5
8
|
const fs_1 = require("fs");
|
|
6
9
|
const path_1 = require("path");
|
|
7
10
|
const os_1 = require("os");
|
|
8
|
-
const
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
const node_forge_1 = __importDefault(require("node-forge"));
|
|
9
13
|
const TLS_DIR = (0, path_1.join)((0, os_1.homedir)(), '.crewx', 'tls');
|
|
14
|
+
const CA_CERT_PATH = (0, path_1.join)(TLS_DIR, 'ca.pem');
|
|
15
|
+
const CA_KEY_PATH = (0, path_1.join)(TLS_DIR, 'ca-key.pem');
|
|
10
16
|
const CERT_PATH = (0, path_1.join)(TLS_DIR, 'cert.pem');
|
|
11
17
|
exports.CERT_PATH = CERT_PATH;
|
|
12
18
|
const KEY_PATH = (0, path_1.join)(TLS_DIR, 'key.pem');
|
|
@@ -20,38 +26,117 @@ async function resolveHttpsOptions() {
|
|
|
20
26
|
key: (0, fs_1.readFileSync)(process.env.TLS_KEY),
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
|
-
if ((0, fs_1.existsSync)(CERT_PATH) && (0, fs_1.existsSync)(KEY_PATH)) {
|
|
29
|
+
if ((0, fs_1.existsSync)(CA_CERT_PATH) && (0, fs_1.existsSync)(CERT_PATH) && (0, fs_1.existsSync)(KEY_PATH)) {
|
|
24
30
|
return {
|
|
25
31
|
cert: (0, fs_1.readFileSync)(CERT_PATH),
|
|
26
32
|
key: (0, fs_1.readFileSync)(KEY_PATH),
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{ type: 7, ip: '::1' },
|
|
41
|
-
],
|
|
35
|
+
// Generate CA (or reuse existing) + server cert signed by CA
|
|
36
|
+
const ca = ensureCACert();
|
|
37
|
+
const server = generateServerCert(ca.cert, ca.key);
|
|
38
|
+
(0, fs_1.writeFileSync)(CERT_PATH, server.certPem, { mode: 0o644 });
|
|
39
|
+
(0, fs_1.writeFileSync)(KEY_PATH, server.keyPem, { mode: 0o600 });
|
|
40
|
+
if (ca.isNew) {
|
|
41
|
+
installCA(CA_CERT_PATH);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
cert: Buffer.from(server.certPem),
|
|
45
|
+
key: Buffer.from(server.keyPem),
|
|
42
46
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
}
|
|
48
|
+
function ensureCACert() {
|
|
49
|
+
if ((0, fs_1.existsSync)(CA_CERT_PATH) && (0, fs_1.existsSync)(CA_KEY_PATH)) {
|
|
50
|
+
return {
|
|
51
|
+
cert: node_forge_1.default.pki.certificateFromPem((0, fs_1.readFileSync)(CA_CERT_PATH, 'utf8')),
|
|
52
|
+
key: node_forge_1.default.pki.privateKeyFromPem((0, fs_1.readFileSync)(CA_KEY_PATH, 'utf8')),
|
|
53
|
+
isNew: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const keys = node_forge_1.default.pki.rsa.generateKeyPair(2048);
|
|
57
|
+
const cert = node_forge_1.default.pki.createCertificate();
|
|
58
|
+
cert.publicKey = keys.publicKey;
|
|
59
|
+
cert.serialNumber = randomSerialNumber();
|
|
60
|
+
cert.validity.notBefore = new Date();
|
|
61
|
+
cert.validity.notAfter = new Date();
|
|
62
|
+
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 10);
|
|
63
|
+
const attrs = [
|
|
64
|
+
{ name: 'commonName', value: 'SowonLabs CrewX Local CA' },
|
|
65
|
+
{ name: 'organizationName', value: 'SowonLabs' },
|
|
66
|
+
];
|
|
67
|
+
cert.setSubject(attrs);
|
|
68
|
+
cert.setIssuer(attrs);
|
|
69
|
+
cert.setExtensions([
|
|
70
|
+
{ name: 'basicConstraints', cA: true },
|
|
71
|
+
{ name: 'keyUsage', keyCertSign: true, cRLSign: true },
|
|
72
|
+
]);
|
|
73
|
+
cert.sign(keys.privateKey, node_forge_1.default.md.sha256.create());
|
|
47
74
|
(0, fs_1.mkdirSync)(TLS_DIR, { recursive: true });
|
|
48
|
-
(0, fs_1.writeFileSync)(
|
|
49
|
-
(0, fs_1.writeFileSync)(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log(
|
|
75
|
+
(0, fs_1.writeFileSync)(CA_CERT_PATH, node_forge_1.default.pki.certificateToPem(cert), { mode: 0o644 });
|
|
76
|
+
(0, fs_1.writeFileSync)(CA_KEY_PATH, node_forge_1.default.pki.privateKeyToPem(keys.privateKey), {
|
|
77
|
+
mode: 0o600,
|
|
78
|
+
});
|
|
79
|
+
console.log('ποΈ SowonLabs CrewX Local CA created: ~/.crewx/tls/ca.pem');
|
|
80
|
+
return { cert, key: keys.privateKey, isNew: true };
|
|
81
|
+
}
|
|
82
|
+
function generateServerCert(caCert, caKey) {
|
|
83
|
+
const host = (0, os_1.hostname)();
|
|
84
|
+
const keys = node_forge_1.default.pki.rsa.generateKeyPair(2048);
|
|
85
|
+
const cert = node_forge_1.default.pki.createCertificate();
|
|
86
|
+
cert.publicKey = keys.publicKey;
|
|
87
|
+
cert.serialNumber = randomSerialNumber();
|
|
88
|
+
cert.validity.notBefore = new Date();
|
|
89
|
+
cert.validity.notAfter = new Date();
|
|
90
|
+
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
|
|
91
|
+
cert.setSubject([{ name: 'commonName', value: host }]);
|
|
92
|
+
cert.setIssuer(caCert.subject.attributes);
|
|
93
|
+
cert.setExtensions([
|
|
94
|
+
{
|
|
95
|
+
name: 'subjectAltName',
|
|
96
|
+
altNames: [
|
|
97
|
+
{ type: 2, value: 'localhost' },
|
|
98
|
+
{ type: 2, value: host },
|
|
99
|
+
{ type: 7, ip: '127.0.0.1' },
|
|
100
|
+
{ type: 7, ip: '::1' },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
cert.sign(caKey, node_forge_1.default.md.sha256.create());
|
|
105
|
+
console.log('π Server certificate issued by SowonLabs CA: ~/.crewx/tls/cert.pem');
|
|
53
106
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
107
|
+
certPem: node_forge_1.default.pki.certificateToPem(cert),
|
|
108
|
+
keyPem: node_forge_1.default.pki.privateKeyToPem(keys.privateKey),
|
|
56
109
|
};
|
|
57
110
|
}
|
|
111
|
+
function installCA(caCertPath) {
|
|
112
|
+
if (process.env.CREWX_TRUST_CA === '0') {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const platform = process.platform;
|
|
116
|
+
console.log('');
|
|
117
|
+
console.log('π λΈλΌμ°μ κ²½κ³ μμ΄ HTTPSλ₯Ό μ¬μ©νλ €λ©΄ CA μΈμ¦μλ₯Ό λ±λ‘ν΄μΌ ν©λλ€.');
|
|
118
|
+
console.log(' λ±λ‘νμ§ μμλ HTTPSλ λμνμ§λ§, λΈλΌμ°μ μμ "μ£Όμ μν¨" κ²½κ³ κ° νμλ©λλ€.');
|
|
119
|
+
console.log('');
|
|
120
|
+
try {
|
|
121
|
+
if (platform === 'win32') {
|
|
122
|
+
(0, child_process_1.execSync)(`powershell -Command "Import-Certificate -FilePath '${caCertPath}' -CertStoreLocation Cert:\\CurrentUser\\Root"`, { stdio: 'inherit' });
|
|
123
|
+
}
|
|
124
|
+
else if (platform === 'darwin') {
|
|
125
|
+
(0, child_process_1.execSync)(`security add-trusted-cert -r trustRoot -k ~/Library/Keychains/login.keychain-db "${caCertPath}"`, { stdio: 'inherit' });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
console.log(' Linuxμμλ μλ λ±λ‘μ΄ νμν©λλ€:');
|
|
129
|
+
console.log(` sudo cp ${caCertPath} /usr/local/share/ca-certificates/crewx-ca.crt`);
|
|
130
|
+
console.log(' sudo update-ca-certificates');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
console.log('β
SowonLabs CAκ° μμ€ν
μ λ±λ‘λμμ΅λλ€. λΈλΌμ°μ κ²½κ³ μμ΄ HTTPSλ₯Ό μ¬μ©ν μ μμ΅λλ€.');
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
console.log('β οΈ CA λ±λ‘μ μ€ν¨νμ΅λλ€. HTTPSλ λμνμ§λ§ λΈλΌμ°μ μμ κ²½κ³ κ° νμλ©λλ€.');
|
|
137
|
+
console.log(` μλ λ±λ‘: ${caCertPath}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function randomSerialNumber() {
|
|
141
|
+
return node_forge_1.default.util.bytesToHex(node_forge_1.default.random.getBytesSync(16));
|
|
142
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crewx",
|
|
3
|
-
"version": "0.8.6-rc.
|
|
3
|
+
"version": "0.8.6-rc.2",
|
|
4
4
|
"description": "CrewX β AI agent team dashboard with Electron UI and CLI (Web + Electron + Global CLI)",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"bin": {
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"js-tiktoken": "^1.0.21",
|
|
56
56
|
"js-yaml": "^4.1.1",
|
|
57
57
|
"md-to-slack": "^1.0.0",
|
|
58
|
+
"node-forge": "^1.3.1",
|
|
58
59
|
"open": "^11.0.0",
|
|
59
60
|
"reflect-metadata": "^0.2.2",
|
|
60
61
|
"remark-parse": "^11.0.0",
|
|
61
62
|
"remark-stringify": "^11.0.0",
|
|
62
63
|
"rxjs": "^7.8.1",
|
|
63
|
-
"selfsigned": "^5.5.0",
|
|
64
64
|
"swagger-ui-express": "^5.0.1",
|
|
65
65
|
"unified": "^11.0.5",
|
|
66
66
|
"unist-util-visit": "^5.0.0",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"wink-nlp-utils": "^2.1.0",
|
|
69
69
|
"yargs": "^17.7.0",
|
|
70
70
|
"zod": "^3.22.0",
|
|
71
|
-
"@crewx/cli": "0.8.6-rc.
|
|
72
|
-
"@crewx/doc": "0.1.8",
|
|
71
|
+
"@crewx/cli": "0.8.6-rc.2",
|
|
73
72
|
"@crewx/cron": "0.1.8",
|
|
73
|
+
"@crewx/doc": "0.1.8",
|
|
74
74
|
"@crewx/memory": "0.1.10",
|
|
75
75
|
"@crewx/knowledge-core": "0.1.6",
|
|
76
|
-
"@crewx/sdk": "0.8.6-rc.
|
|
76
|
+
"@crewx/sdk": "0.8.6-rc.3",
|
|
77
77
|
"@crewx/shared": "0.0.5",
|
|
78
78
|
"@crewx/wbs": "0.1.9",
|
|
79
79
|
"@crewx/search": "0.1.9",
|
|
80
|
-
"@crewx/
|
|
81
|
-
"@crewx/
|
|
80
|
+
"@crewx/workflow": "0.3.18",
|
|
81
|
+
"@crewx/skill": "0.1.8"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@ccusage/codex": "^0.0.1",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"@types/express": "^5.0.0",
|
|
108
108
|
"@types/js-yaml": "^4.0.9",
|
|
109
109
|
"@types/node": "^20.10.0",
|
|
110
|
+
"@types/node-forge": "^1.3.11",
|
|
110
111
|
"@types/react": "^18.2.0",
|
|
111
112
|
"@types/react-dom": "^18.2.0",
|
|
112
113
|
"@types/supertest": "^7.2.0",
|