fix(device-auth): inline helpers into each hook handler (JSVM scope) #4

Merged
richiexec merged 1 commit from fix/device-auth-jsvm-scope into main 2026-07-19 17:48:47 +00:00

1 commit

Author SHA1 Message Date
0d29431734 fix(device-auth): inline helpers into each hook handler (JSVM scope)
PocketBase runs every routerAdd/cronAdd handler in its OWN isolated JSVM, so the
file-level helpers/consts (nowSeconds, genCode, CODE_ALPHABET, the TTLs, and the
DEVICE_APPROVE_HTML page) were invisible inside the callbacks — every route threw
`ReferenceError: <name> is not defined` at request time (POST /request, the
cleanup cron, GET /device). A runtime-only trap that only surfaces on a live
PocketBase, which the original PR couldn't exercise.

Define what each handler needs *inside* it (local scope works). No behavior
change; syntax-checked with `node --check`.

Fixes the deploy of device-auth (amber-app #12).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 19:48:03 +02:00