@floegence/flowersec-core 0.22.1 → 0.24.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 +17 -65
- package/YAMUX_ALIGNMENT.md +4 -4
- package/dist/client-connect/connectCore.d.ts +3 -3
- package/dist/client-connect/connectCore.js +120 -106
- package/dist/client.d.ts +2 -0
- package/dist/controlplane/issuer.d.ts +5 -2
- package/dist/controlplane/issuer.js +76 -16
- package/dist/controlplane/request.js +3 -1
- package/dist/defaults.d.ts +2 -0
- package/dist/defaults.js +2 -0
- package/dist/e2ee/handshake.d.ts +2 -2
- package/dist/e2ee/secureChannel.d.ts +2 -2
- package/dist/e2ee/secureChannel.js +22 -10
- package/dist/endpoint/index.d.ts +1 -0
- package/dist/endpoint/index.js +26 -5
- package/dist/proxy/controllerWindow.js +4 -5
- package/dist/proxy/runtime.js +10 -19
- package/dist/reconnect/index.js +141 -88
- package/dist/rpc/server.d.ts +1 -0
- package/dist/rpc/server.js +49 -20
- package/dist/streamio/index.js +3 -6
- package/dist/utils/errors.d.ts +1 -1
- package/dist/yamux/byteReader.d.ts +2 -0
- package/dist/yamux/byteReader.js +28 -24
- package/dist/yamux/errors.d.ts +8 -0
- package/dist/yamux/errors.js +18 -0
- package/dist/yamux/session.js +8 -5
- package/dist/yamux/stream.d.ts +1 -1
- package/dist/yamux/stream.js +3 -3
- package/package.json +4 -1
package/dist/yamux/session.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ByteReader } from "./byteReader.js";
|
|
|
2
2
|
import { decodeHeader, encodeHeader, HEADER_LEN } from "./header.js";
|
|
3
3
|
import { FLAG_ACK, FLAG_RST, FLAG_SYN, TYPE_DATA, TYPE_GO_AWAY, TYPE_PING, TYPE_WINDOW_UPDATE, YAMUX_VERSION } from "./constants.js";
|
|
4
4
|
import { YamuxStream } from "./stream.js";
|
|
5
|
-
import { YamuxResourceExhaustedError } from "./errors.js";
|
|
5
|
+
import { YamuxPingTimeoutError, YamuxResourceExhaustedError } from "./errors.js";
|
|
6
6
|
import { SDK_DEFAULTS } from "../defaults.js";
|
|
7
7
|
export const DEFAULT_YAMUX_LIMITS = Object.freeze({
|
|
8
8
|
maxActiveStreams: SDK_DEFAULTS.yamux.maxActiveStreams,
|
|
@@ -11,7 +11,7 @@ export const DEFAULT_YAMUX_LIMITS = Object.freeze({
|
|
|
11
11
|
preferredOutboundFrameBytes: SDK_DEFAULTS.yamux.preferredOutboundFrameBytes,
|
|
12
12
|
maxStreamReceiveBytes: SDK_DEFAULTS.yamux.maxStreamReceiveBytes,
|
|
13
13
|
maxSessionReceiveBytes: SDK_DEFAULTS.yamux.maxSessionReceiveBytes,
|
|
14
|
-
maxStreamWriteQueueBytes: SDK_DEFAULTS.
|
|
14
|
+
maxStreamWriteQueueBytes: SDK_DEFAULTS.yamux.maxStreamWriteQueueBytes,
|
|
15
15
|
});
|
|
16
16
|
// YamuxSession multiplexes multiple streams over a single byte stream.
|
|
17
17
|
export class YamuxSession {
|
|
@@ -129,7 +129,7 @@ export class YamuxSession {
|
|
|
129
129
|
return await new Promise((resolve, reject) => {
|
|
130
130
|
const timer = setTimeout(() => {
|
|
131
131
|
this.pingWaiters.delete(opaque);
|
|
132
|
-
const error = new
|
|
132
|
+
const error = new YamuxPingTimeoutError();
|
|
133
133
|
reject(error);
|
|
134
134
|
this.fail(error);
|
|
135
135
|
}, timeoutMs);
|
|
@@ -229,8 +229,11 @@ export class YamuxSession {
|
|
|
229
229
|
this.pingWaiters.clear();
|
|
230
230
|
const streams = Array.from(this.streams.values());
|
|
231
231
|
this.streams.clear();
|
|
232
|
-
for (const s of streams)
|
|
233
|
-
s.reset(new Error("session closed"))
|
|
232
|
+
for (const s of streams) {
|
|
233
|
+
void Promise.resolve(s.reset(new Error("session closed"))).catch(() => {
|
|
234
|
+
// Session shutdown has already made the stream terminal.
|
|
235
|
+
});
|
|
236
|
+
}
|
|
234
237
|
}
|
|
235
238
|
wakeSendWindowWaiters() {
|
|
236
239
|
for (const [streamId, ws] of this.sendWindowWaiters) {
|
package/dist/yamux/stream.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class YamuxStream {
|
|
|
23
23
|
write(data: Uint8Array): Promise<void>;
|
|
24
24
|
private writeSerial;
|
|
25
25
|
close(): Promise<void>;
|
|
26
|
-
reset(err
|
|
26
|
+
reset(err?: Error): Promise<void>;
|
|
27
27
|
private fail;
|
|
28
28
|
bufferedReceiveBytes(): number;
|
|
29
29
|
releaseBufferedReceiveBytes(): number;
|
package/dist/yamux/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { concatBytes } from "../utils/bin.js";
|
|
2
2
|
import { encodeHeader } from "./header.js";
|
|
3
3
|
import { DEFAULT_MAX_STREAM_WINDOW, FLAG_ACK, FLAG_FIN, FLAG_RST, FLAG_SYN, TYPE_DATA, TYPE_WINDOW_UPDATE } from "./constants.js";
|
|
4
|
-
import { YamuxResourceExhaustedError } from "./errors.js";
|
|
4
|
+
import { YamuxResourceExhaustedError, YamuxStreamResetError } from "./errors.js";
|
|
5
5
|
// YamuxStream manages per-stream flow control and state transitions.
|
|
6
6
|
export class YamuxStream {
|
|
7
7
|
// Stream identifier within the session.
|
|
@@ -152,7 +152,7 @@ export class YamuxStream {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
// reset tears down the stream and notifies the peer.
|
|
155
|
-
reset(err) {
|
|
155
|
+
reset(err = new Error("stream reset")) {
|
|
156
156
|
if (this.resetTask != null)
|
|
157
157
|
return this.resetTask;
|
|
158
158
|
if (!this.fail(err))
|
|
@@ -206,7 +206,7 @@ export class YamuxStream {
|
|
|
206
206
|
w();
|
|
207
207
|
}
|
|
208
208
|
if ((flags & FLAG_RST) !== 0) {
|
|
209
|
-
if (this.fail(new
|
|
209
|
+
if (this.fail(new YamuxStreamResetError()))
|
|
210
210
|
this.session.onStreamClosed(this.id);
|
|
211
211
|
}
|
|
212
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/flowersec-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Flowersec core TypeScript library (browser-friendly E2EE + multiplexing over WebSocket).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -121,6 +121,8 @@
|
|
|
121
121
|
"build": "tsc -p tsconfig.build.json",
|
|
122
122
|
"bench": "vitest bench --run",
|
|
123
123
|
"test": "npm run build && vitest run",
|
|
124
|
+
"test:browser": "npm run build && playwright test",
|
|
125
|
+
"ensure:browser": "node ./scripts/ensure-playwright-chromium.mjs",
|
|
124
126
|
"test:coverage": "npm run build && vitest run --coverage",
|
|
125
127
|
"lint": "eslint .",
|
|
126
128
|
"verify:package": "node ./scripts/verify-package-exports.mjs",
|
|
@@ -136,6 +138,7 @@
|
|
|
136
138
|
"devDependencies": {
|
|
137
139
|
"@types/node": "^24.0.0",
|
|
138
140
|
"@types/ws": "^8.5.12",
|
|
141
|
+
"@playwright/test": "1.58.2",
|
|
139
142
|
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
140
143
|
"@typescript-eslint/parser": "^8.18.0",
|
|
141
144
|
"@vitest/coverage-v8": "4.1.0",
|