# Call-Time Identity (/docs/identity/call-time)



Every call through Voidnet already carries billing and rate limits. With call-time identity, it also carries the buyer. Your server learns who is calling, signed and verifiable, without any custom protocol.

## What changes [#what-changes]

A buyer calls your app through Voidnet. Voidnet authenticates the buyer, applies billing and limits, then calls your server. Without identity, you only see Voidnet. With identity, the request carries a signed statement naming the buyer's Voidnet account, and you can resolve it to the user you already have.

You change nothing about how you publish. You add one setting and one validation step.

## Enable it [#enable-it]

1. Open **Console → Identity**.
2. Set your app's mode:
   * `none` — no identity is forwarded. Today's behaviour.
   * `optional` — identity is forwarded when the buyer connected. The call proceeds without it otherwise.
   * `required` — the call is rejected until the buyer connects. Nothing is charged for a rejected call.
3. Give your server the audience URI shown on the page. It is unique to your publisher account and does not change per app.

## What arrives [#what-arrives]

One header on every request:

```
X-Voidnet-Identity: <JWT>
```

The token is a standard RS256 JWT access token. Its claims:

| Claim                | Meaning                         |
| -------------------- | ------------------------------- |
| `iss`                | `https://oauth.openvoidnet.com` |
| `sub`                | The stable Voidnet user id      |
| `aud`                | Your audience URI               |
| `exp`                | Expiry, 15 minutes after issue  |
| `email`              | The buyer's verified email      |
| `email_verified`     | Whether it is verified          |
| `name`               | Display name, when granted      |
| `preferred_username` | Username, when granted          |

The buyer's password, API keys, wallet, and usage never leave Voidnet. Only what the buyer approved is shared.

## Validate it [#validate-it]

Verify the signature, the issuer, the audience and the expiry. No call back to Voidnet is needed.

```ts
import { createRemoteJWKSet, jwtVerify } from "jose";

const ISSUER = "https://oauth.openvoidnet.com";
const jwks = createRemoteJWKSet(
  new URL(`${ISSUER}/.well-known/jwks.json`),
);

export async function resolveVoidnetUser(header: string | undefined, audience: string) {
  if (!header) return null;

  const { payload } = await jwtVerify(header, jwks, {
    issuer: ISSUER,
    audience,
  });

  return {
    sub: String(payload.sub),
    email: typeof payload.email === "string" ? payload.email : null,
    emailVerified: payload.email_verified === true,
    name: typeof payload.name === "string" ? payload.name : null,
  };
}
```

If verification fails, treat the call as having no identity. Do not fall back to an email header, a query parameter, or an unsigned value.

## Match it to your user [#match-it-to-your-user]

1. Look up `(provider = "voidnet", sub)`. If it exists, that is your user.
2. Otherwise, if `email_verified` is true and exactly one local user has that verified email, link it and store `sub`.
3. Otherwise, ask the buyer to link explicitly.
4. After linking, resolve by `sub` only. Email changes no longer affect the link.

This is the same rule you already use for Google, Microsoft Entra ID, or your own password accounts: one local user, several external identities.

## What the buyer controls [#what-the-buyer-controls]

A buyer connects once, from **Console → Connected Apps**. They see every publisher they connected, what they shared, and when it was last used. They can disconnect at any time. A publisher never receives a password, an API key, or access to any other publisher.

## Handle the two errors [#handle-the-two-errors]

| Error                    | Meaning                                                   | What to do                                                       |
| ------------------------ | --------------------------------------------------------- | ---------------------------------------------------------------- |
| `identity_link_required` | The app requires identity and the buyer has not connected | Return the error unchanged so the buyer can connect from Voidnet |
| `identity_unavailable`   | The identity provider could not issue a token             | Return the error; do not serve the call as anonymous             |

A `required` app rejects the call before billing and before your server is called. Nothing is charged.

## Revocation [#revocation]

When a buyer disconnects, Voidnet stops issuing tokens for that publisher. A token already issued stays valid until it expires, at most 15 minutes. Your server needs no revocation endpoint.

## Security notes [#security-notes]

* Validate the audience. A token issued for another publisher must not be accepted.
* Do not log the token. Log the resolved `sub` if you need a correlation id.
* Treat absence of the header as "no identity", not as an error, unless your app is set to `required`.
* Trust the `email_verified` claim. Never auto-link on an unverified email.
