@kmugalkhod/lightcode 0.1.1 → 0.1.3

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 (3) hide show
  1. package/cli.js +1 -1
  2. package/lightcode.cjs +40 -8
  3. package/package.json +2 -3
package/cli.js CHANGED
@@ -85,7 +85,7 @@ var init_logger = __esm(() => {
85
85
  });
86
86
 
87
87
  // packages/shared/src/version.ts
88
- var lightcodeVersion = "0.1.1";
88
+ var lightcodeVersion = "0.1.3";
89
89
 
90
90
  // packages/shared/src/index.ts
91
91
  var productName = "Lightcode";
package/lightcode.cjs CHANGED
@@ -35,20 +35,52 @@ try {
35
35
  // Bun uses its own TLS stack and does not read the Windows certificate store,
36
36
  // so corporate SSL proxies (which install their CA into Windows) are invisible
37
37
  // to Bun unless we forward the certs explicitly.
38
+ // Strategy: use PowerShell only to export raw DER .cer files; do all PEM
39
+ // formatting in Node.js where string/encoding handling is reliable.
38
40
  if (process.platform === "win32" && !process.env.NODE_EXTRA_CA_CERTS) {
39
41
  try {
40
- const winca = require("win-ca/api");
41
- const pems = [];
42
- winca.each({ store: ["root", "ca"], format: winca.der2.pem }, (pem) => {
43
- pems.push(pem);
42
+ const tmpDir = os.tmpdir();
43
+ const cerDir = path.join(tmpDir, "lightcode-certs");
44
+ const pemFile = path.join(tmpDir, "lightcode-win-ca.pem");
45
+ const ps1File = path.join(tmpDir, "lightcode-cert-export.ps1");
46
+
47
+ if (!fs.existsSync(cerDir)) fs.mkdirSync(cerDir, { recursive: true });
48
+
49
+ // Forward slashes work in PowerShell and avoid backslash escaping issues
50
+ const cerDirFwd = cerDir.replace(/\\/g, "/");
51
+ const psLines = [
52
+ "$i = 0",
53
+ 'foreach ($s in @("Root", "CA")) {',
54
+ ' try {',
55
+ ' foreach ($c in (Get-ChildItem "Cert:\\LocalMachine\\$s" -EA Stop)) {',
56
+ ' Export-Certificate -Cert $c -FilePath "' + cerDirFwd + '/$i.cer" -Type CERT | Out-Null',
57
+ ' $i++',
58
+ ' }',
59
+ ' } catch {}',
60
+ '}',
61
+ ];
62
+ fs.writeFileSync(ps1File, psLines.join("\n"), "utf8");
63
+ spawnSync("powershell", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", ps1File], { stdio: "pipe" });
64
+ try { fs.unlinkSync(ps1File); } catch {}
65
+
66
+ // Convert DER .cer files to PEM entirely in Node.js
67
+ const cerFiles = fs.existsSync(cerDir) ? fs.readdirSync(cerDir).filter(function(f) { return f.endsWith(".cer"); }) : [];
68
+ const pems = cerFiles.map(function(f) {
69
+ const der = fs.readFileSync(path.join(cerDir, f));
70
+ const b64 = der.toString("base64").match(/.{1,64}/g).join("\n");
71
+ return "-----BEGIN CERTIFICATE-----\n" + b64 + "\n-----END CERTIFICATE-----";
44
72
  });
73
+
45
74
  if (pems.length > 0) {
46
- const tmpFile = path.join(os.tmpdir(), "lightcode-win-ca.pem");
47
- fs.writeFileSync(tmpFile, pems.join("\n"), "utf8");
48
- process.env.NODE_EXTRA_CA_CERTS = tmpFile;
75
+ fs.writeFileSync(pemFile, pems.join("\n") + "\n", "ascii");
76
+ process.env.NODE_EXTRA_CA_CERTS = pemFile;
49
77
  }
78
+
79
+ // Cleanup individual cert files
80
+ cerFiles.forEach(function(f) { try { fs.unlinkSync(path.join(cerDir, f)); } catch {} });
81
+ try { fs.rmdirSync(cerDir); } catch {}
50
82
  } catch {
51
- // win-ca not available or failed — Bun uses its own bundled roots
83
+ // cert export failed — Bun uses its own bundled roots
52
84
  }
53
85
  }
54
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmugalkhod/lightcode",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Lightcode — a personal AI coding agent with a terminal UI and local session storage.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,7 +29,6 @@
29
29
  "hono": "4.12.25",
30
30
  "react": "^19.0.0",
31
31
  "react-router": "^7.1.0",
32
- "zod": "^4.4.3",
33
- "win-ca": "^3.5.1"
32
+ "zod": "^4.4.3"
34
33
  }
35
34
  }