Skip to content

SDK Compliance: CEP & Feature Parity with TS SDK #64

@harsh04044

Description

@harsh04044

SDK Compliance Tracker

Tracking feature parity between rs-sdk and the TS SDK implementation. Checked items are implemented and tested. Open items are planned for future releases. Reference: TS SDK v0.9.0.


CEP Support

CEP-4: Encryption Support

  • NIP-44 v2 encrypt / decrypt
  • NIP-59 single-layer gift wrap (kind 1059)
  • Ephemeral gift wrap (kind 21059)
  • EncryptionMode enum (Optional / Required / Disabled)
  • GiftWrapMode enum (Optional / Ephemeral / Persistent)
  • Encryption policy enforcement (reject mismatched messages)
  • Server mirrors inbound gift-wrap kind on response
  • support_encryption tag emitted and parsed
  • support_encryption_ephemeral tag emitted and parsed
  • Capability discovery via parse_discovered_peer_capabilities()

CEP-6: Server Announcements (kinds 11316-11320)

  • Publish kind 11316 (server announcement)
  • Publish kind 11317 (tools list)
  • Publish kind 11318 (resources list)
  • Publish kind 11319 (resource templates list)
  • Publish kind 11320 (prompts list)
  • Delete announcements (NIP-09 kind 5)
  • set_announcement_extra_tags() / set_announcement_pricing_tags()
  • AnnouncementManager orchestrator (synthetic MCP requests, automated publish on start)
  • Kind 11316 content should be full InitializeResult (protocolVersion, capabilities, serverInfo) — currently only ServerInfo
  • Publish announcements to bootstrap relays (not just connected pool)
  • Skip bootstrap if all relays are local

CEP-8: Payments

  • cap tags for capability pricing (['cap', 'tool:name', '100', 'sats'])
  • pmi tags for payment method identifiers
  • notifications/payment_required / payment_accepted / payment_rejected
  • Server payment gating middleware
  • Client payment handler wrapper
  • Dynamic pricing (resolvePrice callback with waive/reject/quote)
  • PMI negotiation (client preference order)
  • Idempotency by requestEventId
  • TTL-based verification timeout
  • Synthetic progress heartbeats (client-side, resets MCP timeout during settlement)
  • NWC payment processor (NIP-47: make_invoice, lookup_invoice)
  • LNbits payment processor (REST API)
  • Zap payment processor (NIP-57: LNURL-pay + kind 9734/9735)
  • NWC payment handler (client: pay_invoice)
  • LNbits payment handler (client: pay via REST)
  • Client payment policy hook

CEP-17: Relay List Metadata Discoverability

  • Kind 10002 constant
  • r tag constant
  • Bootstrap relay URLs (6 defaults)
  • Server publishes kind 10002 relay list on start
  • Client fetches kind 10002 to discover server relays
  • Operational relay selection from r tags
  • Relay resolution chain: config → nprofile hints → kind 10002 → fallback → bootstrap
  • discoveryRelayUrls config option
  • fallbackOperationalRelayUrls config option

CEP-19: Ephemeral Gift Wraps

  • Kind 21059 / 1059 constants
  • GiftWrapMode enum (Optional / Ephemeral / Persistent)
  • Single-layer gift wrap with configurable kind
  • Subscribe to both 1059 + 21059
  • isGiftWrapKindAllowed() enforcement
  • support_encryption_ephemeral tag
  • Server mirrors inbound wrap kind on response
  • Client learns server ephemeral support
  • Server learns client ephemeral support
  • Gift wrap kind stored in correlation route for mirroring

CEP-22: Oversized Payload Transfer

  • support_oversized_transfer tag constant defined
  • Wire oversized_enabled from config (currently hardcoded false)
  • Frame types: Start, Chunk, End, Accept, Abort
  • Sender: UTF-8-safe chunk splitting + SHA-256 digest
  • Sender: orchestration (start → accept? → chunks → end)
  • Receiver: state machine with out-of-order chunk handling
  • Receiver: reassembly + digest verification + JSON-RPC validation
  • Accept handshake when peer support unknown
  • Transfer timeout watchdog (5 min default)
  • Policy limits (100MB max, 10K chunks, 64 concurrent)
  • Error types (Policy, Digest, Reassembly, Sequence, Abort)
  • Client→Server oversized requests
  • Server→Client oversized responses

