# AMH-1 — Approval Flow and Page

Version 0.2.8-draft · Part of the AllowedBy specification set (AskMyHuman is the approval page)

## 1. Purpose

Defines how an approval request is created, what the human sees and signs, where they approve, who may approve, how step-up is performed, and how the grant comes back to the requester.

## 2. Roles

- **Requester**: the service (service-initiated) or the runtime (runtime-initiated), see ABY-2 §7.
- **Creating node**: receives the approval request, forwards it to the home node, countersigns the grant, logs, and serves the poll.
- **Home node**: the node where the human enrolled their passkey (OAID-7 §4). It is the only party that builds the grant core and its `display` (ABY-1 §3.2); it serves the approval page, runs the WebAuthn ceremony, and is the human's wallet (§11). It may be the creating node.
- **Approval page**: AskMyHuman, the human-facing page at the home node's `{approval_page}{aid}`. Links use `askmyhuman.org` or the node's own prefix.
- **Human**: the approver.

## 3. Creating an approval request

`POST {approvals}`:

```json
{
  "v": 1,
  "audience": ["https://api.example.com"],
  "sub": "did:oaid:node.example.org:01JB3KA0…",
  "capabilities": [ { "cap": "invoices:approve", "constraints": { "scope": "invoice:4711", "amount": { "max": "4200.00", "currency": "EUR", "per": "call", "field": "/total" } } } ],
  "level": 2,
  "single_use": { "request_digest": "X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE" },
  "standing": { "allowed": false },
  "human_hint": "q3VtZ8m…",
  "human_home": "home.example.net",
  "disclose": { "required": [], "optional": [] },
  "expires_in": 900,
  "callback": "https://api.example.com/allowedby/callback"
}
```

| Member | Meaning |
|---|---|
| `audience` | Explicit service origins; `"*"` is rejected |
| `sub` | The passport the grant will be bound to. In service-initiated mode the service copies it from the request it challenged. |
| `initiator` | Not sent by the caller; a request that contains it is `400 invalid_request`. The creating node derives it from the caller's authentication: `{ "by": "service", "kid" }` when a service key signed, `{ "by": "runtime" }` otherwise. It goes into the core (ABY-1 §2). |
| `renews` | `gid` of the grant this approval renews (§9), when it is a renewal |
| `level` | Minimum level required: 1, 2 or 3, anything else is `400 invalid_request` |
| `qes` | `true` when the route requires a qualified electronic signature (OAID-7 §10); `level` MUST then be 2 or 3 |
| `level_profile` | `eu` or `na` when the route accepts only that profile of level 3 (OAID-7 §5.3); `level` MUST then be 3 |
| `single_use` | Present when the grant must be single-use (ABY-1 §7) |
| `standing.allowed` | Whether the human may choose a standing grant; `max_period` in seconds may be given |
| `human_hint` | The pairwise `human.id` the service linked to its account (§7). REQUIRED for `write-hard` and `irreversible`. |
| `human_home` | The human's home node, when known. |
| `disclose` | `{ "required": [ … ], "optional": [ … ] }`: attributes from the catalogue (OAID-7 §7), each declared in the audience's `disclosure` member, else `400 invalid_request`. Encrypted to the `disclosure_key` taken **only** from the audience's `/.well-known/allowedby`, never from the request. |
| `mandate` | `true` when the route requires a mandate (ORG-1 §6). The home node then offers the approval only for an organisation that gave the human a mandate, and disables Allow "as yourself". |
| `expires_in` | 60 to 3600 seconds, default 900 |
| `callback` | OPTIONAL `https` URL whose host is the host of an `audience` origin, else `400 invalid_request`; the node POSTs to it when the state changes. The poll endpoint remains authoritative. |

Rules:

- `write-hard` and `irreversible` approvals MUST be **service-initiated** and carry `human_hint`. Runtime-initiated approvals (including case 0 pre-approval) are limited to `read` and `write`. Verifiers enforce this through `initiator` (ABY-2 §5 step 8); nodes do not check classes.
- Caller authentication: a runtime signs with an `AllowedBy-Proof` (ABY-2 §3) with its passport in `Allowed-By`; a service signs with a proof using a key from `keys` in its `/.well-known/allowedby` (ABY-3 §5), fetched by the node from the audience origin. There are no unauthenticated requests.
- A service-initiated request's `audience` MUST be exactly the one origin whose key signed it; otherwise `400 invalid_request`.
- Public nodes cap runtime-initiated creation at 1,000 approvals per month per operator (fair use).

Response `201`:

