fix(device-auth): inline helpers into each hook handler (JSVM scope) #4
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/device-auth-jsvm-scope"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The deployed device-auth hooks throw at request time — confirmed from the PocketBase logs:
Root cause: PocketBase runs every
routerAdd/cronAddhandler in its own isolated JSVM, so file-levelconst/functiondefinitions aren't visible inside the callbacks. The helpers (nowSeconds,genCode,CODE_ALPHABET, the TTLs) and theDEVICE_APPROVE_HTMLpage were defined at file scope → every handler that referenced themReferenceErrored. A runtime-only trap the original PR (#3) couldn't hit without a live PocketBase.Fix: define what each handler needs inside it (local scope works). No behavior change;
node --checkclean on both files.infoandpollalready worked (they don't use the file-level helpers), which is what pinned the diagnosis.Merge + redeploy; then
POST /api/device-auth/requestshould return a code and/device?code=…should render the approve page. On-device TV↔phone test follows.🤖 Generated with Claude Code