@floegence/flowersec-core 0.27.0 → 2.0.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 +91 -22
- package/THIRD_PARTY_NOTICES.md +141 -0
- package/dist/browser/connectSession.d.ts +13 -0
- package/dist/browser/connectSession.js +40 -0
- package/dist/browser/index.d.ts +3 -10
- package/dist/browser/index.js +2 -5
- package/dist/browser/runtimeCapability.d.ts +13 -0
- package/dist/browser/runtimeCapability.js +27 -0
- package/dist/browser/sessionRuntime.d.ts +2 -0
- package/dist/browser/sessionRuntime.js +21 -0
- package/dist/browser/webTransportClient.d.ts +8 -0
- package/dist/browser/webTransportClient.js +55 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +126 -0
- package/dist/cliSpendMarker.d.ts +1 -0
- package/dist/cliSpendMarker.js +22 -0
- package/dist/connectionController.d.ts +54 -0
- package/dist/connectionController.js +438 -0
- package/dist/connector/adapters/webSocketCandidate.d.ts +7 -0
- package/dist/connector/adapters/webSocketCandidate.js +116 -0
- package/dist/connector/adapters/webTransportCandidate.d.ts +5 -0
- package/dist/connector/adapters/webTransportCandidate.js +73 -0
- package/dist/connector/admissionCommit.d.ts +31 -0
- package/dist/connector/admissionCommit.js +239 -0
- package/dist/connector/sessionAcceptor.d.ts +16 -0
- package/dist/connector/sessionAcceptor.js +114 -0
- package/dist/connector/sessionConfig.d.ts +3 -0
- package/dist/connector/sessionConfig.js +30 -0
- package/dist/connector/sessionConnector.d.ts +45 -0
- package/dist/connector/sessionConnector.js +603 -0
- package/dist/defaults.d.ts +7 -7
- package/dist/defaults.js +7 -7
- package/dist/facade.d.ts +12 -27
- package/dist/facade.js +6 -24
- package/dist/node/connectSession.d.ts +21 -0
- package/dist/node/connectSession.js +62 -0
- package/dist/node/index.d.ts +3 -11
- package/dist/node/index.js +2 -8
- package/dist/node/runtimeCapability.d.ts +7 -0
- package/dist/node/runtimeCapability.js +10 -0
- package/dist/node/sessionRuntime.d.ts +2 -0
- package/dist/node/sessionRuntime.js +13 -0
- package/dist/node/webTransportClient.d.ts +9 -0
- package/dist/node/webTransportClient.js +56 -0
- package/dist/node/webTransportServer.d.ts +22 -0
- package/dist/node/webTransportServer.js +100 -0
- package/dist/node/wsFactory.d.ts +3 -1
- package/dist/node/wsFactory.js +4 -3
- package/dist/proxy/controllerGuard.d.ts +4 -4
- package/dist/proxy/controllerGuard.js +83 -177
- package/dist/proxy/disableUpstreamServiceWorkerRegister.d.ts +3 -1
- package/dist/proxy/disableUpstreamServiceWorkerRegister.js +19 -17
- package/dist/proxy/index.d.ts +16 -15
- package/dist/proxy/index.js +8 -14
- package/dist/proxy/integration.d.ts +23 -71
- package/dist/proxy/integration.js +37 -340
- package/dist/proxy/registerServiceWorker.d.ts +1 -10
- package/dist/proxy/registerServiceWorker.js +43 -105
- package/dist/proxy/runtime.d.ts +3 -63
- package/dist/proxy/runtime.js +349 -462
- package/dist/proxy/scope.d.ts +6 -0
- package/dist/proxy/scope.js +131 -0
- package/dist/proxy/serviceWorker.d.ts +5 -16
- package/dist/proxy/serviceWorker.js +230 -617
- package/dist/proxy/stream.d.ts +9 -0
- package/dist/proxy/stream.js +40 -0
- package/dist/proxy/types.d.ts +78 -30
- package/dist/proxy/windowBridge.d.ts +61 -0
- package/dist/proxy/windowBridge.js +344 -0
- package/dist/proxy/wsPatch.d.ts +4 -14
- package/dist/proxy/wsPatch.js +173 -268
- package/dist/public/artifact.d.ts +11 -0
- package/dist/public/artifact.js +44 -0
- package/dist/public/artifactLease.d.ts +10 -0
- package/dist/public/artifactLease.js +48 -0
- package/dist/public/connectError.d.ts +6 -0
- package/dist/public/connectError.js +9 -0
- package/dist/public/contract.d.ts +83 -0
- package/dist/public/contract.js +17 -0
- package/dist/public/streamMetadata.d.ts +10 -0
- package/dist/public/streamMetadata.js +40 -0
- package/dist/rpc/caller.d.ts +1 -1
- package/dist/rpc/client.d.ts +1 -4
- package/dist/rpc/client.js +0 -21
- package/dist/rpc/rpcProxy.d.ts +1 -1
- package/dist/rpc/server.d.ts +1 -1
- package/dist/rpc/validate.d.ts +1 -1
- package/dist/rpc/wire.d.ts +15 -0
- package/dist/runtime/errors.d.ts +6 -0
- package/dist/runtime/errors.js +10 -0
- package/dist/transport/webSocketAdapter.d.ts +24 -0
- package/dist/transport/webSocketAdapter.js +234 -0
- package/dist/transport/webTransportAdapter.d.ts +27 -0
- package/dist/transport/webTransportAdapter.js +519 -0
- package/dist/utils/errors.d.ts +2 -20
- package/dist/utils/errors.js +73 -20
- package/dist/v2/admissionError.d.ts +4 -0
- package/dist/v2/admissionError.js +8 -0
- package/dist/v2/artifact.d.ts +128 -0
- package/dist/v2/artifact.js +1126 -0
- package/dist/v2/artifactLease.d.ts +1 -0
- package/dist/v2/artifactLease.js +7 -0
- package/dist/v2/capability.d.ts +29 -0
- package/dist/v2/capability.js +190 -0
- package/dist/v2/carrier.d.ts +79 -0
- package/dist/v2/carrier.js +405 -0
- package/dist/v2/contract.d.ts +37 -0
- package/dist/v2/contract.js +1 -0
- package/dist/v2/handshake.d.ts +80 -0
- package/dist/v2/handshake.js +470 -0
- package/dist/v2/opaqueArtifact.d.ts +1 -0
- package/dist/v2/opaqueArtifact.js +2 -0
- package/dist/v2/protocol.d.ts +99 -0
- package/dist/v2/protocol.js +739 -0
- package/dist/v2/publicSession.d.ts +1 -0
- package/dist/v2/publicSession.js +179 -0
- package/dist/v2/retryDisposition.d.ts +16 -0
- package/dist/v2/retryDisposition.js +30 -0
- package/dist/v2/session.d.ts +277 -0
- package/dist/v2/session.js +1879 -0
- package/dist/v2/streamLifetimeLedger.d.ts +31 -0
- package/dist/v2/streamLifetimeLedger.js +131 -0
- package/dist/v2/streamMetadata.d.ts +1 -0
- package/dist/v2/streamMetadata.js +7 -0
- package/dist/v2/unreliableMessage.d.ts +43 -0
- package/dist/v2/unreliableMessage.js +252 -0
- package/dist/vendor/tr46.d.ts +10 -0
- package/dist/vendor/tr46.js +501 -0
- package/dist/ws-client/binaryTransport.d.ts +0 -3
- package/dist/ws-client/binaryTransport.js +15 -39
- package/dist/yamux/errors.d.ts +0 -4
- package/dist/yamux/errors.js +0 -9
- package/dist/yamux/session.d.ts +0 -5
- package/dist/yamux/session.js +4 -70
- package/dist/yamux/stream.d.ts +1 -0
- package/dist/yamux/stream.js +4 -0
- package/package.json +29 -81
- package/sbom/cyclonedx.json +2764 -0
- package/sbom/spdx.json +1947 -0
- package/YAMUX_ALIGNMENT.md +0 -127
- package/dist/_examples/flowersec/demo/v1.facade.gen.d.ts +0 -12
- package/dist/_examples/flowersec/demo/v1.facade.gen.js +0 -15
- package/dist/_examples/flowersec/demo/v1.gen.d.ts +0 -16
- package/dist/_examples/flowersec/demo/v1.gen.js +0 -86
- package/dist/_examples/flowersec/demo/v1.rpc.gen.d.ts +0 -11
- package/dist/_examples/flowersec/demo/v1.rpc.gen.js +0 -22
- package/dist/browser/connect.d.ts +0 -13
- package/dist/browser/connect.js +0 -31
- package/dist/browser/reconnectConfig.d.ts +0 -15
- package/dist/browser/reconnectConfig.js +0 -20
- package/dist/client-connect/common.d.ts +0 -26
- package/dist/client-connect/common.js +0 -167
- package/dist/client-connect/connectCore.d.ts +0 -61
- package/dist/client-connect/connectCore.js +0 -572
- package/dist/client-connect/contract.d.ts +0 -8
- package/dist/client-connect/contract.js +0 -51
- package/dist/client-connect/termination.d.ts +0 -6
- package/dist/client-connect/termination.js +0 -7
- package/dist/client-connect/transportSecurity.d.ts +0 -27
- package/dist/client-connect/transportSecurity.js +0 -199
- package/dist/client-connect/tunnelAttachCloseReason.d.ts +0 -3
- package/dist/client-connect/tunnelAttachCloseReason.js +0 -23
- package/dist/client.d.ts +0 -23
- package/dist/connect/artifact.d.ts +0 -36
- package/dist/connect/artifact.js +0 -213
- package/dist/connect/resolveArtifact.d.ts +0 -22
- package/dist/connect/resolveArtifact.js +0 -87
- package/dist/controlplane/channelInit.d.ts +0 -27
- package/dist/controlplane/channelInit.js +0 -116
- package/dist/controlplane/http.d.ts +0 -16
- package/dist/controlplane/http.js +0 -59
- package/dist/controlplane/index.d.ts +0 -6
- package/dist/controlplane/index.js +0 -5
- package/dist/controlplane/issuer.d.ts +0 -18
- package/dist/controlplane/issuer.js +0 -113
- package/dist/controlplane/request.d.ts +0 -51
- package/dist/controlplane/request.js +0 -273
- package/dist/controlplane/token.d.ts +0 -33
- package/dist/controlplane/token.js +0 -119
- package/dist/direct-client/connect.d.ts +0 -9
- package/dist/direct-client/connect.js +0 -90
- package/dist/direct-client/index.d.ts +0 -1
- package/dist/direct-client/index.js +0 -1
- package/dist/e2ee/constants.d.ts +0 -9
- package/dist/e2ee/constants.js +0 -18
- package/dist/e2ee/errors.d.ts +0 -5
- package/dist/e2ee/errors.js +0 -8
- package/dist/e2ee/framing.d.ts +0 -12
- package/dist/e2ee/framing.js +0 -57
- package/dist/e2ee/handshake.d.ts +0 -88
- package/dist/e2ee/handshake.js +0 -353
- package/dist/e2ee/index.d.ts +0 -7
- package/dist/e2ee/index.js +0 -7
- package/dist/e2ee/kdf.d.ts +0 -15
- package/dist/e2ee/kdf.js +0 -39
- package/dist/e2ee/record.d.ts +0 -11
- package/dist/e2ee/record.js +0 -80
- package/dist/e2ee/secureChannel.d.ts +0 -93
- package/dist/e2ee/secureChannel.js +0 -342
- package/dist/e2ee/transcript.d.ts +0 -23
- package/dist/e2ee/transcript.js +0 -31
- package/dist/endpoint/index.d.ts +0 -84
- package/dist/endpoint/index.js +0 -557
- package/dist/endpoint/node.d.ts +0 -9
- package/dist/endpoint/node.js +0 -51
- package/dist/gen/flowersec/controlplane/v1.gen.d.ts +0 -36
- package/dist/gen/flowersec/controlplane/v1.gen.js +0 -135
- package/dist/gen/flowersec/direct/v1.gen.d.ts +0 -21
- package/dist/gen/flowersec/direct/v1.gen.js +0 -101
- package/dist/gen/flowersec/e2ee/v1.gen.d.ts +0 -68
- package/dist/gen/flowersec/e2ee/v1.gen.js +0 -194
- package/dist/gen/flowersec/rpc/v1.gen.d.ts +0 -30
- package/dist/gen/flowersec/rpc/v1.gen.js +0 -107
- package/dist/gen/flowersec/tunnel/v1.gen.d.ts +0 -23
- package/dist/gen/flowersec/tunnel/v1.gen.js +0 -104
- package/dist/index.d.ts +0 -22
- package/dist/index.js +0 -22
- package/dist/node/connect.d.ts +0 -10
- package/dist/node/connect.js +0 -29
- package/dist/node/reconnectConfig.d.ts +0 -16
- package/dist/node/reconnectConfig.js +0 -20
- package/dist/observability/index.d.ts +0 -1
- package/dist/observability/index.js +0 -1
- package/dist/observability/observer.d.ts +0 -52
- package/dist/observability/observer.js +0 -314
- package/dist/proxy/appWindow.d.ts +0 -37
- package/dist/proxy/appWindow.js +0 -273
- package/dist/proxy/bootstrap.d.ts +0 -35
- package/dist/proxy/bootstrap.js +0 -119
- package/dist/proxy/constants.d.ts +0 -7
- package/dist/proxy/constants.js +0 -8
- package/dist/proxy/controllerWindow.d.ts +0 -12
- package/dist/proxy/controllerWindow.js +0 -384
- package/dist/proxy/cookieJar.d.ts +0 -7
- package/dist/proxy/cookieJar.js +0 -136
- package/dist/proxy/headerPolicy.d.ts +0 -14
- package/dist/proxy/headerPolicy.js +0 -134
- package/dist/proxy/portStream.d.ts +0 -5
- package/dist/proxy/portStream.js +0 -256
- package/dist/proxy/preset.d.ts +0 -29
- package/dist/proxy/preset.js +0 -111
- package/dist/proxy/runtimeScope.d.ts +0 -57
- package/dist/proxy/runtimeScope.js +0 -218
- package/dist/proxy/server.d.ts +0 -28
- package/dist/proxy/server.js +0 -833
- package/dist/proxy/windowBridgeProtocol.d.ts +0 -65
- package/dist/proxy/windowBridgeProtocol.js +0 -11
- package/dist/reconnect/artifactControlplane.d.ts +0 -16
- package/dist/reconnect/artifactControlplane.js +0 -35
- package/dist/reconnect/index.d.ts +0 -36
- package/dist/reconnect/index.js +0 -388
- package/dist/rpc-proxy/index.d.ts +0 -1
- package/dist/rpc-proxy/index.js +0 -1
- package/dist/rpc-proxy/rpcProxy.d.ts +0 -1
- package/dist/rpc-proxy/rpcProxy.js +0 -1
- package/dist/streamhello/index.d.ts +0 -1
- package/dist/streamhello/index.js +0 -1
- package/dist/streamhello/streamHello.d.ts +0 -3
- package/dist/streamhello/streamHello.js +0 -13
- package/dist/streamio/index.d.ts +0 -32
- package/dist/streamio/index.js +0 -87
- package/dist/tunnel-client/connect.d.ts +0 -9
- package/dist/tunnel-client/connect.js +0 -147
- package/dist/tunnel-client/index.d.ts +0 -1
- package/dist/tunnel-client/index.js +0 -1
- package/dist/ws/index.d.ts +0 -1
- package/dist/ws/index.js +0 -1
- /package/dist/{client.js → rpc/wire.js} +0 -0
package/README.md
CHANGED
|
@@ -1,40 +1,109 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Flowersec for TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@floegence/flowersec-core` is the ESM-only Flowersec v2 SDK for browsers and Node.js. Its public package surface is limited to the root, `/browser`, `/node`, and `/proxy` entrypoints.
|
|
4
|
+
|
|
5
|
+
Flowersec 2.0.0 is the published coordinated TypeScript SDK release.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install @floegence/flowersec-core
|
|
10
|
+
npm install @floegence/flowersec-core@2.0.0
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Public API
|
|
14
|
+
|
|
15
|
+
- `@floegence/flowersec-core` exports the portable artifact, lease, session, stream, RPC, stream-metadata, and connection-controller API, plus profile-owned unreliable messages when negotiated.
|
|
16
|
+
- `@floegence/flowersec-core/browser` adds `connect(...)`, `createConnectionController(...)`, and their options.
|
|
17
|
+
- `@floegence/flowersec-core/node` adds `connect(...)`, `createConnectionController(...)`, and their options.
|
|
18
|
+
- `@floegence/flowersec-core/proxy` adds the `Session`-based HTTP/WebSocket runtime, Service Worker and controller/app-window bridges, strict `proxy.runtime@2` validation, and `connectProxyBrowser(...)` composition.
|
|
19
|
+
|
|
20
|
+
The root type exports are:
|
|
21
|
+
|
|
22
|
+
- Artifact lifecycle: `Artifact`, closed `ArtifactError` parse failures, and `ArtifactLease`.
|
|
23
|
+
- Sessions: `Session`, `SessionTermination`, `RpcPeer`, `RpcResult<Response>`, `ByteStream`, `IncomingStream`, `StreamMetadata`, `OperationOptions`, and `StreamOpenOptions`. Create metadata with `createStreamMetadata(...)`; invalid values throw `StreamMetadataError` before opening a stream.
|
|
24
|
+
- Unreliable messages: `UnreliableMessageChannel`, `UnreliableMessageSendOptions`, and `UnreliableMessageSendResult`.
|
|
25
|
+
- JSON values: `JsonPrimitive`, `JsonValue`, and `JsonObject`.
|
|
26
|
+
- Errors: `ConnectErrorCode`, `SessionErrorCode`, and structured `RetryDisposition`.
|
|
27
|
+
- Connection lifecycle: `ArtifactSource`, `ArtifactSourceResult`, `ConnectionController`, `ConnectionState`, `ConnectionSnapshot`, `ConnectionControllerFailure`, `ConnectionControllerError`, and `RetryDisposition`.
|
|
28
|
+
|
|
29
|
+
Retry ownership belongs to `ConnectionController`; applications do not classify error text or run a parallel retry scheduler. Public failures remain redacted and reveal no carrier, candidate, URL, credential, stage, key, or diagnostic details.
|
|
30
|
+
|
|
31
|
+
`RpcResult<Response>` is a discriminated union. `RpcPeer.call(...)` requires a decoder for successful payloads, so the typed success value has passed application validation before it is returned. Check `result.ok` before reading either the typed success `payload` or bounded application `error`; a result cannot contain both. RPC call and notify are portable across SDKs, while `RpcPeer.onNotify(...)` is a TypeScript-specific subscription convenience.
|
|
32
|
+
|
|
33
|
+
When connector options omit a connection timeout, browser and Node.js connectors use the shared ten-second default.
|
|
34
|
+
|
|
35
|
+
## Connection Lifecycle
|
|
36
|
+
|
|
37
|
+
The Browser and Node `connect(...)` operations are one-shot and never reconnect. Long-lived applications can create the runtime-specific `ConnectionController` with a refreshable `ArtifactSource`. Every attempt must return a fresh `ArtifactLease`; a one-time artifact or lease is not a controller source.
|
|
38
|
+
|
|
39
|
+
The controller has one scheduler and one in-flight attempt. Its states are `idle`, `connecting`, `connected`, `waiting`, `failed`, and `closed`; snapshots expose the current structured `retryDisposition` while waiting. Call `start()` once, observe immutable snapshots with `subscribe(...)`, await an established session with `waitForSession(...)`, and use `retryNow()` only to wake a `waiting` controller. `close()` cancels acquisition, connection, and waiting before closing the current session.
|
|
40
|
+
|
|
41
|
+
Source failures return a structured `terminal`, `retryable`, or `retry_after` disposition. Thrown or malformed source failures are terminal. Retry delay is deterministic exponential backoff from 250 ms, doubling to a 30-second maximum with no jitter; `retry_after` is never attempted before its specified Unix-millisecond boundary. Attempts are unlimited unless `maximumAttempts` is explicitly set.
|
|
42
|
+
|
|
43
|
+
A newly established session replaces `currentSession` atomically. The controller never migrates or replays streams, RPC calls, or writes from a terminated session; callers start new application operations on the new session.
|
|
44
|
+
|
|
45
|
+
A negotiated `Session.unreliableMessages` channel sends defensively copied `Uint8Array` values and returns `accepted`, `dropped_expired`, `dropped_budget`, or `dropped_carrier`. `receive(...)` also returns a fresh `Uint8Array`. Invalid payloads, unavailable channels, cancellation, closure, and internal failures remain redacted public operation errors.
|
|
46
|
+
|
|
47
|
+
## Capability Layers
|
|
48
|
+
|
|
49
|
+
The portable core is the same application model used by every Flowersec SDK:
|
|
50
|
+
opaque artifact parsing, a durable single-use lease, one-shot connection,
|
|
51
|
+
carrier-neutral sessions, RPC, reliable streams, redacted public errors, and
|
|
52
|
+
the optional single-owner `ConnectionController`. Callers should not compare
|
|
53
|
+
raw TypeScript error-code strings with other SDKs.
|
|
12
54
|
|
|
13
|
-
|
|
55
|
+
Only this portable core is required to align across languages. Complete SDK
|
|
56
|
+
profiles and language conveniences intentionally differ by runtime.
|
|
14
57
|
|
|
15
|
-
|
|
58
|
+
The TypeScript SDK profile is split by entrypoint: browsers own WebSocket and
|
|
59
|
+
WebTransport dialing, while Node.js owns WebSocket and WebTransport dialing through
|
|
60
|
+
the native `@fails-components/webtransport` adapter. Its language convenience
|
|
61
|
+
includes static generic RPC result typing, notification subscriptions, and
|
|
62
|
+
proxy composition. These conveniences do not expand the
|
|
63
|
+
portable core required from Go, Swift, or Rust.
|
|
16
64
|
|
|
17
|
-
##
|
|
65
|
+
## Opaque Boundaries
|
|
18
66
|
|
|
19
|
-
|
|
20
|
-
- Node.js client and endpoint transport: `@floegence/flowersec-core/node`
|
|
21
|
-
- Controlplane artifact helpers: `@floegence/flowersec-core/controlplane`
|
|
22
|
-
- Endpoint session serving: `@floegence/flowersec-core/endpoint`
|
|
23
|
-
- RPC: `@floegence/flowersec-core/rpc`
|
|
24
|
-
- Reconnect: `@floegence/flowersec-core/reconnect`
|
|
25
|
-
- HTTP/WebSocket proxy and browser runtime: `@floegence/flowersec-core/proxy`
|
|
26
|
-
- Observability: `@floegence/flowersec-core/observability`
|
|
67
|
+
`Artifact` is an opaque handle. Applications cannot inspect its connection data or serialize it back to protocol JSON. `ArtifactLease` exposes no spend operation; only the connector may invoke the durable callback. `Session` exposes RPC, stream operations, liveness, rekeying, `waitTermination()`, and closure without revealing the selected transport or peer endpoint identity. Public streams expose their kind and terminal state, but no protocol stream identifier.
|
|
27
68
|
|
|
28
|
-
|
|
69
|
+
`ConnectError` and `SessionError` expose only a closed `code`. They do not retain raw causes, credentials, URLs, candidate diagnostics, transport objects, peer details, or internal routing and handshake state.
|
|
29
70
|
|
|
30
|
-
|
|
71
|
+
Candidate lists, runtime capability descriptors, transport factories, admission state, Yamux, wire messages, cryptographic state, keys, and spend-ledger internals are not package exports.
|
|
31
72
|
|
|
32
|
-
|
|
73
|
+
Admission rejection reasons are server-authorized bounded protocol tokens. Clients validate their wire form without carrying a deployment-specific reason registry; the public error boundary remains closed and redacted.
|
|
33
74
|
|
|
34
|
-
The
|
|
75
|
+
The proxy entrypoint accepts an opaque `ArtifactLease` or an already connected `Session`. Its public runtime never exposes the selected carrier, a Yamux stream, raw artifact fields, or proxy wire frames. Cross-window bridges require an exact allowed origin and may require a bounded capability nonce; runtime failures are mapped to closed status/code values before reaching Service Worker or Window messages.
|
|
35
76
|
|
|
36
|
-
##
|
|
77
|
+
## Transport v2 Support
|
|
37
78
|
|
|
38
|
-
|
|
79
|
+
WebSocket, raw QUIC, and WebTransport are equal carrier candidates. Browser and Node.js support below describes this SDK's profiles, not the portable API.
|
|
80
|
+
|
|
81
|
+
Raw QUIC and WebTransport preserve native FIN, RESET_STREAM, STOP_SENDING, flow control, and migration behavior. The TypeScript SDK support below is narrower than the protocol carrier set.
|
|
82
|
+
|
|
83
|
+
WebSocket uses Yamux only inside its carrier adapter. Yamux has no independent STOP_SENDING primitive, so that operation is explicitly unavailable rather than emulated with a full stream reset.
|
|
84
|
+
|
|
85
|
+
Browser applications receive a ready `Session` from `connect(...)`. The browser connector supports WSS and WebTransport production connections. WebTransport uses native HTTP/3 bidirectional streams and does not use Yamux.
|
|
86
|
+
|
|
87
|
+
Chromium does not support a WebTransport pooling option; each carrier creates an independent native WebTransport connection.
|
|
88
|
+
|
|
89
|
+
Cold-connection diagnostics require every independent carrier to meet the declared deadline. A `dial_failed` result remains a test failure and is not hidden by pooling, retry, or timeout relaxation.
|
|
90
|
+
|
|
91
|
+
Node.js applications receive the same `Session` contract from `connect(...)`. The Node.js connector supports WSS and WebTransport production connections for direct and tunnel artifacts. It requires an absolute HTTP(S) `origin`; a custom certificate authority can be supplied through `tls.ca`. Invalid origin and TLS options fail as `ConnectError` with `invalid_options` and are terminal to the optional connection controller.
|
|
92
|
+
|
|
93
|
+
The Node WebTransport direct listener/server is owned by the Node runtime and the `flowersec-ts-cli` server path. It uses the same native carrier acceptor and session engine as the client connector; it is not a second protocol implementation.
|
|
94
|
+
|
|
95
|
+
The connectors select an eligible transport from the opaque artifact internally. They do not accept a public transport selector, capability manifest, candidate factory, or admission-reason override. Unsupported artifacts fail closed. The TypeScript package does not expose raw QUIC dialing.
|
|
96
|
+
|
|
97
|
+
Transport v2 production carrier support: browsers support WebSocket and WebTransport; Node.js supports WebSocket and WebTransport dialing for direct clients and both tunnel roles. Node WebTransport uses the pinned native quiche adapter and is covered by a real admission/session integration test without Playwright.
|
|
98
|
+
|
|
99
|
+
Flowersec disables application 0-RTT. Reliable streams never use QUIC DATAGRAM; runtimes with negotiated native DATAGRAM expose it only through carrier-neutral unreliable messages.
|
|
100
|
+
|
|
101
|
+
## Verify
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm run build
|
|
105
|
+
npm test
|
|
106
|
+
npm run verify:package
|
|
107
|
+
```
|
|
39
108
|
|
|
40
|
-
|
|
109
|
+
See the [API contract](../docs/API_CONTRACT.md), [Transport v2 architecture](../docs/TRANSPORT_V2_ARCHITECTURE.md), [threat model](../docs/THREAT_MODEL.md), and [error model](../docs/ERROR_MODEL.md).
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Third Party Notices
|
|
2
|
+
|
|
3
|
+
This file is generated from the canonical Flowersec source dependency inventory for flowersec-ts.
|
|
4
|
+
Do not edit it manually. License decisions are reviewed by the repository source license policy.
|
|
5
|
+
|
|
6
|
+
- @fails-components/webtransport 1.6.7 (Declared: BSD-3-Clause; selected: BSD-3-Clause; source: https://registry.npmjs.org/@fails-components/webtransport/-/webtransport-1.6.7.tgz)
|
|
7
|
+
- @fails-components/webtransport-transport-http3-quiche 1.6.7 (Declared: BSD-3-Clause; selected: BSD-3-Clause; source: https://registry.npmjs.org/@fails-components/webtransport-transport-http3-quiche/-/webtransport-transport-http3-quiche-1.6.7.tgz)
|
|
8
|
+
- @isaacs/fs-minipass 4.0.1 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz)
|
|
9
|
+
- @noble/ciphers 0.6.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.6.0.tgz)
|
|
10
|
+
- @noble/curves 1.9.7 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz)
|
|
11
|
+
- @noble/hashes 1.8.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz)
|
|
12
|
+
- @types/debug 4.1.13 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz)
|
|
13
|
+
- @types/ms 2.1.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz)
|
|
14
|
+
- ansi-regex 5.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz)
|
|
15
|
+
- ansi-styles 4.3.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz)
|
|
16
|
+
- base64-js 1.5.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz)
|
|
17
|
+
- bindings 1.5.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz)
|
|
18
|
+
- bl 4.1.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/bl/-/bl-4.1.0.tgz)
|
|
19
|
+
- buffer 5.7.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz)
|
|
20
|
+
- chownr 1.1.4 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz)
|
|
21
|
+
- chownr 3.0.0 (Declared: BlueOak-1.0.0; selected: BlueOak-1.0.0; source: https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz)
|
|
22
|
+
- cliui 8.0.1 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz)
|
|
23
|
+
- cmake-js 8.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/cmake-js/-/cmake-js-8.0.0.tgz)
|
|
24
|
+
- color-convert 2.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz)
|
|
25
|
+
- color-name 1.1.4 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz)
|
|
26
|
+
- debug 4.4.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/debug/-/debug-4.4.3.tgz)
|
|
27
|
+
- decompress-response 6.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz)
|
|
28
|
+
- deep-extend 0.6.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz)
|
|
29
|
+
- detect-libc 2.1.2 (Declared: Apache-2.0; selected: Apache-2.0; source: https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz)
|
|
30
|
+
- emoji-regex 8.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz)
|
|
31
|
+
- end-of-stream 1.4.5 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz)
|
|
32
|
+
- escalade 3.2.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz)
|
|
33
|
+
- expand-template 2.0.3 (Declared: MIT OR WTFPL; selected: MIT; source: https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz)
|
|
34
|
+
- file-uri-to-path 1.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz)
|
|
35
|
+
- fs-constants 1.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz)
|
|
36
|
+
- fs-extra 11.4.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.0.tgz)
|
|
37
|
+
- get-caller-file 2.0.5 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz)
|
|
38
|
+
- github-from-package 0.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz)
|
|
39
|
+
- graceful-fs 4.2.11 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz)
|
|
40
|
+
- ieee754 1.2.1 (Declared: BSD-3-Clause; selected: BSD-3-Clause; source: https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz)
|
|
41
|
+
- inherits 2.0.4 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz)
|
|
42
|
+
- ini 1.3.8 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/ini/-/ini-1.3.8.tgz)
|
|
43
|
+
- is-fullwidth-code-point 3.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz)
|
|
44
|
+
- isexe 4.0.0 (Declared: BlueOak-1.0.0; selected: BlueOak-1.0.0; source: https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz)
|
|
45
|
+
- jsonfile 6.2.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz)
|
|
46
|
+
- mimic-response 3.1.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz)
|
|
47
|
+
- minimist 1.2.8 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz)
|
|
48
|
+
- minipass 7.1.3 (Declared: BlueOak-1.0.0; selected: BlueOak-1.0.0; source: https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz)
|
|
49
|
+
- minizlib 3.1.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz)
|
|
50
|
+
- mkdirp-classic 0.5.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz)
|
|
51
|
+
- ms 2.1.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/ms/-/ms-2.1.3.tgz)
|
|
52
|
+
- napi-build-utils 2.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz)
|
|
53
|
+
- node-abi 3.94.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/node-abi/-/node-abi-3.94.0.tgz)
|
|
54
|
+
- node-addon-api 7.1.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz)
|
|
55
|
+
- node-api-headers 1.9.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/node-api-headers/-/node-api-headers-1.9.0.tgz)
|
|
56
|
+
- once 1.4.0 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/once/-/once-1.4.0.tgz)
|
|
57
|
+
- prebuild-install 7.1.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz)
|
|
58
|
+
- pump 3.0.4 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/pump/-/pump-3.0.4.tgz)
|
|
59
|
+
- punycode 2.3.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz)
|
|
60
|
+
- rc 1.2.8 (Declared: BSD-2-Clause OR MIT OR Apache-2.0; selected: MIT; source: https://registry.npmjs.org/rc/-/rc-1.2.8.tgz)
|
|
61
|
+
- readable-stream 3.6.2 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz)
|
|
62
|
+
- require-directory 2.1.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz)
|
|
63
|
+
- safe-buffer 5.2.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz)
|
|
64
|
+
- semver 7.7.3 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/semver/-/semver-7.7.3.tgz)
|
|
65
|
+
- simple-concat 1.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz)
|
|
66
|
+
- simple-get 4.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz)
|
|
67
|
+
- string_decoder 1.3.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz)
|
|
68
|
+
- string-width 4.2.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz)
|
|
69
|
+
- strip-ansi 6.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz)
|
|
70
|
+
- strip-json-comments 2.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz)
|
|
71
|
+
- tar 7.5.22 (Declared: BlueOak-1.0.0; selected: BlueOak-1.0.0; source: https://registry.npmjs.org/tar/-/tar-7.5.22.tgz)
|
|
72
|
+
- tar-fs 2.1.5 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.5.tgz)
|
|
73
|
+
- tar-stream 2.2.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz)
|
|
74
|
+
- tr46 5.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz)
|
|
75
|
+
- tunnel-agent 0.6.0 (Declared: Apache-2.0; selected: Apache-2.0; source: https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz)
|
|
76
|
+
- universalify 2.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz)
|
|
77
|
+
- url-join 4.0.1 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz)
|
|
78
|
+
- util-deprecate 1.0.2 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz)
|
|
79
|
+
- which 6.0.1 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/which/-/which-6.0.1.tgz)
|
|
80
|
+
- wrap-ansi 7.0.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz)
|
|
81
|
+
- wrappy 1.0.2 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz)
|
|
82
|
+
- ws 8.21.0 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/ws/-/ws-8.21.0.tgz)
|
|
83
|
+
- y18n 5.0.8 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz)
|
|
84
|
+
- yallist 5.0.0 (Declared: BlueOak-1.0.0; selected: BlueOak-1.0.0; source: https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz)
|
|
85
|
+
- yargs 17.7.3 (Declared: MIT; selected: MIT; source: https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz)
|
|
86
|
+
- yargs-parser 21.1.1 (Declared: ISC; selected: ISC; source: https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz)
|
|
87
|
+
## Distributed Dependency License Materials
|
|
88
|
+
|
|
89
|
+
The following dependencies are incorporated into distributed Flowersec files or binaries.
|
|
90
|
+
Their reviewed upstream license, notice, copyright, and patent materials are reproduced below.
|
|
91
|
+
|
|
92
|
+
### punycode 2.3.1
|
|
93
|
+
|
|
94
|
+
#### Reviewed bundled license text
|
|
95
|
+
|
|
96
|
+
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
97
|
+
|
|
98
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
99
|
+
a copy of this software and associated documentation files (the
|
|
100
|
+
"Software"), to deal in the Software without restriction, including
|
|
101
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
102
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
103
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
104
|
+
the following conditions:
|
|
105
|
+
|
|
106
|
+
The above copyright notice and this permission notice shall be
|
|
107
|
+
included in all copies or substantial portions of the Software.
|
|
108
|
+
|
|
109
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
110
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
111
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
112
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
113
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
114
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
115
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
116
|
+
|
|
117
|
+
### tr46 5.0.0
|
|
118
|
+
|
|
119
|
+
#### Reviewed bundled license text
|
|
120
|
+
|
|
121
|
+
The MIT License (MIT)
|
|
122
|
+
|
|
123
|
+
Copyright (c) Sebastian Mayr
|
|
124
|
+
|
|
125
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
126
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
127
|
+
in the Software without restriction, including without limitation the rights
|
|
128
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
129
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
130
|
+
furnished to do so, subject to the following conditions:
|
|
131
|
+
|
|
132
|
+
The above copyright notice and this permission notice shall be included in all
|
|
133
|
+
copies or substantial portions of the Software.
|
|
134
|
+
|
|
135
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
136
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
137
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
138
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
139
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
140
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
141
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ArtifactLease } from "../public/artifactLease.js";
|
|
2
|
+
import type { Session } from "../public/contract.js";
|
|
3
|
+
import { type ArtifactSource, type ConnectionController } from "../connectionController.js";
|
|
4
|
+
export type SessionOptions = Readonly<{
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
connectTimeoutMs?: number;
|
|
7
|
+
}>;
|
|
8
|
+
export type ConnectionControllerOptions = Readonly<{
|
|
9
|
+
connectTimeoutMs?: number;
|
|
10
|
+
maximumAttempts?: number;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function createConnectionController(source: ArtifactSource, options?: ConnectionControllerOptions): ConnectionController;
|
|
13
|
+
export declare function connect(lease: ArtifactLease, options?: SessionOptions): Promise<Session>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { composeCandidateAttemptFactoryV2, SessionConnectorV2, } from "../connector/sessionConnector.js";
|
|
2
|
+
import { createWebSocketCandidateFactoryV2 } from "../connector/adapters/webSocketCandidate.js";
|
|
3
|
+
import { createWebTransportCandidateFactoryV2 } from "../connector/adapters/webTransportCandidate.js";
|
|
4
|
+
import { detectBrowserRuntimeCapabilityV2 } from "./runtimeCapability.js";
|
|
5
|
+
import { projectSessionV2 } from "../v2/publicSession.js";
|
|
6
|
+
import { createBrowserWebTransportClientV2 } from "./webTransportClient.js";
|
|
7
|
+
import { browserSessionRuntimeV2 } from "./sessionRuntime.js";
|
|
8
|
+
import { createConnectionControllerV2, } from "../connectionController.js";
|
|
9
|
+
export function createConnectionController(source, options = {}) {
|
|
10
|
+
const controllerOptions = options.maximumAttempts === undefined
|
|
11
|
+
? {}
|
|
12
|
+
: { maximumAttempts: options.maximumAttempts };
|
|
13
|
+
return createConnectionControllerV2(source, async (lease, signal) => await connect(lease, {
|
|
14
|
+
signal,
|
|
15
|
+
...(options.connectTimeoutMs === undefined ? {} : { connectTimeoutMs: options.connectTimeoutMs }),
|
|
16
|
+
}), controllerOptions);
|
|
17
|
+
}
|
|
18
|
+
export async function connect(lease, options = {}) {
|
|
19
|
+
const { signal, ...connectorOptions } = options;
|
|
20
|
+
const connector = new SessionConnectorV2(lease, composeCandidateAttemptFactoryV2({
|
|
21
|
+
websocket: createWebSocketCandidateFactoryV2(defaultWebSocketFactory),
|
|
22
|
+
webtransport: createWebTransportCandidateFactoryV2(async (candidate, artifact, signal) => await createBrowserWebTransportClientV2(candidate.normalized_url, {
|
|
23
|
+
path: artifact.path.kind,
|
|
24
|
+
inboundBidirectionalStreamCapacity: artifact.session.max_inbound_streams + 2,
|
|
25
|
+
signal,
|
|
26
|
+
})),
|
|
27
|
+
}), {
|
|
28
|
+
...connectorOptions,
|
|
29
|
+
capability: detectBrowserRuntimeCapabilityV2(),
|
|
30
|
+
runtime: browserSessionRuntimeV2,
|
|
31
|
+
});
|
|
32
|
+
const result = await connector.connect(signal === undefined ? {} : { signal });
|
|
33
|
+
return projectSessionV2(result.session);
|
|
34
|
+
}
|
|
35
|
+
function defaultWebSocketFactory(url, subprotocol) {
|
|
36
|
+
const Constructor = globalThis.WebSocket;
|
|
37
|
+
if (Constructor === undefined)
|
|
38
|
+
throw new Error("WebSocket is unavailable in this browser runtime");
|
|
39
|
+
return new Constructor(url, subprotocol);
|
|
40
|
+
}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { TransportSecurityPolicy, TransportSecurityPolicyInput, TransportSecurityPolicyPreset, NetworkPlaintextPolicyOptions, } from "../client-connect/transportSecurity.js";
|
|
5
|
-
export type { ConnectArtifact, CorrelationContext, CorrelationKV, DirectClientConnectArtifact, ScopeMetadataEntry, TunnelClientConnectArtifact, } from "../connect/artifact.js";
|
|
6
|
-
export { assertConnectArtifact } from "../connect/artifact.js";
|
|
7
|
-
export type { RequestConnectArtifactInput, RequestEntryConnectArtifactInput } from "../controlplane/request.js";
|
|
8
|
-
export { requestConnectArtifact, requestEntryConnectArtifact, } from "../controlplane/request.js";
|
|
9
|
-
export type { BrowserReconnectConfig, DirectBrowserReconnectConfig, TunnelBrowserReconnectConfig, } from "./reconnectConfig.js";
|
|
10
|
-
export { createBrowserReconnectConfig, createDirectBrowserReconnectConfig, createTunnelBrowserReconnectConfig, } from "./reconnectConfig.js";
|
|
1
|
+
export * from "../facade.js";
|
|
2
|
+
export { connect, createConnectionController } from "./connectSession.js";
|
|
3
|
+
export type { ConnectionControllerOptions, SessionOptions, } from "./connectSession.js";
|
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { assertConnectArtifact } from "../connect/artifact.js";
|
|
4
|
-
export { requestConnectArtifact, requestEntryConnectArtifact, } from "../controlplane/request.js";
|
|
5
|
-
export { createBrowserReconnectConfig, createDirectBrowserReconnectConfig, createTunnelBrowserReconnectConfig, } from "./reconnectConfig.js";
|
|
1
|
+
export * from "../facade.js";
|
|
2
|
+
export { connect, createConnectionController } from "./connectSession.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RuntimeCapabilityDescriptorV2, type UnsupportedRuntimeCarrierV2 } from "../v2/capability.js";
|
|
2
|
+
export type BrowserRuntimeFeaturesV2 = Readonly<{
|
|
3
|
+
WebSocket?: unknown;
|
|
4
|
+
WebTransport?: unknown;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const BROWSER_RUNTIME_CAPABILITY_V2: Readonly<{
|
|
7
|
+
language: string;
|
|
8
|
+
runtime: string;
|
|
9
|
+
schemaVersion: 2;
|
|
10
|
+
tuples: readonly import("../v2/capability.js").RuntimeCapabilityTupleV2[];
|
|
11
|
+
unsupported: readonly UnsupportedRuntimeCarrierV2[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare function detectBrowserRuntimeCapabilityV2(runtime?: BrowserRuntimeFeaturesV2): RuntimeCapabilityDescriptorV2;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineRuntimeCapabilityDescriptorV2, } from "../v2/capability.js";
|
|
2
|
+
import { hasWebTransportConstructorSurfaceV2 } from "../transport/webTransportAdapter.js";
|
|
3
|
+
const tuples = Object.freeze([
|
|
4
|
+
{ carrier: "websocket", datagrams: false, migration: false, networkMode: "dial", path: "direct", reliableStreams: true, sessionRole: "client" },
|
|
5
|
+
{ carrier: "websocket", datagrams: false, migration: false, networkMode: "dial", path: "tunnel", reliableStreams: true, sessionRole: "client" },
|
|
6
|
+
{ carrier: "websocket", datagrams: false, migration: false, networkMode: "dial", path: "tunnel", reliableStreams: true, sessionRole: "server" },
|
|
7
|
+
{ carrier: "webtransport", datagrams: true, migration: false, networkMode: "dial", path: "direct", reliableStreams: true, sessionRole: "client" },
|
|
8
|
+
{ carrier: "webtransport", datagrams: true, migration: false, networkMode: "dial", path: "tunnel", reliableStreams: true, sessionRole: "client" },
|
|
9
|
+
{ carrier: "webtransport", datagrams: true, migration: false, networkMode: "dial", path: "tunnel", reliableStreams: true, sessionRole: "server" },
|
|
10
|
+
]);
|
|
11
|
+
export const BROWSER_RUNTIME_CAPABILITY_V2 = defineRuntimeCapabilityDescriptorV2("browser", tuples, [{ carrier: "raw_quic", reason: "browser_no_raw_udp" }]);
|
|
12
|
+
export function detectBrowserRuntimeCapabilityV2(runtime = globalThis) {
|
|
13
|
+
const available = new Set();
|
|
14
|
+
if (typeof runtime.WebSocket === "function")
|
|
15
|
+
available.add("websocket");
|
|
16
|
+
if (hasWebTransportConstructorSurfaceV2(runtime.WebTransport))
|
|
17
|
+
available.add("webtransport");
|
|
18
|
+
const unsupported = [{ carrier: "raw_quic", reason: "browser_no_raw_udp" }];
|
|
19
|
+
if (!available.has("websocket")) {
|
|
20
|
+
unsupported.push({ carrier: "websocket", reason: "browser_websocket_api_unavailable" });
|
|
21
|
+
}
|
|
22
|
+
if (!available.has("webtransport")) {
|
|
23
|
+
unsupported.push({ carrier: "webtransport", reason: "browser_webtransport_api_unavailable" });
|
|
24
|
+
}
|
|
25
|
+
unsupported.sort((left, right) => left.carrier.localeCompare(right.carrier));
|
|
26
|
+
return defineRuntimeCapabilityDescriptorV2("browser", tuples.filter(({ carrier }) => available.has(carrier)), unsupported);
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RuntimeError } from "../runtime/errors.js";
|
|
2
|
+
export const browserSessionRuntimeV2 = Object.freeze({
|
|
3
|
+
entropy(length) {
|
|
4
|
+
requireLength(length);
|
|
5
|
+
const runtime = globalThis.crypto;
|
|
6
|
+
if (runtime === undefined || typeof runtime.getRandomValues !== "function") {
|
|
7
|
+
throw new RuntimeError("runtime_unsupported", "browser cryptographic entropy is unavailable");
|
|
8
|
+
}
|
|
9
|
+
const output = new Uint8Array(length);
|
|
10
|
+
runtime.getRandomValues(output);
|
|
11
|
+
return output;
|
|
12
|
+
},
|
|
13
|
+
monotonicMilliseconds() {
|
|
14
|
+
return performance.now();
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
function requireLength(length) {
|
|
18
|
+
if (!Number.isSafeInteger(length) || length < 1 || length > 65_536) {
|
|
19
|
+
throw new RangeError("entropy length must be an integer from 1 to 65536");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NativeCarrierSessionV2 } from "../v2/carrier.js";
|
|
2
|
+
import type { PathKind } from "../v2/contract.js";
|
|
3
|
+
export type BrowserWebTransportClientOptionsV2 = Readonly<{
|
|
4
|
+
path: PathKind;
|
|
5
|
+
inboundBidirectionalStreamCapacity: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function createBrowserWebTransportClientV2(url: string, options: BrowserWebTransportClientOptionsV2): Promise<NativeCarrierSessionV2>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { adaptWebTransportCarrierSessionV2, } from "../transport/webTransportAdapter.js";
|
|
2
|
+
import { RuntimeError } from "../runtime/errors.js";
|
|
3
|
+
export async function createBrowserWebTransportClientV2(url, options) {
|
|
4
|
+
const parsed = validateWebTransportURL(url, options.path);
|
|
5
|
+
const Constructor = globalThis.WebTransport;
|
|
6
|
+
if (Constructor === undefined) {
|
|
7
|
+
throw new RuntimeError("runtime_unsupported", "WebTransport is unavailable in this browser runtime");
|
|
8
|
+
}
|
|
9
|
+
if (options.signal?.aborted === true)
|
|
10
|
+
throw options.signal.reason;
|
|
11
|
+
// Chromium does not implement a WebTransport pooling constructor option.
|
|
12
|
+
// Every carrier is one independent native WebTransport created from its URL.
|
|
13
|
+
const transport = new Constructor(parsed.href);
|
|
14
|
+
try {
|
|
15
|
+
await raceAbort(transport.ready, options.signal);
|
|
16
|
+
return adaptWebTransportCarrierSessionV2(transport, options);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
transport.close({ closeCode: 6, reason: "WebTransport start failed" });
|
|
20
|
+
const detail = error instanceof Error && error.message !== "" ? `: ${error.message}` : "";
|
|
21
|
+
throw new RuntimeError("runtime_start_failed", `browser WebTransport failed to start${detail}`, error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function validateWebTransportURL(raw, path) {
|
|
25
|
+
let parsed;
|
|
26
|
+
try {
|
|
27
|
+
parsed = new URL(raw);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
throw new RuntimeError("runtime_start_failed", "invalid WebTransport URL", error);
|
|
31
|
+
}
|
|
32
|
+
const expectedPath = path === "direct"
|
|
33
|
+
? "/flowersec/webtransport/v2/direct"
|
|
34
|
+
: "/flowersec/webtransport/v2/tunnel";
|
|
35
|
+
if (parsed.protocol !== "https:" ||
|
|
36
|
+
parsed.username !== "" ||
|
|
37
|
+
parsed.password !== "" ||
|
|
38
|
+
parsed.pathname !== expectedPath ||
|
|
39
|
+
parsed.search !== "" ||
|
|
40
|
+
parsed.hash !== "") {
|
|
41
|
+
throw new RuntimeError("runtime_start_failed", `WebTransport URL must use ${expectedPath}`);
|
|
42
|
+
}
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
async function raceAbort(promise, signal) {
|
|
46
|
+
if (signal === undefined)
|
|
47
|
+
return await promise;
|
|
48
|
+
if (signal.aborted)
|
|
49
|
+
throw signal.reason;
|
|
50
|
+
return await new Promise((resolve, reject) => {
|
|
51
|
+
const abort = () => reject(signal.reason);
|
|
52
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
53
|
+
void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
54
|
+
});
|
|
55
|
+
}
|
package/dist/cli.d.ts
ADDED