@browsercore/contracts 0.2.5 → 0.2.7
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 +80 -10
- package/dist/config.d.ts +99 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +20 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts.d.ts +43 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +24 -3
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/platform.d.ts +33 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +6 -6
- package/dist/tcp-transport.d.ts +29 -5
- package/dist/tcp-transport.d.ts.map +1 -1
- package/dist/time.d.ts +75 -21
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +5 -4
- package/dist/time.js.map +1 -1
- package/dist/tls-engine.d.ts +317 -0
- package/dist/tls-engine.d.ts.map +1 -0
- package/dist/tls-engine.js +41 -0
- package/dist/tls-engine.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @browsercore/contracts
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@browsercore/contracts)
|
|
4
|
-
[](https://github.
|
|
5
|
-
[](https://jverneuer.github.io/browsercore-contracts/COVERAGE.md)
|
|
5
|
+
[](https://github.com/jverneuer/browsercore-contracts/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
6
7
|
|
|
7
8
|
The canonical interface package for the browsercore stack. Every protocol
|
|
8
9
|
package, runtime adapter, and consumer depends on these contracts — they
|
|
@@ -10,9 +11,15 @@ define how components communicate without coupling them to each other. As of
|
|
|
10
11
|
0.2.5 this is the canonical single definition for `Transport`,
|
|
11
12
|
`CryptoProvider`, and `CompressionProvider` (the implementing packages
|
|
12
13
|
re-export them), plus the `Platform` service contracts (events, time,
|
|
13
|
-
telemetry, network).
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
telemetry, network). As of 0.2.6: every `Platform` bundle is **optional**
|
|
15
|
+
(capabilities are resolved, not faked), `Network.udp` is a **factory**
|
|
16
|
+
(`UdpSocketFactory`), `Clock` is **THE** time contract (superseding the five
|
|
17
|
+
sibling-local shapes), `TlsHandshakeEngine` is the contracts-level seam that
|
|
18
|
+
lets quic drive a TLS handshake without importing `@browsercore/tls`, and the
|
|
19
|
+
`ProxyConfig` family / `ProfileId` / `CookieJarConsumer` config types have
|
|
20
|
+
their canonical homes here (owning packages alias next wave). Deliberately
|
|
21
|
+
package-local surfaces that remain duplicated (e.g. the full `CookieJar`)
|
|
22
|
+
are documented as such at each definition.
|
|
16
23
|
|
|
17
24
|
## Why this package exists
|
|
18
25
|
|
|
@@ -26,7 +33,9 @@ any package diverges.
|
|
|
26
33
|
**Alternative implementations welcome.** The contracts define exactly what a
|
|
27
34
|
component must satisfy — nothing more. Want to write a different transport?
|
|
28
35
|
Implement `Transport`. A different crypto backend? Implement
|
|
29
|
-
`CryptoProvider` (synchronous — WebCrypto cannot satisfy it
|
|
36
|
+
`CryptoProvider` (synchronous — WebCrypto cannot satisfy it; see
|
|
37
|
+
[docs/design-decisions.md](docs/design-decisions.md) for why that is
|
|
38
|
+
deliberate and what an async future would cost). A
|
|
30
39
|
different runtime (Bun, Deno, Workers)? Implement the `Platform` service
|
|
31
40
|
interfaces. The contracts are the spec; the packages are the reference
|
|
32
41
|
implementations.
|
|
@@ -60,12 +69,14 @@ compression, events, telemetry, time) down through options.
|
|
|
60
69
|
|
|
61
70
|
| Module | Purpose | Key exports |
|
|
62
71
|
|---|---|---|
|
|
63
|
-
| **Contracts** | Canonical provider interfaces — the single definitions the implementing packages re-export | `CryptoProvider`, `CompressionProvider`, `Transport`, `DatagramTransport`, `CookieJar`, `PacketCallback` |
|
|
64
|
-
| **Platform** | The composition root + per-service bundles | `Platform`, `PlatformOptions`, `Network`, `Crypto`, `Compression` |
|
|
72
|
+
| **Contracts** | Canonical provider interfaces — the single definitions the implementing packages re-export | `CryptoProvider`, `CompressionProvider`, `Transport`, `DatagramTransport`, `UdpSocketFactory`, `CookieJar`, `PacketCallback` |
|
|
73
|
+
| **Platform** | The composition root + per-service bundles — **every bundle optional** | `Platform`, `PlatformOptions`, `Network`, `Crypto`, `Compression` |
|
|
65
74
|
| **Events** | Structural emitter interface (a method surface, **not** EventTarget-backed) injected via `Platform.events` | `EventProvider`, `TypedEventEmitter<T>` |
|
|
66
|
-
| **Time** | Clock +
|
|
75
|
+
| **Time** | THE canonical Clock (wall + monotonic + sleep + timers) and the Duration/Scheduler helpers | `Clock`, `TimerHandle`, `Time`, `Duration`, `Scheduler`, `Deadline` |
|
|
76
|
+
| **TLS Engine** | The quic↔tls handshake seam — protocol packages never import each other | `TlsHandshakeEngine`, `TlsHandshakeContext`, `ClientHelloConfig`, `ServerHello`, `Certificate`, `CipherSuite`, `NamedGroup`, `SignatureScheme`, `AeadAlgorithm`, `ProtocolVersion`, `KeyPair`, `TrafficSecrets`, `ApplicationTrafficSecrets`, `HandshakePhase`, `AlertLevel` |
|
|
77
|
+
| **Config** | Canonical configuration types (owning packages alias next wave) | `ProxyConfig`, `ProxyScheme`, `ProxyTarget`, `ProxyCredentials`, `CookieJarConsumer` |
|
|
67
78
|
| **Telemetry** | OTel-aligned observability | `Logger`, `Tracer`, `Span`, `Metrics`, `Telemetry` |
|
|
68
|
-
| **Models** | Shared data structures that cross package boundaries | `BrowserProfile`, `TlsProfile`, `Http1Profile`, `Http2Profile`, `Request`, `Response`, `Headers`, `Cookie`, `TransportState`, `CloseReason`, `ContentEncoding` |
|
|
79
|
+
| **Models** | Shared data structures that cross package boundaries | `BrowserProfile`, `TlsProfile`, `Http1Profile`, `Http2Profile`, `ProfileId`, `Request`, `Response`, `Headers`, `Cookie`, `TransportState`, `CloseReason`, `ContentEncoding` |
|
|
69
80
|
| **Net** | Platform-agnostic TCP + DNS contracts for runtime portability | `Net`, `DnsResolver`, `Socket`, `ConnectOptions`, `IPAddress` |
|
|
70
81
|
| **IANA Tables** | Canonical TLS wire code lookup tables (single source of truth) | `CIPHER_SUITE_CODES`, `NAMED_GROUP_CODES`, `SIGNATURE_SCHEME_CODES`, `VERSION_CODES` |
|
|
71
82
|
|
|
@@ -78,6 +89,65 @@ implementation-local types exported by the protocol packages themselves
|
|
|
78
89
|
now the canonical single definitions that `@browsercore/transport` and
|
|
79
90
|
`@browsercore/crypto` re-export.
|
|
80
91
|
|
|
92
|
+
## Platform semantics (0.2.6)
|
|
93
|
+
|
|
94
|
+
**Every `Platform` bundle is optional** — `network?`, `crypto?`,
|
|
95
|
+
`compression?`, `events?`, `telemetry?`, `time?` — and every `Network`
|
|
96
|
+
member is optional (`tcp?`, `dns?`, `udp?`). A platform carries exactly the
|
|
97
|
+
capabilities its runtime has; nothing has to be faked. The contract is:
|
|
98
|
+
|
|
99
|
+
- **Consumers resolve what they use and throw typed errors naming the
|
|
100
|
+
missing capability.** `@browsercore/fetch`'s `proxyDialPlatform`
|
|
101
|
+
(`fetch/src/proxy.ts`) demonstrated the pattern while the fields were
|
|
102
|
+
still required — untouched bundles were throwing getters naming the
|
|
103
|
+
culprit. With optional bundles the same guarantee is expressed by
|
|
104
|
+
omitting the field, and consumers write
|
|
105
|
+
`platform.network?.tcp ?? throw missingCapability("platform.network.tcp")`.
|
|
106
|
+
- **Implementers may provide everything** — an implementation providing
|
|
107
|
+
more than a consumer requires (e.g. `browsersmith`'s `createPlatform()`)
|
|
108
|
+
always satisfies the interface. Optionality removes the obligation to
|
|
109
|
+
fake capabilities, never the permission to supply them.
|
|
110
|
+
|
|
111
|
+
**UDP is a factory, not an instance.** `Network.udp` is a
|
|
112
|
+
`UdpSocketFactory` — `connect(address)` returns a per-connection
|
|
113
|
+
`DatagramTransport`. The previous instance shape (`udp: DatagramTransport`)
|
|
114
|
+
forced the composition root to bind one socket at module-import time
|
|
115
|
+
(browsersmith's import-time `createSocket("udp4")` singleton —
|
|
116
|
+
replaceability audit, 2026-11-16). A factory binds sockets at connection
|
|
117
|
+
time, per connection, and lets UDP-less runtimes (Cloudflare Workers) omit
|
|
118
|
+
the capability instead of dead-binding a socket.
|
|
119
|
+
|
|
120
|
+
**`Clock` is THE time contract.** `now()` (wall, epoch ms),
|
|
121
|
+
`monotonic()` (monotonic ms — never `Date.now()` deltas for deadline math),
|
|
122
|
+
`sleep(ms)`, `setTimeout(ms, fn)` / `clearTimeout(handle)` with
|
|
123
|
+
`TimerHandle` an opaque `object` (not `NodeJS.Timeout` — runtime timer
|
|
124
|
+
tokens must not leak into published declarations). It supersedes the five
|
|
125
|
+
package-local sibling Clock shapes (tls/http1/http2/http3/quic), whose
|
|
126
|
+
`options.clock` seams migrate onto it in the next wave. `Time` remains as
|
|
127
|
+
the `Platform` bundle name aliasing `Clock`; `Duration`/`Scheduler`/
|
|
128
|
+
`Deadline` stay for duration-composed scheduling.
|
|
129
|
+
|
|
130
|
+
**`TlsHandshakeEngine` is the quic↔tls seam.** Protocol packages never
|
|
131
|
+
import each other (the no-hard-wires invariant); this interface —
|
|
132
|
+
`runHandshake` / `generateKeyShares` / `cipherSuiteToAead` plus the pure
|
|
133
|
+
handshake data types — is what `@browsercore/tls` implements and the
|
|
134
|
+
composition root injects into quic, replacing quic's direct tls imports
|
|
135
|
+
(the audit's single no-hard-wires violation). http3's fake-quic
|
|
136
|
+
compatibility test is the proof-of-concept for swapping a structural engine
|
|
137
|
+
implementation.
|
|
138
|
+
|
|
139
|
+
**Canonical config homes.** `ProxyConfig`/`ProxyScheme`/`ProxyTarget`/
|
|
140
|
+
`ProxyCredentials` (verbatim from `@browsercore/proxy`), `ProfileId` (the
|
|
141
|
+
ten built-in registry ids), and `CookieJarConsumer` (the minimal jar surface
|
|
142
|
+
fetch actually calls — `@browsercore/cookies`' full jar satisfies it
|
|
143
|
+
structurally) are defined here as canonical; the owning packages alias onto
|
|
144
|
+
them in the next wave.
|
|
145
|
+
|
|
146
|
+
Further rationale (why the sync crypto/compression contracts are deliberate,
|
|
147
|
+
why WebCrypto/CompressionStream are not valid backends, and what an async
|
|
148
|
+
future would cost) lives in
|
|
149
|
+
[docs/design-decisions.md](docs/design-decisions.md).
|
|
150
|
+
|
|
81
151
|
## Usage
|
|
82
152
|
|
|
83
153
|
### Importing types (compile-time only)
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical config types — the shared configuration vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Homes for pure-data configuration shapes that cross package boundaries
|
|
5
|
+
* (replaceability audit 2026-11-16, remediation item #3 groundwork:
|
|
6
|
+
* "contracts-ify fetch's public option types" — fetch's public API is welded
|
|
7
|
+
* to sibling concrete types; these canonical definitions let the next wave
|
|
8
|
+
* alias the owning packages onto them instead).
|
|
9
|
+
*
|
|
10
|
+
* Canonical-with-alias-next-wave: each family below is copied verbatim from
|
|
11
|
+
* the package that owns it today. That package re-exports the canonical type
|
|
12
|
+
* in the next wave (the rename-free adoption pattern transport/crypto
|
|
13
|
+
* performed for Transport/CryptoProvider in 0.2.5), so there is exactly one
|
|
14
|
+
* definition and zero drift.
|
|
15
|
+
*
|
|
16
|
+
* Litmus test: pure data, no behavior — if it has methods with logic, it is
|
|
17
|
+
* a contract, not a config, and does not belong here.
|
|
18
|
+
*/
|
|
19
|
+
import type { Cookie } from "./models.js";
|
|
20
|
+
/**
|
|
21
|
+
* Proxy schemes.
|
|
22
|
+
*
|
|
23
|
+
* - `http` — HTTP CONNECT tunneling (RFC 9110 §9.3.6)
|
|
24
|
+
* - `socks5` — SOCKS5 with client-side DNS: the hostname is resolved locally
|
|
25
|
+
* and the resolved IP is sent on the wire
|
|
26
|
+
* - `socks5h` — SOCKS5 with remote DNS: the hostname is sent verbatim and
|
|
27
|
+
* the proxy resolves it (curl's `socks5h` semantics)
|
|
28
|
+
*/
|
|
29
|
+
export type ProxyScheme = "http" | "socks5" | "socks5h";
|
|
30
|
+
/**
|
|
31
|
+
* A parsed, validated proxy endpoint.
|
|
32
|
+
*
|
|
33
|
+
* Produced by `@browsercore/proxy`'s `parseProxyUrl` or hand-assembled by the
|
|
34
|
+
* caller. All fields are readonly — configs are shared, never mutated.
|
|
35
|
+
*
|
|
36
|
+
* The `username`/`password` fields use an explicit `| undefined` so values
|
|
37
|
+
* parsed from URLs (where "absent" and "empty" genuinely differ) stay
|
|
38
|
+
* assignable under `exactOptionalPropertyTypes`.
|
|
39
|
+
*/
|
|
40
|
+
export interface ProxyConfig {
|
|
41
|
+
/** Tunneling scheme. */
|
|
42
|
+
readonly scheme: ProxyScheme;
|
|
43
|
+
/** Proxy host (DNS name or IP literal). */
|
|
44
|
+
readonly host: string;
|
|
45
|
+
/** Proxy port, 1–65535. */
|
|
46
|
+
readonly port: number;
|
|
47
|
+
/** Proxy username, when the proxy requires authentication. */
|
|
48
|
+
readonly username?: string | undefined;
|
|
49
|
+
/** Proxy password, when the proxy requires authentication. */
|
|
50
|
+
readonly password?: string | undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The destination requested through the proxy — what the client wants to
|
|
54
|
+
* reach, not the proxy itself.
|
|
55
|
+
*/
|
|
56
|
+
export interface ProxyTarget {
|
|
57
|
+
/** Target host (DNS name or IP literal). */
|
|
58
|
+
readonly host: string;
|
|
59
|
+
/** Target port, 1–65535. */
|
|
60
|
+
readonly port: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Credentials for proxy authentication.
|
|
64
|
+
*
|
|
65
|
+
* Used verbatim as RFC 1929 username/password (SOCKS5) or Basic auth
|
|
66
|
+
* (HTTP CONNECT). Field length limits are enforced by the handshake, not
|
|
67
|
+
* by this type.
|
|
68
|
+
*/
|
|
69
|
+
export interface ProxyCredentials {
|
|
70
|
+
readonly username: string;
|
|
71
|
+
readonly password: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `CookieJarConsumer` — the structural minimal surface a cookie-consuming
|
|
75
|
+
* client (fetch) actually needs from a jar.
|
|
76
|
+
*
|
|
77
|
+
* Derived from fetch's real call sites (`fetch/src/client.ts`):
|
|
78
|
+
* `applyCookies` calls `jar.getCookies(url)` to build the Cookie header and
|
|
79
|
+
* `storeCookies` calls `jar.setCookie(raw, url)` per Set-Cookie header —
|
|
80
|
+
* nothing else (no id, no clone, no clear/serialize). `@browsercore/cookies`'
|
|
81
|
+
* full `CookieJar` (with SameSite-context matching, removal, and
|
|
82
|
+
* (de)serialization) satisfies this interface structurally as a strict
|
|
83
|
+
* superset; fetch migrates its `options.cookieJar` onto this type next wave,
|
|
84
|
+
* dropping its direct `@browsercore/cookies` type dependency.
|
|
85
|
+
*
|
|
86
|
+
* Parameter order matches `@browsercore/cookies` (`setCookie(raw, url)`),
|
|
87
|
+
* NOT the legacy full `CookieJar` in `contracts.ts` (whose
|
|
88
|
+
* `setCookie(url, cookie)` order is flipped and reconciled separately).
|
|
89
|
+
*/
|
|
90
|
+
export interface CookieJarConsumer {
|
|
91
|
+
/**
|
|
92
|
+
* All cookies that match the given URL, ordered per RFC 6265 §5.4
|
|
93
|
+
* (domain/path specificity, earlier-set first).
|
|
94
|
+
*/
|
|
95
|
+
getCookies(url: string): readonly Cookie[];
|
|
96
|
+
/** Parse a raw Set-Cookie header value and store the resulting cookie. */
|
|
97
|
+
setCookie(raw: string, url: string): void;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM1C;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IACxB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC7B;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC3C,0EAA0E;IAC1E,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical config types — the shared configuration vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Homes for pure-data configuration shapes that cross package boundaries
|
|
5
|
+
* (replaceability audit 2026-11-16, remediation item #3 groundwork:
|
|
6
|
+
* "contracts-ify fetch's public option types" — fetch's public API is welded
|
|
7
|
+
* to sibling concrete types; these canonical definitions let the next wave
|
|
8
|
+
* alias the owning packages onto them instead).
|
|
9
|
+
*
|
|
10
|
+
* Canonical-with-alias-next-wave: each family below is copied verbatim from
|
|
11
|
+
* the package that owns it today. That package re-exports the canonical type
|
|
12
|
+
* in the next wave (the rename-free adoption pattern transport/crypto
|
|
13
|
+
* performed for Transport/CryptoProvider in 0.2.5), so there is exactly one
|
|
14
|
+
* definition and zero drift.
|
|
15
|
+
*
|
|
16
|
+
* Litmus test: pure data, no behavior — if it has methods with logic, it is
|
|
17
|
+
* a contract, not a config, and does not belong here.
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
package/dist/contracts.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ import type { EventProvider } from "./events.js";
|
|
|
23
23
|
*
|
|
24
24
|
* All operations are synchronous by design — an async-only backend such as
|
|
25
25
|
* WebCrypto cannot implement this interface; it is NOT a valid backend.
|
|
26
|
+
* The full rationale (sync protocol state machines, pure-JS noble backends
|
|
27
|
+
* covering the surface including ML-KEM, the cost of an async future) is
|
|
28
|
+
* recorded in [docs/design-decisions.md](docs/design-decisions.md).
|
|
26
29
|
*/
|
|
27
30
|
export interface CryptoProvider {
|
|
28
31
|
randomBytes(length: number): Uint8Array;
|
|
@@ -82,7 +85,8 @@ export interface CryptoProvider {
|
|
|
82
85
|
*
|
|
83
86
|
* All operations are synchronous by design. An async-stream backend such as
|
|
84
87
|
* WebCompressionStream cannot implement this interface — it is NOT a valid
|
|
85
|
-
* backend (the former claim that it was has been corrected).
|
|
88
|
+
* backend (the former claim that it was has been corrected). The full
|
|
89
|
+
* rationale lives in [docs/design-decisions.md](docs/design-decisions.md).
|
|
86
90
|
*
|
|
87
91
|
* The async `encode/decode(ContentEncoding)` shape had zero consumers and is
|
|
88
92
|
* dropped. This sync shape is the single source of truth.
|
|
@@ -158,8 +162,13 @@ export interface Transport extends EventProvider {
|
|
|
158
162
|
* Canonical definition (replaceability audit 2026-11-16): signature-identical
|
|
159
163
|
* to `@browsercore/transport`'s local copy, which re-exports this one.
|
|
160
164
|
*
|
|
165
|
+
* One instance represents ONE datagram endpoint (a bound socket talking to a
|
|
166
|
+
* single peer addressing scheme). Do not share an instance across independent
|
|
167
|
+
* connections — obtain one per connection from a {@link UdpSocketFactory}
|
|
168
|
+
* (injected as `Platform.network.udp`).
|
|
169
|
+
*
|
|
161
170
|
* Implemented by: the composition root's UDP adapter (`browsersmith`,
|
|
162
|
-
* `Platform.network.udp`). Consumed by `@browsercore/quic`.
|
|
171
|
+
* via `Platform.network.udp.connect()`). Consumed by `@browsercore/quic`.
|
|
163
172
|
*/
|
|
164
173
|
export interface DatagramTransport {
|
|
165
174
|
readonly id: string;
|
|
@@ -171,16 +180,46 @@ export interface DatagramTransport {
|
|
|
171
180
|
close(reason?: DatagramCloseReason): Promise<void>;
|
|
172
181
|
}
|
|
173
182
|
/**
|
|
174
|
-
* `
|
|
183
|
+
* `UdpSocketFactory` — the canonical injected UDP entry point.
|
|
184
|
+
*
|
|
185
|
+
* Factory, deliberately NOT an instance: the old `Platform.network.udp` shape
|
|
186
|
+
* (`udp: DatagramTransport`) forced the composition root to bind ONE socket
|
|
187
|
+
* at module load — `browsersmith`'s adapter called `createSocket("udp4")` at
|
|
188
|
+
* import time and shared that singleton everywhere (replaceability audit
|
|
189
|
+
* 2026-11-16: "udp default = import-time-bound createSocket('udp4') singleton").
|
|
190
|
+
* A factory keeps socket creation at connection time, per connection: the
|
|
191
|
+
* consumer (`@browsercore/quic`) calls `connect()` when it opens a session and
|
|
192
|
+
* closes the returned {@link DatagramTransport} when the session ends. Nothing
|
|
193
|
+
* datagram-related happens merely because the platform module was imported —
|
|
194
|
+
* which is what makes a UDP-less runtime (e.g. Cloudflare Workers) able to
|
|
195
|
+
* omit the factory entirely instead of dead-binding a socket.
|
|
196
|
+
*
|
|
197
|
+
* Implemented by: the composition root (`browsersmith`, injected as
|
|
198
|
+
* `Platform.network.udp` — now optional). Consumed by `@browsercore/quic`.
|
|
199
|
+
*/
|
|
200
|
+
export interface UdpSocketFactory {
|
|
201
|
+
/**
|
|
202
|
+
* Open a datagram endpoint for communicating with `address`.
|
|
203
|
+
* Resolves once the socket is ready to send/receive.
|
|
204
|
+
*/
|
|
205
|
+
connect(address: UdpAddress): Promise<DatagramTransport>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `CookieJar` — the full cookie storage surface.
|
|
175
209
|
*
|
|
176
210
|
* Implemented by: `@browsercore/cookies` (its local `CookieJar` is the shape
|
|
177
211
|
* consumers actually bind; note its `setCookie` parameter order is
|
|
178
|
-
* `(
|
|
212
|
+
* `(raw, url)` — flipped relative to this interface. Reconciling the two
|
|
179
213
|
* is tracked separately from the Transport/CryptoProvider unification.)
|
|
180
214
|
*
|
|
181
215
|
* Why here: fetch and browsersmith both use `CookieJar`. Provided via
|
|
182
216
|
* `FetchClientOptions.cookieJar`, populated from `Platform` or a custom
|
|
183
217
|
* implementation — never hardcoded to a runtime store.
|
|
218
|
+
*
|
|
219
|
+
* Consumers that only READ cookies out of a jar (send `getCookies`, store
|
|
220
|
+
* `setCookie`) should depend on the narrower structural `CookieJarConsumer`
|
|
221
|
+
* (see `config.ts`) instead — `@browsercore/cookies`' full jar satisfies it
|
|
222
|
+
* as a strict superset.
|
|
184
223
|
*/
|
|
185
224
|
export interface CookieJar {
|
|
186
225
|
getCookies(url: string): readonly Cookie[];
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACR,eAAe,EACf,MAAM,EACN,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,MAAM,EACN,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EAClB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* ▼
|
|
23
23
|
* browsersmith (composition root — builds & threads Platform)
|
|
24
24
|
*/
|
|
25
|
-
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, CookieJar, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
|
|
26
|
-
export type { ProfileId, BrowserProfile, TlsProfile, Http1Profile, Http2Profile, HpackProfile, Http2PriorityFrame, Request, Response, FetchOptions, FetchResponse, Headers, Cookie, HashId, EcdhCurve, X25519KeyPair, MLKEM768KeyPair, EcdhKeyPair, UdpAddress, TransportState, CloseReason, DatagramCloseReason, TlsState, ContentEncoding, } from "./models.js";
|
|
25
|
+
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, UdpSocketFactory, CookieJar, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
|
|
26
|
+
export type { ProfileId, RegisteredProfileId, BrowserProfile, TlsProfile, Http1Profile, Http2Profile, HpackProfile, Http2PriorityFrame, Request, Response, FetchOptions, FetchResponse, Headers, Cookie, HashId, EcdhCurve, X25519KeyPair, MLKEM768KeyPair, EcdhKeyPair, UdpAddress, TransportState, CloseReason, DatagramCloseReason, TlsState, ContentEncoding, } from "./models.js";
|
|
27
27
|
export { CIPHER_GREASE_PLACEHOLDER, CIPHER_SUITE_CODES, NAMED_GROUP_CODES, SIGNATURE_SCHEME_CODES, VERSION_CODES, } from "./models.js";
|
|
28
28
|
export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, Network, } from "./tcp-transport.js";
|
|
29
|
+
export type { AeadAlgorithm, CipherSuite, NamedGroup, SignatureScheme, ProtocolVersion, ClientHelloConfig, ServerHello, Certificate, KeyPair, TrafficSecrets, ApplicationTrafficSecrets, HandshakePhase, AlertLevel, TlsHandshakeContext, TlsHandshakeEngine, } from "./tls-engine.js";
|
|
30
|
+
export type { ProxyScheme, ProxyConfig, ProxyTarget, ProxyCredentials, CookieJarConsumer, } from "./config.js";
|
|
29
31
|
export type { EventProvider, TypedEventEmitter, } from "./events.js";
|
|
30
32
|
export type { Logger, Span, Tracer, Metrics, Telemetry, } from "./telemetry.js";
|
|
31
|
-
export type { Clock, Deadline, Scheduler, Time, } from "./time.js";
|
|
33
|
+
export type { Clock, TimerHandle, Deadline, Scheduler, Time, } from "./time.js";
|
|
32
34
|
/** Duration static factories — `Duration.seconds(5)`, `Duration.milliseconds(250)`. */
|
|
33
35
|
export { Duration } from "./time.js";
|
|
34
36
|
export type { Compression, Crypto, Platform, PlatformOptions, } from "./platform.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAEhB,SAAS,EAET,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EACT,mBAAmB,EAEnB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAElB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EAEX,UAAU,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,QAAQ,EAER,eAAe,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,cAAc,EACd,MAAM,EACN,GAAG,EACH,WAAW,EACX,SAAS,EACT,OAAO,GACV,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EAER,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EAEf,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,UAAU,EAEV,mBAAmB,EACnB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AAMzB,YAAY,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,aAAa,EACb,iBAAiB,GACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,GACZ,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EACR,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,IAAI,GACP,MAAM,WAAW,CAAC;AAEnB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAMrC,YAAY,EACR,WAAW,EACX,MAAM,EACN,QAAQ,EACR,eAAe,GAClB,MAAM,eAAe,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA4DH,8DAA8D;AAC9D,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAqFrB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAarC,8EAA8E;AAC9E,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,qCAAqC"}
|
package/dist/models.d.ts
CHANGED
|
@@ -23,10 +23,31 @@ export interface ProtocolFrame {
|
|
|
23
23
|
readonly timestamp: number;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Profile identifier —
|
|
27
|
-
*
|
|
26
|
+
* Profile identifier — the registry keys of @browsercore/profiles' built-in
|
|
27
|
+
* browser fingerprints.
|
|
28
|
+
*
|
|
29
|
+
* Canonical union (0.2.6), derived from the profiles registry
|
|
30
|
+
* (`@browsercore/profiles/src/registry.ts` indexes exactly these ids from the
|
|
31
|
+
* chrome/firefox/safari/edge profile sources — extend here when a new
|
|
32
|
+
* browser version lands). `@browsercore/profiles` currently keeps its own
|
|
33
|
+
* branded `ProfileId` (`string & { __brand: "ProfileId" }`); the two
|
|
34
|
+
* reconcile next wave (canonical-with-alias), where profiles also decides how
|
|
35
|
+
* runtime-registered custom ids (`registerProfile`) widen the set. Consumers
|
|
36
|
+
* passing a known registry id get literal autocomplete and typo protection
|
|
37
|
+
* here.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The closed set of registry-shipped profile ids. Literal autocomplete +
|
|
41
|
+
* typo protection; deliberately NOT exported alone — see {@link ProfileId}.
|
|
42
|
+
*/
|
|
43
|
+
export type RegisteredProfileId = "chrome-120" | "chrome-128" | "chrome-140" | "edge-120" | "edge-128" | "firefox-120" | "firefox-128" | "firefox-135" | "safari-17" | "safari-18";
|
|
44
|
+
/**
|
|
45
|
+
* ProfileId = the registry ids PLUS any runtime-registered custom id
|
|
46
|
+
* (`registerProfile`). The `(string & {})` widening keeps literal
|
|
47
|
+
* autocomplete and typo-flagging for the known ids while accepting custom
|
|
48
|
+
* registrations — a closed union would break the registry's extension point.
|
|
28
49
|
*/
|
|
29
|
-
export type ProfileId = string;
|
|
50
|
+
export type ProfileId = RegisteredProfileId | (string & Record<never, never>);
|
|
30
51
|
/**
|
|
31
52
|
* Complete browser fingerprint definition.
|
|
32
53
|
* Pure data — no protocol logic.
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAMD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAMD;;;;;;;;;;;;;GAaG;AACH;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GACzB,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,UAAU,GACV,aAAa,GACb,aAAa,GACb,aAAa,GACb,WAAW,GACX,WAAW,CAAC;AAElB;;;;;GAKG;AAIH,MAAM,MAAM,SAAS,GAAG,mBAAmB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,C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1D,CAAC"}
|
package/dist/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgaH,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,sEAAsE;AACtE,0EAA0E;AAC1E,kBAAkB;AAElB,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAChE,CAAC,yBAAyB,CAAC,EAAE,MAAM;IACnC,sBAAsB,EAAE,MAAM;IAC9B,sBAAsB,EAAE,MAAM;IAC9B,4BAA4B,EAAE,MAAM;IACpC,sBAAsB,EAAE,MAAM;IAC9B,uCAAuC,EAAE,MAAM;IAC/C,qCAAqC,EAAE,MAAM;IAC7C,uCAAuC,EAAE,MAAM;IAC/C,qCAAqC,EAAE,MAAM;IAC7C,6CAA6C,EAAE,MAAM;IACrD,2CAA2C,EAAE,MAAM;IACnD,kCAAkC,EAAE,MAAM;IAC1C,kCAAkC,EAAE,MAAM;IAC1C,oCAAoC,EAAE,MAAM;IAC5C,oCAAoC,EAAE,MAAM;IAC5C,uCAAuC,EAAE,MAAM;IAC/C,uCAAuC,EAAE,MAAM;IAC/C,qCAAqC,EAAE,MAAM;IAC7C,qCAAqC,EAAE,MAAM;IAC7C,+BAA+B,EAAE,MAAM;IACvC,+BAA+B,EAAE,MAAM;IACvC,4BAA4B,EAAE,MAAM;IACpC,4BAA4B,EAAE,MAAM;IACpC,+BAA+B,EAAE,MAAM;IACvC,+BAA+B,EAAE,MAAM;IACvC,qCAAqC,EAAE,MAAM;IAC7C,mCAAmC,EAAE,MAAM;IAC3C,6BAA6B,EAAE,MAAM;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IAC/D,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,cAAc,EAAE,MAAM;IACtB,cAAc,EAAE,MAAM;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACpE,sBAAsB,EAAE,MAAM;IAC9B,sBAAsB,EAAE,MAAM;IAC9B,sBAAsB,EAAE,MAAM;IAC9B,UAAU,EAAE,MAAM;IAClB,mBAAmB,EAAE,MAAM;IAC3B,mBAAmB,EAAE,MAAM;IAC3B,mBAAmB,EAAE,MAAM;IAC3B,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;IACxB,cAAc,EAAE,MAAM;IACtB,OAAO,EAAE,MAAM;CAClB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC3D,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;CACpB,CAAC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
* │
|
|
13
13
|
* ▼
|
|
14
14
|
* Platform
|
|
15
|
-
* ├── network
|
|
16
|
-
* ├── crypto
|
|
17
|
-
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
-
* ├── events
|
|
19
|
-
* ├── telemetry
|
|
20
|
-
* └── time
|
|
15
|
+
* ├── network? (TCP, DNS, UDP socket factory — each member optional)
|
|
16
|
+
* ├── crypto? (CryptoProvider)
|
|
17
|
+
* ├── compression? (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events? (EventProvider)
|
|
19
|
+
* ├── telemetry? (logger, tracer, metrics)
|
|
20
|
+
* └── time? (Clock — the canonical time contract)
|
|
21
21
|
*
|
|
22
22
|
* All fields are interfaces — this file has zero runtime behavior
|
|
23
23
|
* and zero node:* imports.
|
|
24
24
|
*/
|
|
25
25
|
import type { Network, Net, DnsResolver } from "./tcp-transport.js";
|
|
26
|
-
import type { CryptoProvider, CompressionProvider,
|
|
26
|
+
import type { CryptoProvider, CompressionProvider, UdpSocketFactory } from "./contracts.js";
|
|
27
27
|
import type { EventProvider } from "./events.js";
|
|
28
28
|
import type { Telemetry } from "./telemetry.js";
|
|
29
29
|
import type { Time } from "./time.js";
|
|
@@ -55,14 +55,33 @@ export interface Crypto {
|
|
|
55
55
|
* imports) and threaded down through options to every protocol package.
|
|
56
56
|
* No package hardwires runtime imports; all capabilities arrive via this
|
|
57
57
|
* object. This is the seam that makes BrowserCore portable and testable.
|
|
58
|
+
*
|
|
59
|
+
* Every bundle is OPTIONAL (replaceability audit 2026-11-16, remediation
|
|
60
|
+
* item #5: "Platform all-or-nothing with REQUIRED udp" forced consumers to
|
|
61
|
+
* lie to the type system). A platform now carries exactly the capabilities
|
|
62
|
+
* its runtime has — a UDP-less runtime (Cloudflare Workers) omits
|
|
63
|
+
* `network.udp`, a crypto-less test platform omits `crypto`. Consumers
|
|
64
|
+
* resolve the bundle they use and, when it is absent, throw a typed error
|
|
65
|
+
* that names the missing capability. The sanctioned pattern already exists:
|
|
66
|
+
* `@browsercore/fetch`'s `proxyDialPlatform` (`fetch/src/proxy.ts`) assembles
|
|
67
|
+
* a minimal platform whose untouched bundles are throwing getters naming the
|
|
68
|
+
* culprit — with optional bundles the same guarantee is expressed by simply
|
|
69
|
+
* omitting the field, and consumers write
|
|
70
|
+
* `platform.network?.tcp ?? throw new MissingCapabilityError("platform.network.tcp")`.
|
|
71
|
+
*
|
|
72
|
+
* Implementers may still provide every bundle (browsersmith's `createPlatform()`
|
|
73
|
+
* does) — an implementation that provides more than a consumer requires
|
|
74
|
+
* always satisfies the interface. Optionality only removes the obligation to
|
|
75
|
+
* FAKE capabilities a runtime lacks.
|
|
58
76
|
*/
|
|
59
77
|
export interface Platform {
|
|
60
|
-
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
78
|
+
/** Network bundle (TCP, DNS, UDP factory) — each member independently optional. */
|
|
79
|
+
readonly network?: Network;
|
|
80
|
+
readonly crypto?: Crypto;
|
|
81
|
+
readonly compression?: Compression;
|
|
82
|
+
readonly events?: EventProvider;
|
|
83
|
+
readonly telemetry?: Telemetry;
|
|
84
|
+
readonly time?: Time;
|
|
66
85
|
}
|
|
67
86
|
/**
|
|
68
87
|
* Options for overriding individual platform adapters.
|
|
@@ -74,7 +93,7 @@ export interface PlatformOptions {
|
|
|
74
93
|
readonly network?: {
|
|
75
94
|
readonly tcp?: Net;
|
|
76
95
|
readonly dns?: DnsResolver;
|
|
77
|
-
readonly udp?:
|
|
96
|
+
readonly udp?: UdpSocketFactory;
|
|
78
97
|
};
|
|
79
98
|
readonly crypto?: {
|
|
80
99
|
readonly provider?: CryptoProvider;
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,oBAAo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CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;CACxB"}
|
package/dist/platform.js
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* │
|
|
13
13
|
* ▼
|
|
14
14
|
* Platform
|
|
15
|
-
* ├── network
|
|
16
|
-
* ├── crypto
|
|
17
|
-
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
-
* ├── events
|
|
19
|
-
* ├── telemetry
|
|
20
|
-
* └── time
|
|
15
|
+
* ├── network? (TCP, DNS, UDP socket factory — each member optional)
|
|
16
|
+
* ├── crypto? (CryptoProvider)
|
|
17
|
+
* ├── compression? (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events? (EventProvider)
|
|
19
|
+
* ├── telemetry? (logger, tracer, metrics)
|
|
20
|
+
* └── time? (Clock — the canonical time contract)
|
|
21
21
|
*
|
|
22
22
|
* All fields are interfaces — this file has zero runtime behavior
|
|
23
23
|
* and zero node:* imports.
|
package/dist/tcp-transport.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* what any one runtime provides. Packages depend on this contract; runtimes
|
|
12
12
|
* adapt to it.
|
|
13
13
|
*/
|
|
14
|
-
import type {
|
|
14
|
+
import type { UdpSocketFactory } from "./contracts.js";
|
|
15
15
|
/** Options for establishing a TCP connection. */
|
|
16
16
|
export interface ConnectOptions {
|
|
17
17
|
/** Target host (IP literal or resolved address). */
|
|
@@ -82,14 +82,38 @@ export interface DnsResolver {
|
|
|
82
82
|
/**
|
|
83
83
|
* `Network` — the injected network bundle (part of `Platform`).
|
|
84
84
|
*
|
|
85
|
-
* Aggregates `Net`, `DnsResolver`, and `
|
|
85
|
+
* Aggregates `Net`, `DnsResolver`, and the `UdpSocketFactory` into a single
|
|
86
86
|
* object that `browsersmith` assembles and passes down through
|
|
87
87
|
* `Platform.network`. Protocol packages never import `node:net` /
|
|
88
88
|
* `node:dgram` directly.
|
|
89
|
+
*
|
|
90
|
+
* Every member is OPTIONAL (replaceability audit 2026-11-16, remediation
|
|
91
|
+
* item #5): a platform provides exactly the capabilities its runtime has,
|
|
92
|
+
* and a consumer resolves the member it needs before use — a missing member
|
|
93
|
+
* is a typed, named failure at the point of use, never a silent stub. The
|
|
94
|
+
* sanctioned pattern is `@browsercore/fetch`'s `proxyDialPlatform`
|
|
95
|
+
* (`fetch/src/proxy.ts`): it reads only `network.tcp` (all schemes) and
|
|
96
|
+
* `network.dns` (socks5 with a hostname target) and raises its own typed
|
|
97
|
+
* error naming the missing capability when a required member is absent —
|
|
98
|
+
* which is why `dns` stays genuinely `undefined` there instead of being
|
|
99
|
+
* faked. Consumers should do the same: dereference defensively
|
|
100
|
+
* (`platform.network?.tcp`) and throw an explicit error such as
|
|
101
|
+
* `"platform.network.udp is not available on this runtime"` that names the
|
|
102
|
+
* missing capability, so a wiring gap is diagnosable at the call site.
|
|
89
103
|
*/
|
|
90
104
|
export interface Network {
|
|
91
|
-
|
|
92
|
-
readonly
|
|
93
|
-
|
|
105
|
+
/** TCP connect capability. Omitted by datagram-only or connectionless runtimes. */
|
|
106
|
+
readonly tcp?: Net;
|
|
107
|
+
/** DNS resolution capability. Omitted when the runtime cannot resolve (proxy remote-DNS paths). */
|
|
108
|
+
readonly dns?: DnsResolver;
|
|
109
|
+
/**
|
|
110
|
+
* UDP datagram factory. A FACTORY, not a shared instance: `connect()`
|
|
111
|
+
* returns a per-connection {@link UdpSocketFactory} socket so nothing is
|
|
112
|
+
* bound at module-import time (the former instance shape forced
|
|
113
|
+
* `browsersmith`'s import-time `createSocket("udp4")` singleton —
|
|
114
|
+
* replaceability audit 2026-11-16). Omitted by runtimes without UDP
|
|
115
|
+
* (e.g. Cloudflare Workers — HTTP/3 is unavailable there, HTTP/2 is not).
|
|
116
|
+
*/
|
|
117
|
+
readonly udp?: UdpSocketFactory;
|
|
94
118
|
}
|
|
95
119
|
//# sourceMappingURL=tcp-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../src/tcp-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../src/tcp-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMvD,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,MAAM;IACnB;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC;IACpE,yCAAyC;IACzC,GAAG,IAAI,IAAI,CAAC;IACZ,gEAAgE;IAChE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,oCAAoC;IACpC,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,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;CACnC"}
|
package/dist/time.d.ts
CHANGED
|
@@ -3,26 +3,80 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These interfaces describe what BrowserCore needs from a runtime's time and
|
|
5
5
|
* scheduling facilities. They are implemented by thin adapters (e.g.
|
|
6
|
-
* `browsersmith/src/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
-
* packages call `clock.now()` / `
|
|
8
|
-
* never against `setTimeout` or `performance.now`
|
|
9
|
-
* stays runtime-agnostic and deterministically
|
|
6
|
+
* `browsersmith/src/platform/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
+
* Protocol packages call `clock.now()` / `clock.sleep()` against these
|
|
8
|
+
* interfaces — never against `setTimeout`, `Date.now`, or `performance.now`
|
|
9
|
+
* directly — so the stack stays runtime-agnostic and deterministically
|
|
10
|
+
* testable.
|
|
10
11
|
*
|
|
11
12
|
* Design rule: the interface is defined by what packages *consume*, not by
|
|
12
13
|
* what any one runtime provides.
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* An opaque timer handle returned by {@link Clock.setTimeout}.
|
|
16
17
|
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
18
|
+
* Deliberately `object`, NOT `NodeJS.Timeout`/`number`: the runtime-coupling
|
|
19
|
+
* audit (2026-11-16) flagged `NodeJS.Timeout` leaking into published `.d.ts`
|
|
20
|
+
* (`transport/src/timers.ts` — the only `NodeJS.` reference polyrepo-wide) as
|
|
21
|
+
* a platform-independence loss. Every runtime's timer token (Node's
|
|
22
|
+
* `Timeout`, a browser's numeric id, a Workers `ScheduledController`) is an
|
|
23
|
+
* `object` or boxes into one, so `object` is the maximal-width opaque token:
|
|
24
|
+
* implementations hand back whatever they want, callers hand it to
|
|
25
|
+
* {@link Clock.clearTimeout} and nothing else. Treating it as anything more
|
|
26
|
+
* specific is a contract violation.
|
|
27
|
+
*/
|
|
28
|
+
export type TimerHandle = object;
|
|
29
|
+
/**
|
|
30
|
+
* `Clock` — THE canonical time source for the entire stack.
|
|
31
|
+
*
|
|
32
|
+
* Supersedes (replaceability audit 2026-11-16, remediation item #6 +
|
|
33
|
+
* runtime-coupling audit fact #3: "five incompatible sibling Clock interfaces
|
|
34
|
+
* exist — tls/http1/http2/http3/quic each define their own"): the five
|
|
35
|
+
* package-local shapes were —
|
|
36
|
+
*
|
|
37
|
+
* tls : { now(): number; sleep(ms): Promise<void> }
|
|
38
|
+
* http1 : { now(): number }
|
|
39
|
+
* http2 : { now(): number; setTimeout(cb, ms); clearTimeout(t) }
|
|
40
|
+
* http3 : { now(): number; setTimeout(cb, ms): () => void } (disposer)
|
|
41
|
+
* quic : { now(): number }
|
|
42
|
+
*
|
|
43
|
+
* This interface is the single shape all of them migrate onto (next wave):
|
|
44
|
+
* their `options.clock` seams switch to importing this type, their local
|
|
45
|
+
* declarations are deleted, and their bare `setTimeout`/`Date.now` call
|
|
46
|
+
* sites route through an injected Clock. `@browsercore/transport`'s bare
|
|
47
|
+
* timers (`timers.ts`) and `@browsercore/fetch`'s bare `setTimeout`
|
|
48
|
+
* (`client.ts`, `pool.ts`) — the audit's top two behavioral-coupling
|
|
49
|
+
* findings — migrate onto the same seam.
|
|
50
|
+
*
|
|
51
|
+
* Unit contract:
|
|
52
|
+
* - `now()` is WALL time (epoch ms, `Date.now()`-comparable) — for
|
|
53
|
+
* timestamps, logging, certificate validity. It CAN jump (NTP).
|
|
54
|
+
* - `monotonic()` is MONOTONIC time in ms — for elapsed/deadline math.
|
|
55
|
+
* Never compare `now()` against `monotonic()`; never use `Date.now()`
|
|
56
|
+
* deltas for deadlines (wall-clock drift corrupts timeouts).
|
|
19
57
|
*/
|
|
20
58
|
export interface Clock {
|
|
21
|
-
/** Wall-clock time, epoch milliseconds. */
|
|
59
|
+
/** Wall-clock time, epoch milliseconds (comparable with `Date.now()`). */
|
|
22
60
|
now(): number;
|
|
23
|
-
/**
|
|
24
|
-
monotonic():
|
|
61
|
+
/** Monotonic time in milliseconds — never goes backwards; for elapsed/deadline math. */
|
|
62
|
+
monotonic(): number;
|
|
63
|
+
/** Resolve after `ms` milliseconds (replacement for bare `setTimeout`-as-sleep). */
|
|
64
|
+
sleep(ms: number): Promise<void>;
|
|
65
|
+
/** Run `fn` once after `ms` milliseconds; cancel via {@link clearTimeout}. */
|
|
66
|
+
setTimeout(ms: number, fn: () => void): TimerHandle;
|
|
67
|
+
/** Cancel a pending timer obtained from {@link setTimeout}. */
|
|
68
|
+
clearTimeout(handle: TimerHandle): void;
|
|
25
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* `Time` — the `Platform` bundle name for {@link Clock}.
|
|
72
|
+
*
|
|
73
|
+
* Alias kept so `Platform.time` reads as a bundle alongside
|
|
74
|
+
* `network`/`crypto`; the underlying contract is THE Clock above (the former
|
|
75
|
+
* `{ clock, scheduler }` bundle shape was implemented by zero protocol
|
|
76
|
+
* packages — runtime-coupling audit 2026-11-16 — and the five sibling clocks
|
|
77
|
+
* all bind the Clock surface directly, so the Clock IS the bundle).
|
|
78
|
+
*/
|
|
79
|
+
export type Time = Clock;
|
|
26
80
|
/**
|
|
27
81
|
* A duration interval.
|
|
28
82
|
*
|
|
@@ -35,29 +89,29 @@ export interface Duration {
|
|
|
35
89
|
}
|
|
36
90
|
/**
|
|
37
91
|
* A deadline bound to an AbortSignal.
|
|
92
|
+
*
|
|
93
|
+
* `expiresAt` is in {@link Clock.monotonic} milliseconds (reconciled with the
|
|
94
|
+
* canonical Clock in 0.2.6 — it was a `bigint` nanosecond value tied to the
|
|
95
|
+
* old superseded Clock whose `monotonic()` returned ns; with `monotonic()`
|
|
96
|
+
* now in ms, the deadline unit matches so `scheduler.deadline()` results stay
|
|
97
|
+
* comparable against the injected clock).
|
|
38
98
|
*/
|
|
39
99
|
export interface Deadline {
|
|
40
100
|
readonly signal: AbortSignal;
|
|
41
|
-
readonly expiresAt:
|
|
101
|
+
readonly expiresAt: number;
|
|
42
102
|
}
|
|
43
103
|
/**
|
|
44
104
|
* Scheduler — creates delays, timeouts, and deadlines.
|
|
105
|
+
*
|
|
106
|
+
* Kept for callers that compose `Duration`-based scheduling; the five sibling
|
|
107
|
+
* clock migrations bind {@link Clock} directly (`sleep`/`setTimeout` cover
|
|
108
|
+
* the same ground without pre-wrapping durations).
|
|
45
109
|
*/
|
|
46
110
|
export interface Scheduler {
|
|
47
111
|
delay(duration: Duration, signal?: AbortSignal): Promise<void>;
|
|
48
112
|
timeout(duration: Duration): AbortSignal;
|
|
49
113
|
deadline(duration: Duration): Deadline;
|
|
50
114
|
}
|
|
51
|
-
/**
|
|
52
|
-
* `Time` — the injected time bundle (part of `Platform`).
|
|
53
|
-
*
|
|
54
|
-
* Aggregates `Clock` and `Scheduler` into a single object that `browsersmith`
|
|
55
|
-
* assembles and passes down through `Platform.time`.
|
|
56
|
-
*/
|
|
57
|
-
export interface Time {
|
|
58
|
-
readonly clock: Clock;
|
|
59
|
-
readonly scheduler: Scheduler;
|
|
60
|
-
}
|
|
61
115
|
/**
|
|
62
116
|
* `Duration` factory — pure function object, no runtime deps.
|
|
63
117
|
*
|
package/dist/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,KAAK;IAClB,0EAA0E;IAC1E,GAAG,IAAI,MAAM,CAAC;IACd,wFAAwF;IACxF,SAAS,IAAI,MAAM,CAAC;IACpB,oFAAoF;IACpF,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IACpD,+DAA+D;IAC/D,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC1C;AAMD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;IACjB,OAAO,MAAM,MAAM,KAAG,QAAQ;IAC9B,YAAY,MAAM,MAAM,KAAG,QAAQ;CACtC,CAAC"}
|
package/dist/time.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These interfaces describe what BrowserCore needs from a runtime's time and
|
|
5
5
|
* scheduling facilities. They are implemented by thin adapters (e.g.
|
|
6
|
-
* `browsersmith/src/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
-
* packages call `clock.now()` / `
|
|
8
|
-
* never against `setTimeout` or `performance.now`
|
|
9
|
-
* stays runtime-agnostic and deterministically
|
|
6
|
+
* `browsersmith/src/platform/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
+
* Protocol packages call `clock.now()` / `clock.sleep()` against these
|
|
8
|
+
* interfaces — never against `setTimeout`, `Date.now`, or `performance.now`
|
|
9
|
+
* directly — so the stack stays runtime-agnostic and deterministically
|
|
10
|
+
* testable.
|
|
10
11
|
*
|
|
11
12
|
* Design rule: the interface is defined by what packages *consume*, not by
|
|
12
13
|
* what any one runtime provides.
|
package/dist/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA4GH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IAChF,YAAY,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;CACxF,CAAC"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS handshake engine contracts — the seam that lets QUIC drive a TLS
|
|
3
|
+
* handshake without importing `@browsercore/tls`.
|
|
4
|
+
*
|
|
5
|
+
* Why this module exists (replaceability audit 2026-11-16, remediation
|
|
6
|
+
* item #2): `@browsercore/quic` RUNTIME-EMBEDS the tls handshake engine —
|
|
7
|
+
* `runHandshake` / `generateKeyShares` / `cipherSuiteToAead` plus twelve
|
|
8
|
+
* types imported directly from `@browsercore/tls`
|
|
9
|
+
* (`quic/src/handshake/quic-handshake.ts`) — the one true protocol→protocol
|
|
10
|
+
* engine coupling in the stack, and the only violation of the no-hard-wires
|
|
11
|
+
* invariant ("protocol packages must never import each other directly; all
|
|
12
|
+
* inter-package communication flows through Platform interfaces defined in
|
|
13
|
+
* @browsercore/contracts").
|
|
14
|
+
*
|
|
15
|
+
* The fix shape: `@browsercore/tls` implements
|
|
16
|
+
* {@link TlsHandshakeEngine} and the composition root (browsersmith) injects
|
|
17
|
+
* it into quic via options, exactly like crypto/transport/events — quic
|
|
18
|
+
* consumes this interface, never the tls package directly. The pattern is
|
|
19
|
+
* already proven end-to-end by http3's fake-quic compatibility test
|
|
20
|
+
* (`http3/tests/fake-quic.ts`): a local structural implementation satisfying
|
|
21
|
+
* the consumer's contract is the sanctioned way to swap an engine.
|
|
22
|
+
*
|
|
23
|
+
* Shape derivation: every operation and type below is exactly what quic
|
|
24
|
+
* CALLS and the data it passes/receives on the real code path
|
|
25
|
+
* (`quic-handshake.ts` imports `runHandshake`, `generateKeyShares`,
|
|
26
|
+
* `cipherSuiteToAead` and the types `AeadAlgorithm`, `CipherSuite`,
|
|
27
|
+
* `ClientHelloConfig`, `ServerHello`, `Certificate`, `TrafficSecrets`,
|
|
28
|
+
* `HandshakeContext`, `HandshakePhase`, `AlertLevel`; `KeyPair` and
|
|
29
|
+
* `ApplicationTrafficSecrets` ride along as the callback/return data).
|
|
30
|
+
* Division of labor: quic implements the context itself (its
|
|
31
|
+
* `QuicHandshakeContext` — the consumer-side SPI), so
|
|
32
|
+
* {@link TlsHandshakeContext} here describes only the structural data
|
|
33
|
+
* surface the engine reads and mutates; the engine implements
|
|
34
|
+
* {@link TlsHandshakeEngine}. `HandshakeContext` AS A TYPE stays
|
|
35
|
+
* consumer-side (quic's class keeps implementing it structurally); nothing
|
|
36
|
+
* here is a class or carries runtime behavior.
|
|
37
|
+
*
|
|
38
|
+
* All shapes are pure data / function signatures — no runtime, no node:*.
|
|
39
|
+
*/
|
|
40
|
+
import type { CryptoProvider, Transport } from "./contracts.js";
|
|
41
|
+
import type { HashId } from "./models.js";
|
|
42
|
+
/** TLS 1.3 AEAD algorithms used by record protection (TLS 1.3 only negotiates these four). */
|
|
43
|
+
export type AeadAlgorithm = "AES-128-GCM" | "AES-256-GCM" | "AES-128-CCM" | "CHACHA20-POLY1305";
|
|
44
|
+
/**
|
|
45
|
+
* A TLS cipher suite: string-literal union, never bare string.
|
|
46
|
+
*
|
|
47
|
+
* Covers every suite the shipped browser profiles OFFER (the four TLS 1.3
|
|
48
|
+
* AEAD suites plus the TLS 1.2 suites and GREASE placeholder real browsers
|
|
49
|
+
* place in the offered list); the NEGOTIATED suite is always one of the four
|
|
50
|
+
* AEAD suites. Keyed by the same canonical names as
|
|
51
|
+
* {@link ../models.js~CIPHER_SUITE_CODES}.
|
|
52
|
+
*/
|
|
53
|
+
export type CipherSuite = "TLS_GREASE_RESERVED_0" | "TLS_AES_128_GCM_SHA256" | "TLS_AES_256_GCM_SHA384" | "TLS_CHACHA20_POLY1305_SHA256" | "TLS_AES_128_CCM_SHA256" | "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" | "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" | "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" | "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" | "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" | "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" | "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" | "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" | "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" | "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" | "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" | "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" | "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" | "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" | "TLS_RSA_WITH_AES_128_GCM_SHA256" | "TLS_RSA_WITH_AES_256_GCM_SHA384" | "TLS_RSA_WITH_AES_128_CBC_SHA" | "TLS_RSA_WITH_AES_256_CBC_SHA" | "TLS_RSA_WITH_AES_128_CBC_SHA256" | "TLS_RSA_WITH_AES_256_CBC_SHA256" | "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" | "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" | "TLS_RSA_WITH_3DES_EDE_CBC_SHA";
|
|
54
|
+
/** Named groups for key exchange (ECDHE / hybrid PQ), IANA canonical names. */
|
|
55
|
+
export type NamedGroup = "secp256r1" | "secp384r1" | "secp521r1" | "x25519" | "x448" | "ffdhe2048" | "ffdhe3072" | "X25519MLKEM768" | "X25519Kyber768";
|
|
56
|
+
/** Signature algorithms accepted in CertificateVerify (IANA canonical names). */
|
|
57
|
+
export type SignatureScheme = "ecdsa_secp256r1_sha256" | "ecdsa_secp384r1_sha384" | "ecdsa_secp521r1_sha512" | "ecdsa_sha1" | "ed25519" | "rsa_pss_rsae_sha256" | "rsa_pss_rsae_sha384" | "rsa_pss_rsae_sha512" | "rsa_pkcs1_sha256" | "rsa_pkcs1_sha384" | "rsa_pkcs1_sha512" | "rsa_pkcs1_sha1";
|
|
58
|
+
/**
|
|
59
|
+
* A TLS protocol version — name plus IANA wire code as a discriminated pair
|
|
60
|
+
* (the wire code is what the supported_versions extension carries).
|
|
61
|
+
*/
|
|
62
|
+
export type ProtocolVersion = {
|
|
63
|
+
readonly name: "TLS 1.2";
|
|
64
|
+
readonly wire: 0x0303;
|
|
65
|
+
} | {
|
|
66
|
+
readonly name: "TLS 1.3";
|
|
67
|
+
readonly wire: 0x0304;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* ClientHello configuration — the fingerprint-driven offer.
|
|
71
|
+
*
|
|
72
|
+
* Pure data: the offered cipher suites, exact extension order, GREASE flag,
|
|
73
|
+
* key-share groups, signature algorithms, supported versions, SNI, and ALPN.
|
|
74
|
+
* Higher layers (fetch) translate a `BrowserProfile` into this shape. quic's
|
|
75
|
+
* options surface keeps its own wider `ClientHelloConfigLike` mirror
|
|
76
|
+
* (plain-string lists) and converts to this typed shape at the engine call.
|
|
77
|
+
*/
|
|
78
|
+
export interface ClientHelloConfig {
|
|
79
|
+
/** Ordered list of cipher suites the client advertises (most-preferred first). */
|
|
80
|
+
readonly cipherSuites: readonly CipherSuite[];
|
|
81
|
+
/**
|
|
82
|
+
* Extension types in the exact order they must appear in the ClientHello.
|
|
83
|
+
* Every type present here is emitted; anything absent is omitted. This is
|
|
84
|
+
* the primary fingerprinting signal, so the order is load-bearing.
|
|
85
|
+
*/
|
|
86
|
+
readonly extensionOrder: readonly number[];
|
|
87
|
+
/** Named groups for key share, ordered by preference. */
|
|
88
|
+
readonly keyShareGroups: readonly NamedGroup[];
|
|
89
|
+
/**
|
|
90
|
+
* Named groups ADVERTISED in supported_groups when the advertised set
|
|
91
|
+
* differs from the groups actually shared in key_share (real Chrome
|
|
92
|
+
* advertises a wider set than it key-shares). When omitted,
|
|
93
|
+
* supported_groups is derived from {@link keyShareGroups}.
|
|
94
|
+
*/
|
|
95
|
+
readonly supportedGroups?: readonly NamedGroup[];
|
|
96
|
+
/** Signature algorithms the client accepts in CertificateVerify. */
|
|
97
|
+
readonly signatureAlgorithms: readonly SignatureScheme[];
|
|
98
|
+
/** Protocol versions the client advertises via supported_versions. */
|
|
99
|
+
readonly supportedVersions: readonly ProtocolVersion[];
|
|
100
|
+
/** Server Name Indication hostname (SNI). */
|
|
101
|
+
readonly serverName: string;
|
|
102
|
+
/** ALPN protocols the client wishes to negotiate (e.g. "h2", "h3"). */
|
|
103
|
+
readonly alpnProtocols?: readonly string[];
|
|
104
|
+
/** Whether to inject GREASE (RFC 8701) sentinel values. */
|
|
105
|
+
readonly grease: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* EC point formats offered in the `ec_point_formats` extension (wire byte
|
|
108
|
+
* values). Omit for the default (uncompressed only).
|
|
109
|
+
*/
|
|
110
|
+
readonly ecPointFormats?: readonly number[];
|
|
111
|
+
/**
|
|
112
|
+
* Algorithm IDs offered in the `compress_certificate` extension
|
|
113
|
+
* (RFC 8879), as 16-bit IANA wire values. Omit for the default `[2]`
|
|
114
|
+
* (brotli).
|
|
115
|
+
*/
|
|
116
|
+
readonly compressCertificateAlgorithms?: readonly number[];
|
|
117
|
+
/**
|
|
118
|
+
* Target ClientHello message length in bytes for the PADDING extension
|
|
119
|
+
* (RFC 7685). Omit to disable padding.
|
|
120
|
+
*/
|
|
121
|
+
readonly recordPadding?: number;
|
|
122
|
+
}
|
|
123
|
+
/** A parsed ServerHello — the first handshake message the server sends. */
|
|
124
|
+
export interface ServerHello {
|
|
125
|
+
/**
|
|
126
|
+
* Legacy protocol version (always 0x0303 in TLS 1.3, for middlebox
|
|
127
|
+
* compatibility). The real negotiated version is {@link selectedVersion}.
|
|
128
|
+
*/
|
|
129
|
+
readonly protocolVersion: number;
|
|
130
|
+
readonly random: Uint8Array;
|
|
131
|
+
readonly sessionId: Uint8Array;
|
|
132
|
+
readonly cipherSuite: CipherSuite;
|
|
133
|
+
readonly compressionMethod: number;
|
|
134
|
+
/**
|
|
135
|
+
* The protocol version the server actually negotiated, from the
|
|
136
|
+
* supported_versions extension. This is the authoritative version.
|
|
137
|
+
*/
|
|
138
|
+
readonly selectedVersion: ProtocolVersion;
|
|
139
|
+
/** Raw, undecoded ServerHello extensions bytes. */
|
|
140
|
+
readonly extensions: Uint8Array;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A parsed X.509 certificate (validation-relevant fields only) — pure data.
|
|
144
|
+
* The engine writes the validated leaf into the context's `peerCertificate`.
|
|
145
|
+
*/
|
|
146
|
+
export interface Certificate {
|
|
147
|
+
/** DER-encoded TBSCertificate bytes, needed for signature verification. */
|
|
148
|
+
readonly tbsBytes: Uint8Array;
|
|
149
|
+
/** DER-encoded SubjectPublicKeyInfo. */
|
|
150
|
+
readonly subjectPublicKeyInfo: Uint8Array;
|
|
151
|
+
/** Subject alternative DNS names (from the SAN extension), if any. */
|
|
152
|
+
readonly subjectAltNames: readonly string[];
|
|
153
|
+
/** Common Name from the subject DN, if present (legacy hostname match). */
|
|
154
|
+
readonly commonName?: string;
|
|
155
|
+
/** Not-before timestamp (epoch seconds). */
|
|
156
|
+
readonly notBefore: number;
|
|
157
|
+
/** Not-after timestamp (epoch seconds). */
|
|
158
|
+
readonly notAfter: number;
|
|
159
|
+
/** True if the certificate has the keyUsage bit for digital signature. */
|
|
160
|
+
readonly keyUsageDigitalSignature: boolean;
|
|
161
|
+
/** True if the certificate has the keyUsage bit for key encipherment/agreement. */
|
|
162
|
+
readonly keyUsageKeyEncipherment: boolean;
|
|
163
|
+
/** Signature algorithm used by the issuer over the TBSCertificate. */
|
|
164
|
+
readonly signatureScheme: SignatureScheme;
|
|
165
|
+
/** Raw signature value from the issuer. */
|
|
166
|
+
readonly signatureValue: Uint8Array;
|
|
167
|
+
/** DER-encoded SubjectPublicKeyInfo of the issuer (for chain building). */
|
|
168
|
+
readonly issuer: string;
|
|
169
|
+
/** True for a CA certificate. */
|
|
170
|
+
readonly isCa: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* A key share for one named group — the data `generateKeyShares` returns.
|
|
174
|
+
* `privateKey` is opaque to the consumer; the engine consumes it during the
|
|
175
|
+
* handshake.
|
|
176
|
+
*/
|
|
177
|
+
export interface KeyPair {
|
|
178
|
+
readonly algorithm: NamedGroup;
|
|
179
|
+
/** Private key bytes (opaque to the consumer of the engine). */
|
|
180
|
+
readonly privateKey: Uint8Array;
|
|
181
|
+
/** Public key bytes, as they appear in a KeyShareEntry. */
|
|
182
|
+
readonly publicKey: Uint8Array;
|
|
183
|
+
}
|
|
184
|
+
/** Traffic secrets derived by the TLS 1.3 key schedule for one direction. */
|
|
185
|
+
export interface TrafficSecrets {
|
|
186
|
+
/** AEAD key for this direction. */
|
|
187
|
+
readonly key: Uint8Array;
|
|
188
|
+
/** AEAD IV (often called "write_iv") for this direction. */
|
|
189
|
+
readonly iv: Uint8Array;
|
|
190
|
+
}
|
|
191
|
+
/** Full set of application traffic secrets for both directions after the handshake. */
|
|
192
|
+
export interface ApplicationTrafficSecrets {
|
|
193
|
+
readonly client: TrafficSecrets;
|
|
194
|
+
readonly server: TrafficSecrets;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The handshake phase at which the engine currently is — granular enough
|
|
198
|
+
* that a timeout or error names exactly which step was in progress. The
|
|
199
|
+
* consumer exposes it as `currentPhase` on the context for error attribution.
|
|
200
|
+
*/
|
|
201
|
+
export type HandshakePhase = "init" | "client_hello" | "server_hello" | "key_exchange" | "encrypted_extensions" | "certificate" | "certificate_verify" | "finished" | "client_finished" | "application";
|
|
202
|
+
/** Alert level of a TLS alert, per RFC 8446 §6. */
|
|
203
|
+
export type AlertLevel = "warning" | "fatal";
|
|
204
|
+
/**
|
|
205
|
+
* `TlsHandshakeContext` — the slice of consumer state the handshake engine
|
|
206
|
+
* reads and mutates while driving a handshake to completion.
|
|
207
|
+
*
|
|
208
|
+
* Implemented by the CONSUMER: quic's `QuicHandshakeContext` satisfies this
|
|
209
|
+
* structurally today (against tls's local `HandshakeContext`, whose shape is
|
|
210
|
+
* identical where it matters), which is why the fields are mutable — the
|
|
211
|
+
* engine mutates the context's negotiated parameters and secrets in place,
|
|
212
|
+
* and the consumer reads them after `runHandshake` resolves (quic then
|
|
213
|
+
* derives its QUIC packet-protection keys from the intermediate secrets).
|
|
214
|
+
* The full tls-local `HandshakeContext` type stays consumer/implementer-side;
|
|
215
|
+
* this is the contract-level structural description of the same surface.
|
|
216
|
+
*
|
|
217
|
+
* The `compression` field is deliberately the structural slice
|
|
218
|
+
* `{ brotliDecompress }` (RFC 8879 CompressedCertificate) rather than
|
|
219
|
+
* {@link CompressionProvider}: quic already declares it that way
|
|
220
|
+
* structurally, and it keeps this module decoupled from the compression
|
|
221
|
+
* contract. QUIC never advertises compress_certificate, so quic's value is
|
|
222
|
+
* always `undefined`.
|
|
223
|
+
*/
|
|
224
|
+
export interface TlsHandshakeContext {
|
|
225
|
+
/** The byte-stream transport the handshake runs over (e.g. QUIC stream 0). */
|
|
226
|
+
readonly transport: Transport;
|
|
227
|
+
/** Cryptographic provider, injected by the consumer (no default). */
|
|
228
|
+
crypto: CryptoProvider;
|
|
229
|
+
/**
|
|
230
|
+
* Brotli decompression for RFC 8879 CompressedCertificate (type 25).
|
|
231
|
+
* `undefined` when the consumer did not advertise compress_certificate —
|
|
232
|
+
* the server must then never send a compressed certificate.
|
|
233
|
+
*/
|
|
234
|
+
compression: {
|
|
235
|
+
brotliDecompress(data: Uint8Array): Uint8Array;
|
|
236
|
+
} | undefined;
|
|
237
|
+
/** Mutable: buffered bytes not yet consumed by the record framer. */
|
|
238
|
+
readBuffer: Uint8Array;
|
|
239
|
+
/** Mutable: running transcript of full handshake messages. */
|
|
240
|
+
readonly transcript: Uint8Array[];
|
|
241
|
+
/** Mutable: negotiated cipher suite plus the derived AEAD and hash. */
|
|
242
|
+
cipherSuite: CipherSuite;
|
|
243
|
+
aead: AeadAlgorithm;
|
|
244
|
+
hash: HashId;
|
|
245
|
+
/** Mutable: parsed ServerHello, set when it arrives. */
|
|
246
|
+
serverHello: ServerHello;
|
|
247
|
+
/** Mutable: handshake traffic secrets (per direction) and the raw secrets. */
|
|
248
|
+
clientHsTraffic: TrafficSecrets;
|
|
249
|
+
serverHsTraffic: TrafficSecrets;
|
|
250
|
+
clientHsTrafficSecret: Uint8Array;
|
|
251
|
+
serverHsTrafficSecret: Uint8Array;
|
|
252
|
+
masterSecret: Uint8Array;
|
|
253
|
+
/**
|
|
254
|
+
* Mutable: raw application traffic secrets, set when the engine derives
|
|
255
|
+
* them. Retained so the consumer can rotate keys on KeyUpdate
|
|
256
|
+
* (RFC 8446 §4.6.3) — and so quic can derive its 1-RTT keys.
|
|
257
|
+
*/
|
|
258
|
+
clientAppSecret: Uint8Array;
|
|
259
|
+
serverAppSecret: Uint8Array;
|
|
260
|
+
/** Mutable: handshake-direction record sequence counters. */
|
|
261
|
+
clientHsSeq: number;
|
|
262
|
+
serverHsSeq: number;
|
|
263
|
+
/** True once the handshake traffic secrets have been derived (sendAlert gate). */
|
|
264
|
+
hsTrafficReady: boolean;
|
|
265
|
+
/** Set when the server negotiates ALPN in EncryptedExtensions. */
|
|
266
|
+
alpnProtocol?: string | undefined;
|
|
267
|
+
/** Set to the validated leaf once the Certificate message is consumed. */
|
|
268
|
+
peerCertificate?: Certificate | undefined;
|
|
269
|
+
/** Mutable: the handshake phase currently in progress (error attribution). */
|
|
270
|
+
currentPhase: HandshakePhase;
|
|
271
|
+
/** Optional debug trace callback — one line before/after each I/O and crypto step. */
|
|
272
|
+
onDebug: ((msg: string) => void) | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* Send a TLS alert (RFC 8446 §6) to the peer. Best-effort. QUIC signals
|
|
275
|
+
* transport-level errors via CONNECTION_CLOSE (RFC 9001 §4.8), so its
|
|
276
|
+
* implementation is a no-op — the hook exists for TLS-over-TCP consumers.
|
|
277
|
+
*/
|
|
278
|
+
sendAlert(level: AlertLevel, description: number): Promise<void>;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* `TlsHandshakeEngine` — the injected TLS 1.3 handshake engine.
|
|
282
|
+
*
|
|
283
|
+
* Implemented by `@browsercore/tls` (wired at the composition root into
|
|
284
|
+
* quic's options); quic consumes this, never the tls package directly
|
|
285
|
+
* (no-hard-wires invariant). Each operation below is exactly the function
|
|
286
|
+
* quic's handshake orchestration calls on `@browsercore/tls` today —
|
|
287
|
+
* signatures lifted verbatim so the tls implementation satisfies this
|
|
288
|
+
* interface without adaptation.
|
|
289
|
+
*/
|
|
290
|
+
export interface TlsHandshakeEngine {
|
|
291
|
+
/**
|
|
292
|
+
* Drive the TLS 1.3 handshake to completion against `ctx`.
|
|
293
|
+
*
|
|
294
|
+
* The engine mutates the context's negotiated parameters and secrets
|
|
295
|
+
* (including the INTERMEDIATE handshake secrets quic needs for its key
|
|
296
|
+
* phases) and resolves with the final application traffic secrets.
|
|
297
|
+
*
|
|
298
|
+
* @param ctx Consumer-implemented state (see {@link TlsHandshakeContext}).
|
|
299
|
+
* @param config ClientHello configuration (the fingerprint offer).
|
|
300
|
+
* @param serverName SNI hostname (for SNI + certificate validation).
|
|
301
|
+
* @param trustAnchors Trust anchors (PEM/DER) for certificate validation.
|
|
302
|
+
* @param generateKeyShares Key-share generator — `(groups) => Promise<KeyPair[]>`;
|
|
303
|
+
* the consumer injects its crypto provider here
|
|
304
|
+
* (quic: `(groups) => engine.generateKeyShares(groups, crypto)`).
|
|
305
|
+
* @param now Current epoch SECONDS (injected so cert validation stays deterministic).
|
|
306
|
+
*/
|
|
307
|
+
runHandshake(ctx: TlsHandshakeContext, config: ClientHelloConfig, serverName: string, trustAnchors: readonly Uint8Array[], generateKeyShares: (groups: readonly string[]) => Promise<KeyPair[]>, now: number): Promise<ApplicationTrafficSecrets>;
|
|
308
|
+
/**
|
|
309
|
+
* Generate key shares for the requested groups (all offered groups,
|
|
310
|
+
* including post-quantum hybrids). Delegates to the injected crypto
|
|
311
|
+
* provider; quic wraps this into its `runHandshake` callback.
|
|
312
|
+
*/
|
|
313
|
+
generateKeyShares(groups: readonly string[], crypto: CryptoProvider): Promise<KeyPair[]>;
|
|
314
|
+
/** Map a TLS cipher suite to its AEAD algorithm (exhaustive over TLS 1.3 suites). */
|
|
315
|
+
cipherSuiteToAead(cipherSuite: CipherSuite): AeadAlgorithm;
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=tls-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls-engine.d.ts","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChE,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C;IACxB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,0EAA0E;IAC1E,eAAe,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,8EAA8E;IAC9E,YAAY,EAAE,cAAc,CAAC;IAC7B,sFAAsF;IACtF,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC7C;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE;AAMD;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CACR,GAAG,EAAE,mBAAmB,EACxB,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,SAAS,UAAU,EAAE,EACnC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,EACpE,GAAG,EAAE,MAAM,GACZ,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAEtC;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEzF,qFAAqF;IACrF,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,CAAC;CAC9D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS handshake engine contracts — the seam that lets QUIC drive a TLS
|
|
3
|
+
* handshake without importing `@browsercore/tls`.
|
|
4
|
+
*
|
|
5
|
+
* Why this module exists (replaceability audit 2026-11-16, remediation
|
|
6
|
+
* item #2): `@browsercore/quic` RUNTIME-EMBEDS the tls handshake engine —
|
|
7
|
+
* `runHandshake` / `generateKeyShares` / `cipherSuiteToAead` plus twelve
|
|
8
|
+
* types imported directly from `@browsercore/tls`
|
|
9
|
+
* (`quic/src/handshake/quic-handshake.ts`) — the one true protocol→protocol
|
|
10
|
+
* engine coupling in the stack, and the only violation of the no-hard-wires
|
|
11
|
+
* invariant ("protocol packages must never import each other directly; all
|
|
12
|
+
* inter-package communication flows through Platform interfaces defined in
|
|
13
|
+
* @browsercore/contracts").
|
|
14
|
+
*
|
|
15
|
+
* The fix shape: `@browsercore/tls` implements
|
|
16
|
+
* {@link TlsHandshakeEngine} and the composition root (browsersmith) injects
|
|
17
|
+
* it into quic via options, exactly like crypto/transport/events — quic
|
|
18
|
+
* consumes this interface, never the tls package directly. The pattern is
|
|
19
|
+
* already proven end-to-end by http3's fake-quic compatibility test
|
|
20
|
+
* (`http3/tests/fake-quic.ts`): a local structural implementation satisfying
|
|
21
|
+
* the consumer's contract is the sanctioned way to swap an engine.
|
|
22
|
+
*
|
|
23
|
+
* Shape derivation: every operation and type below is exactly what quic
|
|
24
|
+
* CALLS and the data it passes/receives on the real code path
|
|
25
|
+
* (`quic-handshake.ts` imports `runHandshake`, `generateKeyShares`,
|
|
26
|
+
* `cipherSuiteToAead` and the types `AeadAlgorithm`, `CipherSuite`,
|
|
27
|
+
* `ClientHelloConfig`, `ServerHello`, `Certificate`, `TrafficSecrets`,
|
|
28
|
+
* `HandshakeContext`, `HandshakePhase`, `AlertLevel`; `KeyPair` and
|
|
29
|
+
* `ApplicationTrafficSecrets` ride along as the callback/return data).
|
|
30
|
+
* Division of labor: quic implements the context itself (its
|
|
31
|
+
* `QuicHandshakeContext` — the consumer-side SPI), so
|
|
32
|
+
* {@link TlsHandshakeContext} here describes only the structural data
|
|
33
|
+
* surface the engine reads and mutates; the engine implements
|
|
34
|
+
* {@link TlsHandshakeEngine}. `HandshakeContext` AS A TYPE stays
|
|
35
|
+
* consumer-side (quic's class keeps implementing it structurally); nothing
|
|
36
|
+
* here is a class or carries runtime behavior.
|
|
37
|
+
*
|
|
38
|
+
* All shapes are pure data / function signatures — no runtime, no node:*.
|
|
39
|
+
*/
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=tls-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls-engine.js","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG"}
|