API Reference
postMessage Protocol
Communication protocol between Universe Shell and modules via window.postMessage.
postMessage Protocol
Modules communicate with the Universe Shell via the browser's window.postMessage API. This is the bridge between the parent window (Shell) and the iframe (your module).
Message Types
Module β Shell
| Message Type | Description | Payload |
|---|---|---|
REQUEST_AUTH_SESSION | Request JWT tokens from Shell | none |
navigate | Navigate Shell to a path | { path: string } |
Shell β Module
| Message Type | Description | Payload |
|---|---|---|
AUTH_SESSION | JWT tokens for Supabase | { access_token, refresh_token } |
SESSION_RESET | Wipe all local caches and sign out | none |
SESSION_USER_CHANGED | New user signed in β wipe before re-auth | { userId: string | null } |
Flow: Session reset (sign-out / user change)
When the Shell signs out, or detects that a different user has signed in, it broadcasts a session-reset message to every active iframe. Modules must:
queryClient.clear()β drop all cached server datasupabase.auth.signOut()β invalidate the local Supabase session- Clear any module-specific localStorage caches (e.g. simulator drafts, waste records, tenant IDs)
- Reset UI to the loading / unauthenticated state
Modules that ignore these messages will leak data from a previous user into the next session β incognito would be the only escape hatch.
Flow: Authentication
Flow: Navigation
URL Parameters
The Shell passes context via iframe URL query parameters:
| Parameter | Type | Description |
|---|---|---|
org_id | UUID | Organization ID for the current tenant |
Example iframe URL:
Security Notes
- Shell β Module: the Shell posts
AUTH_SESSION(andSESSION_RESET/SESSION_USER_CHANGED) to your module's exact origin β never'*'. The origin is derived from the module's configured base/deploy URL (new URL(baseUrl).origin). If your module is redirected to a different origin after load, the browser will silently drop these messages and tokens will not be delivered β keep the module on its configured origin. - Shell inbound validation: the Shell accepts
navigate/REQUEST_AUTH_SESSIONonly from the exact origin it embedded. It does not substring-match (origin.includes('insolitum.ai')) β a lookalike such ashttps://insolitum.ai.evil.comis rejected. - Module β Shell: your module should likewise validate
event.originon theAUTH_SESSIONit receives against the expected Shell origin before trusting the tokens. Never trust message data without validation. - JWT tokens are short-lived; Supabase handles refresh automatically.