@campfire-net/campfire-mcp 0.1.2 → 0.4.0

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 (2) hide show
  1. package/index.js +31 -6
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -38,25 +38,50 @@ function getBinaryPath() {
38
38
  const cachedBin = path.join(cacheDir, platform === 'win32' ? 'cf-mcp.exe' : 'cf-mcp');
39
39
  if (fs.existsSync(cachedBin)) return cachedBin;
40
40
 
41
- // Download from GitHub Releases
41
+ // Download from GitHub Releases with checksum verification
42
+ const crypto = require('crypto');
42
43
  const goArch = arch === 'x64' ? 'amd64' : arch;
43
44
  const goPlatform = platform;
44
45
  const ext = platform === 'win32' ? 'zip' : 'tar.gz';
45
- const url = `https://github.com/campfire-net/campfire/releases/latest/download/cf_${goPlatform}_${goArch}.${ext}`;
46
+ const archiveName = `cf_${goPlatform}_${goArch}.${ext}`;
47
+ const baseUrl = 'https://github.com/campfire-net/campfire/releases/latest/download';
48
+ const archiveUrl = `${baseUrl}/${archiveName}`;
49
+ const checksumsUrl = `${baseUrl}/checksums.txt`;
50
+ const archivePath = path.join(cacheDir, archiveName);
46
51
 
47
- process.stderr.write(`campfire-mcp: downloading binary from ${url}\n`);
52
+ process.stderr.write(`campfire-mcp: downloading ${archiveName}\n`);
48
53
  fs.mkdirSync(cacheDir, { recursive: true });
49
54
 
50
55
  try {
56
+ // Download archive and checksums
57
+ execSync(`curl -sL "${archiveUrl}" -o "${archivePath}"`, { stdio: 'pipe' });
58
+ const checksums = execSync(`curl -sL "${checksumsUrl}"`, { encoding: 'utf8' });
59
+
60
+ // Verify SHA256
61
+ const archiveData = fs.readFileSync(archivePath);
62
+ const actualHash = crypto.createHash('sha256').update(archiveData).digest('hex');
63
+ const expectedLine = checksums.split('\n').find(l => l.includes(archiveName));
64
+ if (!expectedLine) {
65
+ throw new Error(`checksum not found for ${archiveName}`);
66
+ }
67
+ const expectedHash = expectedLine.trim().split(/\s+/)[0];
68
+ if (actualHash !== expectedHash) {
69
+ fs.unlinkSync(archivePath);
70
+ throw new Error(`checksum mismatch: expected ${expectedHash}, got ${actualHash}`);
71
+ }
72
+ process.stderr.write(`campfire-mcp: checksum verified\n`);
73
+
74
+ // Extract
51
75
  if (platform === 'win32') {
52
- execSync(`curl -sL "${url}" -o "${cacheDir}/cf.zip" && cd "${cacheDir}" && tar -xf cf.zip cf-mcp.exe`, { stdio: 'pipe' });
76
+ execSync(`cd "${cacheDir}" && tar -xf "${archivePath}" --strip-components=1 --include='*/cf-mcp.exe'`, { stdio: 'pipe' });
53
77
  } else {
54
- execSync(`curl -sL "${url}" | tar xz -C "${cacheDir}" --strip-components=1 --wildcards '*/cf-mcp'`, { stdio: 'pipe' });
78
+ execSync(`tar xzf "${archivePath}" -C "${cacheDir}" --strip-components=1 --wildcards '*/cf-mcp'`, { stdio: 'pipe' });
55
79
  }
80
+ fs.unlinkSync(archivePath);
56
81
  fs.chmodSync(cachedBin, 0o755);
57
82
  if (fs.existsSync(cachedBin)) return cachedBin;
58
83
  } catch (e) {
59
- throw new Error(`campfire-mcp: failed to download binary: ${e.message}\nInstall manually: curl -fsSL https://getcampfire.dev/install.sh | sh`);
84
+ throw new Error(`campfire-mcp: failed to download/verify binary: ${e.message}\nInstall manually: curl -fsSL https://getcampfire.dev/install.sh | sh`);
60
85
  }
61
86
 
62
87
  throw new Error('campfire-mcp: could not find or download binary');
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@campfire-net/campfire-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.4.0",
4
4
  "description": "Campfire MCP server — decentralized coordination protocol for AI agents",
5
5
  "bin": {
6
6
  "campfire-mcp": "index.js"
7
7
  },
8
8
  "optionalDependencies": {
9
- "@campfire-net/campfire-mcp-linux-x64": "0.1.0",
10
- "@campfire-net/campfire-mcp-linux-arm64": "0.1.0",
11
- "@campfire-net/campfire-mcp-darwin-x64": "0.1.0",
12
- "@campfire-net/campfire-mcp-darwin-arm64": "0.1.0",
13
- "@campfire-net/campfire-mcp-win32-x64": "0.1.0"
9
+ "@campfire-net/campfire-mcp-linux-x64": "0.2.0",
10
+ "@campfire-net/campfire-mcp-linux-arm64": "0.2.0",
11
+ "@campfire-net/campfire-mcp-darwin-x64": "0.2.0",
12
+ "@campfire-net/campfire-mcp-darwin-arm64": "0.2.0",
13
+ "@campfire-net/campfire-mcp-win32-x64": "0.2.0"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",