@floegence/flowersec-core 7.0.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 +6 -5
- package/THIRD_PARTY_NOTICES.md +8 -8
- package/dist/node/acceptorV3.js +9 -4
- package/dist/node/connectSessionV3.d.ts +2 -2
- package/dist/node/connectSessionV3.js +9 -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/nativeTransportAddon.d.ts +1 -5
- package/dist/node/nativeTransportAddon.js +3 -5
- 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.d.ts +3 -1
- package/dist/node/rawQuicServerV3.js +18 -3
- package/dist/node/tunnelRuntimeV3.js +42 -8
- package/dist/node/webSocketServerV3.js +27 -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/vendor/tr46.js +17 -23
- 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 +12 -12
- package/sbom/cyclonedx.json +43 -43
- package/sbom/spdx.json +49 -49
package/README.md
CHANGED
|
@@ -92,16 +92,17 @@ WSS, raw QUIC, and WebTransport for clients, direct listeners, and
|
|
|
92
92
|
opaque tunnel listeners. Raw QUIC and WebTransport require the Flowersec native
|
|
93
93
|
package for macOS or glibc Linux on arm64/x64. Node does not issue artifacts.
|
|
94
94
|
|
|
95
|
-
For WebTransport, pass `
|
|
95
|
+
For WebTransport, pass `webTransport: true`
|
|
96
96
|
and a canonical HTTP(S) `origin` to `connect` or `createConnectionController`.
|
|
97
|
-
Use `carrier: "webtransport"
|
|
97
|
+
Use `carrier: "webtransport"` and a nonempty
|
|
98
98
|
`allowedOrigins` list on the corresponding listener. An absent Origin is
|
|
99
99
|
rejected. With a wildcard bind address, supply the public HTTPS URL with the
|
|
100
100
|
same port and the exact `/flowersec/webtransport/v5/direct` or
|
|
101
|
-
`/flowersec/webtransport/v5/tunnel` path.
|
|
102
|
-
|
|
101
|
+
`/flowersec/webtransport/v5/tunnel` path. Node speaks draft02. Configure an
|
|
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,19 +3,19 @@
|
|
|
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)
|
|
14
14
|
- @types/node 26.4.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@types/node/-/node-26.4.0.tgz)
|
|
15
15
|
- punycode 2.3.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz)
|
|
16
|
-
- tr46
|
|
16
|
+
- tr46 7.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz)
|
|
17
17
|
- undici-types 8.3.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz)
|
|
18
|
-
- ws 8.
|
|
18
|
+
- ws 8.22.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/ws/-/ws-8.22.0.tgz)
|
|
19
19
|
## Distributed Dependency License Materials
|
|
20
20
|
|
|
21
21
|
The following dependencies are incorporated into distributed Flowersec files or binaries.
|
|
@@ -46,7 +46,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
46
46
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
47
47
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
48
48
|
|
|
49
|
-
### tr46
|
|
49
|
+
### tr46 7.0.0
|
|
50
50
|
|
|
51
51
|
#### Reviewed bundled license text
|
|
52
52
|
|
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";
|
|
@@ -9,7 +10,7 @@ import { unwrapArtifactHandleV3, } from "../v3/publicApi.js";
|
|
|
9
10
|
import { SessionHandlersV3, createRPCRouter, freezeSessionHandlersV3, } from "./acceptor.js";
|
|
10
11
|
import { serveFrozenStreamHandlers } from "../public/streamHandlers.js";
|
|
11
12
|
import { createNativeRawQuicDriver, loadNativeTransportAddon, } from "./nativeTransportAddon.js";
|
|
12
|
-
import { startNodeRawQuicListenerV3, startNodeWebTransportListener, } from "./rawQuicServerV3.js";
|
|
13
|
+
import { startNodeRawQuicListenerV3, startNodeWebTransportListener, validateWebTransportListeners, } from "./rawQuicServerV3.js";
|
|
13
14
|
import { startNodeWebSocketListenerV3, } from "./webSocketServerV3.js";
|
|
14
15
|
import { runtimeAuthorizationRequestV3FromDecoded, } from "./runtimeAuthorizationV3.js";
|
|
15
16
|
const DEFAULT_ADMISSION_TIMEOUT_MS = 10_000;
|
|
@@ -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) {
|
|
@@ -272,6 +276,7 @@ async function listen(state, listener, ingress) {
|
|
|
272
276
|
}
|
|
273
277
|
}
|
|
274
278
|
function validateOptions(options) {
|
|
279
|
+
validateWebTransportListeners(options.listeners);
|
|
275
280
|
if (options.listeners.length === 0 ||
|
|
276
281
|
(options.maxPendingSessions !== undefined && (!Number.isSafeInteger(options.maxPendingSessions) || options.maxPendingSessions < 1 || options.maxPendingSessions > 65536)) ||
|
|
277
282
|
!Number.isSafeInteger(options.maxInboundStreams) || options.maxInboundStreams < 1 ||
|
|
@@ -5,7 +5,7 @@ import { type ArtifactSourceV3, type ConnectionControllerV3 } from "../v3/connec
|
|
|
5
5
|
import { RPCHandlers, type SessionHandlerBinding } from "./acceptor.js";
|
|
6
6
|
export type NodeTLSRootsV3 = string | Uint8Array | readonly (string | Uint8Array)[];
|
|
7
7
|
export type SessionOptionsV3 = Readonly<{
|
|
8
|
-
|
|
8
|
+
webTransport?: boolean;
|
|
9
9
|
origin?: string;
|
|
10
10
|
roots?: NodeTLSRootsV3;
|
|
11
11
|
connectionPath?: NodeConnectionPath;
|
|
@@ -18,7 +18,7 @@ export type SessionOptionsV3 = Readonly<{
|
|
|
18
18
|
tunnelIngressURL?: string;
|
|
19
19
|
}>;
|
|
20
20
|
export type ConnectionControllerOptionsV3 = Readonly<{
|
|
21
|
-
|
|
21
|
+
webTransport?: boolean;
|
|
22
22
|
origin?: string;
|
|
23
23
|
roots?: NodeTLSRootsV3;
|
|
24
24
|
connectionPath?: NodeConnectionPath;
|
|
@@ -11,9 +11,11 @@ import { createNativeRawQuicDriver, createNativeWebTransportDriver, tryLoadNativ
|
|
|
11
11
|
import { createNodeRawQuicClientV3 } from "./rawQuicAdapterV3.js";
|
|
12
12
|
import { createRPCRouter, freezeRPCHandlers, RPCHandlers, } from "./acceptor.js";
|
|
13
13
|
export async function connectV3(lease, options) {
|
|
14
|
+
validateWebTransportOptIn(options);
|
|
14
15
|
return await connectArtifactLeaseWithRuntimeV3(lease, options, () => nodeRuntime(options));
|
|
15
16
|
}
|
|
16
17
|
export function createConnectionControllerV3(source, options) {
|
|
18
|
+
validateWebTransportOptIn(options);
|
|
17
19
|
if (options.rpcHandlers !== undefined && !(options.rpcHandlers instanceof RPCHandlers)) {
|
|
18
20
|
throw new ConnectErrorV3("artifact_invalid", { kind: "terminal" });
|
|
19
21
|
}
|
|
@@ -26,6 +28,12 @@ export function createConnectionControllerV3(source, options) {
|
|
|
26
28
|
};
|
|
27
29
|
return createCoreControllerV3(source, async (context) => await attemptClaimedArtifactLeaseV3(context, runtime), coreOptions);
|
|
28
30
|
}
|
|
31
|
+
function validateWebTransportOptIn(options) {
|
|
32
|
+
if ("webTransportProfile" in options)
|
|
33
|
+
throw new TypeError("webTransportProfile was removed; use webTransport: true for draft02, or use a raw_quic candidate for Go-initiated connections");
|
|
34
|
+
if (options.webTransport !== undefined && typeof options.webTransport !== "boolean")
|
|
35
|
+
throw new TypeError("webTransport must be a boolean");
|
|
36
|
+
}
|
|
29
37
|
function nodeRuntime(options) {
|
|
30
38
|
const connectTimeoutMilliseconds = options.connectTimeoutMs ?? SDK_DEFAULTS.transport.connectTimeoutMs;
|
|
31
39
|
if (!Number.isSafeInteger(connectTimeoutMilliseconds) || connectTimeoutMilliseconds < 1) {
|
|
@@ -36,9 +44,7 @@ function nodeRuntime(options) {
|
|
|
36
44
|
}
|
|
37
45
|
const addon = options.connectionPath === undefined ? tryLoadNativeTransportAddon() : undefined;
|
|
38
46
|
const rawQuic = addon === undefined ? undefined : createNativeRawQuicDriver(addon);
|
|
39
|
-
|
|
40
|
-
throw new ConnectErrorV3("artifact_invalid", { kind: "terminal" });
|
|
41
|
-
const webTransport = addon !== undefined && options.webTransportProfile !== undefined ? createNativeWebTransportDriver(addon, options.webTransportProfile) : undefined;
|
|
47
|
+
const webTransport = addon !== undefined && options.webTransport === true ? createNativeWebTransportDriver(addon) : undefined;
|
|
42
48
|
const capability = detectNodeRuntimeCapabilityV3(rawQuic !== undefined, options.origin !== undefined, webTransport !== undefined);
|
|
43
49
|
let rpcSnapshot;
|
|
44
50
|
try {
|
|
@@ -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)
|
|
@@ -43,16 +43,13 @@ export type NativeRawQuicDriver = Readonly<{
|
|
|
43
43
|
}>): Promise<NativeCarrierSessionV3>;
|
|
44
44
|
bindRawQuic(options: NativeRawQuicBindOptions): Promise<NativeRawQuicListener>;
|
|
45
45
|
}>;
|
|
46
|
-
type WebTransportProfile = "draft02" | "native_h3";
|
|
47
46
|
export type NativeWebTransportConnectOptions = NativeRawQuicConnectOptions & Readonly<{
|
|
48
47
|
url: string;
|
|
49
48
|
origin: string;
|
|
50
|
-
profile?: WebTransportProfile;
|
|
51
49
|
}>;
|
|
52
50
|
export type NativeWebTransportBindOptions = NativeRawQuicBindOptions & Readonly<{
|
|
53
51
|
authorityHost: string;
|
|
54
52
|
allowedOrigins: readonly string[];
|
|
55
|
-
profile?: WebTransportProfile;
|
|
56
53
|
}>;
|
|
57
54
|
type NativeOperation<T> = Readonly<{
|
|
58
55
|
result(): Promise<T>;
|
|
@@ -102,7 +99,6 @@ type NativeRawQuicListenerBinding = Readonly<{
|
|
|
102
99
|
}>;
|
|
103
100
|
export type NativeTransportAddonBinding = Readonly<{
|
|
104
101
|
contractVersion(): number;
|
|
105
|
-
supportsNativeH3?(): boolean;
|
|
106
102
|
connectRawQuic(options: NativeRawQuicConnectOptions): NativeOperation<NativeRawQuicSessionBinding>;
|
|
107
103
|
bindRawQuic(options: NativeRawQuicBindOptions): Promise<NativeRawQuicListenerBinding>;
|
|
108
104
|
connectWebTransport?(options: NativeWebTransportConnectOptions): NativeOperation<NativeRawQuicSessionBinding>;
|
|
@@ -117,7 +113,7 @@ type RequireFunction = (specifier: string) => unknown;
|
|
|
117
113
|
export declare function loadNativeTransportAddon(requireFunction?: RequireFunction): NativeTransportAddonBinding;
|
|
118
114
|
export declare function tryLoadNativeTransportAddon(requireFunction?: RequireFunction): NativeTransportAddonBinding | undefined;
|
|
119
115
|
export declare function createNativeRawQuicDriver(addon?: NativeTransportAddonBinding): NativeRawQuicDriver;
|
|
120
|
-
export declare function createNativeWebTransportDriver(addon: NativeTransportAddonBinding
|
|
116
|
+
export declare function createNativeWebTransportDriver(addon: NativeTransportAddonBinding): Readonly<{
|
|
121
117
|
connect(options: NativeWebTransportConnectOptions, signal?: AbortSignal): Promise<Readonly<{
|
|
122
118
|
kind: "webtransport" | "raw_quic";
|
|
123
119
|
path: PathKind;
|
|
@@ -76,18 +76,16 @@ function isNativeTransportAddon(value) {
|
|
|
76
76
|
typeof candidate.connectRawQuic === "function" &&
|
|
77
77
|
typeof candidate.bindRawQuic === "function";
|
|
78
78
|
}
|
|
79
|
-
export function createNativeWebTransportDriver(addon
|
|
79
|
+
export function createNativeWebTransportDriver(addon) {
|
|
80
80
|
const { connectWebTransport, bindWebTransport } = addon;
|
|
81
81
|
if (typeof connectWebTransport !== "function" || typeof bindWebTransport !== "function")
|
|
82
82
|
return undefined;
|
|
83
|
-
if (profile === "native_h3" && addon.supportsNativeH3?.() !== true)
|
|
84
|
-
return undefined;
|
|
85
83
|
return Object.freeze({
|
|
86
84
|
async connect(options, signal) {
|
|
87
|
-
return wrapSession(await settle(connectWebTransport(
|
|
85
|
+
return wrapSession(await settle(connectWebTransport(options), signal, value => value.abort()), "webtransport", options.path);
|
|
88
86
|
},
|
|
89
87
|
async bind(options) {
|
|
90
|
-
const native = await bindWebTransport(
|
|
88
|
+
const native = await bindWebTransport(options);
|
|
91
89
|
return Object.freeze({ address: () => native.address(), close: () => native.close(),
|
|
92
90
|
accept: async (operation = {}) => wrapSession(await settle(native.accept(), operation.signal, value => value.abort()), "webtransport", options.path) });
|
|
93
91
|
},
|
|
@@ -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;
|