Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
docs(sdk): document the CSRF gate, the ENS miss and the Payee field an SDK user hits
nirholas7f77c0c45451
diff --git a/packages/irl/README.md b/packages/irl/README.mdindex 96d699756..fe7a78b3d 100644--- a/packages/irl/README.md+++ b/packages/irl/README.md@@ -133,9 +133,11 @@ alongside the fix so `nearby()` can prove the read.| Field | Type | Notes ||---|---|---|| `lat` / `lng` | `number` | The fix used to mint the token. |+| `accuracy` | `number \| null` | Reported GPS accuracy in metres, when the fix carried one. || `token` | `string` | HMAC-signed presence token (header `x-irl-fix` on reads). || `expiresIn` | `number` | Token lifetime in seconds: **180** (3 min). Re-`checkIn()` when it lapses. || `cell` | `string` | The precision-7 geohash (~153 m) the fix fell in, the client's "re-mint on cell change" trigger. |+| `raw` | `unknown` | The untouched `POST /api/irl/fix-token` body. |The token anchor is coarsened to ~110 m server-side, so the token itself nevercarries a fine coordinate. A read is authorized only when its claimed point is@@ -330,7 +332,11 @@ const { proof, collectible } = await completeWorldLine({console.log('agent-signed proof:', proof.signature, '→', proof.verifyUrl);```-Place a quest on your pin (signed-in: pass `apiKey` to `createIrl`):+Place a quest on your pin (signed-in: pass `apiKey` to `createIrl`, which sends it+as a bearer token. `createWorldLine` is the one authenticated write here, and a+bearer is the simplest way to make it: a caller authenticating with a session+cookie instead must also mint `GET /api/csrf-token` and echo it in the+`X-CSRF-Token` header, or the write answers `403 csrf_missing`):```jsimport { createIrl } from '@three-ws/irl';diff --git a/packages/mocap/README.md b/packages/mocap/README.mdindex 02ce053aa..68430c6e1 100644--- a/packages/mocap/README.md+++ b/packages/mocap/README.md@@ -97,6 +97,32 @@ const shared = await listClips({}, { includePublic: true, limit: 100 });The SDK is a thin client over `/api/mocap/clips`. Every write needs a sessioncookie or a bearer token with the right scope; reads of public clips are open.+**Writing with a session cookie also needs a CSRF token.** Cookie-authenticated+writes are double-submit protected: mint a token with `GET /api/csrf-token` and+echo it in the `X-CSRF-Token` header on every `POST`/`PATCH`/`DELETE`, or the+call answers `403 csrf_missing`. Tokens are single-use, so mint one per write.+Bearer tokens are exempt (a bearer is not auto-attached by a browser, so it is+its own proof of intent), which makes `{ token }` the simpler path outside the+browser:++```js+import { createMocap } from '@three-ws/mocap';++// Bearer: nothing else to do.+const mocap = createMocap({ token: process.env.THREEWS_TOKEN });++// Session cookie: wrap fetch and attach a fresh CSRF token per write.+const cookieClient = createMocap({+ headers: { cookie },+ fetch: async (url, init = {}) => {+ if ((init.method || 'GET') === 'GET') return fetch(url, init);+ const res = await fetch('https://three.ws/api/csrf-token', { headers: { cookie } });+ const { data } = await res.json();+ return fetch(url, { ...init, headers: { ...init.headers, 'x-csrf-token': data.token } });+ },+});+```+### `saveClip(recording, meta, auth) → Promise<Clip>`Persist a browser recording. Wraps `POST /api/mocap/clips`. The `recording` is@@ -141,8 +167,10 @@ it. Pass the `id` when you need to name one exact clip.### `listClips(auth, opts?) → Promise<{ items, nextCursor }>`-List clips **without frames** (metadata only: cheap). Wraps-`GET /api/mocap/clips`. Cursor-paginated, newest first.+List clips **without frames** (metadata only: cheap, `frames` is `null` on every+row). Wraps `GET /api/mocap/clips`. Cursor-paginated, newest first. Returns+`{ items, nextCursor, raw }`, where `nextCursor` is `null` on the last page and+`raw` is the untouched wire envelope.| Option | Type | Default | Notes ||---|---|---|---|@@ -183,7 +211,7 @@ camelCases the wire row and keeps the untouched original on `raw`:| `avatarId` | `uuid \| null` | Bound avatar, if any. || `playCount` | `number` | Non-owner fetches. || `price` | `{ amount, currency } \| null` | `null` when free. |-| `owner` | `'self' \| 'other'` | Relative to the caller. |+| `owner` | `'self' \| 'other' \| null` | Relative to the caller. Projected by `listClips` only; `null` on a single-clip read or write. || `raw` | `unknown` | The untouched wire row (`duration_ms`, `frame_count`, …). |## How it works@@ -239,6 +267,7 @@ SDK surfaces them as a typed `ThreeWsError` carrying the `code`:| `code` | HTTP | Meaning | Recovery ||---|---|---|---|| `unauthorized` | 401 | Write with no session/token. | Sign in or pass a bearer `token`. |+| `csrf_missing` / `csrf_invalid` | 403 | Cookie-authenticated write with no (or a spent) `X-CSRF-Token`. | Mint one per write from `GET /api/csrf-token`, or use a bearer token. || `insufficient_scope` | 403 | Token lacks `avatars:write` / `avatars:delete`. | Mint a token with the scope. || `validation_error` | 400 | `meta`/`recording` failed schema. | Fix the field named in `message`. || `unsupported_format` | 400 | `format` isn't a known wire format. | Use a [supported format](#how-it-works). |diff --git a/packages/names/README.md b/packages/names/README.mdindex b289eee20..203ab195a 100644--- a/packages/names/README.md+++ b/packages/names/README.md@@ -216,9 +216,19 @@ agent wallet; **`.sol` domain** (including `foo.threews.sol`) → on-chain owner### `resolvePayee(name) → Promise<Payee>`-Resolve-only, no payment. Wraps `GET /api/x402/pay-by-name?name=<name>`. Returns-`{ name, address, source, resolved, claim? }` where `source` is one of-`address`, `sns`, or `username`. A `404` means the name resolved nowhere.+Resolve-only, no payment. Wraps `GET /api/x402/pay-by-name?name=<name>`. A `404`+means the name resolved nowhere, and surfaces as a typed `not_found`.++**Returns** `Payee`++| Field | Type | Notes |+|---|---|---|+| `name` | `string \| null` | The canonical form of the name that matched. |+| `address` | `string \| null` | The wallet a payment would land in. |+| `source` | `'address' \| 'sns' \| 'username'` | Which namespace answered. |+| `resolved` | `string \| null` | The same canonical name as `name`. **Unlike `resolve()`, this is a string, not a boolean**: `'alice.threews.sol'` for an SNS hit, `'@alice'` for a username. There is no `resolved: false` here, a name that resolves nowhere is the `404` above. |+| `claim` | `object \| null` | The three.ws user behind a `*.threews.sol` claim, when there is one. |+| `raw` | `unknown` | The untouched wire body. |## How it works@@ -292,6 +302,7 @@ real faults reject.| State | HTTP | Meaning | Recovery ||---|---|---|---|| `resolved: false` | 200 | Name has no owner. **Not an error.** | Show "unclaimed"; offer to mint. |+| `resolved: false` (ENS) | 404 | An unregistered `.eth`. The ENS endpoint reports a miss as a `404`; `resolve()` normalizes it to the same `resolved: false` result the `.sol` lane returns, so one call has one contract. The 404 envelope stays on `raw`. | Same as above. || `validation_error` | 400 | Malformed name, label, or amount. | Fix the input. Labels are 1-63 chars `[a-z0-9-]`. || `unauthorized` | 401 | Mint or `mode: 'send'` without auth. | Sign in or pass a bearer `token`. || `forbidden` | 403 | `ownerAddress` not linked to your account. | Link the wallet, or omit it. |