# Scopes and claims

What a client may ask for, and what each token says about the person.

## Scopes

| Scope | Gives |
|---|---|
| `openid` | Who signed in: `sub`. Always needed |
| `profile` | `name` |
| `email` | `email` and `email_verified` |
| `orgs` | The organisations the person is in, and their role in each |
| `offline_access` | A refresh token, so the client stays signed in |

## Access token claims

| Claim | Value |
|---|---|
| `iss` | The issuer |
| `sub` | The person's Buun account id, `usr_...` |
| `aud` | One audience: the `resource` asked for, or the client itself |
| `iat`, `exp` | Seconds since the epoch. 15 minutes apart at most |
| `jti` | A random id |
| `client_id` | The client the token was issued to |
| `scope` | The granted scopes, space separated |
| `act` | Only on a traded token: `{ "sub": "<the gateway's exchange client>" }` |

## ID token claims

| Claim | Value |
|---|---|
| `iss`, `sub`, `aud`, `iat`, `exp` | As above; `aud` is the client, and it lasts 5 minutes |
| `auth_time` | When the person signed in |
| `amr` | How they signed in |
| `nonce` | The `nonce` the client sent, when it sent one |
| `sid` | The session |
| `email`, `email_verified`, `name` | As the scopes allow |

## Ids

| Prefix | What |
|---|---|
| `usr_` | A person |
| `cli_` | A client |
| `buun_ac_` | An authorization code |
| `buun_rt_` | A refresh token |

## Products

| Id | Name | Home |
|---|---|---|
| `plotwork` | Plotwork | `https://plotwork.dev` |
| `flung` | Flung | `https://flung.dev` |
| `gunspec` | GunSpec | `https://gunspec.io` |
| `destroy` | Destroy Network | `https://destroy.network` |
| `cryptflare` | CryptFlare | `https://cryptflare.com` |

The list lives in `PRODUCTS` of `@buun-group/core`. A new product is added there first.

Source: https://developers.buungroup.com/reference/claims
