@browsercore/contracts 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tcp-transport.d.ts +18 -0
- package/dist/tcp-transport.d.ts.map +1 -1
- package/dist/tls-session.d.ts +169 -0
- package/dist/tls-session.d.ts.map +1 -0
- package/dist/tls-session.js +51 -0
- package/dist/tls-session.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,10 +78,11 @@ compression, events, telemetry, time) down through options.
|
|
|
78
78
|
| **Events** | Structural emitter interface (a method surface, **not** EventTarget-backed) injected via `Platform.events` | `EventProvider`, `TypedEventEmitter<T>` |
|
|
79
79
|
| **Time** | THE canonical Clock (wall + monotonic + sleep + timers) and the Duration/Scheduler helpers | `Clock`, `TimerHandle`, `Time`, `Duration`, `Scheduler`, `Deadline` |
|
|
80
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` |
|
|
81
|
+
| **TLS Session** | The tls↔browsersmith resumption seam: one ticket record per NewSessionTicket and the string-keyed (SNI) ticket store browsersmith implements and tls consumes; sync by design, `get` never consumes — the caller pops via `delete` | `TlsSessionStore`, `TlsResumptionTicket` |
|
|
81
82
|
| **Config** | Canonical configuration types (owning packages alias next wave) | `ProxyConfig`, `ProxyScheme`, `ProxyTarget`, `ProxyCredentials`, `CookieJarConsumer` |
|
|
82
83
|
| **Telemetry** | OTel-aligned observability | `Logger`, `Tracer`, `Span`, `Metrics`, `Telemetry` |
|
|
83
84
|
| **Models** | Shared data structures that cross package boundaries | `BrowserProfile`, `TlsProfile`, `Http1Profile`, `Http2Profile`, `ProfileId`, `Request`, `Response`, `Headers`, `Cookie`, `TransportState`, `CloseReason`, `ContentEncoding` |
|
|
84
|
-
| **Net** | Platform-agnostic TCP + DNS contracts for runtime portability | `Net`, `DnsResolver`, `Socket`, `ConnectOptions`, `IPAddress` |
|
|
85
|
+
| **Net** | Platform-agnostic TCP + DNS contracts for runtime portability (`DnsResolver.lookupAll?` — optional single dual-family lookup) | `Net`, `DnsResolver`, `Socket`, `ConnectOptions`, `IPAddress` |
|
|
85
86
|
| **IANA Tables** | Canonical TLS wire code lookup tables (single source of truth) | `CIPHER_SUITE_CODES`, `NAMED_GROUP_CODES`, `SIGNATURE_SCHEME_CODES`, `VERSION_CODES` |
|
|
86
87
|
|
|
87
88
|
The former "Protocol Connection Contracts" (`TlsConnection`, `Http1Connection`,
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export type { ProfileId, RegisteredProfileId, BrowserProfile, TlsProfile, Http1P
|
|
|
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
29
|
export type { AeadAlgorithm, CipherSuite, NamedGroup, SignatureScheme, CertificateSignatureAlgorithm, ProtocolVersion, ClientHelloConfig, ServerHello, Certificate, KeyPair, TrafficSecrets, ApplicationTrafficSecrets, HandshakePhase, AlertLevel, TlsHandshakeContext, TlsHandshakeEngine, } from "./tls-engine.js";
|
|
30
|
+
export type { TlsResumptionTicket, TlsSessionStore, } from "./tls-session.js";
|
|
30
31
|
export type { ProxyScheme, ProxyConfig, ProxyTarget, ProxyCredentials, CookieJarConsumer, } from "./config.js";
|
|
31
32
|
export type { EventProvider, TypedEventEmitter, } from "./events.js";
|
|
32
33
|
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,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"}
|
|
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,mBAAmB,EACnB,eAAe,GAClB,MAAM,kBAAkB,CAAC;AAM1B,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;AA4DH,8DAA8D;AAC9D,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;
|
|
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;AAiGrB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAarC,8EAA8E;AAC9E,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,qCAAqC"}
|
package/dist/tcp-transport.d.ts
CHANGED
|
@@ -78,6 +78,24 @@ export interface DnsResolver {
|
|
|
78
78
|
* @returns Resolved addresses (at least one).
|
|
79
79
|
*/
|
|
80
80
|
lookup(hostname: string, family: 4 | 6): Promise<readonly IPAddress[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve a hostname to EVERY address the resolver returns, both address
|
|
83
|
+
* families, in the resolver's own order — one system lookup where the
|
|
84
|
+
* platform performs one (e.g. Node's `dns.lookup` with `all: true` issues
|
|
85
|
+
* a single `getaddrinfo` call covering A and AAAA).
|
|
86
|
+
*
|
|
87
|
+
* Optional so existing implementations stay valid: resolvers that cannot
|
|
88
|
+
* enumerate both families in one call (per-family shims, the Workers
|
|
89
|
+
* edge passthrough) simply omit it, and callers fall back to pairing
|
|
90
|
+
* {@link lookup} calls. Implementers who CAN perform a single dual-family
|
|
91
|
+
* lookup should provide it — it lets transports resolve once, with the
|
|
92
|
+
* platform's native ordering, instead of issuing two family-specific
|
|
93
|
+
* lookups and stitching the results.
|
|
94
|
+
*
|
|
95
|
+
* @param hostname - DNS name to resolve.
|
|
96
|
+
* @returns Every resolved address, both families, resolver's own order.
|
|
97
|
+
*/
|
|
98
|
+
lookupAll?(hostname: string): Promise<readonly IPAddress[]>;
|
|
81
99
|
}
|
|
82
100
|
/**
|
|
83
101
|
* `Network` — the injected network bundle (part of `Platform`).
|
|
@@ -1 +1 @@
|
|
|
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,iDAA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,CAAC;CAC1B;AAED,kCAAkC;AAClC,MAAM,WAAW,WAAW;IACxB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;IACvE;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;CAC/D;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,OAAO;IACpB,mFAAmF;IACnF,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IACnB,mGAAmG;IACnG,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACnC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS session-resumption contracts — the ticket record and the ticket
|
|
3
|
+
* store seam between `@browsercore/tls` (consumer) and browsersmith
|
|
4
|
+
* (implementer).
|
|
5
|
+
*
|
|
6
|
+
* Why this module exists: PSK-based TLS 1.3 session resumption needs a
|
|
7
|
+
* ticket store whose lifecycle crosses a package boundary. `@browsercore/tls`
|
|
8
|
+
* consumes the store — it offers a valid stored ticket as the single PSK
|
|
9
|
+
* identity (Chrome 140 wire rules) and writes every received
|
|
10
|
+
* NewSessionTicket back — while browsersmith, the composition root, owns
|
|
11
|
+
* the concrete store, the opt-in flag, and the default-off policy. Both
|
|
12
|
+
* sides import these definitions from here (canonical-type rule,
|
|
13
|
+
* code-standards §22; litmus test: "Could another package reasonably
|
|
14
|
+
* import this type?"), so neither re-declares the shape and the two
|
|
15
|
+
* sides cannot drift. This is the same seam pattern as
|
|
16
|
+
* {@link ./tls-engine.js~TlsHandshakeEngine}: the implementing package
|
|
17
|
+
* satisfies the interface, the consuming package depends on it, the
|
|
18
|
+
* composition root injects it.
|
|
19
|
+
*
|
|
20
|
+
* Decisions this contract bakes in:
|
|
21
|
+
*
|
|
22
|
+
* - **The store key is the SNI serverName string.** That is all the TLS
|
|
23
|
+
* engine knows — the transport arrives already connected, carrying no
|
|
24
|
+
* proxy or privacy context. Chrome additionally partitions its cache by
|
|
25
|
+
* privacy mode, proxy chain, and network anonymization key
|
|
26
|
+
* (net:ssl_client_session_cache.h:44-62); a caller needing those
|
|
27
|
+
* partitions encodes them into its own key strings. The interface stays
|
|
28
|
+
* a plain `string`-keyed map.
|
|
29
|
+
* - **Synchronous by design.** The store is consulted at ClientHello
|
|
30
|
+
* build time, inside the handshake, and Chrome's cache lookup is
|
|
31
|
+
* synchronous too (net:ssl_client_session_cache.cc `Lookup`). An async
|
|
32
|
+
* interface would force every handshake to await before it can offer,
|
|
33
|
+
* for no benefit: the shipped store is an in-memory Map, and a
|
|
34
|
+
* persistent store can warm its in-memory mirror so lookups stay sync.
|
|
35
|
+
* - **Single-use pop lives in the caller, not the store.** Every TLS 1.3
|
|
36
|
+
* session is single-use (bssl:ssl_session.cc:955-957); Chrome removes
|
|
37
|
+
* the ticket atomically inside its cache at offer time, before the
|
|
38
|
+
* handshake outcome is known (`Entry::Pop`,
|
|
39
|
+
* net:ssl_client_session_cache.cc:151-160). This contract splits the
|
|
40
|
+
* read from the pop: `get` is side-effect-free so a caller can inspect
|
|
41
|
+
* the store without consuming — that inspectability, not Chrome parity
|
|
42
|
+
* (Chrome's Lookup pops), is the reason get is side-effect-free — and
|
|
43
|
+
* consumption is the explicit {@link TlsSessionStore.delete}, which
|
|
44
|
+
* carries the same-turn duty the split imposes (see `delete`).
|
|
45
|
+
*
|
|
46
|
+
* Pure data and signatures — no runtime, no node:* (design rule 2).
|
|
47
|
+
* `CipherSuite` is imported from `./tls-engine.js` for the ticket's
|
|
48
|
+
* PRF-hash guard; it stays exported from there, not re-exported here.
|
|
49
|
+
*/
|
|
50
|
+
import type { CipherSuite } from "./tls-engine.js";
|
|
51
|
+
/**
|
|
52
|
+
* `TlsSessionStore` — the cross-connection resumption ticket store.
|
|
53
|
+
*
|
|
54
|
+
* Browsersmith implements this (the shipped shape is an in-memory,
|
|
55
|
+
* Chrome-like LRU cache) and the TLS engine consumes it: when a store is
|
|
56
|
+
* present the engine offers a valid stored ticket as the single PSK
|
|
57
|
+
* identity and writes received NewSessionTickets back; with no store the
|
|
58
|
+
* ClientHello stays byte-identical to a non-resuming client. Exactly one
|
|
59
|
+
* ticket lives per key (newest wins) — TLS 1.3 tickets are single-use,
|
|
60
|
+
* so deeper per-key queues buy nothing; the engine pops at offer time
|
|
61
|
+
* and fresh tickets repopulate after each handshake. Keys are opaque to
|
|
62
|
+
* the contract: the engine keys by SNI serverName (see the module
|
|
63
|
+
* header for why, and for how richer partitions compose into the key).
|
|
64
|
+
*/
|
|
65
|
+
export interface TlsSessionStore {
|
|
66
|
+
/**
|
|
67
|
+
* Newest outstanding ticket for `key`, or undefined. NOT consumed by
|
|
68
|
+
* get — consumption is the explicit {@link TlsSessionStore.delete}
|
|
69
|
+
* below, so a caller can inspect the store without side effects. A
|
|
70
|
+
* caller that offers the ticket runs get and delete back-to-back in
|
|
71
|
+
* the same synchronous turn (see delete for why that pairing is on
|
|
72
|
+
* the caller).
|
|
73
|
+
*/
|
|
74
|
+
get(key: string): TlsResumptionTicket | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Store/replaces the ticket for `key` (newest wins). The engine calls
|
|
77
|
+
* this for every NewSessionTicket the server sends post-handshake.
|
|
78
|
+
*/
|
|
79
|
+
set(key: string, ticket: TlsResumptionTicket): void;
|
|
80
|
+
/**
|
|
81
|
+
* Remove the ticket for `key` (no-op if absent) — the offer-time pop.
|
|
82
|
+
* The engine deletes when it hands a ticket out, before the handshake
|
|
83
|
+
* outcome is known. The pop enforces single use only when delete runs
|
|
84
|
+
* back-to-back with the get that read the ticket, in the same
|
|
85
|
+
* synchronous turn: nothing in this interface pairs the two calls,
|
|
86
|
+
* so an `await` between them lets a second connection read the same
|
|
87
|
+
* single-use ticket and offer it twice (Chrome stays correct by
|
|
88
|
+
* popping inside its lookup — `Entry::Pop`,
|
|
89
|
+
* net:ssl_client_session_cache.cc:151-160).
|
|
90
|
+
*/
|
|
91
|
+
delete(key: string): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `TlsResumptionTicket` — one TLS 1.3 NewSessionTicket, canonicalized as
|
|
95
|
+
* the record the store keeps and the engine resumes from. The canonical
|
|
96
|
+
* home of the shape `@browsercore/tls` declares locally as
|
|
97
|
+
* `ResumptionTicket` (tls aliases the contracts type and keeps its old
|
|
98
|
+
* name as a deprecated alias — the same rename-free adoption contracts
|
|
99
|
+
* performed for `CertificateSignatureAlgorithm`), with the server's
|
|
100
|
+
* lifetime hint added. Its fields are exactly the wire record's
|
|
101
|
+
* resumption-relevant data (RFC 8446 §4.2.11/§4.6.1/§7.5). Deliberately
|
|
102
|
+
* absent: the ticket nonce (consumed at PSK-derivation time
|
|
103
|
+
* `HKDF-Expand-Label(resumption_master_secret, "resumption", nonce, …)`,
|
|
104
|
+
* never retained), the ALPN (freely renegotiated on a resumed connection
|
|
105
|
+
* without early data, so resumption must not pin it), and the server
|
|
106
|
+
* name (it is the store key, not a property of the record).
|
|
107
|
+
*/
|
|
108
|
+
export interface TlsResumptionTicket {
|
|
109
|
+
/**
|
|
110
|
+
* The opaque ticket identity bytes from the NewSessionTicket message.
|
|
111
|
+
* The client echoes them verbatim as the single PSK identity when it
|
|
112
|
+
* offers resumption (RFC 8446 §4.2.11) — opaque to the client, they
|
|
113
|
+
* are the server's sole lookup key.
|
|
114
|
+
*/
|
|
115
|
+
readonly ticket: Uint8Array;
|
|
116
|
+
/**
|
|
117
|
+
* The resumption pre-shared secret, derived as
|
|
118
|
+
* `HKDF-Expand-Label(resumption_master_secret, "resumption",
|
|
119
|
+
* ticket_nonce, Hash.length)` (RFC 8446 §7.5). The binder computation
|
|
120
|
+
* and the PSK key schedule consume it; it never crosses the wire.
|
|
121
|
+
* The record carries a live bearer secret: treat the whole record as
|
|
122
|
+
* sensitive — it is never logged, serialized, or persisted outside
|
|
123
|
+
* process memory.
|
|
124
|
+
*/
|
|
125
|
+
readonly psk: Uint8Array;
|
|
126
|
+
/**
|
|
127
|
+
* The server's u32 age-obfuscation addend from the NewSessionTicket.
|
|
128
|
+
* `obfuscated_ticket_age = (now - receivedAt) + ticketAgeAdd` (mod
|
|
129
|
+
* 2^32) is what the client places in the PSK identity, hiding the
|
|
130
|
+
* ticket's true age from observers (RFC 8446 §4.2.11).
|
|
131
|
+
*/
|
|
132
|
+
readonly ticketAgeAdd: number;
|
|
133
|
+
/**
|
|
134
|
+
* The cipher suite of the handshake that issued the ticket. The PSK
|
|
135
|
+
* derives from this suite's hash, so resumption is offered only while
|
|
136
|
+
* the offered suite's PRF hash matches it — the guard that drops the
|
|
137
|
+
* PSK from the second ClientHello when a HelloRetryRequest selects a
|
|
138
|
+
* different hash (bssl:extensions.cc:1883-1889).
|
|
139
|
+
*/
|
|
140
|
+
readonly cipherSuite: CipherSuite;
|
|
141
|
+
/**
|
|
142
|
+
* Epoch milliseconds at which the client received the ticket,
|
|
143
|
+
* stamped by the producer from its injected wall clock
|
|
144
|
+
* (code-standards §22), never from a bare `Date.now()`. Age and
|
|
145
|
+
* expiry math (`receivedAt + lifetime`) anchor on this value, and
|
|
146
|
+
* the one-second future wiggle (a back-dated ticket is rejected) is
|
|
147
|
+
* measured against it (net:ssl_client_session_cache.cc:126-137).
|
|
148
|
+
*/
|
|
149
|
+
readonly receivedAt: number;
|
|
150
|
+
/**
|
|
151
|
+
* Server-advertised ticket lifetime in seconds, from the
|
|
152
|
+
* NewSessionTicket's mandatory `lifetime` field (RFC 8446 §4.6.1);
|
|
153
|
+
* `0` means the ticket never resumes. The field is optional here as
|
|
154
|
+
* a type-move only — records written by `@browsercore/tls` under its
|
|
155
|
+
* pre-contracts `ResumptionTicket` alias predate this field — not
|
|
156
|
+
* because the wire allows omission: consumers treat undefined as no
|
|
157
|
+
* server hint and apply their own default window (2 days, Chrome's
|
|
158
|
+
* `session_psk_dhe_timeout`).
|
|
159
|
+
*/
|
|
160
|
+
readonly lifetimeSeconds?: number;
|
|
161
|
+
/**
|
|
162
|
+
* The `max_early_data_size` in bytes that the ticket's `early_data`
|
|
163
|
+
* extension advertised, 0 when absent. Informational only — the
|
|
164
|
+
* client never offers 0-RTT — so this records the server's ceiling
|
|
165
|
+
* without the client ever using it.
|
|
166
|
+
*/
|
|
167
|
+
readonly maxEarlyDataSize: number;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=tls-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls-session.d.ts","sourceRoot":"","sources":["../src/tls-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOnD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;IAElD;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAEpD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAMD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;OASG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACrC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS session-resumption contracts — the ticket record and the ticket
|
|
3
|
+
* store seam between `@browsercore/tls` (consumer) and browsersmith
|
|
4
|
+
* (implementer).
|
|
5
|
+
*
|
|
6
|
+
* Why this module exists: PSK-based TLS 1.3 session resumption needs a
|
|
7
|
+
* ticket store whose lifecycle crosses a package boundary. `@browsercore/tls`
|
|
8
|
+
* consumes the store — it offers a valid stored ticket as the single PSK
|
|
9
|
+
* identity (Chrome 140 wire rules) and writes every received
|
|
10
|
+
* NewSessionTicket back — while browsersmith, the composition root, owns
|
|
11
|
+
* the concrete store, the opt-in flag, and the default-off policy. Both
|
|
12
|
+
* sides import these definitions from here (canonical-type rule,
|
|
13
|
+
* code-standards §22; litmus test: "Could another package reasonably
|
|
14
|
+
* import this type?"), so neither re-declares the shape and the two
|
|
15
|
+
* sides cannot drift. This is the same seam pattern as
|
|
16
|
+
* {@link ./tls-engine.js~TlsHandshakeEngine}: the implementing package
|
|
17
|
+
* satisfies the interface, the consuming package depends on it, the
|
|
18
|
+
* composition root injects it.
|
|
19
|
+
*
|
|
20
|
+
* Decisions this contract bakes in:
|
|
21
|
+
*
|
|
22
|
+
* - **The store key is the SNI serverName string.** That is all the TLS
|
|
23
|
+
* engine knows — the transport arrives already connected, carrying no
|
|
24
|
+
* proxy or privacy context. Chrome additionally partitions its cache by
|
|
25
|
+
* privacy mode, proxy chain, and network anonymization key
|
|
26
|
+
* (net:ssl_client_session_cache.h:44-62); a caller needing those
|
|
27
|
+
* partitions encodes them into its own key strings. The interface stays
|
|
28
|
+
* a plain `string`-keyed map.
|
|
29
|
+
* - **Synchronous by design.** The store is consulted at ClientHello
|
|
30
|
+
* build time, inside the handshake, and Chrome's cache lookup is
|
|
31
|
+
* synchronous too (net:ssl_client_session_cache.cc `Lookup`). An async
|
|
32
|
+
* interface would force every handshake to await before it can offer,
|
|
33
|
+
* for no benefit: the shipped store is an in-memory Map, and a
|
|
34
|
+
* persistent store can warm its in-memory mirror so lookups stay sync.
|
|
35
|
+
* - **Single-use pop lives in the caller, not the store.** Every TLS 1.3
|
|
36
|
+
* session is single-use (bssl:ssl_session.cc:955-957); Chrome removes
|
|
37
|
+
* the ticket atomically inside its cache at offer time, before the
|
|
38
|
+
* handshake outcome is known (`Entry::Pop`,
|
|
39
|
+
* net:ssl_client_session_cache.cc:151-160). This contract splits the
|
|
40
|
+
* read from the pop: `get` is side-effect-free so a caller can inspect
|
|
41
|
+
* the store without consuming — that inspectability, not Chrome parity
|
|
42
|
+
* (Chrome's Lookup pops), is the reason get is side-effect-free — and
|
|
43
|
+
* consumption is the explicit {@link TlsSessionStore.delete}, which
|
|
44
|
+
* carries the same-turn duty the split imposes (see `delete`).
|
|
45
|
+
*
|
|
46
|
+
* Pure data and signatures — no runtime, no node:* (design rule 2).
|
|
47
|
+
* `CipherSuite` is imported from `./tls-engine.js` for the ticket's
|
|
48
|
+
* PRF-hash guard; it stays exported from there, not re-exported here.
|
|
49
|
+
*/
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=tls-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls-session.js","sourceRoot":"","sources":["../src/tls-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG"}
|