@apexacc/cli 1.5.42 → 1.5.44

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/apex.cjs +19 -0
  2. package/package.json +1 -1
package/apex.cjs CHANGED
@@ -37,6 +37,24 @@ function download(url, dest) {
37
37
  })
38
38
  }
39
39
 
40
+ async function verifySha256(filePath, hashUrl) {
41
+ try {
42
+ const hashPath = filePath + '.sha256'
43
+ await download(hashUrl, hashPath)
44
+ const { createHash } = require('crypto'), fs = require('fs')
45
+ const expectedHash = fs.readFileSync(hashPath, 'utf8').trim().split(/\s+/)[0]
46
+ const actualHash = createHash('sha256').update(fs.readFileSync(filePath)).digest('hex')
47
+ fs.unlinkSync(hashPath)
48
+ if (actualHash !== expectedHash) {
49
+ fs.unlinkSync(filePath)
50
+ throw new Error('Binary hash mismatch — aborting for security.')
51
+ }
52
+ } catch (e) {
53
+ if (e.message.includes('hash mismatch')) throw e
54
+ console.warn('Warning: could not verify binary hash:', e.message)
55
+ }
56
+ }
57
+
40
58
  async function ensureBinary() {
41
59
  if (existsSync(BIN_PATH)) return
42
60
  console.log('Downloading Apex Copilot (~150MB), please wait...')
@@ -44,6 +62,7 @@ async function ensureBinary() {
44
62
  const assetName = isWin ? `apex-${target}.exe` : `apex-${target}`
45
63
  mkdirSync(BIN_DIR, { recursive: true })
46
64
  await download(`https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`, BIN_PATH)
65
+ await verifySha256(BIN_PATH, `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}.sha256`)
47
66
  if (!isWin) require('fs').chmodSync(BIN_PATH, 0o755)
48
67
  if (isWin) {
49
68
  const nativesDir = join(os.homedir(), '.apex', 'natives', '16.3.6')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexacc/cli",
3
- "version": "1.5.42",
3
+ "version": "1.5.44",
4
4
  "description": "Apex Copilot CLI — Due diligence toolkit for founders",
5
5
  "author": {
6
6
  "name": "Apex Accelerator",