Files
Scoreboard/deploy/verify-signature.mjs
T
AskaEth 8039da384d fix(build): 署名自检改用 Node 字节比对(findstr 在 chcp 65001 下匹配不了 UTF-8 中文)
findstr 会误报 NOT found,而实测 exe 里署名是存在的。改成 verify-signature.mjs
读字节 includes 比对,缺失时让构建硬失败。
2026-09-09 22:21:28 +08:00

28 lines
943 B
JavaScript

// 校验注入后的 exe 里确实含有署名。
//
// 为什么不用 findstr:它在 chcp 65001 下匹配不了 UTF-8 中文(会静默误报 NOT found),
// 而 build.bat 又必须保持纯 ASCII。用 Node 读字节比对最稳。
import { existsSync, readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
const root = dirname(import.meta.dirname)
const sigFile = join(root, 'deploy', 'signature.build.txt')
const exe = join(root, 'dist', 'scoreboard.exe')
if (!existsSync(sigFile)) process.exit(0)
const sig = readFileSync(sigFile, 'utf8').trim()
if (sig === '') process.exit(0)
if (!existsSync(exe)) {
console.error(' [warn] scoreboard.exe not found, skip signature check')
process.exit(0)
}
if (!readFileSync(exe).includes(Buffer.from(sig, 'utf8'))) {
console.error(' [ERROR] internal signature NOT found in scoreboard.exe')
process.exit(1)
}
console.log(' internal signature verified in exe')