@browsercore/contracts 0.1.4 → 0.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 browsercore contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,67 +1,113 @@
1
- # @browsercore/api
2
- [![coverage](https://img.shields.io/endpoint?url=https://jverneuer.github.io/browsercore-api/badge.json)](https://github.com/jverneuer/browsercore-api)
1
+ # @browsercore/contracts
3
2
 
4
- Shared interfaces and packet inspection types for the browsercore stack.
3
+ [![npm version](https://img.shields.io/npm/v/@browsercore/contracts)](https://www.npmjs.com/package/@browsercore/contracts)
4
+ [![coverage](https://img.shields.io/endpoint?url=https://jverneuer.github.io/browsercore-contracts/badge.json)](https://github.com/jverneuer/browsercore-contracts/blob/main/COVERAGE.md)
5
+ [![CI](https://img.shields.io/github/actions/workflow/status/jverneuer/browsercore-contracts/ci.yml?label=CI)](https://github.com/jverneuer/browsercore-contracts/actions/workflows/ci.yml)
5
6
 
6
- ## Purpose
7
+ The canonical interface package for the browsercore stack. Every protocol
8
+ package, runtime adapter, and consumer depends on these contracts — they
9
+ define how components communicate without coupling them to each other.
7
10
 
8
- This package defines the frame types and callback interfaces that protocol packages use to emit packet inspection data. It has **zero runtime dependencies** and is safe to import from any layer.
11
+ ## Why this package exists
9
12
 
10
- ## Frame Types
13
+ **Zero drift through global interface distribution.** Without a shared
14
+ contracts package, every `@browsercore/*` package would define its own version
15
+ of `Transport`, `BrowserProfile`, `FetchClient`, etc. When one package changes
16
+ a shape, the others silently break at runtime. By centralizing every
17
+ cross-package interface here, a type error becomes a compile error the moment
18
+ any package diverges.
11
19
 
12
- | Frame Type | Protocol | Extends |
13
- |------------|----------|---------|
14
- | `TlsFrame` | `"tls"` | `ProtocolFrame` |
15
- | `Http2Frame` | `"http2"` | `ProtocolFrame` |
16
- | `Http3Frame` | `"http3"` | `ProtocolFrame` |
17
- | `QuicFrame` | `"quic"` | `ProtocolFrame` |
20
+ **Alternative implementations welcome.** The contracts define exactly what a
21
+ component must satisfy — nothing more. Want to write a different TLS engine?
22
+ Implement `TlsConnection`. A different transport? Implement `Transport`. A
23
+ different runtime (Bun, Deno, Workers)? Implement `Net` and `DnsResolver`. The
24
+ contracts are the spec; the packages are the reference implementations.
18
25
 
19
- All frame types are discriminated by the `protocol` field.
26
+ **Implementation-independent.** No `node:crypto`, `node:net`, `Buffer`, or any
27
+ runtime details leak into these types. They are portable TypeScript interfaces
28
+ and plain data.
20
29
 
21
- ## Usage in Protocol Packages
30
+ ## Architecture
22
31
 
23
- Add the `onPacket` callback to your options:
32
+ ```
33
+ @browsercore/contracts (this package — interfaces + models + wire codes)
34
+ ▲
35
+ │
36
+ ┌──────┼─────────────┐
37
+ │ │ │
38
+ ▼ ▼ ▼
39
+ tls http2 transport
40
+ │ │ │
41
+ └───────┴─────────────┘
42
+ ▼
43
+ @browsercore/fetch
44
+ ▼
45
+ browsersmith (entrypoint)
46
+ ```
24
47
 
25
- ```typescript
26
- import type { PacketCallback, PacketInspectionOptions } from "@browsercore/api";
48
+ Dependency direction is strictly upward — contracts is the root dependency.
49
+ No package below contracts in the graph; every other package imports from it.
27
50
 
28
- interface MyOptions {
29
- // ... existing options
30
- readonly onPacket?: PacketCallback;
31
- }
51
+ ## What's inside
32
52
 
33
- async function connect(options: MyOptions) {
34
- // Emit frames when callback is set
35
- if (options.onPacket) {
36
- options.onPacket({
37
- protocol: "tls",
38
- direction: "sent",
39
- timestamp: Date.now(),
40
- // ... protocol-specific fields
41
- });
42
- }
43
- }
53
+ | Module | Purpose | Key exports |
54
+ |---|---|---|
55
+ | **Contracts** | Provider + connection interfaces that protocol packages implement | `CryptoProvider`, `CompressionProvider`, `Transport`, `DatagramTransport`, `TlsConnection`, `Http1Connection`, `Http2Connection`, `Http3Connection`, `QuicConnection`, `QuicStream`, `FetchClient`, `CookieJar`, `Clock`, `PacketCallback` |
56
+ | **Models** | Shared data structures that cross package boundaries | `BrowserProfile`, `TlsProfile`, `Http1Profile`, `Http2Profile`, `Request`, `Response`, `Headers`, `Cookie`, `TransportState`, `CloseReason`, `ContentEncoding` |
57
+ | **Net** | Platform-agnostic TCP + DNS contracts for runtime portability | `Net`, `DnsResolver`, `Socket`, `ConnectOptions`, `IPAddress` |
58
+ | **Options** | Configuration objects passed to each protocol package | `TlsOptions`, `Http1Options`, `Http2Options`, `Http3Options`, `QuicOptions`, `FetchClientOptions` |
59
+ | **IANA Tables** | Canonical TLS wire code lookup tables (single source of truth) | `CIPHER_SUITE_CODES`, `NAMED_GROUP_CODES`, `SIGNATURE_SCHEME_CODES`, `VERSION_CODES` |
60
+
61
+ ## Usage
62
+
63
+ ### Importing types (compile-time only)
64
+
65
+ ```ts
66
+ import type { Net, DnsResolver, Transport, BrowserProfile } from "@browsercore/contracts";
44
67
  ```
45
68
 
46
- ## Usage in Consumers (e.g., browsersmith)
69
+ Type imports are erased at compile time — zero runtime cost.
47
70
 
48
- ```typescript
49
- import { createInspectorSession } from "@browsercore/devtools";
50
- import type { PacketCallback } from "@browsercore/api";
71
+ ### Importing wire code tables (runtime)
51
72
 
52
- const session = createInspectorSession();
73
+ ```ts
74
+ import { CIPHER_SUITE_CODES, NAMED_GROUP_CODES } from "@browsercore/contracts";
75
+
76
+ const aes128 = CIPHER_SUITE_CODES["TLS_AES_128_GCM_SHA256"]; // 0x1301
77
+ const x25519 = NAMED_GROUP_CODES["x25519"]; // 0x001d
78
+ ```
53
79
 
54
- // Create a callback that feeds the inspector
55
- const onPacket: PacketCallback = (frame) => session.addFrame(frame);
80
+ ### Implementing an alternative package
56
81
 
57
- // Pass to all protocol packages
58
- const client = createClient({
59
- tls: { onPacket },
60
- http2: { onPacket },
61
- http3: { onPacket },
62
- });
82
+ ```ts
83
+ import type { Transport, TransportState, CloseReason } from "@browsercore/contracts";
84
+
85
+ class MyCustomTransport implements Transport {
86
+ // Implement the interface — the rest of the stack works unchanged
87
+ }
63
88
  ```
64
89
 
65
- ## Zero Overhead
90
+ ## Design rules
91
+
92
+ 1. **If a type crosses a package boundary, it lives here.** Litmus test:
93
+ *"Could two packages reasonably import this type?"* If yes → contracts.
94
+ If only one package uses it → stays in that package.
95
+
96
+ 2. **No runtime behavior.** Only TypeScript types and `const` data tables.
97
+ No classes with logic, no functions with side effects.
98
+
99
+ 3. **No Node built-ins.** Types reference only portable primitives:
100
+ `string`, `number`, `Uint8Array`, `Promise`, `IterableIterator`.
101
+
102
+ 4. **Branded types for IDs.** `ProfileId`, `StreamId`, `ConnectionId` etc.
103
+ are opaque branded types, not bare `string`/`number`.
104
+
105
+ 5. **Discriminated unions for state.** `TransportState`, `CloseReason`,
106
+ `TlsState` model every valid state explicitly — invalid combinations
107
+ are unrepresentable.
108
+
109
+ ## Zero overhead
66
110
 
67
- When `onPacket` is undefined (the default), protocol packages skip frame emission entirely. The guard `if (options.onPacket)` is a single branch with negligible cost.
111
+ All type exports are erased by the TypeScript compiler. The only runtime
112
+ exports are the IANA wire code tables — plain `const` objects with no
113
+ dependencies, no side effects.
@@ -4,7 +4,7 @@
4
4
  * Litmus test: "Could another package reasonably import this type?"
5
5
  * If yes → belongs here. If only one protocol touches it → stays in that package.
6
6
  */
7
- import type { Cookie, FetchOptions, FetchResponse, ProtocolFrame, Request, Response, UdpAddress } from "./models.js";
7
+ import type { ContentEncoding, Cookie, DatagramCloseReason, EcdhCurve, EcdhKeyPair, FetchOptions, FetchResponse, HashId, ProtocolFrame, Request, Response, TransportState, CloseReason, TlsState, UdpAddress, X25519KeyPair } from "./models.js";
8
8
  /**
9
9
  * Cryptographic primitive abstraction.
10
10
  * Implemented by: @browsercore/crypto
@@ -198,7 +198,4 @@ export type PacketCallback = (frame: ProtocolFrame) => void;
198
198
  export interface PacketInspectionOptions {
199
199
  readonly onPacket?: PacketCallback;
200
200
  }
201
- import type { HashId, EcdhCurve, X25519KeyPair, EcdhKeyPair } from "./models.js";
202
- import type { ContentEncoding } from "./models.js";
203
- import type { TransportState, CloseReason, DatagramCloseReason, TlsState } from "./models.js";
204
201
  //# sourceMappingURL=contracts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGR,MAAM,EACN,YAAY,EACZ,aAAa,EAEb,aAAa,EACb,OAAO,EACP,QAAQ,EACR,UAAU,EACb,MAAM,aAAa,CAAC;AAMrB;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IACxC,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACrC,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,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Y,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACtB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC3C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,IAAI,MAAM,CAAC;IACpB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IAClB,GAAG,IAAI,MAAM,CAAC;IACd,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;CACjE;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACtC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Platform-agnostic event contracts.
3
+ *
4
+ * These interfaces describe what BrowserCore needs from an event system.
5
+ * They are implemented by thin adapters (e.g. `browsersmith/src/events/node/`)
6
+ * and injected so the protocol stack stays runtime-agnostic.
7
+ *
8
+ * Design rule: expose only what transport/protocol packages consume.
9
+ * Don't mirror Node's EventEmitter API.
10
+ */
11
+ /**
12
+ * Minimal event emitter surface — the structural subset of
13
+ * `node:events.EventEmitter` that BrowserCore depends on.
14
+ *
15
+ * Any runtime emitter that satisfies these methods can be injected.
16
+ */
17
+ export interface EventProvider {
18
+ on(event: string, listener: (...args: unknown[]) => void): void;
19
+ once(event: string, listener: (...args: unknown[]) => void): void;
20
+ off(event: string, listener: (...args: unknown[]) => void): void;
21
+ removeListener(event: string, listener: (...args: unknown[]) => void): void;
22
+ emit(event: string, ...args: unknown[]): boolean;
23
+ listenerCount(event: string): number;
24
+ removeAllListeners(event?: string): void;
25
+ }
26
+ /**
27
+ * Typed event emitter — maps event names to their listener signatures.
28
+ *
29
+ * Consumers define a map of event handlers and get compile-time
30
+ * type safety on `emit` arguments and `on` callbacks.
31
+ */
32
+ export interface TypedEventEmitter<T extends Record<string, (...args: unknown[]) => void>> {
33
+ on<K extends keyof T>(event: K, listener: T[K]): void;
34
+ once<K extends keyof T>(event: K, listener: T[K]): void;
35
+ off<K extends keyof T>(event: K, listener: T[K]): void;
36
+ emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): boolean;
37
+ }
38
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAClE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACjD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrF,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACvD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACzE"}
package/dist/events.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Platform-agnostic event contracts.
3
+ *
4
+ * These interfaces describe what BrowserCore needs from an event system.
5
+ * They are implemented by thin adapters (e.g. `browsersmith/src/events/node/`)
6
+ * and injected so the protocol stack stays runtime-agnostic.
7
+ *
8
+ * Design rule: expose only what transport/protocol packages consume.
9
+ * Don't mirror Node's EventEmitter API.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/index.d.ts CHANGED
@@ -25,6 +25,10 @@
25
25
  export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, TlsConnection, Http1Connection, Http2Connection, Http3Connection, QuicConnection, QuicStream, FetchClient, CookieJar, Clock, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
26
26
  export type { ProfileId, BrowserProfile, TlsProfile, Http1Profile, Http2Profile, Request, Response, FetchOptions, FetchResponse, Headers, Cookie, HashId, EcdhCurve, X25519KeyPair, 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
- export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, } from "./net.js";
28
+ export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, Network, } from "./net.js";
29
+ export type { EventProvider, TypedEventEmitter, } from "./events.js";
30
+ export type { Logger, Span, Tracer, Metrics, Telemetry, } from "./telemetry.js";
31
+ export type { Duration, Deadline, Scheduler, Time, } from "./time.js";
32
+ export type { Compression, Crypto, Platform, } from "./platform.js";
29
33
  export type { TlsOptions, Http1Options, Http2Options, Http3Options, QuicOptions, FetchClientOptions, } from "./options.js";
30
34
  //# sourceMappingURL=index.d.ts.map
@@ -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,EAEjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EAEV,WAAW,EACX,SAAS,EAET,KAAK,EACL,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EAET,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,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,GACZ,MAAM,UAAU,CAAC;AAMlB,YAAY,EACR,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,kBAAkB,GACrB,MAAM,cAAc,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,EAEjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,UAAU,EAEV,WAAW,EACX,SAAS,EAET,KAAK,EACL,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EAET,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,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,UAAU,CAAC;AAMlB,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,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,IAAI,GACP,MAAM,WAAW,CAAC;AAWnB,YAAY,EACR,WAAW,EACX,MAAM,EACN,QAAQ,GACX,MAAM,eAAe,CAAC;AAMvB,YAAY,EACR,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,kBAAkB,GACrB,MAAM,cAAc,CAAC"}
package/dist/net.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  *
9
9
  * Design rule: expose only what transport consumes. Don't mirror Node's API.
10
10
  */
11
+ import type { DatagramTransport } from "./contracts.js";
11
12
  /** Options for establishing a TCP connection. */
12
13
  export interface ConnectOptions {
13
14
  /** Target host (IP literal or resolved address). */
@@ -69,4 +70,15 @@ export interface DnsResolver {
69
70
  */
70
71
  lookup(hostname: string, family: 4 | 6): Promise<readonly IPAddress[]>;
71
72
  }
73
+ /**
74
+ * Aggregated network bundle — TCP, DNS, and UDP.
75
+ *
76
+ * Passed down from the composition root. Bundles the three network
77
+ * capabilities so consumers receive one object instead of three.
78
+ */
79
+ export interface Network {
80
+ readonly tcp: Net;
81
+ readonly dns: DnsResolver;
82
+ readonly udp: DatagramTransport;
83
+ }
72
84
  //# sourceMappingURL=net.d.ts.map
package/dist/net.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../src/net.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mBAAmB;IACnB,QAA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GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;CAC1E;AAMD;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;CACnC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Platform — the root composition interface.
3
+ *
4
+ * This is the single object that browsersmith assembles and passes down
5
+ * to every protocol package. Each field is a service bundle that groups
6
+ * related platform capabilities (network, crypto, compression, events,
7
+ * telemetry, time).
8
+ *
9
+ * Architecture:
10
+ *
11
+ * browsersmith (composition root)
12
+ * │
13
+ * ▼
14
+ * Platform
15
+ * ├── network (TCP, DNS, UDP)
16
+ * ├── crypto (CryptoProvider)
17
+ * ├── compression (gzip, deflate, brotli, etc.)
18
+ * ├── events (EventProvider)
19
+ * ├── telemetry (logger, tracer, metrics)
20
+ * └── time (Clock + Scheduler)
21
+ *
22
+ * All fields are interfaces — this file has zero runtime behavior
23
+ * and zero node:* imports.
24
+ */
25
+ import type { Network } from "./net.js";
26
+ import type { CryptoProvider } from "./contracts.js";
27
+ import type { EventProvider } from "./events.js";
28
+ import type { Telemetry } from "./telemetry.js";
29
+ import type { Time } from "./time.js";
30
+ /**
31
+ * Synchronous compression/decompression bundle.
32
+ *
33
+ * Why sync: callers already own the hot path and want predictable latency.
34
+ * Streaming variants belong on the implementation, not the contract.
35
+ */
36
+ export interface Compression {
37
+ gzipSync(data: Uint8Array): Uint8Array;
38
+ gunzipSync(data: Uint8Array): Uint8Array;
39
+ deflateSync(data: Uint8Array): Uint8Array;
40
+ inflateSync(data: Uint8Array): Uint8Array;
41
+ brotliCompressSync(data: Uint8Array): Uint8Array;
42
+ brotliDecompressSync(data: Uint8Array): Uint8Array;
43
+ decompressSync(data: Uint8Array): Uint8Array;
44
+ }
45
+ /**
46
+ * Aggregated crypto bundle — wraps CryptoProvider.
47
+ */
48
+ export interface Crypto {
49
+ readonly provider: CryptoProvider;
50
+ }
51
+ /**
52
+ * Platform — the single composition root for all runtime services.
53
+ *
54
+ * Every protocol package receives the fields it needs. No package
55
+ * hardwires node:* imports; all capabilities arrive via this object.
56
+ */
57
+ export interface Platform {
58
+ readonly network: Network;
59
+ readonly crypto: Crypto;
60
+ readonly compression: Compression;
61
+ readonly events: EventProvider;
62
+ readonly telemetry: Telemetry;
63
+ readonly time: Time;
64
+ }
65
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMtC;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACzC,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC1C,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC1C,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACjD,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACnD,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;CAChD;AAMD;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACrC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACvB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Platform — the root composition interface.
3
+ *
4
+ * This is the single object that browsersmith assembles and passes down
5
+ * to every protocol package. Each field is a service bundle that groups
6
+ * related platform capabilities (network, crypto, compression, events,
7
+ * telemetry, time).
8
+ *
9
+ * Architecture:
10
+ *
11
+ * browsersmith (composition root)
12
+ * │
13
+ * ▼
14
+ * Platform
15
+ * ├── network (TCP, DNS, UDP)
16
+ * ├── crypto (CryptoProvider)
17
+ * ├── compression (gzip, deflate, brotli, etc.)
18
+ * ├── events (EventProvider)
19
+ * ├── telemetry (logger, tracer, metrics)
20
+ * └── time (Clock + Scheduler)
21
+ *
22
+ * All fields are interfaces — this file has zero runtime behavior
23
+ * and zero node:* imports.
24
+ */
25
+ export {};
26
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Platform-agnostic telemetry contracts.
3
+ *
4
+ * These interfaces describe the logging, tracing, and metrics surface
5
+ * that BrowserCore needs. They are implemented by thin adapters
6
+ * (e.g. `browsersmith/src/telemetry/node/`) and injected.
7
+ *
8
+ * Design rule: expose only what packages consume. Don't mirror any
9
+ * specific telemetry SDK (OpenTelemetry, pino, etc.).
10
+ */
11
+ /**
12
+ * Structured logger — the minimal surface protocol packages need.
13
+ */
14
+ export interface Logger {
15
+ debug(message: string, attrs?: Readonly<Record<string, unknown>>): void;
16
+ info(message: string, attrs?: Readonly<Record<string, unknown>>): void;
17
+ warn(message: string, attrs?: Readonly<Record<string, unknown>>): void;
18
+ error(message: string, attrs?: Readonly<Record<string, unknown>>): void;
19
+ }
20
+ /**
21
+ * A single trace span.
22
+ */
23
+ export interface Span {
24
+ setAttribute(key: string, value: unknown): Span;
25
+ end(): void;
26
+ }
27
+ /**
28
+ * Tracer — creates spans.
29
+ */
30
+ export interface Tracer {
31
+ startSpan(name: string, attrs?: Readonly<Record<string, unknown>>): Span;
32
+ }
33
+ /**
34
+ * Metrics counter/gauge recorder.
35
+ */
36
+ export interface Metrics {
37
+ add(name: string, value: number, attrs?: Readonly<Record<string, unknown>>): void;
38
+ }
39
+ /**
40
+ * Aggregated telemetry bundle — passed down from the composition root.
41
+ */
42
+ export interface Telemetry {
43
+ readonly logger: Logger;
44
+ readonly tracer: Tracer;
45
+ readonly metrics: Metrics;
46
+ }
47
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IACvE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC3E;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAChD,GAAG,IAAI,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC5E;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CACrF;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC7B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Platform-agnostic telemetry contracts.
3
+ *
4
+ * These interfaces describe the logging, tracing, and metrics surface
5
+ * that BrowserCore needs. They are implemented by thin adapters
6
+ * (e.g. `browsersmith/src/telemetry/node/`) and injected.
7
+ *
8
+ * Design rule: expose only what packages consume. Don't mirror any
9
+ * specific telemetry SDK (OpenTelemetry, pino, etc.).
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/time.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Platform-agnostic time contracts.
3
+ *
4
+ * These interfaces describe what BrowserCore needs from a runtime's
5
+ * time and scheduling facilities. They are implemented by thin adapters
6
+ * (e.g. `browsersmith/src/time/node/`) and injected so protocol packages
7
+ * can schedule delays, timeouts, and deadlines without hardwiring to
8
+ * `setTimeout` or `performance.now`.
9
+ *
10
+ * Design rule: expose only what transport/protocol packages consume.
11
+ */
12
+ /**
13
+ * Time source — wall clock and monotonic counter.
14
+ *
15
+ * `monotonic()` returns high-resolution nanoseconds and MUST NOT
16
+ * go backwards (unlike wall-clock `now()`).
17
+ */
18
+ export interface Clock {
19
+ /** Wall-clock time, epoch milliseconds. */
20
+ now(): number;
21
+ /** High-resolution monotonic time, nanoseconds. */
22
+ monotonic(): bigint;
23
+ }
24
+ /**
25
+ * A duration interval.
26
+ *
27
+ * Returned by the `Duration` factory. Both accessors reflect the same
28
+ * interval in different units.
29
+ */
30
+ export interface Duration {
31
+ readonly milliseconds: number;
32
+ seconds(): number;
33
+ }
34
+ /**
35
+ * A deadline bound to an AbortSignal.
36
+ */
37
+ export interface Deadline {
38
+ readonly signal: AbortSignal;
39
+ readonly expiresAt: bigint;
40
+ }
41
+ /**
42
+ * Scheduler — creates delays, timeouts, and deadlines.
43
+ */
44
+ export interface Scheduler {
45
+ delay(duration: Duration, signal?: AbortSignal): Promise<void>;
46
+ timeout(duration: Duration): AbortSignal;
47
+ deadline(duration: Duration): Deadline;
48
+ }
49
+ /**
50
+ * Aggregated time bundle — passed down from the composition root.
51
+ */
52
+ export interface Time {
53
+ readonly clock: Clock;
54
+ readonly scheduler: Scheduler;
55
+ }
56
+ /**
57
+ * Duration factory — pure function object, no runtime deps.
58
+ * Platform implementations use this to build Duration values.
59
+ */
60
+ export declare const Duration: {
61
+ seconds: (n: number) => Duration;
62
+ milliseconds: (n: number) => Duration;
63
+ };
64
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IAClB,2CAA2C;IAC3C,GAAG,IAAI,MAAM,CAAC;IACd,mDAAmD;IACnD,SAAS,IAAI,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;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;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CACjC;AAMD;;;GAGG;AACH,eAAO,MAAM,QAAQ;IACjB,OAAO,MAAM,MAAM,KAAG,QAAQ;IAC9B,YAAY,MAAM,MAAM,KAAG,QAAQ;CACtC,CAAC"}
package/dist/time.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Platform-agnostic time contracts.
3
+ *
4
+ * These interfaces describe what BrowserCore needs from a runtime's
5
+ * time and scheduling facilities. They are implemented by thin adapters
6
+ * (e.g. `browsersmith/src/time/node/`) and injected so protocol packages
7
+ * can schedule delays, timeouts, and deadlines without hardwiring to
8
+ * `setTimeout` or `performance.now`.
9
+ *
10
+ * Design rule: expose only what transport/protocol packages consume.
11
+ */
12
+ // ===========================================================================
13
+ // Duration factory
14
+ // ===========================================================================
15
+ /**
16
+ * Duration factory — pure function object, no runtime deps.
17
+ * Platform implementations use this to build Duration values.
18
+ */
19
+ export const Duration = {
20
+ seconds: (n) => ({ milliseconds: n * 1000, seconds: () => n }),
21
+ milliseconds: (n) => ({ milliseconds: n, seconds: () => n / 1000 }),
22
+ };
23
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmDH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;GAGG;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"}
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "@browsercore/contracts",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Shared interfaces, models, and options for the browsercore stack",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/jverneuer/browsercore-contracts.git"
8
+ },
9
+ "homepage": "https://github.com/jverneuer/browsercore-contracts#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/jverneuer/browsercore-contracts/issues"
12
+ },
13
+ "license": "MIT",
5
14
  "type": "module",
15
+ "sideEffects": false,
6
16
  "main": "./dist/index.js",
7
17
  "types": "./dist/index.d.ts",
8
18
  "exports": {
@@ -12,19 +22,27 @@
12
22
  }
13
23
  },
14
24
  "files": [
15
- "dist"
25
+ "dist",
26
+ "LICENSE"
16
27
  ],
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org/"
31
+ },
17
32
  "scripts": {
33
+ "clean": "rm -rf dist",
18
34
  "build": "tsc -p tsconfig.json",
19
- "typecheck": "tsc --noEmit",
20
- "clean": "rm -rf dist"
21
- },
22
- "license": "MIT",
23
- "publishConfig": {
24
- "access": "public"
35
+ "prepublishOnly": "npm run clean && npm run build",
36
+ "typecheck": "tsc -p tsconfig.json --noEmit",
37
+ "test": "vitest run",
38
+ "lint": "oxlint --type-aware src/"
25
39
  },
26
40
  "devDependencies": {
27
41
  "@types/node": "^26.1.2",
28
- "typescript": "^7.0.2"
42
+ "@vitest/coverage-v8": "^4.1.10",
43
+ "oxlint": "^1.76.0",
44
+ "oxlint-tsgolint": "7.0.2001",
45
+ "typescript": "^7.0.2",
46
+ "vitest": "^4.1.10"
29
47
  }
30
48
  }