proof — a signed JWT issued by Bondify’s servers. Before you create a session or trust any of the user’s identity data, your backend must verify that proof cryptographically. The @bondify/server package exposes a single async function, verifyProof, that decodes and validates the token, throws on any failure, and returns a clean user object you can safely store or use to issue your own credentials.
Install
Environment variable
Store your secret key in an environment variable. Never hard-code it in source files..env
Express example
The/api/session endpoint receives the proof from your frontend, verifies it, then issues your own JWT or sets a session cookie.
server.ts
Fastify example
The same pattern works identically in Fastify:server.ts
verifyProof signature
| Parameter | Type | Description |
|---|---|---|
proof | string | The JWT proof string received from the client |
secretKey | string | Your BONDIFY_SECRET_KEY from the dashboard |
BondifyUser object
verifyProof resolves with a plain object containing the verified user’s identity:
| Field | Type | Description |
|---|---|---|
telegramId | string | The user’s unique Telegram ID |
name | string | The user’s display name from Telegram |
username | string | null | The user’s Telegram @handle — null if they have none set |
telegramId is the stable primary identifier for a user — it never changes even if the user updates their name or @handle. Use it as the foreign key when storing users in your database.Error handling
verifyProof throws a BondifyError in all failure cases. Always wrap the call in try/catch and respond with 401 Unauthorized — never let an unverified proof result in a valid session.
verifyProof throws:
| Error code | Cause |
|---|---|
INVALID_PROOF | The JWT signature does not match — possibly tampered or issued by a different key |
EXPIRED | The proof was issued more than 5 minutes ago and is no longer valid |
WRONG_PROJECT | The proof was issued for a different project ID |
Upserting users in your database
A typical session creation flow looks up the user bytelegramId and creates them if they don’t exist yet:
Next steps
HTML Widget
The fastest way to collect the proof on a static HTML page — no npm install needed.
Next.js integration
Call
verifyProof inside a Next.js Server Action and set a session cookie in one step.