MessageTypeId Specification
4. MessageTypeId Specification
Purpose
Each message transmitted in the system must include a MessageTypeId, which uniquely defines:
- The purpose and semantic meaning of the message
- Its allowed direction (who may send and receive it)
- Its associated JSON Schema, used for validation
- Permission requirements that determine access control
This structure allows W3S to perform strict schema validation and role-based permission enforcement, reducing the risk of malformed, unauthorized, or spoofed messages.
Authorization Model
Every MessageTypeId is registered with:
-
A known JSON Schema
-
A set of allowed actors or roles (e.g., Sensor, Client, Admin)
-
A defined directional constraint, such as:
OSS8 → W3SW3S → ClientClient → W3S → OSS8
Each DeviceId has an associated role-based permission model that maps users (identified by their Zitadel ID) to roles, and roles to allowed MessageTypeIds and directions. Permissions are evaluated per device, enabling fine-grained access control.
At runtime, W3S uses this model to:
- Reject messages that violate schema or direction rules
- Reject or log unauthorized user actions based on role assignments
- Apply policy evaluation consistently across all message flows
Validation Process
Upon receiving a message, W3S performs the following steps:
-
Authentication Authentication is performed once during WebSocket upgrade using Zitadel token introspection. The authenticated Zitadel ID is bound to the tunnel and used to identify the sender for all subsequent messages.
-
Device ID Verification For OSS8 messages, the authenticated Zitadel ID must match the claimed
DeviceIdin the message. For client messages, the sender's role for the givenDeviceIdis checked before routing or handling. -
MessageTypeId Lookup The
MessageTypeIdis used to retrieve its schema definition and permission constraints. -
Schema Validation The
Payloadis validated against the registered schema. For binary messages, only the JSON header is validated. -
Permission & Direction Check Based on the
UserId,DeviceId, andMessageTypeId, W3S evaluates whether the action is allowed. This decision is made using the per-device role mapping and direction constraints. -
Routing or Consumption Valid messages are forwarded, handled, or consumed as appropriate. Unauthorized or invalid messages are rejected or quarantined.
Binary MessageTypeIds
Some MessageTypeIds (e.g. OSS_IMAGE_FRAME) are used in messages with a binary payload. These follow the binary message framing format described in Section 3.
For these messages:
- Only the JSON header is validated against the schema
- The
Payloadsection of the JSON header contains metadata describing the binary content - Schema validation includes checking consistency between declared and actual image metadata
Versioning Strategy
-
Each message includes a
Versionfield to indicate the sender’s protocol version. -
W3S operates on a single canonical API version but supports backward compatibility within a controlled version range.
-
When schema changes are breaking:
- A new
MessageTypeIdis introduced with its own schema, or - Schema validation logic is version-aware and handles legacy formats explicitly.
- A new