@agentonboard/sdk/hono provides requireAgentAccount(c, options) for Hono apps on Cloudflare Workers, Bun, Deno, Node.js, and Fastly Compute without nodejs_compat flags.
Copy-paste agent prompt
Integrate AgentOnboard into this Hono repository.
1. Inspect the codebase and install `@agentonboard/sdk`.
2. Read these docs before editing:
- https://docs.agentonboard.xyz/hono.md
- https://docs.agentonboard.xyz/verify.md
- https://docs.agentonboard.xyz/accounts.md
- https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
- Which auth provider or users table should `resolveAccount` query?
- Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
- What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
- Call `requireAgentAccount(c, options)` from `@agentonboard/sdk/hono`.
- Hardcode `audience` to the normalized production Domain.
- Normalize emails with `normalizeEmail(email)` from `@agentonboard/sdk` (never raw `email.toLowerCase()`).
- Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
1. Install the SDK
- npm
- pnpm
- yarn
- bun
npm install @agentonboard/sdk
pnpm add @agentonboard/sdk
yarn add @agentonboard/sdk
bun add @agentonboard/sdk
2. Guard your Hono route
src/index.ts
import { Hono } from "hono";
import { normalizeEmail } from "@agentonboard/sdk";
import { requireAgentAccount } from "@agentonboard/sdk/hono";
const app = new Hono();
// Simulated user database
const accounts = new Map([["ada@example.com", "user_123"]]);
app.post("/api/notes", async (c) => {
const session = await requireAgentAccount(c, {
audience: "notes.com",
resolveAccount: async ({ email }) => {
return accounts.get(normalizeEmail(email)) ?? null;
},
});
// session.response is a standard Response (401, 403, or 500)
if (!session.ok) return session.response;
return c.json({ success: true, user: session.user });
});
export default app;
Use
session.user directlyThe binding does not mutate Hono’s c.set() context map. Read session.user directly from the returned object so TypeScript types stay exact.3. Test with curl
Mint a 5-minute test token usingPOST /api/v1/token/exchange and call your Hono service:
# Mint a 5-minute test token
TOKEN=$(curl -s -X POST https://agentonboard.xyz/api/v1/token/exchange \
-H "Authorization: Bearer aon_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"audience":"notes.com"}' \
| jq -r '.token')
# Call your Hono service
curl -i -X POST http://localhost:8787/api/notes \
-H "Authorization: Bearer $TOKEN"