# How it works

Four parties take part: the **agent**, your **app**, the **person**, and a **node** that the person and your app trust.

## Three documents

| Document | Who signs it | What it says |
|---|---|---|
| Passport | The node | Which agent this is, who operates it, and which key it holds |
| Grant | The person (passkey) and the node | What the person approved, for which app, for how long, with which limits |
| Proof | The agent | This request: method, address, body and time, with the agent's key |

The agent sends the first two in `Allowed-By` and the proof in `AllowedBy-Proof`.

## What your app checks

The SDK does all of this offline, on each request, in about a millisecond:

1. The passport or grant comes from a node you trust, is not expired, and is not withdrawn.
2. The person's passkey signed exactly this grant, and their identity level is enough for the route.
3. The proof is for this exact request, by the agent the grant names, and was never seen before.
4. The grant covers the action, the resource and the amount.
5. A serious action has an approval made for this request only, and it has not been used.

Anything unknown, missing or unreadable is refused. See [error codes](https://docs.allowedby.com/errors) for each refusal.

## Levels: how sure you are of the person

| Level | The person | Use it for |
|---|---|---|
| 0 | is not asked: only the agent is identified | Public or per-agent data |
| 1 | tapped a passkey | Everyday actions |
| 2 | has a verified legal identity, and tapped a passkey | Orders, contracts, anything hard to undo |
| 3 | is verified at the highest level, with a hardware passkey | Payments and signatures of value |

## Classes: how serious the action is

| Class | Example | Approval |
|---|---|---|
| `read` | List notes | Reused until it ends |
| `write` | Add a note | Reused until it ends |
| `write-hard` | Delete, publish | For that request, once |
| `irreversible` | Pay, sign | For that request, once |

For the last two, your app creates the approval itself. The agent cannot change what the person will read.

## The node

A node issues passports, shows the approval page, and countersigns grants. It learns what was approved, never the data
in your app. You choose which nodes to trust: one hosted node, your own, or a signed list.
