@sideband/secure-relay 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @sideband/secure-relay
2
2
 
3
- End-to-end encrypted communication between browsers and daemons via untrusted relay servers.
3
+ Low-level E2EE primitives for the Sideband Relay Protocol (SBRP).
4
+
5
+ Implements authenticated handshake, key derivation, and message encryption for secure browser ↔ daemon communication via untrusted relay servers. Most applications should use `@sideband/peer` instead of this package directly.
4
6
 
5
7
  ## Features
6
8
 
@@ -10,6 +12,15 @@ End-to-end encrypted communication between browsers and daemons via untrusted re
10
12
  - **TOFU identity pinning** — Trust-on-first-use with key change detection
11
13
  - **Replay protection** — Bitmap-based sequence window
12
14
 
15
+ ## Non-Goals
16
+
17
+ This package intentionally does NOT:
18
+
19
+ - Handle network transport or WebSockets
20
+ - Manage session lifecycle or reconnection
21
+ - Persist identity keys or TOFU pins
22
+ - Implement relay authentication or tokens
23
+
13
24
  ## Install
14
25
 
15
26
  ```bash
@@ -18,7 +29,7 @@ bun add @sideband/secure-relay
18
29
 
19
30
  ## Usage
20
31
 
21
- ```typescript
32
+ ```ts
22
33
  import {
23
34
  generateIdentityKeyPair,
24
35
  createHandshakeInit,
@@ -34,7 +45,8 @@ import {
34
45
  asClientId,
35
46
  } from "@sideband/secure-relay";
36
47
 
37
- // Daemon: generate identity keypair (persist this!)
48
+ // Daemon: generate identity keypair ONCE and persist securely.
49
+ // Regenerating causes TOFU mismatch warnings for all clients.
38
50
  const identity = generateIdentityKeyPair();
39
51
  const daemonId = asDaemonId("my-daemon");
40
52
 
@@ -61,25 +73,35 @@ const { sessionKeys } = processHandshakeAccept(
61
73
  );
62
74
  const daemonSession = createDaemonSession(sessionKeys);
63
75
 
64
- // Encrypt/decrypt messages
76
+ // Encrypt/decrypt messages (sessions are stateful — do not clone)
65
77
  const encrypted = encryptClientToDaemon(daemonSession, plaintext);
66
78
  const decrypted = decryptClientToDaemon(clientSession, encrypted);
67
79
  ```
68
80
 
81
+ ## TOFU Security
82
+
83
+ Identity keys use trust-on-first-use (TOFU) pinning:
84
+
85
+ - Pin daemon identity keys on first successful handshake
86
+ - Never accept key changes silently — `identity_key_changed` indicates potential MITM
87
+ - On mismatch, present both fingerprints and require explicit user approval
88
+
69
89
  ## Error Handling
70
90
 
71
91
  All errors throw `SbrpError` with a specific `code`:
72
92
 
73
- | Code | Meaning |
74
- | ---------------------- | ----------------------------------------- |
75
- | `identity_key_changed` | Pinned key doesn't match (potential MITM) |
76
- | `handshake_failed` | Signature verification failed |
77
- | `decrypt_failed` | Message authentication failed |
78
- | `sequence_error` | Replay detected or sequence out of window |
93
+ | Code | Meaning | Recovery |
94
+ | ---------------------- | ----------------------------------------- | ------------------------- |
95
+ | `identity_key_changed` | Pinned key doesn't match (potential MITM) | Close session, alert user |
96
+ | `handshake_failed` | Signature verification failed | Close session |
97
+ | `decrypt_failed` | Message authentication failed | Close session |
98
+ | `sequence_error` | Replay detected or sequence out of window | Close session |
99
+
100
+ All errors are fatal — close the session and re-handshake.
79
101
 
80
102
  ## Specification
81
103
 
82
- See [Secure Relay Protocol](https://sideband.tech/specs/secure-relay-protocol) for the full protocol specification.
104
+ See the [SBRP protocol specification](https://sideband.tech/protocols/sbrp/) for implementation details.
83
105
 
84
106
  ## License
85
107