Passport — Enriched Identity, Branding & Permissions
A Passport is a self-contained identity object that travels with a user across every Tawa service. It carries identity, org branding, and permissions — all…
Commandprovision
About
A Passport is a self-contained identity object that travels with a user across every Tawa service. It carries identity, org branding, and permissions — all bundled at token mint time by Bio-ID. Services never make a second call to get this data.
Skill Content
This is the raw markdown that gets installed as a Claude Code command.
---
name: tawa-passport
description: "The Passport object (identity, orgs, branding, permissions), the passport socket, branded/white-label/headless auth modes, onboarding flows. Use when reading user identity or building headless auth."
---
# Passport — Enriched Identity, Branding & Permissions
## What It Is
A Passport is a self-contained identity object that travels with a user across every Tawa service. It carries identity, org branding, and permissions — all bundled at token mint time by Bio-ID. Services never make a second call to get this data.
One login, everywhere. One object, everything you need.
> Canonical spec: `tawa-platform/architecture/passport-branding-auth` in the Bible.
---
## The Passport Object
```typescript
interface Passport {
// Identity
bioId: string // unique user ID (immutable)
email: string
firstName: string
lastName: string
displayName: string
avatar?: string
userType: string // 'user' | 'service' | 'admin'
roles: string[] // roles in primary org
// Primary org
orgSlug: string
orgId: string // ORG-xxx format
orgName: string
// All org memberships (multi-org users)
orgs: {
orgSlug: string
orgId: string
orgName: string
roles: string[]
modules: string[]
}[]
// Aggregated modules across all orgs
modules: string[]
// Branding — loaded from vault at mint time (when passport.includeBranding: true)
branding: {
displayName: string // org display name for UI chrome
tagline?: string
logoUrl?: string // primary logo (SVG or PNG)
logoMarkUrl?: string // icon/mark for small surfaces
primaryColor: string // hex — defaults to '#0F172A'
secondaryColor?: string // hex
websiteUrl?: string
verified: boolean // platform verified this entity
whiteLabelApproved: boolean // approved for custom domain + hideEcoBranding
}
// Permissions — resolved from Koko at mint time
permissions: {
scopes: string[] // e.g. ['raterspot:rate', 'docman:read']
}
// Vault link
iecHash?: string // entity's chain address (if vault entity exists)
// Session metadata
issuedAt: string
connectedServices: string[]
}
```
---
## Using the Passport in Your Service
### Reading Identity + Branding (Most Common)
```typescript
// req.user IS the Passport — already populated by Janus or your middleware
const { orgSlug, branding, permissions } = req.user
// Brand the page
document.title = branding.displayName
headerLogo.src = branding.logoUrl
root.style.setProperty('--primary', branding.primaryColor)
// Check permission
if (permissions.scopes.includes('raterspot:rate')) {
showRatingPanel()
}
// No vault lookup. No Koko call. It's already in the token.
```
### React — Via Passport Socket
```typescript
import { useEffect, useState } from 'react'
const BIO_ID_URL = process.env.NEXT_PUBLIC_BIO_ID_URL || 'https://bio.insureco.io'
export function usePassport(token: string | null) {
const [passport, setPassport] = useState<Passport | null>(null)
useEffect(() => {
if (!token) return
const ws = new WebSocket(`${BIO_ID_URL.replace(/^http/, 'ws')}/passport?token=${token}`)
ws.onmessage = (e) => {
const { type, passport } = JSON.parse(e.data)
if (type === 'identity' || type === 'passport_updated') setPassport(passport)
if (type === 'revoked') setPassport(null)
}
ws.onclose = () => setPassport(null)
return () => ws.close()
}, [token])
return passport
}
```
### Node.js / CLI
```typescript
import WebSocket from 'ws'
const BIO_ID_URL = process.env.BIO_ID_URL || 'https://bio.insureco.io'
export function connectPassport(token: string, onIdentity: (passport: Passport) => void) {
const ws = new WebSocket(`${BIO_ID_URL.replace(/^http/, 'ws')}/passport?token=${token}`)
ws.on('message', (raw) => {
const { type, passport } = JSON.parse(raw.toString())
if (type === 'identity' || type === 'passport_updated') onIdentity(passport)
if (type === 'revoked') process.exit(0)
})
return () => ws.close()
}
```
---
## The Socket
```
wss://bio.insureco.io/passport?token=<access_token>
```
Advertised in Bio-ID's OIDC configuration as `passport_endpoint`.
### Events
| Event type | When | Payload |
|------------|------|---------|
| `identity` | On connect (if session valid) | `{ type, passport }` |
| `passport_updated` | Role/org/branding change | `{ type, passport }` |
| `revoked` | Logout or token invalidated | `{ type }` |
### Error Codes
| Code | Reason |
|------|--------|
| `4001` | Missing token — no `?token=` in URL |
| `4003` | Invalid token — expired or tampered |
| `4004` | User not found or suspended |
---
## Three Auth Modes
All three modes produce the same Passport object. The mode determines the user experience.
| Mode | Bio-ID visible? | User redirected? | Dev builds UI? |
|------|----------------|-----------------|----------------|
| **Branded** | Yes — "Sign in with Bio-ID" | Yes (bio.tawa.pro) | No |
| **White-Label** | No — org's domain + branding | Yes (custom domain) | No (CSS only) |
| **Headless** | No — completely invisible | No — server-to-server | Yes — fully custom |
### Branded (default)
```yaml
spec:
auth:
mode: sso
```
### White-Label
```yaml
spec:
auth:
mode: sso
passport:
includeBranding: true
```
Org's vault branding auto-applies to the consent screen. Custom domain + hideEcoBranding requires `whiteLabelApproved: true` on the vault entity.
### Headless
```yaml
spec:
auth:
mode: sso
passport:
includeBranding: true
headless: true
allowedOrigins:
- https://yourapp.com
```
```typescript
const bio = BioAuth.fromEnv()
// Signup — server-to-server, no redirect
const tokens = await bio.embed.signup({
email, password, firstName,
orgSlug: 'acme-agency', // optional — see "Agency and MGA sign-up" for clients that require an org
})
// Login
const tokens = await bio.embed.login({ email, password })
// Magic link (you send the email yourself)
const { magicToken } = await bio.embed.createMagicLink({ email })
// Verify magic token
const tokens = await bio.embed.verify({ token: magicToken })
// Refresh
const tokens = await bio.embed.refresh({ refreshToken })
```
---
## Onboarding Flows
### Self-Signup (no invite)
```
Any mode → user signs up → Bio-ID auto-creates personal org (slug from name)
→ Passport minted with new org → user lands in service
```
This is for a client that does **not** have `requiresOrg` set. A client with `requiresOrg`
(agency and MGA apps) creates no org at signup. See the next section.
### Agency and MGA sign-up (`requiresOrg`)
An agency or MGA app does not want a throwaway personal org. A Bio-ID admin sets
`requiresOrg: true` on the client (`PATCH /api/admin/oauth-clients/:clientId`). The org is then
created from the person's InsureBio record, not from their name.
```
1. Signup with no org POST /api/embed/signup { email, password, firstName }
→ Bio-ID creates the user and no org.
2. Sign in The person gets a code and a token. The token has no org.
3. Find the agency bio-api GET /v1/me/matches → InsureBio records that may be theirs.
4. Create the org POST /api/embed/orgs, one of two bodies (below).
5. Use the new tokens The response carries tokens with the org active.
6. Check verification bio-api GET /v1/me/agency → status of the claim.
```
`POST /api/embed/orgs` needs **both** of these:
- The headless client: `X-Client-Id` with `X-Client-Secret`, or an allowed `Origin`. The client
must have `headlessEnabled`.
- The signed-in person: `Authorization: Bearer <access token>`. The token must have been issued
to the same client (`403 CLIENT_MISMATCH` if not). The person is whoever the token names. The
body cannot name one.
Body, either form:
```jsonc
// A match from /v1/me/matches
{ "iecHash": "…" }
// No match: describe the agency. state is 2 letters. npn or fein is required.
{ "name": "Acme Insurance", "type": "retail-agency", // or "mga"
"state": "CO", "npn": "12345", "fein": "12-3456789" }
```
```jsonc
// 201 on create, 200 when the same person repeats the same request
{ "success": true, "data": {
"org": { "orgId": "ORG-…", "orgSlug": "acme-insurance", "name": "Acme Insurance",
"type": "retail-agency", "iecHash": "…", "verification": "pending" },
"tokens": { "access_token": "…", "refresh_token": "…", "token_type": "Bearer",
"expires_in": 3600, "user": { … }, "branding": { … } } } }
```
`tokens` has the same shape as `embed/login`, with the new org active.
What Bio-ID does:
- Creates the org from the record and makes the first person `owner` and `agency_admin`. This is
the same for agencies and MGAs.
- Claims the record in bio-vault, server to server. Your app does not call the vault.
- Sets `verification` to `verified` or `pending`. A `pending` org works now. The claim is
reviewed later. Read the result from `GET /v1/me/agency`.
- Sends the vault the person's own Bio-ID email from the user record, never a value from the
request. The vault binds a claim only for a verified email, so an account with an unverified
email always gets `pending`.
- While the vault claim runs, the org is stored as `claiming`. The API never returns that value.
A repeat call, or a call from anyone else for the same record, gets `503 RETRY_LATER` until the
claim finishes. Wait a moment and retry. A `claiming` org that is over 2 minutes old is
abandoned, and its owner's next request finishes it.
- If a step fails, nothing is kept. No org is left without a member.
- Rate limit: 10 org-create requests per 10 minutes per person (`429 RATE_LIMITED`), on top of the
client and IP signup limit.
Errors (`{ success: false, error, code }`):
| Status | Code | Meaning |
|---|---|---|
| 400 | `VALIDATION_ERROR`, `INVALID_JSON` | Body is not `{ iecHash }` or `{ name, type, state, npn \| fein }` |
| 400 | `ENTITY_NOT_SUPPORTED` | The record is not an agency, MGA or carrier |
| 401 | `UNAUTHORIZED`, `INVALID_TOKEN`, `USER_NOT_FOUND` | No bearer token, bad token, or no such person |
| 403 | `CLIENT_MISMATCH` | Token was issued to another client |
| 403 | `PERSONA_FORBIDDEN`, `USER_INACTIVE`, `FORBIDDEN_ORG_TYPE` | Test personas cannot own an org. Account not active. Platform orgs cannot be claimed |
| 404 | `ENTITY_NOT_FOUND` | No InsureBio record for that `iecHash` |
| 409 | `CLAIMED_BY_OTHER_ORG` | Another org already claimed this record |
| 422 | `LICENSE_NOT_ACTIVE` | No active license found for the agency or MGA |
| 429 | `RATE_LIMITED` | More than 10 org-create requests in 10 minutes for this person. The client and IP signup limit can also return 429 |
| 500, 502 | `INTERNAL_ERROR`, `CLAIM_SERVICE_ERROR` | Bio-ID or the registry failed |
| 503 | `RETRY_LATER` | Registry unreachable or busy, or this org is still `claiming`. Try again. A repeat is safe |
A `requiresOrg` client never gets an org-less token:
- `embed/signup` creates no org.
- `/oauth/authorize` sends a person with no org to the hosted step at `/oauth/org`. It makes
the same call, then returns to authorize. Its `next` parameter accepts only paths under
`/oauth/authorize` and `/claim`. Anything else goes to `/`. With `prompt=none` it returns
`interaction_required` instead, because it can show no page.
- `/api/oauth/token` refuses an org-less user with `403 interaction_required` and
`org_required` in the description.
### Invite
```
Admin: POST /api/v2/orgs/:orgSlug/invites { email, role, modules }
→ Bio-ID stores invite, sends email (or returns inviteUrl for headless)
→ User clicks link → signup (if new) or login (if existing)
→ Attached to inviting org with specified role
→ Passport minted with inviting org as primary
```
Headless invite acceptance:
```typescript
const tokens = await bio.embed.signup({
email, password, firstName,
inviteToken: 'TOKEN', // resolves to org + role
})
```
### Service-Initiated (with orgSlug)
```typescript
// Create user directly in an org (requires org:manage scope)
const tokens = await bio.embed.signup({
email: '[email protected]',
password: tempPassword,
firstName: 'New',
orgSlug: 'acme-agency',
role: 'agent',
})
```
---
## Vault Branding
Branding lives on vault entities at `profile.branding`. The Passport reads it at mint time.
### Two Tiers
| Tier | Who | What they can set |
|------|-----|-------------------|
| **Claimed** | Any entity after claim flow | displayName, tagline, logoUrl, logoMarkUrl, colors, website, phone, email |
| **White-Label Approved** | Platform approval | customDomain, hideEcoBranding, emailFromName, customCss |
### Vault API
```
GET /v1/branding/:orgSlug → 0 gas, public
PATCH /v1/entities/:iecHash/branding → 2 gas, auth required
```
### SDK
```typescript
import { VaultClient } from '@insureco/bio-vault'
const vault = VaultClient.fromEnv()
const branding = await vault.getBranding('acme-agency')
```
---
## How It Fits with OAuth
| Flow | Use when |
|------|----------|
| Full-page redirect | First login, consent screens |
| Popup | Staying on page during auth |
| Headless embed API | Full control, Bio-ID invisible |
| **Passport socket** | Already authenticated — propagate identity silently |
After any OAuth flow completes, Bio-ID publishes the Passport on the socket. Any connected service receives the identity immediately.
---
## Key Use Cases
- **Branding** — `req.user.branding.logoUrl` renders the org's logo instantly
- **Onboarding** — passport arrives with name, org, modules → no "what's your company?" form
- **Badge widget** — floating identity indicator on any page
- **CLI** — connect on startup, get identity silently
- **Village traversal** — user moves between services, identity follows
- **Permission gating** — `req.user.permissions.scopes` controls feature access
---
## Gotchas
- Token must be a valid Bio-ID access token (RS256 in prod)
- Socket closes on invalid token — don't retry without a fresh token
- Branding in token is cached for up to 1 hour — logo changes propagate on next refresh
- If `passport.includeBranding` is not declared (or `false`) in catalog-info.yaml, Passport carries identity only (no branding)
- Headless mode: always call Bio-ID server-to-server, never from the browser
- `bio.embed.signup({ orgSlug })` requires `org:manage` scope — auto-granted when deployed by that org
- A `requiresOrg` client: signup creates no org. Create it with `POST /api/embed/orgs`. Do not pass `orgSlug` to invent one
Install
Copy the skill content and save it to:
~/.claude/commands/tawa-passport.mdComing soon via CLI:
tawa chaac install tawa-passportDetails
- Format
- Command
- Category
- provision
- Version
- 1.0.99253
- Tokens
- ~3,683
- Updated
- 2026-11-25
platformpassportidentityauthbrandingpermissions