Presence Token
This token represents an ephemeral presence indication, such as typing status or online presence. Unlike other action types, presence tokens are NOT persisted to the database - they are only forwarded via WebSocket in real-time.
The presence token must contain a subject (sub) field referencing the context (e.g., a conversation). For other constraints see the Action Tokens.
Ephemeral Nature
IMPORTANT: PRES tokens are fundamentally different from other action types:
- NOT persisted: Not stored in the database
- NOT content-addressed: No action_id is generated
- Real-time only: Forwarded via WebSocket immediately
- Short TTL: Default time-to-live of 30 seconds
- No delivery tasks: No scheduling or retry logic
This makes PRES tokens ideal for real-time status updates that don’t need to be permanent.
Purpose
PRES tokens serve several important purposes:
- Typing Indicators: Show when someone is typing in a conversation
- Online Status: Indicate when users are online/active
- Activity Updates: Real-time presence in collaborative contexts
- Low-Overhead Updates: Frequent status changes without database writes
Fields
| Field | Required | Description |
|---|---|---|
| iss | Yes | The user’s identity |
| sub | Yes | Context (e.g., CONV action_id) |
| aud | Optional | Specific target user (if omitted, broadcast to context) |
| t | Yes | “PRES:TYPING”, “PRES:ONLINE”, etc. |
| c | Optional | Additional metadata |
| a | Forbidden | Attachments are not allowed |
Subtypes
| Subtype | Description |
|---|---|
| PRES:TYPING | User is currently typing |
| PRES:ONLINE | User is online/active |
| PRES:AWAY | User is away/idle |
| PRES:OFFLINE | User has gone offline |
Additional subtypes can be defined for application-specific presence states.
Subject Reference
The sub (subject) field specifies the context for the presence update:
- For typing indicators: the CONV action_id
- For online status: could be a user’s profile context
- Creates a scoped presence update
Why Subject Instead of Parent:
- PRES doesn’t create hierarchy (unlike comments)
- It’s contextual - “presence in this context”
- Non-hierarchical reference semantics
Processing Flow
User starts typing
β
βΌ
βββββββββββββββββββββββββββββββ
β Create PRES:TYPING token β
β - sub = CONV action_id β
β - aud = (optional recipient)β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Check: Is ephemeral? β
β - Yes! (PRES is ephemeral) β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Forward to WebSocket β
β - No database storage β
β - No action_id generated β
β - No delivery tasks β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Deliver to audience β
β - If aud set: single user β
β - If not: context subscribersβ
βββββββββββββββββββββββββββββββFederation Flow
Local Presence (Same Instance)
User starts typing
β
βΌ
βββββββββββββββββββββββββββββββ
β WebSocket message β
β - Signed PRES token β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Broadcast to CONV β
β subscribers on same instanceβ
βββββββββββββββββββββββββββββββRemote Presence (Cross-Instance)
User starts typing (instance A)
β
βΌ
βββββββββββββββββββββββββββββββ
β Forward to CONV owner β
β (instance B) β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ (HTTP POST to /inbox)
βββββββββββββββββββββββββββββββ
β Instance B receives PRES β
β - Verifies signature β
β - Does NOT store β
β - Forwards to WebSocket β
βββββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Broadcast to other β
β subscribers on instance B β
βββββββββββββββββββββββββββββββTime-To-Live (TTL)
PRES tokens have an implicit TTL:
- Default: 30 seconds
- After TTL expires, presence is considered stale
- Clients should send periodic updates to maintain presence
- No explicit expiration in the token (handled by clients)
Typing indicator flow:
- User starts typing β PRES:TYPING sent
- User continues typing β Periodic PRES:TYPING (e.g., every 5s)
- User stops typing β No more updates
- After 30s β Recipients consider typing stopped
Example
User @alice.cloudillo.net is typing in a conversation:
| Field | Value |
|---|---|
| iss | alice.cloudillo.net |
| sub | a1~NAado5PS4j5+abYtRpBELU0e5OQ+zGf/tuuWvUwQ6PA= |
| iat | 2024-04-13T00:01:10.000Z |
| k | 20240301 |
| t | PRES:TYPING |
Properties:
- No
action_idgenerated (ephemeral) - Not stored in database
- Forwarded immediately via WebSocket
- Recipients see “Alice is typing…”
- After 30s without update, typing indicator disappears
Security Considerations
Since PRES tokens are ephemeral:
- Still require valid signature verification
- Rate limiting applies to prevent spam
- Context (subject) must be valid
- User must have access to the context
Comparison with Persistent Actions
| Aspect | PRES (Ephemeral) | Other Actions |
|---|---|---|
| Database storage | No | Yes |
| Action ID | None | SHA256 hash |
| Delivery tasks | None | Scheduled with retry |
| TTL | 30 seconds | Permanent (until deleted) |
| Use case | Real-time status | Permanent records |
See Also
- Conversation Token - Context for typing indicators
- WebSocket API - Real-time message delivery
- Federation Architecture - How ephemeral actions are forwarded