fix(promptlib): 1.14.1 修正 manifest.files 哈希(1.14.0 市场安装报完整性校验失败)

1.14.0 改了 main.js,但 manifest.files 仍写着旧哈希 720b8aaa,客户端装载时
比对真实字节 e6e9ec6a 直接拒绝,界面显示「未加载 · 完整性校验失败」。

- plugins/promptlib/manifest.json:版本 1.14.1,files 按真实字节重算
- plugins/index.json:同步版本与三处哈希
- scripts/gen-market.js:生成市场包前断言 manifest.files == 实际字节,不符即中断
- tests/plugin-manifest-hashes-test.js:门禁守住 manifest.files / index.json 哈希与版本一致
This commit is contained in:
qiqi committed 2026-11-27 12:08:35 +08:00
1 parent 012fd0267c
commit ea1e865426
6 files changed
+76 -6

No files matched your search

+1 -1
View File
@@ -41,7 +41,7 @@ build esbuild 打包到 dist/(单 dist/app.js = src/ 模块按序
node --check app.js 与 dist/app.js 语法
check-dist.js 产物体检
lint ESLint(src/ + app.js,正确性规则)
test:unit 133 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
test:unit 134 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
test relay-task-graph-fixture + iwb-v32-web-test
test:facts 事实基线守门(见 §5)
typecheck 渐进类型检查(tsc --noEmit;范围 = src/*.js,不含 app.js)
+1 -1
View File
@@ -10,7 +10,7 @@
"app:build": "tauri build",
"lint": "eslint src app.js",
"test": "node tests/relay-task-graph-fixture-test.js && node tests/plugin-style-node-test.js && node tests/inherit-text-test.js",
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/gallery-sync-test.js && node tests/image-blob-store-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/gallery-sync-test.js && node tests/image-blob-store-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
"test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js",
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
+2 -2
View File
@@ -55,9 +55,9 @@
"dir": "promptlib",
"main": "main.js",
"style": "styles.css",
"version": "1.14.0",
"version": "1.14.1",
"files": {
"manifest.json": "4d8d6ce8d5ebe6ba2864f0e7f3708492b82561c8467b0c006343cab3cab1f769",
"manifest.json": "8ab5f502ad98344170c4434f4f3f050565ca15f71c11a41055a6a83f10e98bb4",
"main.js": "e6e9ec6aad1582ae00f23c88a762e84e28ae5403d6739291dd1a44a28e3f49fe",
"styles.css": "203d61278ad98b2a07053851d0cfb42dd826564e5ae4d068ec950423cd09c46b"
}
+2 -2
View File
@@ -1,7 +1,7 @@
{
"id": "promptlib",
"name": "提示词库",
"version": "1.14.0",
"version": "1.14.1",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"提示词"
],
"files": {
"main.js": "720b8aaa040e0310e6c7d7d2fe1ad6ed0a0e437de77d56bf1a2905355c795e13",
"main.js": "e6e9ec6aad1582ae00f23c88a762e84e28ae5403d6739291dd1a44a28e3f49fe",
"styles.css": "203d61278ad98b2a07053851d0cfb42dd826564e5ae4d068ec950423cd09c46b"
}
}
+16
View File
@@ -39,6 +39,22 @@ function readFolderFiles (id) {
if (fs.statSync(abs).isFile()) files.push({ name: 'assets/' + name, data: fs.readFileSync(abs) })
}
}
// v3.26.109:manifest.files 是客户端装载时校验入口文件的依据;写成旧值会让市场安装直接
// 「完整性校验失败(main.js 的 sha256 不符)」(promptlib 1.14.0 就这样发出去过一次)。
// 生成阶段就对照真实字节,不符直接中断,别等用户装不上才发现。
const bad = []
for (const [name, expect] of Object.entries(manifest.files || {})) {
const f = files.find((x) => x.name === name)
if (!f) { bad.push(name + ' 缺失'); continue }
const actual = shaHex(f.data)
if (actual !== String(expect).toLowerCase()) bad.push(name + ' 期望 ' + String(expect).slice(0, 8) + ' 实际 ' + actual.slice(0, 8))
}
if (bad.length) {
console.error('[gen-market] ' + String(manifest.id) + ' 的 manifest.files 与实际字节不符:' + bad.join(';'))
console.error('[gen-market] 修好 manifest.files 再发市场(否则客户端会拒绝装载)')
process.exit(1)
}
return { files, manifest }
}
+54
View File
@@ -0,0 +1,54 @@
'use strict'
// 插件清单哈希守卫:manifest.files / plugins/index.json 的 sha256 必须等于真实字节。
// 背景(v3.26.109):promptlib 1.14.0 改了 main.js 但 manifest.files 还写着上一版的哈希,
// 市场装下来直接「完整性校验失败(main.js 的 sha256 不符)」,用户装不上插件。
// 这里在门禁里盯住源码侧,gen-market.js 里还有一道生成期断言。
const fs = require('fs')
const path = require('path')
const crypto = require('crypto')
const ROOT = path.join(__dirname, '..')
const PLUGINS = path.join(ROOT, 'plugins')
const sha = (buf) => crypto.createHash('sha256').update(buf).digest('hex')
let pass = 0
let fail = 0
function ok (name, cond, extra) {
if (cond) { pass++; console.log(' ✅ ' + name) } else { fail++; console.log(' ❌ ' + name + (extra ? ' —— ' + extra : '')) }
}
console.log('===== 插件清单哈希:manifest.files 必须等于真实字节 =====')
const index = JSON.parse(fs.readFileSync(path.join(PLUGINS, 'index.json'), 'utf8'))
const byId = new Map(index.map((e) => [e.id, e]))
for (const id of fs.readdirSync(PLUGINS)) {
const dir = path.join(PLUGINS, id)
if (!fs.statSync(dir).isDirectory()) continue
const manifestPath = path.join(dir, 'manifest.json')
if (!fs.existsSync(manifestPath)) continue
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
const bad = []
for (const [name, expect] of Object.entries(manifest.files || {})) {
const p = path.join(dir, name)
if (!fs.existsSync(p)) { bad.push(name + ' 缺失'); continue }
const actual = sha(fs.readFileSync(p))
if (actual !== String(expect).toLowerCase()) bad.push(name + ' 期望 ' + String(expect).slice(0, 8) + ' 实际 ' + actual.slice(0, 8))
}
ok('manifest.files 与字节一致:' + id, bad.length === 0, bad.join(';'))
const entry = byId.get(id)
if (!entry) continue
const badIdx = []
for (const [name, expect] of Object.entries(entry.files || {})) {
const p = path.join(dir, name)
if (!fs.existsSync(p)) { badIdx.push(name + ' 缺失'); continue }
const actual = sha(fs.readFileSync(p))
if (actual !== String(expect).toLowerCase()) badIdx.push(name + ' 期望 ' + String(expect).slice(0, 8) + ' 实际 ' + actual.slice(0, 8))
}
ok('plugins/index.json 与字节一致:' + id, badIdx.length === 0, badIdx.join(';'))
ok('版本两处一致:' + id, String(entry.version) === String(manifest.version), 'index=' + entry.version + ' manifest=' + manifest.version)
}
console.log('\nplugin manifest hash checks: ' + pass + ' 通过 / ' + fail + ' 失败')
process.exit(fail ? 1 : 0)