Skip to content

feat(server): add general-purpose inbound middleware seam (CEP-8)#101

Open
harsh04044 wants to merge 1 commit into
ContextVM:mainfrom
harsh04044:feat/cep8-pr0-inbound-middleware
Open

feat(server): add general-purpose inbound middleware seam (CEP-8)#101
harsh04044 wants to merge 1 commit into
ContextVM:mainfrom
harsh04044:feat/cep8-pr0-inbound-middleware

Conversation

@harsh04044

Copy link
Copy Markdown

Part of #100

Adds the inbound middleware seam to NostrServerTransport, the port of ts-sdk's addInboundMiddleware. This is the hook CEP-8 payment gating will register on. Nothing registers on it yet, so on its own the change is behavior-preserving.

With an empty chain the inbound path is unchanged: dispatch_inbound forwards the request to the worker exactly as before, same IncomingRequest. The existing CEP-22 and CEP-41 suites pass untouched, which was the bar for this one.

What's here:

  • middleware.rs: the InboundMiddleware trait, the Next continuation, InboundContext, and the dispatcher/runner.
  • add_inbound_middleware() on the transport, wired into the event loop at both delivery points (normal requests and reassembled CEP-22 oversized ones).
  • PaymentInteractionMode in core::types.

Note:

  • The chain runs on its own task rather than inline, so a middleware that blocks (payment verification, later) doesn't stall event ingestion. Empty chain skips the spawn.
  • Route cleanup keys off whether the request actually reached the worker, not off the middleware's return value, so a dropped request frees its correlation route and a delivered one keeps it even if a middleware returns the wrong bool.

New unit tests cover forward, drop, transform, ordering, panic, and notification handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant