Class BusEnvelopeCanonical
- Namespace
- Stratara.Abstractions.Messaging
- Assembly
- Stratara.Abstractions.dll
Canonical payload projection helpers used by both publishers (when signing) and consumers (when verifying) so the two sides hash identical bytes. The projection covers every field of the message except the signature itself.
public static class BusEnvelopeCanonical
- Inheritance
-
BusEnvelopeCanonical
- Inherited Members
Remarks
Two properties make this projection safe, and both are load-bearing.
Every field is length-prefixed. Joining fields with a separator they are allowed to contain would let content be shifted across a field boundary without changing the projection — so an attacker could alter which command type is dispatched while the signature still verified, defeating the very guard the type name is signed for.
The projection is built from field values, never by re-serializing. The payloads survive the envelope's own deserialization as strings, and every other field is a scalar with a canonical text form, so a message that has been on the wire projects to exactly what its publisher signed. Re-serializing would make the projection depend on property order, escaping and culture, and the resulting failures would be intermittent rather than immediate — the worst shape a signature check can have.
Changing this projection invalidates signatures produced by an older publisher. Fleets move through permissive mode: publishers first, consumers after, then strict again.
Methods
Of(CommandEnvelope)
Canonical projection of a CommandEnvelope — covers the envelope id, the command type, the session context, the heavy-lane flag and a digest of the command payload.
public static string Of(CommandEnvelope envelope)
Parameters
envelopeCommandEnvelopeThe envelope to project.
Returns
- string
The canonical string to sign or verify.
Exceptions
- ArgumentNullException
envelopeisnull.
Of(EventBundle)
Canonical projection of an EventBundle — covers the session context and a digest over every field of every event it carries.
public static string Of(EventBundle bundle)
Parameters
bundleEventBundleThe bundle to project.
Returns
- string
The canonical string to sign or verify.
Exceptions
- ArgumentNullException
bundleisnull.