Skip to content

feat: multiplex TSP frames over the mediator socket (0.6.0) - #4

Merged
stormer78 merged 1 commit into
mainfrom
feat/tsp-frame-demux
Jul 5, 2026
Merged

feat: multiplex TSP frames over the mediator socket (0.6.0)#4
stormer78 merged 1 commit into
mainfrom
feat/tsp-frame-demux

Conversation

@stormer78

Copy link
Copy Markdown
Contributor

What

The affinidi-messaging mediator carries both DIDComm and TSP on a single socket per DID (it sniffs the 0xF8 magic byte on inbound frames). This mirrors that client-side so a wallet needs only one socket for both.

  • _onFrame now 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"). DIDComm frames ({/ey…) are untouched — a leading -E is 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 (_onFrame routes -EonTspFrame; a JSON frame does not; a TSP frame with no handler is dropped, not error-reported). Full suite: 194 pass.

Release notes

  • Version bumped to 0.6.0.
  • types/ is generated from JSDoc at pack time (prepackbuild:types). Heads-up: if npm publish fails at build:types with a .bin/tsc MODULE_NOT_FOUND, run npm install first to repair the tsc shim (the compiler itself is fine).
  • Merge + publish this before the plugin PR — it depends on @openvtc/vti-didcomm-js ^0.6.0.

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>
@stormer78
stormer78 merged commit 406fcd6 into main Jul 5, 2026
1 of 2 checks passed
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