```json
{ "aid": "8ZK3V4Q9T2M6R1XJ5WB0YHCDNE", "code": "K7QM", "approve_url": "https://askmyhuman.org/a/8ZK3V4Q9T2M6R1XJ5WB0YHCDNE", "poll_url": "https://node.example.org/allowedby/v1/approvals/8ZK3V4Q9T2M6R1XJ5WB0YHCDNE/grant", "expires": 1761481800, "state": "pending", "summary": "Approve invoice 4711, up to 4200.00 EUR" }
```

- `aid`: 128 random bits, base32 (26 characters).
- `code`: the **binding code**, 4 characters from Crockford base32 (no `I`, `L`, `O`, `U`). The requester shows it next to the link; the page shows it in large type; the human checks they match.
- `summary`: the `display.summary` the home node built (§4). When `human_home` is unknown it is absent until the human picks their home node.

The node logs an `amh-approval+jwt` entry with `aid`, `sub`, `audience`, `capabilities`, `class`, `level`, the SHA-256 of `display`, `expires`. `callback` and `code` are not logged.

## 4. Display: what the human signs

The home node builds the grant core, including `display` (ABY-1 §3.2), from the request it received:

```json
"display": { "summary": "Approve invoice 4711, up to 4200.00 EUR", "lines": ["Approve invoice 4711, up to 4200.00 EUR per call"], "lang": "en" }
```

- The home node fetches the audience's templates itself from its `/.well-known/allowedby` (ABY-3 §5) over TLS. Each capability has a `summary` template and a `lines` template; placeholders refer only to constraint members (`{scope}`, `{amount.max}`, `{amount.currency}`, `{amount.per}`, `{count.max}`, `{window.from}` …).
- `summary` is the `summary` template of the first capability; `lines` has one entry per capability. At most 280 characters each. Neither the runtime nor the service supplies any text; a missing template or constraint member is `400 invalid_request`.
- `lang` is the template language chosen for the human.
- When `audience` lists several origins, the home node fetches the templates of **every** audience, renders `display` with each, and MUST refuse with `400 invalid_request` unless all renderings are identical. Otherwise one audience of the requester's choosing would word what another then accepts. A home node MAY accept a single audience only.

The WebAuthn challenge is `SHA-256(JCS(grant core))` (ABY-1 §3), so the text the human saw is inside what they signed.

## 5. States, polling and forwarding

States: `pending`, `approved`, `denied`, `expired`, `revoked`. Transitions: `pending → approved | denied | expired`; `approved → revoked`. This is the one approval state machine; other documents cite this section.

`GET {approvals}/{aid}` returns `{ "aid", "state", "expires", "level_reached"?, "gid"? }`.

`GET {approvals}/{aid}/grant` returns `200 application/jwt` with the grant when `approved`; `202` with `Retry-After` when `pending`; `410` with problem details when `denied`, `expired` or `revoked`. A runtime caller MUST sign with the passport key named in `sub`; a service caller with a key from `keys` in its `/.well-known/allowedby`; anyone else gets `404`.

**Forwarding.** The human always approves on their home node's page. When the creating node is not the home node, it forwards the **request** (OAID-2 `POST {approvals}` with `human_home`): audience, capabilities, constraints, `initiator`, `single_use`, `request_digest`, `renews` and times. The home node accepts forwards only from nodes in its own trust list and holds at most 30 pending approvals per human. It builds the core (§4), serves the page and runs the ceremony, then returns the core and the assertion to the creating node, which verifies them against `human.reg` and countersigns. The creating node MUST then send the countersigned grant to the home node with `POST {approvals}/{aid}/grant` on the home node, so the wallet holds it. When `human_home` is unknown, the link page asks the human for their home node (remembered per browser) and hands over to it. Polling always stays at the creating node.

**Disclosure.** When `disclose` was requested, the SD-JWT VC encrypted to the audience (OAID-7) is delivered only to the audience: in the callback body as `disclosure`, or on a poll signed with the service's key. It is never logged and is pruned after 90 days.

**Callback.** The node POSTs `{ "aid", "state", "gid"?, "disclosure"? }` to `callback` with an `AllowedBy-Proof` signed by its `countersign` key, `dth` hashing the node statement's `jti`. Receivers verify against the node statement.

## 6. The approval page

