@mmmnt/flmnt 1.7.0 → 1.9.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmnt/flmnt",
3
- "version": "1.7.0",
3
+ "version": "1.9.1",
4
4
  "description": "flmnt CLI — installs the platform-native flmnt binary.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
2
3
  import {
3
4
  chmodSync,
4
5
  mkdirSync,
@@ -11,7 +12,7 @@ import {
11
12
  import os from 'node:os';
12
13
  import path from 'node:path';
13
14
  import { fileURLToPath } from 'node:url';
14
- import { assetName, binaryName, downloadURL, shouldInstall, target } from '../src/platform.js';
15
+ import { assetName, binaryName, checksumsURL, downloadURL, expectedChecksum, shouldInstall, target } from '../src/platform.js';
15
16
 
16
17
  const REPO = 'mmmnt/flmnt-cli';
17
18
 
@@ -34,6 +35,20 @@ async function main() {
34
35
  }
35
36
  const buf = Buffer.from(await res.arrayBuffer());
36
37
 
38
+ // Verify the download against the published release checksums before trusting the binary.
39
+ const sumsRes = await fetch(checksumsURL(REPO, pkg.version), { redirect: 'follow' });
40
+ if (!sumsRes.ok) {
41
+ throw new Error(`checksum download failed: HTTP ${sumsRes.status}`);
42
+ }
43
+ const expected = expectedChecksum(await sumsRes.text(), asset);
44
+ if (!expected) {
45
+ throw new Error(`no published checksum for ${asset}`);
46
+ }
47
+ const actual = createHash('sha256').update(buf).digest('hex');
48
+ if (actual !== expected) {
49
+ throw new Error(`checksum mismatch for ${asset}: expected ${expected}, got ${actual}`);
50
+ }
51
+
37
52
  const tmp = mkdtempSync(path.join(os.tmpdir(), 'flmnt-'));
38
53
  try {
39
54
  const archivePath = path.join(tmp, asset);
package/src/platform.js CHANGED
@@ -33,6 +33,21 @@ export function downloadURL(repo, version, asset) {
33
33
  return `https://github.com/${repo}/releases/download/v${version}/${asset}`;
34
34
  }
35
35
 
36
+ export function checksumsURL(repo, version) {
37
+ return `https://github.com/${repo}/releases/download/v${version}/flmnt_${version}_checksums.txt`;
38
+ }
39
+
40
+ // Extract the expected sha256 for `asset` from a goreleaser checksums.txt (lines: "<hash> <asset>").
41
+ export function expectedChecksum(checksumsText, asset) {
42
+ for (const line of checksumsText.split('\n')) {
43
+ const [hash, name] = line.trim().split(/\s+/);
44
+ if (name === asset) {
45
+ return hash;
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+
36
51
  export function shouldInstall(version, env) {
37
52
  if (env.FLMNT_SKIP_DOWNLOAD) {
38
53
  return false;