feat(03-10): fail closed on bad credentials + fix backoff index + explicit randomUUID (CR-03, WR-01, WR-08)

- outboxWorker: remove empty-credential fallback; let loadClientForUser throw on error (CR-03)
- outboxWorker: fix backoff index from nextAttemptCount to row.attemptCount so first retry waits 15s not 60s (WR-01)
- events.ts: replace bare crypto.randomUUID() with import { randomUUID } from 'node:crypto' on all three handlers (WR-08)
This commit is contained in:
Lucas Berger
2026-06-05 20:51:48 -04:00
parent c178dcee0c
commit c21b040b36
2 changed files with 11 additions and 16 deletions
+4 -3
View File
@@ -21,6 +21,7 @@
* Mounted under /api/* in index.ts — behind oidcAuthMiddleware.
*/
import { randomUUID } from 'node:crypto'
import { Hono } from 'hono'
import { zValidator } from '@hono/zod-validator'
import { z } from 'zod'
@@ -253,7 +254,7 @@ eventsRouter.post('/create', zValidator('json', eventFieldsSchema), async (c) =>
}
// Generate a UID for the new event (Node.js 22 built-in)
const uid = `${crypto.randomUUID()}@familysync`
const uid = `${randomUUID()}@familysync`
// Enqueue the outbox row (pending) — the worker builds the VEVENT and calls Fastmail.
await db.insert(calendarOutbox).values({
@@ -325,8 +326,8 @@ eventsRouter.patch('/:uid/edit', zValidator('json', eventFieldsSchema), async (c
if (isCalendarMove) {
// D-04: edit-as-move — insert delete+create pair in one transaction (D-04 / Pitfall 5)
const newUid = `${crypto.randomUUID()}@familysync`
const groupId = crypto.randomUUID()
const newUid = `${randomUUID()}@familysync`
const groupId = randomUUID()
await db.transaction(async (tx) => {
// Delete from old calendar