1. MUST be served over HTTPS from the home node's approval origin, which is the passkey `rpId`, and MUST NOT be framed by another origin (`Content-Security-Policy: frame-ancestors 'none'`); the node rejects assertions whose `clientDataJSON.crossOrigin` is true.
2. MUST render **only** the `display` the home node itself built (§4) plus the structured facts below. It MUST NOT render a `display` built elsewhere or anything else from the requester.
3. MUST show, above the fold, in this order: the service (audience hostname verbatim, and its legal name and country when its organisation profile is verified, ORG-1 §2), the identity approving ("as yourself" or "for <organisation>", ORG-1 §6), the binding `code` in large type, `display.summary`, `display.lines`, the agent (operator id and verification state, runtime id), the duration (this once, or a standing period with its expiry date), the level required and the human's current level, the disclosure requested if any (each attribute with its purpose and retention; optional ones unticked), and the budget the grant reserves with what remains (ORG-1 §5.2). When a budget or an organisation policy forbids the approval, MUST say which one and disable Allow.
4. MUST present exactly two primary actions, **Allow** and **Deny**, with equal visual weight, and MUST require the WebAuthn ceremony for Allow. Deny MAY be one click; it is logged as `denied` with no signature.
5. MUST show the operator state plainly: "acme.example (domain verified)" or "unverified operator".
6. When `standing.allowed`, MUST let the human pick a period up to the allowed maximum, defaulting to the shortest reasonable period for the class, and MUST show the resulting expiry date. Single-use approvals offer no choice.
7. **Breadth.** For a runtime-initiated approval with one capability whose only constraint is `scope`, the home node MAY offer the human up to three choices. It builds them from the audience's published vocabulary (ABY-3 §5), and the page shows each one's rendered sentence:
   - **only what was asked**, the default;
   - **all of this type**: the last scope segment replaced by `*`;
   - **everything of this kind**: the same widened scope, plus every capability of the same namespace whose class is `read` or `write` and whose published constraints do not include `amount`.

   The chosen capabilities and their `display` go into the core the human signs, and the level and class maximum are those of the widest capability chosen. Breadth never applies to `write-hard` or `irreversible` capabilities, to amounts, or to service-initiated approvals. Apart from the period and the breadth, nothing on the page changes the capabilities or constraints.
8. When the human's level is below `level`, MUST perform step-up (§6.1) before enabling Allow, and MUST explain in one sentence why ("This action can send money; a verified identity is required"). When `qes` is set, MUST say so before Allow and run the qualified signature right after the passkey tap (OAID-7 §10).
9. MUST work at phone width and with screen readers; the Allow control MUST have an accessible name including the action and the service.
10. MUST show the approval expiry as a countdown or time.
11. MUST NOT be embeddable in frames (`X-Frame-Options: DENY`, CSP `frame-ancestors 'none'`).
12. MUST be served as the bundle whose SRI SHA-384 hash is published as `page_hash` in the node statement (OAID-2). Every change of `page_hash` is logged; monitors alert on unannounced changes.

### 6.1 Step-up

If the human has no passkey at any node: registration at a home node (OAID-7 §4), then continue. L1 to L2 or L3: the page offers the sources listed for that level (OAID-7 §5.1), and only those of the requested `level_profile` when one is set; it opens the provider redirect, hands the presentation request to the wallet (Digital Credentials API or a same-device or cross-device link), or reads the chip, then posts the result to the node, which decides the level (OAID-7 §5). L3 also needs a hardware passkey. When a source gives less than the route needs (a scheme not notified at high, an uncertified wallet), the page says so and offers another source. Step-up results persist for the human; the next approval at that level is a passkey tap.

Creating a new credential for an existing human, including a per-audience credential (OAID-7 §8), MUST be authorised by an assertion from an existing credential of the same human, is logged, and is shown in the wallet.

## 7. Who may approve

- **Linked human.** A service that cares which human approves (anything `write-hard` or above, and any multi-user resource) links the pairwise `human.id` to its own account once, through the reserved capability **`aby:link`** (class `write`), approved while the user is signed in to the service. The link stores the pair `(human.reg.iss, human.id)`; the service accepts a linked human only when both match. Thereafter it sets `human_hint` to the linked id. The home node only offers the approval to the human whose pairwise id for this audience equals `human_hint`. The service still rejects grants whose `human.id` is not authorised for the resource (`human_not_linked`, ABY-2 §6); that check is the service's own authorisation.
- **No hint** (`read` and `write` only): any human who opens the link on their home node may approve. The page MUST state that the approval is not addressed to a named person.
- **Organisational authority.** When the route requires `authority`, the audience organisation's authority policy applies (ABY-1 §5). After the first approver signs, the page shows "waiting for *group name*" and the approval stays `pending` until the quorum has signed or the approval expires; the grant then carries the `authority` countersign.

