@aegis-fluxion/core 0.8.0 → 0.9.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 +78 -2
- package/dist/index.cjs +733 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +733 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Low-level encrypted WebSocket primitives for the `aegis-fluxion` ecosystem.
|
|
4
4
|
|
|
5
|
-
Version: **0.
|
|
5
|
+
Version: **0.9.0**
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -11,6 +11,7 @@ Version: **0.8.0**
|
|
|
11
11
|
- Ephemeral ECDH handshake (`prime256v1`)
|
|
12
12
|
- AES-256-GCM encrypted envelopes
|
|
13
13
|
- ACK request/response (Promise + callback styles)
|
|
14
|
+
- Encrypted chunked streaming for large `Buffer`/`Readable` payloads
|
|
14
15
|
- Secure room routing (`join`, `leave`, `leaveAll`, `to(room).emit(...)`)
|
|
15
16
|
- Middleware phases: `connection`, `incoming`, `outgoing`
|
|
16
17
|
- Rate limiting and DDoS controls per connection and IP
|
|
@@ -27,9 +28,84 @@ npm install @aegis-fluxion/core ws
|
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
31
|
+
## Chunked streaming (new in 0.9.0)
|
|
32
|
+
|
|
33
|
+
`@aegis-fluxion/core@0.9.0` adds secure chunked stream transport for large payloads.
|
|
34
|
+
|
|
35
|
+
### Supported stream sources
|
|
36
|
+
|
|
37
|
+
- `Buffer`
|
|
38
|
+
- `Uint8Array`
|
|
39
|
+
- `Readable`
|
|
40
|
+
- `AsyncIterable<Buffer | Uint8Array | ArrayBuffer>`
|
|
41
|
+
|
|
42
|
+
### Stream APIs
|
|
43
|
+
|
|
44
|
+
- Client outbound: `client.emitStream(event, source, options?)`
|
|
45
|
+
- Client inbound: `client.onStream(event, handler)`
|
|
46
|
+
- Server outbound: `server.emitStreamTo(clientId, event, source, options?)`
|
|
47
|
+
- Server inbound: `server.onStream(event, handler)`
|
|
48
|
+
- Per-client server outbound helper: `serverClient.emitStream(event, source, options?)`
|
|
49
|
+
|
|
50
|
+
### Options
|
|
51
|
+
|
|
52
|
+
- `chunkSizeBytes` (default `64 * 1024`, max `1024 * 1024`)
|
|
53
|
+
- `metadata` (optional object attached to the stream start frame)
|
|
54
|
+
- `totalBytes` (optional size hint; required when source size is unknown and you want announced size)
|
|
55
|
+
- `signal` (`AbortSignal` to cancel transfer)
|
|
56
|
+
|
|
57
|
+
### Example
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { Readable } from "node:stream";
|
|
61
|
+
import { SecureClient, SecureServer } from "@aegis-fluxion/core";
|
|
62
|
+
|
|
63
|
+
const server = new SecureServer({ host: "127.0.0.1", port: 8080 });
|
|
64
|
+
const client = new SecureClient("ws://127.0.0.1:8080");
|
|
65
|
+
|
|
66
|
+
server.onStream("media:upload", async (stream, info, peer) => {
|
|
67
|
+
const chunks: Buffer[] = [];
|
|
68
|
+
|
|
69
|
+
for await (const chunk of stream) {
|
|
70
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const uploaded = Buffer.concat(chunks);
|
|
74
|
+
|
|
75
|
+
await peer.emitStream("media:download", Readable.from(uploaded), {
|
|
76
|
+
chunkSizeBytes: 64 * 1024,
|
|
77
|
+
totalBytes: uploaded.length,
|
|
78
|
+
metadata: { direction: "server-to-client" }
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
console.log("Server received stream", {
|
|
82
|
+
streamId: info.streamId,
|
|
83
|
+
announcedTotalBytes: info.totalBytes,
|
|
84
|
+
receivedBytes: uploaded.length
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
client.on("ready", async () => {
|
|
89
|
+
const payload = Buffer.from("chunked secure payload");
|
|
90
|
+
|
|
91
|
+
const result = await client.emitStream("media:upload", payload, {
|
|
92
|
+
chunkSizeBytes: 64 * 1024,
|
|
93
|
+
totalBytes: payload.length,
|
|
94
|
+
metadata: { direction: "client-to-server" }
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log(result); // { streamId, chunkCount, totalBytes }
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Each chunk is delivered inside reserved internal `start/chunk/end/abort` frames and encrypted
|
|
102
|
+
through the same AES-256-GCM channel used by standard events.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
30
106
|
## Session resumption (TLS 1.3-style)
|
|
31
107
|
|
|
32
|
-
`@aegis-fluxion/core@0.8.0`
|
|
108
|
+
`@aegis-fluxion/core@0.8.0` introduced secure resume-first reconnect behavior:
|
|
33
109
|
|
|
34
110
|
- Full handshake path uses ephemeral ECDH (`hello` frame).
|
|
35
111
|
- Resume path uses ticket-bound proofs (`resume` / `resume-ack` frames).
|