feat: multiplex TSP frames over the mediator socket (0.6.0) - #4
Merged
Conversation
The affinidi-messaging mediator carries both DIDComm and TSP on a single socket per DID (it sniffs the 0xF8 magic byte on inbound frames). Mirror that client-side so a wallet needs only one socket: - `_onFrame` demuxes a "-E"-prefixed frame (base64url(qb2), whose first decoded byte is the 0xF8 TSP magic) to a new `onTspFrame(bytes)` hook, handing over the raw qb2 bytes instead of running it through the DIDComm unpacker (which rejects it with "no skid"). - `sendBinary(bytes)` sends a raw TSP message as a WS binary frame; the mediator routes it to its TSP inbound handler. This lets one warm mediator session carry a wallet's DIDComm inbox and its TSP trust-task traffic concurrently, avoiding the one-socket-per-DID conflict a second dedicated TSP socket would hit. Adds 3 demux unit tests. types/ regenerated from JSDoc at pack time. Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The affinidi-messaging mediator carries both DIDComm and TSP on a single socket per DID (it sniffs the
0xF8magic byte on inbound frames). This mirrors that client-side so a wallet needs only one socket for both._onFramenow demuxes a-E-prefixed frame (base64url(qb2), whose first decoded byte is the0xF8TSP magic) to a newonTspFrame(bytes)hook, handing over the raw qb2 bytes instead of running it through the DIDComm unpacker (which rejects it with "no skid"). DIDComm frames ({/ey…) are untouched — a leading-Eis an unambiguous TSP marker.sendBinary(bytes)sends a raw TSP message as a WS binary frame; the mediator routes it to its TSP inbound handler.This lets one warm mediator session carry a wallet's DIDComm inbox and its TSP trust-task traffic concurrently, avoiding the one-socket-per-DID conflict a second dedicated TSP socket would hit.
Why
Consumed by the browser plugin's new TSP transport (OpenVTC/vta-browser-plugin
feat/tsp-transport). A dedicated TSP socket could send but never received replies — the mediator delivers a holder's inbound over its single live-delivery socket (the DIDComm one), so the reply landed there and failed to unpack. Demuxing on that socket fixes it. Validated end-to-end live (vault list, proxy-login, add, delete over TSP).Tests
+3 demux unit tests (
_onFrameroutes-E→onTspFrame; a JSON frame does not; a TSP frame with no handler is dropped, not error-reported). Full suite: 194 pass.Release notes
types/is generated from JSDoc at pack time (prepack→build:types). Heads-up: ifnpm publishfails atbuild:typeswith a.bin/tscMODULE_NOT_FOUND, runnpm installfirst to repair the tsc shim (the compiler itself is fine).@openvtc/vti-didcomm-js ^0.6.0.