@browsercore/contracts 0.2.6 → 0.2.8
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 +68 -30
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tls-engine.d.ts +51 -3
- package/dist/tls-engine.d.ts.map +1 -1
- package/dist/tls-engine.js +6 -1
- package/dist/tls-engine.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# @browsercore/contracts
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@browsercore/contracts)
|
|
4
|
-
[](https://github.com/jverneuer/browsercore-contracts/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/jverneuer/browsercore-contracts/actions/workflows/ci.yml)
|
|
6
5
|
|
|
7
6
|
The canonical interface package for the browsercore stack. Every protocol
|
|
8
|
-
package, runtime adapter, and consumer depends on these contracts
|
|
7
|
+
package, runtime adapter, and consumer depends on these contracts; they
|
|
9
8
|
define how components communicate without coupling them to each other. As of
|
|
10
9
|
0.2.5 this is the canonical single definition for `Transport`,
|
|
11
10
|
`CryptoProvider`, and `CompressionProvider` (the implementing packages
|
|
@@ -16,7 +15,13 @@ telemetry, network). As of 0.2.6: every `Platform` bundle is **optional**
|
|
|
16
15
|
sibling-local shapes), `TlsHandshakeEngine` is the contracts-level seam that
|
|
17
16
|
lets quic drive a TLS handshake without importing `@browsercore/tls`, and the
|
|
18
17
|
`ProxyConfig` family / `ProfileId` / `CookieJarConsumer` config types have
|
|
19
|
-
their canonical homes here (owning packages alias next wave).
|
|
18
|
+
their canonical homes here (owning packages alias next wave). As of 0.2.8 the
|
|
19
|
+
certificate mirror is canonical too: `CertificateSignatureAlgorithm` (and
|
|
20
|
+
`Certificate.selfSigned`) land here, and tls 0.4.19 imports and re-exports
|
|
21
|
+
this type from `@browsercore/contracts` (earlier tls versions declared a
|
|
22
|
+
structurally identical local union) — one definition, not a second
|
|
23
|
+
`Certificate` beside the engine contract.
|
|
24
|
+
Deliberately
|
|
20
25
|
package-local surfaces that remain duplicated (e.g. the full `CookieJar`)
|
|
21
26
|
are documented as such at each definition.
|
|
22
27
|
|
|
@@ -30,9 +35,9 @@ cross-package interface here, a type error becomes a compile error the moment
|
|
|
30
35
|
any package diverges.
|
|
31
36
|
|
|
32
37
|
**Alternative implementations welcome.** The contracts define exactly what a
|
|
33
|
-
component must satisfy
|
|
38
|
+
component must satisfy, nothing more. Want to write a different transport?
|
|
34
39
|
Implement `Transport`. A different crypto backend? Implement
|
|
35
|
-
`CryptoProvider` (synchronous
|
|
40
|
+
`CryptoProvider` (synchronous; WebCrypto cannot satisfy it, see
|
|
36
41
|
[docs/design-decisions.md](docs/design-decisions.md) for why that is
|
|
37
42
|
deliberate and what an async future would cost). A
|
|
38
43
|
different runtime (Bun, Deno, Workers)? Implement the `Platform` service
|
|
@@ -46,7 +51,7 @@ and plain data.
|
|
|
46
51
|
## Architecture
|
|
47
52
|
|
|
48
53
|
```
|
|
49
|
-
@browsercore/contracts (this package
|
|
54
|
+
@browsercore/contracts (this package: interfaces, services, models)
|
|
50
55
|
▲
|
|
51
56
|
│
|
|
52
57
|
┌──────┼─────────────────────────────┐
|
|
@@ -56,10 +61,10 @@ transport tls http1 http2 http3 quic fetch crypto compression
|
|
|
56
61
|
│ │ │ │ │ │ │ │ │
|
|
57
62
|
└─────────┴──────┴───────┴───────┴───────┴───────┴────────┴─────────┘
|
|
58
63
|
▼
|
|
59
|
-
browsersmith (composition root
|
|
64
|
+
browsersmith (composition root, builds Platform)
|
|
60
65
|
```
|
|
61
66
|
|
|
62
|
-
Dependency direction is strictly upward
|
|
67
|
+
Dependency direction is strictly upward; contracts is the root dependency.
|
|
63
68
|
`browsersmith` is the **only** package allowed `node:*` imports; it builds a
|
|
64
69
|
`Platform` object that threads runtime capabilities (network, crypto,
|
|
65
70
|
compression, events, telemetry, time) down through options.
|
|
@@ -68,11 +73,11 @@ compression, events, telemetry, time) down through options.
|
|
|
68
73
|
|
|
69
74
|
| Module | Purpose | Key exports |
|
|
70
75
|
|---|---|---|
|
|
71
|
-
| **Contracts** | Canonical provider interfaces
|
|
72
|
-
| **Platform** | The composition root + per-service bundles
|
|
76
|
+
| **Contracts** | Canonical provider interfaces, the single definitions the implementing packages re-export | `CryptoProvider`, `CompressionProvider`, `Transport`, `DatagramTransport`, `UdpSocketFactory`, `CookieJar`, `PacketCallback` |
|
|
77
|
+
| **Platform** | The composition root + per-service bundles, **every bundle optional** | `Platform`, `PlatformOptions`, `Network`, `Crypto`, `Compression` |
|
|
73
78
|
| **Events** | Structural emitter interface (a method surface, **not** EventTarget-backed) injected via `Platform.events` | `EventProvider`, `TypedEventEmitter<T>` |
|
|
74
79
|
| **Time** | THE canonical Clock (wall + monotonic + sleep + timers) and the Duration/Scheduler helpers | `Clock`, `TimerHandle`, `Time`, `Duration`, `Scheduler`, `Deadline` |
|
|
75
|
-
| **TLS Engine** | The quic↔tls handshake seam
|
|
80
|
+
| **TLS Engine** | The quic↔tls handshake seam; protocol packages never import each other | `TlsHandshakeEngine`, `TlsHandshakeContext`, `ClientHelloConfig`, `ServerHello`, `Certificate`, `CertificateSignatureAlgorithm`, `CipherSuite`, `NamedGroup`, `SignatureScheme`, `AeadAlgorithm`, `ProtocolVersion`, `KeyPair`, `TrafficSecrets`, `ApplicationTrafficSecrets`, `HandshakePhase`, `AlertLevel` |
|
|
76
81
|
| **Config** | Canonical configuration types (owning packages alias next wave) | `ProxyConfig`, `ProxyScheme`, `ProxyTarget`, `ProxyCredentials`, `CookieJarConsumer` |
|
|
77
82
|
| **Telemetry** | OTel-aligned observability | `Logger`, `Tracer`, `Span`, `Metrics`, `Telemetry` |
|
|
78
83
|
| **Models** | Shared data structures that cross package boundaries | `BrowserProfile`, `TlsProfile`, `Http1Profile`, `Http2Profile`, `ProfileId`, `Request`, `Response`, `Headers`, `Cookie`, `TransportState`, `CloseReason`, `ContentEncoding` |
|
|
@@ -82,7 +87,7 @@ compression, events, telemetry, time) down through options.
|
|
|
82
87
|
The former "Protocol Connection Contracts" (`TlsConnection`, `Http1Connection`,
|
|
83
88
|
`Http2Connection`, `Http3Connection`, `QuicConnection`, `QuicStream`,
|
|
84
89
|
`FetchClient`) and the Options layer (`TlsOptions` … `FetchClientOptions`) were
|
|
85
|
-
removed in 0.2.5
|
|
90
|
+
removed in 0.2.5. They had zero consumers, since every consumer binds the
|
|
86
91
|
implementation-local types exported by the protocol packages themselves
|
|
87
92
|
(replaceability audit, 2026-11-16). `Transport` and `CryptoProvider` here are
|
|
88
93
|
now the canonical single definitions that `@browsercore/transport` and
|
|
@@ -90,36 +95,36 @@ now the canonical single definitions that `@browsercore/transport` and
|
|
|
90
95
|
|
|
91
96
|
## Platform semantics (0.2.6)
|
|
92
97
|
|
|
93
|
-
**Every `Platform` bundle is optional**
|
|
94
|
-
`compression?`, `events?`, `telemetry?`, `time?`
|
|
98
|
+
**Every `Platform` bundle is optional** (`network?`, `crypto?`,
|
|
99
|
+
`compression?`, `events?`, `telemetry?`, `time?`), and every `Network`
|
|
95
100
|
member is optional (`tcp?`, `dns?`, `udp?`). A platform carries exactly the
|
|
96
101
|
capabilities its runtime has; nothing has to be faked. The contract is:
|
|
97
102
|
|
|
98
103
|
- **Consumers resolve what they use and throw typed errors naming the
|
|
99
104
|
missing capability.** `@browsercore/fetch`'s `proxyDialPlatform`
|
|
100
105
|
(`fetch/src/proxy.ts`) demonstrated the pattern while the fields were
|
|
101
|
-
still required
|
|
106
|
+
still required; untouched bundles were throwing getters naming the
|
|
102
107
|
culprit. With optional bundles the same guarantee is expressed by
|
|
103
108
|
omitting the field, and consumers write
|
|
104
109
|
`platform.network?.tcp ?? throw missingCapability("platform.network.tcp")`.
|
|
105
|
-
- **Implementers may provide everything
|
|
110
|
+
- **Implementers may provide everything**: an implementation providing
|
|
106
111
|
more than a consumer requires (e.g. `browsersmith`'s `createPlatform()`)
|
|
107
112
|
always satisfies the interface. Optionality removes the obligation to
|
|
108
113
|
fake capabilities, never the permission to supply them.
|
|
109
114
|
|
|
110
115
|
**UDP is a factory, not an instance.** `Network.udp` is a
|
|
111
|
-
`UdpSocketFactory
|
|
116
|
+
`UdpSocketFactory`: `connect(address)` returns a per-connection
|
|
112
117
|
`DatagramTransport`. The previous instance shape (`udp: DatagramTransport`)
|
|
113
118
|
forced the composition root to bind one socket at module-import time
|
|
114
|
-
(browsersmith's import-time `createSocket("udp4")` singleton
|
|
119
|
+
(browsersmith's import-time `createSocket("udp4")` singleton,
|
|
115
120
|
replaceability audit, 2026-11-16). A factory binds sockets at connection
|
|
116
121
|
time, per connection, and lets UDP-less runtimes (Cloudflare Workers) omit
|
|
117
122
|
the capability instead of dead-binding a socket.
|
|
118
123
|
|
|
119
124
|
**`Clock` is THE time contract.** `now()` (wall, epoch ms),
|
|
120
|
-
`monotonic()` (monotonic ms
|
|
125
|
+
`monotonic()` (monotonic ms; never `Date.now()` deltas for deadline math),
|
|
121
126
|
`sleep(ms)`, `setTimeout(ms, fn)` / `clearTimeout(handle)` with
|
|
122
|
-
`TimerHandle` an opaque `object` (not `NodeJS.Timeout
|
|
127
|
+
`TimerHandle` an opaque `object` (not `NodeJS.Timeout`; runtime timer
|
|
123
128
|
tokens must not leak into published declarations). It supersedes the five
|
|
124
129
|
package-local sibling Clock shapes (tls/http1/http2/http3/quic), whose
|
|
125
130
|
`options.clock` seams migrate onto it in the next wave. `Time` remains as
|
|
@@ -127,18 +132,51 @@ the `Platform` bundle name aliasing `Clock`; `Duration`/`Scheduler`/
|
|
|
127
132
|
`Deadline` stay for duration-composed scheduling.
|
|
128
133
|
|
|
129
134
|
**`TlsHandshakeEngine` is the quic↔tls seam.** Protocol packages never
|
|
130
|
-
import each other (the no-hard-wires invariant); this interface
|
|
135
|
+
import each other (the no-hard-wires invariant); this interface,
|
|
131
136
|
`runHandshake` / `generateKeyShares` / `cipherSuiteToAead` plus the pure
|
|
132
|
-
handshake data types
|
|
137
|
+
handshake data types, is what `@browsercore/tls` implements and the
|
|
133
138
|
composition root injects into quic, replacing quic's direct tls imports
|
|
134
139
|
(the audit's single no-hard-wires violation). http3's fake-quic
|
|
135
140
|
compatibility test is the proof-of-concept for swapping a structural engine
|
|
136
141
|
implementation.
|
|
137
142
|
|
|
143
|
+
**`Certificate.signatureAlgorithm` is a discriminated union (0.2.8,
|
|
144
|
+
breaking).** The engine's certificate mirror previously carried
|
|
145
|
+
`signatureScheme: SignatureScheme`, and the tls parser threw for every
|
|
146
|
+
signature algorithm outside four hardcoded OIDs — making servers presenting
|
|
147
|
+
SHA-384/512 RSA, ECDSA-SHA512, Ed25519, or RSA-PSS certificates unreachable.
|
|
148
|
+
tls 0.4.19 fixed that by never throwing on a structurally valid certificate:
|
|
149
|
+
parsing always succeeds, and `CertificateSignatureAlgorithm` records the
|
|
150
|
+
outcome — `{ kind: "supported", scheme }` when the OID maps to a scheme the
|
|
151
|
+
engine can verify, or `{ kind: "rejected", reason: "sha1" | "md5" |
|
|
152
|
+
"pss-parameters" | "unknown", oid }` naming the policy reason and the
|
|
153
|
+
dotted-arc OID when policy declines it. Acceptance is the ENGINE's decision,
|
|
154
|
+
not the parser's — matching Chrome, which parses SHA-1-signed roots but
|
|
155
|
+
refuses to rely on them. The mirror also gained `Certificate.selfSigned`
|
|
156
|
+
(true when the subject DN bytes equal the issuer DN bytes). This is a
|
|
157
|
+
breaking type change for consumers reading `peerCertificate.signatureScheme`:
|
|
158
|
+
migrate by switching on `peerCertificate.signatureAlgorithm.kind` —
|
|
159
|
+
`"supported"` reads `.scheme` where `signatureScheme` used to be read;
|
|
160
|
+
`"rejected"` surfaces `.reason`/`.oid` instead of a thrown error:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
import type { Certificate } from "@browsercore/contracts";
|
|
164
|
+
|
|
165
|
+
/** `kind` narrows the union; the exhaustive switch needs no default arm. */
|
|
166
|
+
function describeIssuerSignature(certificate: Certificate): string {
|
|
167
|
+
switch (certificate.signatureAlgorithm.kind) {
|
|
168
|
+
case "supported":
|
|
169
|
+
return `signed with ${certificate.signatureAlgorithm.scheme}`;
|
|
170
|
+
case "rejected":
|
|
171
|
+
return `refusing ${certificate.signatureAlgorithm.reason} (${certificate.signatureAlgorithm.oid})`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
138
176
|
**Canonical config homes.** `ProxyConfig`/`ProxyScheme`/`ProxyTarget`/
|
|
139
177
|
`ProxyCredentials` (verbatim from `@browsercore/proxy`), `ProfileId` (the
|
|
140
178
|
ten built-in registry ids), and `CookieJarConsumer` (the minimal jar surface
|
|
141
|
-
fetch actually calls
|
|
179
|
+
fetch actually calls; `@browsercore/cookies`' full jar satisfies it
|
|
142
180
|
structurally) are defined here as canonical; the owning packages alias onto
|
|
143
181
|
them in the next wave.
|
|
144
182
|
|
|
@@ -155,7 +193,7 @@ future would cost) lives in
|
|
|
155
193
|
import type { Net, DnsResolver, Transport, BrowserProfile } from "@browsercore/contracts";
|
|
156
194
|
```
|
|
157
195
|
|
|
158
|
-
Type imports are erased at compile time
|
|
196
|
+
Type imports are erased at compile time, zero runtime cost.
|
|
159
197
|
|
|
160
198
|
### Importing wire code tables (runtime)
|
|
161
199
|
|
|
@@ -172,7 +210,7 @@ const x25519 = NAMED_GROUP_CODES["x25519"]; // 0x001d
|
|
|
172
210
|
import type { Transport, TransportState, CloseReason } from "@browsercore/contracts";
|
|
173
211
|
|
|
174
212
|
class MyCustomTransport implements Transport {
|
|
175
|
-
// Implement the interface
|
|
213
|
+
// Implement the interface and the rest of the stack works unchanged
|
|
176
214
|
}
|
|
177
215
|
```
|
|
178
216
|
|
|
@@ -191,19 +229,19 @@ class MyCustomTransport implements Transport {
|
|
|
191
229
|
4. **Branded types live in the implementing packages.** Opaque ID brands
|
|
192
230
|
(`TransportId` in transport, `ConnectionId` in quic, `CryptoSessionId` in
|
|
193
231
|
crypto) are defined per-package and stay assignable to the plain
|
|
194
|
-
`string`/`number` fields here. Contracts itself ships plain aliases
|
|
232
|
+
`string`/`number` fields here. Contracts itself ships plain aliases:
|
|
195
233
|
`ProfileId` is a plain `string`, not a brand.
|
|
196
234
|
|
|
197
235
|
5. **Discriminated unions for state.** `TransportState`, `CloseReason`,
|
|
198
|
-
`TlsState` model every valid state explicitly
|
|
236
|
+
`TlsState` model every valid state explicitly, invalid combinations
|
|
199
237
|
are unrepresentable.
|
|
200
238
|
|
|
201
239
|
## Zero overhead
|
|
202
240
|
|
|
203
241
|
All type exports are erased by the TypeScript compiler. The only runtime
|
|
204
|
-
exports are the IANA wire code tables and `Duration` factories
|
|
242
|
+
exports are the IANA wire code tables and `Duration` factories, plain
|
|
205
243
|
`const` objects with no dependencies, no side effects.
|
|
206
244
|
|
|
207
245
|
## Contributing
|
|
208
246
|
|
|
209
|
-
Contributions are welcome
|
|
247
|
+
Contributions are welcome: bug reports, reproductions, docs and code alike. Start with [CONTRIBUTING.md](CONTRIBUTING.md); the full guide lives in the [browsersmith repo](https://github.com/jverneuer/browsersmith/blob/main/CONTRIBUTING.md). First timer? Check the [`good first issue`](https://github.com/jverneuer/browsercore-contracts/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label. Security issues: [SECURITY.md](SECURITY.md), never a public issue.
|
package/dist/index.d.ts
CHANGED
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
* browsersmith (composition root — builds & threads Platform)
|
|
24
24
|
*/
|
|
25
25
|
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, UdpSocketFactory, 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";
|
|
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";
|
|
29
|
+
export type { AeadAlgorithm, CipherSuite, NamedGroup, SignatureScheme, CertificateSignatureAlgorithm, ProtocolVersion, ClientHelloConfig, ServerHello, Certificate, KeyPair, TrafficSecrets, ApplicationTrafficSecrets, HandshakePhase, AlertLevel, TlsHandshakeContext, TlsHandshakeEngine, } from "./tls-engine.js";
|
|
30
30
|
export type { ProxyScheme, ProxyConfig, ProxyTarget, ProxyCredentials, CookieJarConsumer, } from "./config.js";
|
|
31
31
|
export type { EventProvider, TypedEventEmitter, } from "./events.js";
|
|
32
32
|
export type { Logger, Span, Tracer, Metrics, Telemetry, } from "./telemetry.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,EACjB,gBAAgB,EAEhB,SAAS,EAET,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,
|
|
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,EAGf,6BAA6B,EAC7B,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;AAwFrB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAarC,8EAA8E;AAC9E,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,qCAAqC"}
|
package/dist/tls-engine.d.ts
CHANGED
|
@@ -26,7 +26,12 @@
|
|
|
26
26
|
* `cipherSuiteToAead` and the types `AeadAlgorithm`, `CipherSuite`,
|
|
27
27
|
* `ClientHelloConfig`, `ServerHello`, `Certificate`, `TrafficSecrets`,
|
|
28
28
|
* `HandshakeContext`, `HandshakePhase`, `AlertLevel`; `KeyPair` and
|
|
29
|
-
* `ApplicationTrafficSecrets` ride along as the callback/return data
|
|
29
|
+
* `ApplicationTrafficSecrets` ride along as the callback/return data;
|
|
30
|
+
* `CertificateSignatureAlgorithm` (0.2.8) rides along inside `Certificate`
|
|
31
|
+
* — this file is its canonical home (code-standards §22): tls 0.4.19
|
|
32
|
+
* imports and re-exports this type from `@browsercore/contracts`; earlier
|
|
33
|
+
* tls versions declared a structurally identical local union. It lives here
|
|
34
|
+
* because it sits on the `Certificate` shape quic receives).
|
|
30
35
|
* Division of labor: quic implements the context itself (its
|
|
31
36
|
* `QuicHandshakeContext` — the consumer-side SPI), so
|
|
32
37
|
* {@link TlsHandshakeContext} here describes only the structural data
|
|
@@ -55,6 +60,37 @@ export type CipherSuite = "TLS_GREASE_RESERVED_0" | "TLS_AES_128_GCM_SHA256" | "
|
|
|
55
60
|
export type NamedGroup = "secp256r1" | "secp384r1" | "secp521r1" | "x25519" | "x448" | "ffdhe2048" | "ffdhe3072" | "X25519MLKEM768" | "X25519Kyber768";
|
|
56
61
|
/** Signature algorithms accepted in CertificateVerify (IANA canonical names). */
|
|
57
62
|
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";
|
|
63
|
+
/**
|
|
64
|
+
* The signature algorithm carried on a parsed certificate, as a
|
|
65
|
+
* discriminated union. Canonical here since 0.2.8: `@browsercore/tls` 0.4.19
|
|
66
|
+
* imports and re-exports this type from `@browsercore/contracts` (earlier
|
|
67
|
+
* tls versions declared a structurally identical local union).
|
|
68
|
+
*
|
|
69
|
+
* Why a union instead of a plain scheme name: certificate parsing used to
|
|
70
|
+
* THROW for every signature algorithm outside a handful of hardcoded OIDs,
|
|
71
|
+
* which made servers presenting SHA-384/512 RSA, ECDSA-SHA512, Ed25519 or
|
|
72
|
+
* RSA-PSS certificates unreachable. Now parsing succeeds for EVERY
|
|
73
|
+
* structurally valid certificate; whether a given signature algorithm is
|
|
74
|
+
* ACCEPTED is the engine's policy decision, not the parser's — matching
|
|
75
|
+
* Chrome, which parses SHA-1-signed roots but refuses to rely on them.
|
|
76
|
+
*
|
|
77
|
+
* - `supported`: the OID mapped to a {@link SignatureScheme} the engine
|
|
78
|
+
* knows how to verify.
|
|
79
|
+
* - `rejected`: the OID parsed but policy declines it; `reason` names why
|
|
80
|
+
* (`sha1` / `md5` — cryptographically broken, `pss-parameters` —
|
|
81
|
+
* RSA-PSS with parameters the engine does not accept, `unknown` — no
|
|
82
|
+
* mapping for the OID) and `oid` carries the dotted-arc algorithm OID for
|
|
83
|
+
* diagnostics and telemetry.
|
|
84
|
+
*/
|
|
85
|
+
export type CertificateSignatureAlgorithm = {
|
|
86
|
+
readonly kind: "supported";
|
|
87
|
+
readonly scheme: SignatureScheme;
|
|
88
|
+
} | {
|
|
89
|
+
readonly kind: "rejected";
|
|
90
|
+
readonly reason: "sha1" | "md5" | "pss-parameters" | "unknown";
|
|
91
|
+
/** Dotted-arc OID of the signature algorithm that was rejected. */
|
|
92
|
+
readonly oid: string;
|
|
93
|
+
};
|
|
58
94
|
/**
|
|
59
95
|
* A TLS protocol version — name plus IANA wire code as a discriminated pair
|
|
60
96
|
* (the wire code is what the supported_versions extension carries).
|
|
@@ -160,14 +196,26 @@ export interface Certificate {
|
|
|
160
196
|
readonly keyUsageDigitalSignature: boolean;
|
|
161
197
|
/** True if the certificate has the keyUsage bit for key encipherment/agreement. */
|
|
162
198
|
readonly keyUsageKeyEncipherment: boolean;
|
|
163
|
-
/**
|
|
164
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Signature algorithm used by the issuer over the TBSCertificate.
|
|
201
|
+
* Parsing never throws on an unrecognized algorithm — `rejected` names
|
|
202
|
+
* the policy reason and acceptance is the engine's decision (see
|
|
203
|
+
* {@link CertificateSignatureAlgorithm}). Replaces the former
|
|
204
|
+
* `signatureScheme: SignatureScheme` field (0.2.8, breaking).
|
|
205
|
+
*/
|
|
206
|
+
readonly signatureAlgorithm: CertificateSignatureAlgorithm;
|
|
165
207
|
/** Raw signature value from the issuer. */
|
|
166
208
|
readonly signatureValue: Uint8Array;
|
|
167
209
|
/** DER-encoded SubjectPublicKeyInfo of the issuer (for chain building). */
|
|
168
210
|
readonly issuer: string;
|
|
169
211
|
/** True for a CA certificate. */
|
|
170
212
|
readonly isCa: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* True when the subject DN bytes equal the issuer DN bytes — a
|
|
215
|
+
* self-issued certificate whose trust rests on being a local trust
|
|
216
|
+
* anchor rather than a chain.
|
|
217
|
+
*/
|
|
218
|
+
readonly selfSigned: boolean;
|
|
171
219
|
}
|
|
172
220
|
/**
|
|
173
221
|
* A key share for one named group — the data `generateKeyShares` returns.
|
package/dist/tls-engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tls-engine.d.ts","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tls-engine.d.ts","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAY1C,8FAA8F;AAC9F,MAAM,MAAM,aAAa,GACnB,aAAa,GACb,aAAa,GACb,aAAa,GACb,mBAAmB,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GACjB,uBAAuB,GACvB,wBAAwB,GACxB,wBAAwB,GACxB,8BAA8B,GAC9B,wBAAwB,GACxB,yCAAyC,GACzC,uCAAuC,GACvC,yCAAyC,GACzC,uCAAuC,GACvC,+CAA+C,GAC/C,6CAA6C,GAC7C,oCAAoC,GACpC,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E,MAAM,CAAC;IACpB,kFAAkF;IAClF,cAAc,EAAE,OAAO,CAAC;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"}
|
package/dist/tls-engine.js
CHANGED
|
@@ -26,7 +26,12 @@
|
|
|
26
26
|
* `cipherSuiteToAead` and the types `AeadAlgorithm`, `CipherSuite`,
|
|
27
27
|
* `ClientHelloConfig`, `ServerHello`, `Certificate`, `TrafficSecrets`,
|
|
28
28
|
* `HandshakeContext`, `HandshakePhase`, `AlertLevel`; `KeyPair` and
|
|
29
|
-
* `ApplicationTrafficSecrets` ride along as the callback/return data
|
|
29
|
+
* `ApplicationTrafficSecrets` ride along as the callback/return data;
|
|
30
|
+
* `CertificateSignatureAlgorithm` (0.2.8) rides along inside `Certificate`
|
|
31
|
+
* — this file is its canonical home (code-standards §22): tls 0.4.19
|
|
32
|
+
* imports and re-exports this type from `@browsercore/contracts`; earlier
|
|
33
|
+
* tls versions declared a structurally identical local union. It lives here
|
|
34
|
+
* because it sits on the `Certificate` shape quic receives).
|
|
30
35
|
* Division of labor: quic implements the context itself (its
|
|
31
36
|
* `QuicHandshakeContext` — the consumer-side SPI), so
|
|
32
37
|
* {@link TlsHandshakeContext} here describes only the structural data
|
package/dist/tls-engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tls-engine.js","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tls-engine.js","sourceRoot":"","sources":["../src/tls-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG"}
|