/** E2E 临时接收器:18790,打印签名/Authorization 校验结果 */ const KEY = "wmh_e2e_key_12345"; Bun.serve({ port: 18790, async fetch(req) { 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; console.log( JSON.stringify({ got: "webhook", auth: req.headers.get("Authorization"), signature_valid: sig === expect, event: payload.event, subject: payload.subject, mailbox: payload.mailbox, custom_header: req.headers.get("X-E2E"), }), ); return Response.json({ ok: true }); }, }); console.log("receiver on :18790");