UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

45 lines (44 loc) 1.26 kB
/** * In-memory nonce cache implementation * * WARNING: This implementation is only suitable for single-instance deployments. * For multi-instance deployments, use Redis, DynamoDB, or Cloudflare KV implementations. */ import { NonceCache } from "@kya-os/contracts/handshake"; /** * In-memory nonce cache with TTL support */ export declare class MemoryNonceCache implements NonceCache { private cache; private cleanupInterval?; constructor(cleanupIntervalMs?: number); /** * Check if a nonce exists in the cache */ has(nonce: string, agentDid?: string): Promise<boolean>; /** * Add a nonce to the cache with TTL * MUST ensure atomic add-if-absent semantics for replay prevention */ add(nonce: string, ttlSeconds: number, agentDid?: string): Promise<void>; /** * Clean up expired entries * Safe to call frequently and should be no-op for backends that auto-expire */ cleanup(): Promise<void>; /** * Get cache statistics */ getStats(): { size: number; expired: number; }; /** * Clear all entries (useful for testing) */ clear(): void; /** * Destroy the cache and stop cleanup interval */ destroy(): void; }