@lasso-ai/cli 1.4.2 → 1.4.4
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.
|
@@ -211,31 +211,49 @@ async function installMkcert() {
|
|
|
211
211
|
}
|
|
212
212
|
async function ensureHostCertificate(onProgress) {
|
|
213
213
|
node_fs_1.default.mkdirSync(paths_1.HOST_DIR, { recursive: true, mode: 0o700 });
|
|
214
|
+
// Check if certificate exists and is trusted
|
|
214
215
|
if (hasCertificate()) {
|
|
215
216
|
const certStatus = hostCertificateStatus();
|
|
216
|
-
|
|
217
|
+
console.log(`[Lasso] Certificate exists, trusted: ${certStatus.trusted}`);
|
|
218
|
+
// If certificate exists but is not trusted and mkcert is available, regenerate it
|
|
219
|
+
if (!certStatus.trusted && isMkcertInstalled()) {
|
|
220
|
+
onProgress?.("Regenerating certificate with mkcert for trusted SSL...");
|
|
221
|
+
try {
|
|
222
|
+
node_fs_1.default.unlinkSync(exports.TLS_CERT_FILE);
|
|
223
|
+
node_fs_1.default.unlinkSync(exports.TLS_KEY_FILE);
|
|
224
|
+
}
|
|
225
|
+
catch { }
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
return { ok: true, trusted: certStatus.trusted };
|
|
229
|
+
}
|
|
217
230
|
}
|
|
218
231
|
onProgress?.("Generating SSL certificate...");
|
|
219
232
|
// Try mkcert first - it creates system-trusted certificates
|
|
220
233
|
if (!isMkcertInstalled()) {
|
|
221
234
|
onProgress?.("mkcert not found, installing...");
|
|
235
|
+
console.log("[Lasso] mkcert not found, attempting installation...");
|
|
222
236
|
const installResult = await installMkcert();
|
|
223
237
|
if (!installResult.ok) {
|
|
224
238
|
console.warn(`[Lasso] ${installResult.error}`);
|
|
225
239
|
console.warn("[Lasso] Falling back to OpenSSL (certificate will show as not secure)");
|
|
226
240
|
}
|
|
227
241
|
}
|
|
242
|
+
else {
|
|
243
|
+
console.log("[Lasso] mkcert is installed");
|
|
244
|
+
}
|
|
228
245
|
if (isMkcertInstalled()) {
|
|
229
246
|
try {
|
|
230
247
|
onProgress?.("Creating trusted certificate with mkcert...");
|
|
231
248
|
const mkcertPath = getMkcertPath();
|
|
249
|
+
console.log(`[Lasso] Using mkcert at: ${mkcertPath}`);
|
|
232
250
|
(0, node_child_process_1.execFileSync)(mkcertPath, ["-cert-file", exports.TLS_CERT_FILE, "-key-file", exports.TLS_KEY_FILE, "localhost", "127.0.0.1", "::1", "*.lasso"], { stdio: "ignore" });
|
|
233
251
|
node_fs_1.default.chmodSync(exports.TLS_KEY_FILE, 0o600);
|
|
234
252
|
onProgress?.("✓ SSL certificate ready (trusted)");
|
|
235
253
|
return { ok: true, trusted: true };
|
|
236
254
|
}
|
|
237
255
|
catch (mkcertError) {
|
|
238
|
-
console.warn("[Lasso] mkcert failed, falling back to OpenSSL");
|
|
256
|
+
console.warn("[Lasso] mkcert failed, falling back to OpenSSL:", mkcertError);
|
|
239
257
|
}
|
|
240
258
|
}
|
|
241
259
|
// Fallback to OpenSSL - creates self-signed certificate (not trusted by browsers)
|
|
@@ -264,8 +282,8 @@ function hostCertificateStatus() {
|
|
|
264
282
|
let trusted = false;
|
|
265
283
|
if (hasCertificate()) {
|
|
266
284
|
try {
|
|
267
|
-
const certContent = node_fs_1.default.readFileSync(exports.TLS_CERT_FILE, "utf8");
|
|
268
|
-
// mkcert certificates include "mkcert" in the issuer
|
|
285
|
+
const certContent = node_fs_1.default.readFileSync(exports.TLS_CERT_FILE, "utf8").toLowerCase();
|
|
286
|
+
// mkcert certificates include "mkcert" in the issuer or subject (case-insensitive)
|
|
269
287
|
trusted = certContent.includes("mkcert");
|
|
270
288
|
}
|
|
271
289
|
catch {
|
package/package.json
CHANGED