CEP-23: Server Identity Profile Metadata

  • PROFILE_METADATA_KIND = 0 constant
  • ProfileMetadata type (name, about, picture, banner, website, nip05, lud16)
  • publishProfileMetadata() on server start
  • profileMetadata config option

CEP-35: Discovery Tags & Capability Learning

  • PeerCapabilities / DiscoveredPeerCapabilities structs
  • has_single_tag() / get_discovery_tags() / learn_peer_capabilities()
  • Server one-shot tag emission (has_sent_common_tags)
  • Client one-shot tag emission (has_sent_discovery_tags)
  • Server learns client caps (OR-assign, never downgrade)
  • Client learns server caps
  • Tag composition order: base → discovery → negotiation

SDK Behaviors Beyond CEPs

Server Transport

  • Multi-client sessions (LRU, default 1000)
  • Session eviction safety (recreate if active routes)
  • Session eviction callback
  • Request/response correlation (3 indexes, atomic pop)
  • Progress token → event ID mapping
  • Authorization: static pubkey whitelist
  • Authorization: static capability exclusions
  • Authorization: initialize/notifications/initialized always allowed
  • Unauthorized error response only if is_announced_server
  • Dedup seen gift-wrap IDs (LRU)
  • broadcast_notification() to all clients
  • Session timeout cleanup (time-based, beyond LRU)
  • Stale route sweep (sweep_stale_routes)
  • Dynamic isPubkeyAllowed(pubkey) callback
  • Dynamic isCapabilityExcluded(exclusion) callback
  • Inbound middleware chain (message, ctx, forward)
  • injectClientPubkey into request.params._meta
  • injectRequestEventId into request.params._meta
  • Per-request Nostr event context store (for cap tag inspection)
  • Pricing tags attached to live capability list responses (not just announcements)

Client Transport

  • Request/response correlation via e tag
  • Pending request LRU (bounded)
  • Dedup gift-wrap envelopes (LRU, pre-decrypt)
  • Stateless mode emulation
  • Gift wrap kind selection (adapts to server capabilities)
  • Discovery tag learning from server (OR-assign)
  • Discovery tag emission (one-shot, requests only)
  • Drop responses without e tag
  • Drop server-originated requests
  • Encryption/gift-wrap policy enforcement
  • Server pubkey verification on inbound events
  • TTL sweep on pending requests
  • serverPubkey accepts npub / nprofile (currently hex only)
  • nprofile relay hints used for relay resolution
  • onEventCreated pre-publish hook (register correlation before publish)
  • withTimeout() on decrypt / sign / publish operations
  • Notification schema validation
  • Oversized transfer sender + receiver
  • Cache server capability list events (tools, resources, prompts)
  • Accessor methods (getServerInitializeName(), getServerToolsListEvent(), etc.)

Gateway

  • start() / stop() lifecycle
  • announce() delegates to transport
  • serve_handler() (rmcp integration)
  • Per-client mode: isolated MCP transport per client pubkey
  • Per-client LRU cache with configurable max
  • Re-initialization handling (INITIALIZE closes existing transport)
  • Session eviction → transport cleanup

Relay Management

  • Relay pool abstraction (RelayPoolTrait)
  • Multi-relay connectivity
  • Auto-reconnection (via nostr-sdk)
  • Publish retry loop (TS SDK retries infinitely at 500ms intervals)
  • Liveness ping (EOSE-based, 2min interval, 20s timeout)
  • Ping timeout triggers relay rebuild + subscription replay
  • publishEventToRelayUrls() for bootstrap relay publication

Encryption & NIPs

  • NIP-44 v2 encrypt / decrypt
  • NIP-59 single-layer gift wrap (kind 1059 + 21059)
  • NIP-01 base protocol
  • NIP-04 encrypt / decrypt (legacy, needed for NWC/CEP-8)
  • NIP-19 bech32 encoding: npub / nprofile parsing
  • NIP-47 Nostr Wallet Connect (needed for CEP-8)
  • NIP-57 Lightning Zaps (needed for CEP-8)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions