bettersight-statement-extra.../pocketbase/pb_hooks
JasonFraser d76d335d9b Add PocketBase schema for the layout mapper (L.3)
New layoutMappings/layoutMappingVersions collections plus documents fields
(layoutMappingUsed/layoutMappingVersionUsed/layoutApplied/layoutFingerprintHash) and
a promote_shared_layout_mapping.pb.js hook that flips a mapping to "shared" once a
second, different user independently creates one with the same fingerprintHash.

Found and fixed a real security gap by testing the live rule rather than trusting the
rule text: the original updateRule only gated WHO could update a layoutMappings
record, not WHICH fields - letting an owner trivially self-promote their own mapping
to "shared" via a plain PATCH, defeating the whole confirmation requirement. Fixed in
a follow-up migration (6_fix_layout_mapping_update_rule.js) that blocks setting status
to "shared" directly while leaving ordinary edits and self-retiring untouched.

Verified against the real rebuilt PocketBase container: both collections and all four
new documents fields confirmed via the REST API; two real signed-up users with a
matching fingerprintHash both correctly flip to shared via the hook, visible to a
third user; a still-private mapping 404s for every other user; the self-promotion
gap reproduced before the fix and confirmed blocked after it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 15:34:43 -04:00
..
ensure_default_project.pb.js Add PocketBase: accounts (password + Google) + schema for R2-backed docs 2026-10-13 00:26:41 -04:00
promote_shared_layout_mapping.pb.js Add PocketBase schema for the layout mapper (L.3) 2026-10-14 15:34:43 -04:00