@idpass/data-collect-core / validateEventScope
Function: validateEventScope()
validateEventScope(
event,scope,lookup):ScopeValidationResult
Defined in: services/ScopeResolver.ts:166
Pure server-side validator for inbound /push events. The caller is
responsible for resolving entity references through whatever store it owns
(Postgres, IndexedDB, in-memory map). The validator only inspects the event
payload and the EntityScopeRef returned by lookup.
Rules (see docs/superpowers/specs/2026-04-28-bounded-sync-scope-design.md §7
and Phase 3 plan):
- Unbounded scope (
areaIds === null && entityTypes === null) → always ok. create-individual/create-group: derive type from event-name suffix, readdata.area_idfrom the payload only.- All other event types: defer to
lookup(entityGuid). Iflookupreturnsundefined, returnunknown_entity— we cannot prove scope membership.update-*events that carry a newdata.area_idmust check BOTH the stored area and the incoming area: a scoped client must not be able to move an entity in or out of its scope. areaIdsset + event resolves to noarea_id→out_of_scope.entityTypesset + entity is"record"(or any non-listed type) →out_of_scope.
Parameters
event
type
string
entityGuid
string
data
Record<string, unknown>
scope
lookup
(guid) => EntityScopeRef | undefined