feat(webui): EULA/PRIVACY consent gate — backend

Server-side consent gate: GET /api/agreements (texts + content-hash version +
consentRequired) and POST /api/agreements/record-consent, persisted to
config/consent.json. Enforced in the auth middleware (CONSENT_ALLOWLIST,
ordered before the must-change-password gate) so the gate is real, not just a
frontend convention. The version is content-derived, so consent is stable
across app upgrades and re-prompts only when the agreement text changes. The
EULA/PRIVACY docs are bundled into dist/ (build fails if they are missing).
This commit is contained in:
DrSmoothl committed 2026-06-19 02:26:48 +08:00
1 parent f71ed2e4db
commit 8c7efc34a9
4 files changed
+382

No files matched your search

+20
View File
@@ -83,6 +83,19 @@ if (missingNatives.length > 0) {
);
}
// Legal docs are served by the WebUI consent gate; a missing one would silently
// disable consent in the shipped build, so fail the build instead (mirrors the
// native-binary guard above).
const missingAgreements = ['EULA.md', 'PRIVACY.md'].filter(
(f) => !fs.existsSync(path.resolve(repoRoot, f)),
);
if (missingAgreements.length > 0) {
throw new Error(
`Missing legal documents required by the WebUI consent gate:\n` +
missingAgreements.map((f) => ` - ${path.resolve(repoRoot, f)}`).join('\n'),
);
}
const BaseConfigPlugin: PluginOption[] = [
// Proton substitutes every `protobuf_encode<T>` / `protobuf_decode<T>`
// call site with a monomorphized codec at build time. WITHOUT this
@@ -109,6 +122,13 @@ const BaseConfigPlugin: PluginOption[] = [
dest: path.join(distDir, 'native', 'ffmpeg'),
flatten: true,
},
// Legal docs served verbatim by the WebUI consent gate. Copied next to
// the bundle so consent.ts's path probe finds them in a packaged deploy.
...['EULA.md', 'PRIVACY.md'].map((file) => ({
src: toPosix(path.resolve(repoRoot, file)),
dest: distDir,
flatten: true,
})),
]
})
];