arcana-ai 0.2.1 → 0.2.2
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/bin/arcana.js +21 -24
- package/package.json +1 -1
package/bin/arcana.js
CHANGED
|
@@ -56,30 +56,27 @@ async function downloadAndExtract() {
|
|
|
56
56
|
writeFileSync(tmp, buf)
|
|
57
57
|
console.error(`arcana: ${(buf.length / 1e6).toFixed(1)}MB, verifying checksum...`)
|
|
58
58
|
|
|
59
|
-
// Verify binary checksum
|
|
60
|
-
const shaUrl = url + ".sha256"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.error(`arcana: checksum verification failed: ${e.message}`)
|
|
81
|
-
process.exit(1)
|
|
82
|
-
}
|
|
59
|
+
// Verify binary integrity — checksum is mandatory, GitHub generates .sha256 for every asset
|
|
60
|
+
const shaUrl = url + ".sha256"
|
|
61
|
+
const shaRes = await fetch(shaUrl)
|
|
62
|
+
if (!shaRes.ok) {
|
|
63
|
+
console.error(`arcana: FATAL — checksum unavailable (${shaUrl})`)
|
|
64
|
+
console.error(`arcana: the binary cannot be verified and will not be executed`)
|
|
65
|
+
try { unlinkSync(tmp) } catch {}
|
|
66
|
+
process.exit(1)
|
|
67
|
+
}
|
|
68
|
+
const shaText = (await shaRes.text()).trim()
|
|
69
|
+
const expectedHash = shaText.split(/\s+/)[0]
|
|
70
|
+
const actualHash = crypto.createHash("sha256").update(buf).digest("hex")
|
|
71
|
+
if (expectedHash !== actualHash) {
|
|
72
|
+
console.error(`arcana: CHECKSUM MISMATCH for ${zipName}`)
|
|
73
|
+
console.error(` expected: ${expectedHash}`)
|
|
74
|
+
console.error(` actual: ${actualHash}`)
|
|
75
|
+
console.error(`arcana: binary may be corrupted or tampered — deleting`)
|
|
76
|
+
try { unlinkSync(tmp) } catch {}
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
console.error(`arcana: checksum OK (SHA256: ${actualHash.slice(0, 16)}...)`)
|
|
83
80
|
|
|
84
81
|
console.error(`arcana: extracting...`)
|
|
85
82
|
|