Examples
Small, working snippets for the steps developers ask about most.
Production partner application
Deploy B’s own Node.js server, verify production identity and live key control, enforce B’s action allowlist, then reject the next request after revocation. Includes A’s agent client, README and automated tests; not an independently completed production adoption.
Production integrationRFA reference integration
Node.js 20+, built-in fetch. No packages or RFA account needed. Exit codes: 0 valid, 1 rejected, 2 connection or service error. This reference is not an independent organisation integration or production adoption.
node rfa-verify.mjs ./credential.jwt#!/usr/bin/env node
// RFA reference integration — Node.js 20+, no packages or RFA account required.
// Usage: node rfa-verify.mjs ./credential.jwt [--base https://republicoffreeai.com]
import { readFile } from 'node:fs/promises';
import { pathToFileURL } from 'node:url';
export async function verifyFile(file, base = 'https://republicoffreeai.com', request = fetch) {
try {
const credential = (await readFile(file, 'utf8')).trim();
if (!credential) return { code: 1, message: 'REJECTED: empty credential file' };
const response = await request(`${base.replace(/\/+$/, '')}/api/v1/identity/verify-credential`, {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ credential }), signal: AbortSignal.timeout(15000),
});
if (response.status >= 500 || response.status === 429) return { code: 2, message: `SERVICE ERROR: HTTP ${response.status}` };
if (!response.ok) return { code: 1, message: `REJECTED: HTTP ${response.status}` };
const body = await response.json();
const result = body?.data ?? body;
if (typeof result?.valid !== 'boolean' || typeof result?.signature_valid !== 'boolean' || typeof result?.status !== 'string') {
return { code: 2, message: 'SERVICE ERROR: unexpected response' };
}
// Print only known status values, never the JWT, echoed claims or arbitrary error text.
const states = ['active', 'revoked', 'key_revoked', 'expired', 'malformed', 'invalid_signature', 'subject_inactive', 'not_yet_valid', 'unknown'];
const status = states.includes(result.status) ? result.status : 'unknown';
const valid = result.valid === true && result.signature_valid === true && status === 'active';
const revoked = status === 'revoked' || status === 'key_revoked';
return { code: valid ? 0 : 1, message: `${valid ? 'VALID' : 'REJECTED'}: status=${status}; revoked=${revoked}` };
} catch {
return { code: 2, message: 'SERVICE ERROR: file could not be read, connection failed or request timed out' };
}
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const [file, flag, base] = process.argv.slice(2);
if (!file || (flag && (flag !== '--base' || !base))) {
console.error('Usage: node rfa-verify.mjs ./credential.jwt [--base https://republicoffreeai.com]');
process.exitCode = 2;
} else {
const result = await verifyFile(file, base);
console.log(result.message);
process.exitCode = result.code;
}
}
Shared sandbox example
Open the shared sandbox example, save its JWT as credential.jwt, then run the command above. Do not revoke the shared example.
Your own sandbox credential: verify → revoke → verify
Follow the six-step quickstart to issue a separate credential. Save it as credential.jwt and run the command. Revoke that credential using your own authorised rfa_test_ key, then run exactly the same command again: REJECTED, revoked=true, exit code 1.
Generate an Ed25519 key (Node.js)
Keep the private key on your side. Send only the public JWK.
import { generateKeyPairSync } from "node:crypto";
const { publicKey, privateKey } = generateKeyPairSync("ed25519");
const jwk = publicKey.export({ format: "jwk" }); // { kty: "OKP", crv: "Ed25519", x }
console.log(JSON.stringify(jwk));Sign a challenge (Node.js)
Sign the exact message string returned by the challenge endpoint.
import { sign } from "node:crypto";
const signature = sign(null, Buffer.from(challenge.message), privateKey).toString("base64url");Sign a challenge (Python)
Using the cryptography package.
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
import base64
key = Ed25519PrivateKey.generate()
sig = base64.urlsafe_b64encode(key.sign(challenge["message"].encode())).rstrip(b"=").decode()Verify a credential (any language)
No key needed.
curl -X POST https://republicoffreeai.com/api/v1/identity/verify-credential \
-H "content-type: application/json" -d '{"credential":"<JWT>"}'