Skip to content

Token System

The token system is the access control backbone. Tokens are opaque strings that map to records in D1.

FieldTypeDescription
token_hashTEXTSHA-256 hash of the token (primary key)
nameTEXTHuman-readable label
roleTEXTvisitor, reviewer, or founder
scopeTEXTComma-separated section keys
person_idTEXTLinks to person record (nullable)
expires_atTEXTISO 8601 expiration timestamp
single_useINTEGER1 if token is consumed on first claim
claimedINTEGER1 if single-use token has been claimed
revokedINTEGER1 if revoked by founder
created_atTEXTCreation timestamp

Scopes are comma-separated section keys. The worker resolves effective scope by:

  1. Splitting the scope string
  2. Checking if the requested section key matches any scope entry
  3. Checking hierarchical membership via suffix matching