chore: CRM-NEW baseline

This commit is contained in:
wangliang
2026-10-23 10:35:28 +08:00
commit aa499f6dbf
111 changed files with 15126 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
'use strict';
const crypto = require('crypto');
/**
* 工具服务入口鉴权:LibreDesk 在工具的 Headers 配置里带 X-Tools-Key。
* 未配置 key 时 fail-closed(返回 enabled=false,server 会直接 503)。
*/
function createAuther(expectedKey) {
const key = String(expectedKey || '');
const expected = Buffer.from(key);
function verify(value) {
if (!key) return false;
const given = Buffer.from(String(value || ''));
if (given.length !== expected.length) return false;
return crypto.timingSafeEqual(given, expected);
}
return { enabled: key.length > 0, verify };
}
module.exports = { createAuther };