PacketRelayDocs

Authenticated rooms#

Rooms join multiple members and attribute each forwarded frame to a member whose hello was signed with an ECDSA P-256 identity key. Use rooms only when the calling product implements the complete signing contract.

Before you start#

  • Provision one P-256 key pair per member.
  • Export the public key as base64-encoded SPKI DER.
  • Produce IEEE-P1363 signatures (r || s, 64 bytes), not DER signatures.
  • Synchronise client clocks closely enough to create a current Unix-epoch millisecond nonce.
  • Implement the jarvis-room-hello-v1 canonical payload described below.

Build the signed hello#

  1. Choose valid session_id and member_id values.

  2. Join these UTF-8 fields with the single byte 0x1f:

    jarvis-room-hello-v1
    session_id
    member_id
    pubkey
    nonce
  3. Base64-encode the joined bytes.

  4. Sign that base64 ASCII string with the member private key.

  5. Send the hello as the first WebSocket text frame:

    {
      "type": "room_hello",
      "session_id": "support-room",
      "member_id": "operator-1",
      "pubkey": "<base64-spki-public-key>",
      "nonce": 1788211200000,
      "sig": "<base64-p1363-signature>"
    }

Use a fresh current nonce for the real request; the number above only shows the JSON type.

Consume room events#

Successful admission returns room_ready. Existing members receive member_joined, while the new member receives a roster as a sequence of member_joined envelopes and then member_count.

Room payloads arrive wrapped:

{"type":"member_frame","member_id":"operator-1","payload":"<raw text>"}

Treat the envelope member_id as the relay-attributed sender. A sender claim inside payload is application data and must not override it.

Verify#

  1. Join the first member and confirm room_ready and a count of one.
  2. Join a second member and confirm both clients observe the membership change.
  3. Send a text frame from the second member and confirm only the first receives the attributed member_frame.
  4. Reconnect with the same key and a newer nonce; admission succeeds.
  5. Close the second client and confirm the first receives member_left.

If it does not work#

Result Check
The socket closes during admission Confirm every required field is present and the hello is a text frame.
Signature is rejected Confirm SPKI key encoding, P1363 signature format, field order, delimiter, and base64 step.
Nonce is rejected Synchronise the client clock and generate a newer millisecond value.
Room is at capacity Raise the configured member limit or use another room.