Middleware Recipes
Nonce Management
import crypto from 'crypto';
const nonces = new Map<string, number>();
const NONCE_TTL_MS = 60_000;
function generateNonce(): string {
const nonce = crypto.randomBytes(16).toString('hex');
nonces.set(nonce, Date.now());
return nonce;
}
function validateNonce(nonce: string): boolean {
const created = nonces.get(nonce);
if (!created || Date.now() - created > NONCE_TTL_MS) {
nonces.delete(nonce);
return false;
}
nonces.delete(nonce); // single-use
return true;
}Signature Verification (Cosmos ADR-036)
Signature Verification (EVM EIP-191)
Ownership Check (BitBadges API)
Proof Decoding
402 Challenge Response
Amount Patterns
Client: Handling a 402
Dependencies
Last updated