@floegence/flowersec-core 7.1.0 → 7.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 +2 -1
- package/THIRD_PARTY_NOTICES.md +5 -5
- package/dist/node/acceptorV3.js +7 -3
- package/dist/node/connectionPath.js +49 -37
- package/dist/node/listenerIngress.d.ts +7 -0
- package/dist/node/listenerIngress.js +21 -0
- package/dist/node/proxyServer.d.ts +1 -0
- package/dist/node/proxyServer.js +173 -78
- package/dist/node/proxyTarget.d.ts +1 -0
- package/dist/node/proxyTarget.js +13 -0
- package/dist/node/rawQuicAdapterV3.js +2 -2
- package/dist/node/rawQuicServerV3.js +12 -1
- package/dist/node/tunnelRuntimeV3.js +40 -7
- package/dist/node/webSocketServerV3.js +24 -2
- package/dist/proxy/bodyIntake.d.ts +13 -0
- package/dist/proxy/bodyIntake.js +55 -0
- package/dist/proxy/controllerGuard.d.ts +4 -0
- package/dist/proxy/controllerGuard.js +79 -37
- package/dist/proxy/fetch.d.ts +2 -1
- package/dist/proxy/fetch.js +55 -27
- package/dist/proxy/integration.d.ts +1 -1
- package/dist/proxy/integration.js +25 -5
- package/dist/proxy/registerServiceWorker.d.ts +5 -0
- package/dist/proxy/registerServiceWorker.js +30 -21
- package/dist/proxy/runtime.d.ts +7 -1
- package/dist/proxy/runtime.js +129 -39
- package/dist/proxy/scope.js +1 -1
- package/dist/proxy/serviceWorker.js +286 -43
- package/dist/proxy/serviceWorkerRuntime.d.ts +5 -2
- package/dist/proxy/serviceWorkerRuntime.js +58 -3
- package/dist/proxy/stream.d.ts +1 -0
- package/dist/proxy/stream.js +6 -3
- package/dist/proxy/types.d.ts +1 -1
- package/dist/proxy/windowBridge.d.ts +3 -1
- package/dist/proxy/windowBridge.js +64 -19
- package/dist/proxy/wsPatch.js +70 -52
- package/dist/public/sessionHandlers.js +3 -2
- package/dist/utils/abort.d.ts +1 -0
- package/dist/utils/abort.js +13 -0
- package/dist/v3/artifactLease.d.ts +6 -0
- package/dist/v3/artifactLease.js +6 -0
- package/dist/v3/contract.d.ts +1 -0
- package/dist/v3/nodeRuntime.js +10 -25
- package/dist/v3/publicSession.d.ts +2 -1
- package/dist/v3/publicSession.js +11 -15
- package/dist/v3/session.d.ts +7 -1
- package/dist/v3/session.js +110 -25
- package/dist/v3/unreliableMessage.d.ts +1 -0
- package/dist/v3/unreliableMessage.js +5 -1
- package/dist/v3/webSocketCarrier.js +24 -11
- package/dist/v3/webTransportCarrier.js +6 -0
- package/dist/ws-client/binaryTransport.d.ts +2 -0
- package/dist/ws-client/binaryTransport.js +8 -2
- package/dist/yamux/byteReader.js +1 -0
- package/dist/yamux/session.d.ts +2 -0
- package/dist/yamux/session.js +4 -1
- package/package.json +3 -3
- package/sbom/cyclonedx.json +31 -31
- package/sbom/spdx.json +38 -38
package/README.md
CHANGED
|
@@ -101,7 +101,8 @@ same port and the exact `/flowersec/webtransport/v5/direct` or
|
|
|
101
101
|
`/flowersec/webtransport/v5/tunnel` path. Node speaks draft02. Configure an
|
|
102
102
|
explicit raw QUIC route for a Go client dialing a Node listener.
|
|
103
103
|
|
|
104
|
-
CA candidates use platform or configured private roots.
|
|
104
|
+
CA candidates use platform or configured private roots. Node native transports use
|
|
105
|
+
the current Node default CA set when no explicit roots are supplied. Pin candidates verify
|
|
105
106
|
only the complete artifact-bound active pin set and never fall back to CA.
|
|
106
107
|
Public errors remain closed and redacted.
|
|
107
108
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
This file is generated from the canonical Flowersec source dependency inventory for flowersec-ts.
|
|
4
4
|
Do not edit it manually. License decisions are reviewed by the repository source license policy.
|
|
5
5
|
|
|
6
|
-
- @floegence/flowersec-node-native 7.
|
|
7
|
-
- @floegence/flowersec-node-native-darwin-arm64 7.
|
|
8
|
-
- @floegence/flowersec-node-native-darwin-x64 7.
|
|
9
|
-
- @floegence/flowersec-node-native-linux-arm64-gnu 7.
|
|
10
|
-
- @floegence/flowersec-node-native-linux-x64-gnu 7.
|
|
6
|
+
- @floegence/flowersec-node-native 7.2.0 (Declared: MIT; selected: MIT; source: https://github.com/floegence/flowersec.git)
|
|
7
|
+
- @floegence/flowersec-node-native-darwin-arm64 7.2.0 (Declared: MIT; selected: MIT; source: https://github.com/floegence/flowersec.git)
|
|
8
|
+
- @floegence/flowersec-node-native-darwin-x64 7.2.0 (Declared: MIT; selected: MIT; source: https://github.com/floegence/flowersec.git)
|
|
9
|
+
- @floegence/flowersec-node-native-linux-arm64-gnu 7.2.0 (Declared: MIT; selected: MIT; source: https://github.com/floegence/flowersec.git)
|
|
10
|
+
- @floegence/flowersec-node-native-linux-x64-gnu 7.2.0 (Declared: MIT; selected: MIT; source: https://github.com/floegence/flowersec.git)
|
|
11
11
|
- @noble/ciphers 2.4.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/ciphers/-/ciphers-2.4.0.tgz)
|
|
12
12
|
- @noble/curves 2.4.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/curves/-/curves-2.4.0.tgz)
|
|
13
13
|
- @noble/hashes 2.4.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/hashes/-/hashes-2.4.0.tgz)
|
package/dist/node/acceptorV3.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { projectSessionV3 } from "../v3/publicSession.js";
|
|
2
2
|
import { rpcFrameLimit } from "../framing/jsonframe.js";
|
|
3
3
|
import { rpcConcurrency } from "../rpc/server.js";
|
|
4
|
-
import {
|
|
4
|
+
import { X509Certificate } from "node:crypto";
|
|
5
|
+
import { boundIngressURL, matchesIngress } from "./listenerIngress.js";
|
|
5
6
|
import { acceptCarrierSessionV3, createAdmissionReasonRegistryV3, } from "../v3/serverAdmission.js";
|
|
6
7
|
import { nodeSessionRuntimeV3 } from "../v3/nodeSessionRuntime.js";
|
|
7
8
|
import { AdmissionStatusV3 } from "../v3/artifact.js";
|
|
@@ -95,7 +96,7 @@ async function admit(state, carrier, ingress, providers) {
|
|
|
95
96
|
let handlers, authorizationKey;
|
|
96
97
|
const authorize = async (request, signal) => {
|
|
97
98
|
const selected = request.request.candidates.find(entry => entry.id === request.request.chosen_candidate_id);
|
|
98
|
-
if (selected
|
|
99
|
+
if (!matchesIngress(selected, ingress))
|
|
99
100
|
throw new Error("authorized candidate does not match the bound listener");
|
|
100
101
|
const authorizationRequest = runtimeAuthorizationRequestV3FromDecoded(request);
|
|
101
102
|
signal?.throwIfAborted();
|
|
@@ -167,9 +168,12 @@ export async function createAcceptorV3(options) {
|
|
|
167
168
|
let rawDriver;
|
|
168
169
|
try {
|
|
169
170
|
for (const listener of options.listeners) {
|
|
171
|
+
const leaf = new X509Certificate(listener.tls.certificate);
|
|
170
172
|
const running = listener.carrier === "websocket"
|
|
171
173
|
? await startNodeWebSocketListenerV3({
|
|
172
174
|
...listener,
|
|
175
|
+
maxPendingSessions: Math.min(options.maxPendingSessions ?? 1024, 1024),
|
|
176
|
+
...(options.admissionTimeoutMs === undefined ? {} : { pendingSessionTimeoutMs: options.admissionTimeoutMs }),
|
|
173
177
|
inboundBidirectionalStreamCapacity: options.maxInboundStreams + 2,
|
|
174
178
|
})
|
|
175
179
|
: listener.carrier === "webtransport" ? await startNodeWebTransportListener({ ...listener, inboundBidirectionalStreamCapacity: options.maxInboundStreams + 2 })
|
|
@@ -178,7 +182,7 @@ export async function createAcceptorV3(options) {
|
|
|
178
182
|
inboundBidirectionalStreamCapacity: options.maxInboundStreams + 2,
|
|
179
183
|
});
|
|
180
184
|
listeners.push(running);
|
|
181
|
-
ingress.push(boundIngressURL("direct", listener.carrier, running.address(), listener.publicURL));
|
|
185
|
+
ingress.push({ url: boundIngressURL("direct", listener.carrier, running.address(), listener.publicURL), leaf });
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
catch (error) {
|
|
@@ -57,10 +57,8 @@ class ConnectionPathAgent extends Agent {
|
|
|
57
57
|
#timeout;
|
|
58
58
|
#lifetime = new AbortController();
|
|
59
59
|
#requests = [];
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
// next request once its predecessor has an assigned socket, so native pool
|
|
63
|
-
// limits include every in-flight route without constructing TLS prematurely.
|
|
60
|
+
#routes = new Map();
|
|
61
|
+
#openingCount = 0;
|
|
64
62
|
addRequest(request, options) {
|
|
65
63
|
if (this.#lifetime.signal.aborted || this.#options.signal?.aborted) {
|
|
66
64
|
rejectUnassignedRequest(request, new Error("Connection path canceled"));
|
|
@@ -70,39 +68,31 @@ class ConnectionPathAgent extends Agent {
|
|
|
70
68
|
this.#drain();
|
|
71
69
|
}
|
|
72
70
|
#drain() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
queueMicrotask(() => this.#drain());
|
|
94
|
-
};
|
|
95
|
-
request.once("socket", advance);
|
|
96
|
-
request.once("close", advance);
|
|
97
|
-
request.once("error", advance);
|
|
98
|
-
try {
|
|
99
|
-
nativeAddRequest.call(this, request, options);
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
rejectUnassignedRequest(request, error instanceof Error ? error : new Error("Connection path failed"));
|
|
103
|
-
advance();
|
|
71
|
+
for (let index = 0; index < this.#requests.length;) {
|
|
72
|
+
const { request, options } = this.#requests[index];
|
|
73
|
+
const origin = this.#origin(options);
|
|
74
|
+
if (!request.destroyed && this.#openingCount > 0 &&
|
|
75
|
+
(this.totalSocketCount + this.#openingCount >= this.maxTotalSockets ||
|
|
76
|
+
(this.#routes.get(origin) ?? 0) >= this.maxSockets)) {
|
|
77
|
+
index++;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
this.#requests.splice(index, 1);
|
|
81
|
+
if (request.destroyed)
|
|
82
|
+
rejectUnassignedRequest(request, new Error("Connection path canceled"));
|
|
83
|
+
else {
|
|
84
|
+
try {
|
|
85
|
+
nativeAddRequest.call(this, request, options);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
rejectUnassignedRequest(request, error instanceof Error ? error : new Error("Connection path failed"));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
104
91
|
}
|
|
105
92
|
}
|
|
93
|
+
#origin(options) {
|
|
94
|
+
return JSON.stringify([options.host ?? options.servername, Number(options.port ?? 443)]);
|
|
95
|
+
}
|
|
106
96
|
constructor(options, timeout) {
|
|
107
97
|
super({ keepAlive: true, maxCachedSessions: 0 });
|
|
108
98
|
this.#options = options;
|
|
@@ -111,7 +101,29 @@ class ConnectionPathAgent extends Agent {
|
|
|
111
101
|
createConnection(options, callback) {
|
|
112
102
|
if (callback === undefined)
|
|
113
103
|
throw new Error("Connection path Agent requires an asynchronous callback");
|
|
114
|
-
const
|
|
104
|
+
const origin = this.#origin(options);
|
|
105
|
+
this.#routes.set(origin, (this.#routes.get(origin) ?? 0) + 1);
|
|
106
|
+
this.#openingCount++;
|
|
107
|
+
const release = () => {
|
|
108
|
+
const remaining = this.#routes.get(origin) - 1;
|
|
109
|
+
if (remaining === 0)
|
|
110
|
+
this.#routes.delete(origin);
|
|
111
|
+
else
|
|
112
|
+
this.#routes.set(origin, remaining);
|
|
113
|
+
if (this.#requests.length)
|
|
114
|
+
queueMicrotask(() => this.#drain());
|
|
115
|
+
};
|
|
116
|
+
const complete = (error, socket) => {
|
|
117
|
+
if (error)
|
|
118
|
+
release();
|
|
119
|
+
else
|
|
120
|
+
socket.once("close", release);
|
|
121
|
+
this.#openingCount--;
|
|
122
|
+
callback(error, socket);
|
|
123
|
+
if (this.#requests.length)
|
|
124
|
+
queueMicrotask(() => this.#drain());
|
|
125
|
+
};
|
|
126
|
+
const fail = (error) => complete(error, undefined);
|
|
115
127
|
const hostname = options.host ?? options.servername;
|
|
116
128
|
const port = Number(options.port ?? 443);
|
|
117
129
|
if (typeof hostname !== "string" || hostname === "" || !Number.isSafeInteger(port) || port < 1 || port > 65535) {
|
|
@@ -155,7 +167,7 @@ class ConnectionPathAgent extends Agent {
|
|
|
155
167
|
signal.addEventListener("abort", abort, { once: true });
|
|
156
168
|
socket.once("secureConnect", () => { clearTimeout(timer); signal.removeEventListener("abort", abort); });
|
|
157
169
|
socket.once("close", () => { clearTimeout(timer); signal.removeEventListener("abort", abort); transport.destroy(); });
|
|
158
|
-
|
|
170
|
+
complete(null, socket);
|
|
159
171
|
}, () => { clearTimeout(timer); fail(new Error("Connection path failed")); });
|
|
160
172
|
// Node's asynchronous Agent factory reports exclusively via callback.
|
|
161
173
|
return undefined;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type { X509Certificate } from "node:crypto";
|
|
2
|
+
import { type CanonicalArtifactCandidateV3 } from "../v3/artifact.js";
|
|
3
|
+
export type BoundIngress = Readonly<{
|
|
4
|
+
url: string;
|
|
5
|
+
leaf: X509Certificate;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function matchesIngress(candidate: CanonicalArtifactCandidateV3 | undefined, ingress: BoundIngress, now?: number): boolean;
|
|
1
8
|
/** A trusted deployment may map a forwarded public URL to one physical listener. */
|
|
2
9
|
export declare function boundIngressURL(path: "direct" | "tunnel", carrier: "websocket" | "raw_quic" | "webtransport", address: Readonly<{
|
|
3
10
|
host: string;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
import { isIP } from "node:net";
|
|
1
2
|
import { normalizeCandidateURL } from "../v3/artifact.js";
|
|
3
|
+
import { snapshotTransportSecurityPolicyV3 } from "../v3/security.js";
|
|
4
|
+
import { verifyPinnedLeafCertificateV3 } from "../v3/nodeRuntime.js";
|
|
2
5
|
import { FLOWERSEC_V3_PATHS } from "../v3/transportConstants.js";
|
|
6
|
+
export function matchesIngress(candidate, ingress, now = Date.now()) {
|
|
7
|
+
if (candidate?.normalized_url !== ingress.url)
|
|
8
|
+
return false;
|
|
9
|
+
try {
|
|
10
|
+
const policy = snapshotTransportSecurityPolicyV3(candidate.tls, Math.floor(now / 1000), ["ca", "pin"]);
|
|
11
|
+
if (policy.mode === "pin") {
|
|
12
|
+
verifyPinnedLeafCertificateV3(ingress.leaf.raw, policy, now);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
const host = new URL(ingress.url).hostname.replace(/^\[|\]$/gu, "");
|
|
16
|
+
const leaf = ingress.leaf;
|
|
17
|
+
return now >= leaf.validFromDate.getTime() && now < leaf.validToDate.getTime() &&
|
|
18
|
+
(isIP(host) ? leaf.checkIP(host) : leaf.checkHost(host, { subject: "never", partialWildcards: false })) !== undefined;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
3
24
|
/** A trusted deployment may map a forwarded public URL to one physical listener. */
|
|
4
25
|
export function boundIngressURL(path, carrier, address, publicURL) {
|
|
5
26
|
if (publicURL !== undefined)
|
|
@@ -13,6 +13,7 @@ export type ProxyServerOptions = Readonly<{
|
|
|
13
13
|
maxJsonFrameBytes?: number;
|
|
14
14
|
maxChunkBytes?: number;
|
|
15
15
|
maxBodyBytes?: number;
|
|
16
|
+
maxBufferedRequestBodyBytes?: number;
|
|
16
17
|
maxWebSocketFrameBytes?: number;
|
|
17
18
|
defaultHTTPRequestTimeoutMs?: number;
|
|
18
19
|
maxHTTPRequestTimeoutMs?: number;
|