## 8. Authenticator loss and recovery

A human with another registered authenticator uses it. A human with none re-enrols at their home node; the node binds the new authenticator to the existing human only through an L2 verification that matches the stored identity record, otherwise a new human is created and existing standing grants expire at their `exp` without renewal.

## 9. Renewal prompts

For standing grants, the home node sends a renewal prompt at 25 % of the period remaining and again 24 hours before the grant's `exp`, with a link to an approval for the same capabilities. Renewal is an approval with `renews: <gid>`. A human MAY disable prompts for a given runtime; the grant then simply expires.

## 10. Denial

A denial is logged with `aid`, `sub`, the capability, time, and an OPTIONAL reason code chosen by the human from a fixed list (`not_me`, `wrong_amount`, `not_now`, `unknown_agent`, `other`). The requester receives `410` with the reason code. A runtime MUST NOT re-request the same action within 10 minutes of a `not_me` or `unknown_agent` denial; the node refuses such a request with `429 rate_limited`.

## 11. Wallet and approval fatigue

The home node is the human's wallet. It MUST:

- list every grant the human signed, at every node (each creating node returns the countersigned grant, §5), with its `display`, audience, operator and expiry;
- offer one-tap revoke per grant, "revoke everything from this operator" and "revoke everything for this service" (ABY-1 revocation, forwarded to each countersigning node);
- let the human set budgets and show what each live grant reserves (ORG-1 §5.2);
- show the disclosure history: which attributes went to whom, when, with the retention declared and a link to the service's privacy policy (ORG-1 §4.2);
- show the mandates, policies and budgets an organisation node applies to the human (ORG-1 §8).

To limit fatigue, the home node MAY:

- **Batch** several pending `read` and `write` approvals with the same audience and the same runtime for the same human into one page and one passkey signature, with one new binding code for the batch. Each approval is listed with its own `display`; the human may deselect any, and the challenge covers exactly the items still selected when they tap Allow. The challenge is `SHA-256(JCS({ "batch": [h1, …, hn] }))` where `hi` is the base64url string of `SHA-256(JCS(core_i))`, n ≤ 20; each resulting grant's `human_sig` carries the `batch` list, and verifiers check their own core hash is in it (ABY-1 §3).
- Send **digest** notifications that group pending `read` and `write` approvals. `write-hard` and `irreversible` approvals are always notified individually.

## 12. Security considerations

- The sentence the human reads is authored by the service, rendered by the home node from templates it fetches from the audience origin, filled only with the constraint values the grant enforces, and signed inside the grant core. No party supplies text at request time, and services verify the grant against the actual request regardless.
- The binding code ties the link the human opened to the conversation that asked for it; a phishing link carries a different code.
- The `rpId` binding of WebAuthn means a phishing page on another origin cannot obtain a valid assertion; `page_hash` makes silent changes to the page detectable.
- Approval links are not secrets: approving requires the human's passkey. A link lives at most 60 minutes; a stale link shows "expired" and nothing else.

## Change log

Every change to this document adds a row here and increments its version (README, Versioning).

| Version | Date | Change |
|---|---|---|
| 0.2.8-draft | 2026-11-18 | `level_profile` in approval requests; step-up offers sources by level and profile, and the node decides the level (CHANGES §24). |
| 0.2.7-draft | 2026-11-08 | Several audiences only with identical renderings; the approval page is never framed (CHANGES §23). |
| 0.2.6-draft | 2026-10-29 | The human may choose the breadth of a read or write approval: only this, all of this type, everything of this kind (CHANGES §20). |
| 0.2.5-draft | 2026-10-29 | `mandate` member in approval requests (CHANGES §19). |
| 0.2.4-draft | 2026-10-29 | Disclosure as required and optional lists; page shows organisation profile, acting identity, purposes and budget; wallet budgets and disclosure history (CHANGES §18). |
| 0.2.3-draft | 2026-10-28 | Levels 1–3 and `qes` in approval requests; step-up to L3; QES on the page (CHANGES §17). |
| 0.2.2-draft | 2026-10-27 | Creation validation (`initiator`, `level`, `callback`); `rate_limited` after denial; batch hash encoding (CHANGES §16). |
| 0.2.1-draft | 2026-10-27 | Forwarding to the home node; grant delivery to the wallet; `human_hint` required for write-hard (CHANGES §15). |
| 0.2.0-draft | 2026-10-27 | Approval page renders only the home node's display; binding code; who may approve; batching (CHANGES §3, §5). |
