Fix PBKDF2 iteration cap (Workers max 100k), add custom domain + error handler

- PBKDF2 iterations 210k->100k (Cloudflare WebCrypto hard limit; miniflare didn't enforce)
- Add cipher.theradicalparty.com custom domain route
- Add onError handler
- Verified live: E2E delivery + offline store-and-forward both working

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
maverick 2026-07-22 02:04:40 +10:00
parent 360bfeb5ab
commit 372a77754a
3 changed files with 11 additions and 2 deletions

View file

@ -11,6 +11,11 @@ export { Mailbox } from "./do/mailbox.js";
const app = new Hono();
app.onError((err, c) => {
console.error("unhandled:", err.stack || err.message);
return c.json({ error: "server error" }, 500);
});
app.get("/api/health", (c) => c.json({ ok: true, service: "cipher" }));
app.route("/api/auth", auth);

View file

@ -4,7 +4,8 @@
import { b64, randomToken, now } from "./util.js";
const PBKDF2_ITERS = 210000;
// Cloudflare Workers caps PBKDF2 at 100k iterations (WebCrypto limit).
const PBKDF2_ITERS = 100000;
async function pbkdf2(password, saltBytes) {
const enc = new TextEncoder();

View file

@ -5,6 +5,9 @@
"compatibility_date": "2025-07-01",
"compatibility_flags": ["nodejs_compat"],
"observability": { "enabled": true },
"routes": [
{ "pattern": "cipher.theradicalparty.com", "custom_domain": true }
],
"assets": {
"directory": "./public",
"binding": "ASSETS",
@ -14,7 +17,7 @@
{
"binding": "DB",
"database_name": "cipher",
"database_id": "REPLACE_AFTER_CREATE",
"database_id": "f80ec87d-02ad-486d-b33a-50322f33c235",
"migrations_dir": "migrations"
}
],