- 单一 Key:API 与 MCP 共用一个 wmh_ Key,凭据迁移至 settings 表(0004 删除 api_credentials) - Markdown:入库时 HTML→Markdown(mailhook 同思路),webhook payload 新增 markdown 字段 - /emails 路由改为 /inboxs 并支持域名筛选;设置按钮移入头像下拉 - 主题切换按钮(头像左侧,亮/暗持久化);设置模态仅 全局 Webhook/账号密码 两 tab 且高度限屏 - 列表操作列按钮加 SVG 图标;mailboxes 去 Webhook 列;最近邮件加收件人列
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
/** E2E 临时接收器:18790,打印签名/Authorization 校验结果 */
|
|
const KEY = "wmh_e2e_key_12345";
|
|
Bun.serve({
|
|
port: 18790,
|
|
async fetch(req) {
|
|
if (req.method === "GET" && new URL(req.url).pathname === "/__stats") {
|
|
return Response.json({ ok: true, note: "see stdout for deliveries" });
|
|
}
|
|
if (req.method !== "POST" || new URL(req.url).pathname !== "/hook") {
|
|
return Response.json({ error: "not found" }, { status: 404 });
|
|
}
|
|
const body = await req.text();
|
|
const ts = req.headers.get("X-WmailHub-Timestamp") ?? "";
|
|
const sig = req.headers.get("X-WmailHub-Signature") ?? "";
|
|
const { hmacSha256Hex } = await import("../../shared/src/index.ts");
|
|
const expect = await hmacSha256Hex(KEY, `${ts}.${body}`);
|
|
const payload = JSON.parse(body) as Record<string, unknown>;
|
|
console.log(
|
|
JSON.stringify({
|
|
got: "webhook",
|
|
auth: req.headers.get("Authorization"),
|
|
signature_valid: sig === expect,
|
|
event: payload.event,
|
|
subject: payload.subject,
|
|
mailbox: payload.mailbox,
|
|
markdown: payload.markdown,
|
|
custom_header: req.headers.get("X-Custom"),
|
|
}),
|
|
);
|
|
return Response.json({ ok: true });
|
|
},
|
|
});
|
|
console.log("receiver on :18790");
|