Skip to main content

Class: Receiver<S, P>

Defined in: packages/messaging/src/receiver.ts:220

The receiving half of the transport, independent of the carrier. The broker subscription and the in-process bus both hand a message to Receiver.handle, so the two paths cannot disagree about a check: this is the single place where

  1. the subject resolves to a registered contract,
  2. the envelope decodes, matches the subject (tenant, schema) and is complete (idempotency key on a mutation, deadline on a request),
  3. an expired message is dropped,
  4. the body validates, leniently,
  5. callerModule is one the carrier vouches for: none on the broker, and in process exactly the caller the wiring names,
  6. the actor is proven: by the gateway's signed actor token, required for every tenant actor and for every message on a key a gateway calls over the broker, and signed by a gateway listed against the key; or, for the platform actor on a key no gateway calls, by the table's grant alone (bootstrap),
  7. the scope is minted: a tenant Scope from a TenantActor; a PlatformScope only from a PlatformActor whose caller holds a platform grant, and
  8. the handler runs inside the correlation context, with the actor's token ambient so a call it makes for the same actor carries it on, and its reply is validated strictly before it leaves.

Receiver.handle never rejects: a verifier that throws is an actor_token_invalid refusal, a minter that throws is a refusal, and an audit hook that throws is logged while the refusal stands.

Type Parameters​

S​

S

P​

P

Implements​

Constructors​

Constructor​

new Receiver<S, P>(options): Receiver<S, P>

Defined in: packages/messaging/src/receiver.ts:236

Parameters​

options​

ReceiverOptions<S, P>

Returns​

Receiver<S, P>

Throws​

A handler is for a subject this module does not serve.

Properties​

module​

readonly module: "identity" | "audit" | "governance" | "trust" | "issuance" | "verification" | "vault" | "signing" | "e-services" | "provisioning"

Defined in: packages/messaging/src/receiver.ts:222

The module served.

Implementation of​

Served.module

Methods​

handle()​

handle(inbound): Promise<ReceiveOutcome>

Defined in: packages/messaging/src/receiver.ts:299

Receives one message. Never throws: every failure is a Reply, or a drop.

Parameters​

inbound​

Inbound

The message as the carrier received it.

Returns​

Promise<ReceiveOutcome>

The reply to send, or dropped.

Implementation of​

Served.handle


keys()​

keys(): RequestKey[]

Defined in: packages/messaging/src/receiver.ts:289

The keys this receiver serves, for the broker to subscribe to.

Returns​

RequestKey[]

Implementation of​

Served.keys


register()​

register<K>(key, handler): void

Defined in: packages/messaging/src/receiver.ts:267

Adds a handler.

Type Parameters​

K​

K extends RequestKey

Parameters​

key​

K

A request key this module serves per the permission table.

handler​

Handler<K, S, P>

The handler.

Returns​

void

Throws​

The key is not served by this module, or has a handler already, or a gateway and a participant that signs no token both call it over the broker: a message without a token could then be either, so the gateway's could pass as the other's.