lean-ctx-bin 3.5.5 → 3.5.6
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/package.json +1 -1
- package/postinstall.js +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lean-ctx-bin",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.6",
|
|
4
4
|
"description": "lean-ctx — the token-efficient context tool for LLM coding agents. Installs a pre-built binary, no Rust required.",
|
|
5
5
|
"keywords": ["lean-ctx", "mcp", "llm", "context", "claude", "cursor", "ai", "token-optimization"],
|
|
6
6
|
"homepage": "https://leanctx.com",
|
package/postinstall.js
CHANGED
|
@@ -6,6 +6,7 @@ const fs = require("fs");
|
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const https = require("https");
|
|
8
8
|
const { createGunzip } = require("zlib");
|
|
9
|
+
const crypto = require("crypto");
|
|
9
10
|
|
|
10
11
|
const REPO = "yvgude/lean-ctx";
|
|
11
12
|
const BIN_DIR = path.join(__dirname, "bin");
|
|
@@ -161,6 +162,27 @@ async function main() {
|
|
|
161
162
|
|
|
162
163
|
try {
|
|
163
164
|
await downloadToFile(asset.browser_download_url, archivePath);
|
|
165
|
+
|
|
166
|
+
const sumsAsset = (release.assets || []).find((a) => a.name === "SHA256SUMS");
|
|
167
|
+
if (sumsAsset) {
|
|
168
|
+
const sumsText = await new Promise((resolve, reject) => {
|
|
169
|
+
httpsGet(sumsAsset.browser_download_url).then((res) => {
|
|
170
|
+
let data = "";
|
|
171
|
+
res.on("data", (c) => (data += c));
|
|
172
|
+
res.on("end", () => resolve(data));
|
|
173
|
+
}).catch(reject);
|
|
174
|
+
});
|
|
175
|
+
const expectedLine = sumsText.split("\n").find((l) => l.includes(assetName));
|
|
176
|
+
if (expectedLine) {
|
|
177
|
+
const expectedHash = expectedLine.trim().split(/\s+/)[0].toLowerCase();
|
|
178
|
+
const fileHash = crypto.createHash("sha256").update(fs.readFileSync(archivePath)).digest("hex");
|
|
179
|
+
if (fileHash !== expectedHash) {
|
|
180
|
+
throw new Error(`SHA256 mismatch: expected ${expectedHash}, got ${fileHash}. Binary may be compromised.`);
|
|
181
|
+
}
|
|
182
|
+
console.log("lean-ctx: SHA256 verified");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
164
186
|
console.log("lean-ctx: downloaded, extracting...");
|
|
165
187
|
|
|
166
188
|
fs.mkdirSync(BIN_DIR, { recursive: true });
|