@browsercore/contracts 0.1.3
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 +67 -0
- package/dist/contracts.d.ts +204 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +8 -0
- package/dist/contracts.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +225 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +89 -0
- package/dist/models.js.map +1 -0
- package/dist/net.d.ts +72 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.js +12 -0
- package/dist/net.js.map +1 -0
- package/dist/options.d.ts +50 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +9 -0
- package/dist/options.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @browsercore/api
|
|
2
|
+
[](https://github.com/jverneuer/browsercore-api)
|
|
3
|
+
|
|
4
|
+
Shared interfaces and packet inspection types for the browsercore stack.
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
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.
|
|
9
|
+
|
|
10
|
+
## Frame Types
|
|
11
|
+
|
|
12
|
+
| Frame Type | Protocol | Extends |
|
|
13
|
+
|------------|----------|---------|
|
|
14
|
+
| `TlsFrame` | `"tls"` | `ProtocolFrame` |
|
|
15
|
+
| `Http2Frame` | `"http2"` | `ProtocolFrame` |
|
|
16
|
+
| `Http3Frame` | `"http3"` | `ProtocolFrame` |
|
|
17
|
+
| `QuicFrame` | `"quic"` | `ProtocolFrame` |
|
|
18
|
+
|
|
19
|
+
All frame types are discriminated by the `protocol` field.
|
|
20
|
+
|
|
21
|
+
## Usage in Protocol Packages
|
|
22
|
+
|
|
23
|
+
Add the `onPacket` callback to your options:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import type { PacketCallback, PacketInspectionOptions } from "@browsercore/api";
|
|
27
|
+
|
|
28
|
+
interface MyOptions {
|
|
29
|
+
// ... existing options
|
|
30
|
+
readonly onPacket?: PacketCallback;
|
|
31
|
+
}
|
|
32
|
+
|
|
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
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage in Consumers (e.g., browsersmith)
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { createInspectorSession } from "@browsercore/devtools";
|
|
50
|
+
import type { PacketCallback } from "@browsercore/api";
|
|
51
|
+
|
|
52
|
+
const session = createInspectorSession();
|
|
53
|
+
|
|
54
|
+
// Create a callback that feeds the inspector
|
|
55
|
+
const onPacket: PacketCallback = (frame) => session.addFrame(frame);
|
|
56
|
+
|
|
57
|
+
// Pass to all protocol packages
|
|
58
|
+
const client = createClient({
|
|
59
|
+
tls: { onPacket },
|
|
60
|
+
http2: { onPacket },
|
|
61
|
+
http3: { onPacket },
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Zero Overhead
|
|
66
|
+
|
|
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.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts — interfaces that define how BrowserCore components communicate.
|
|
3
|
+
*
|
|
4
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
5
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
6
|
+
*/
|
|
7
|
+
import type { Cookie, FetchOptions, FetchResponse, ProtocolFrame, Request, Response, UdpAddress } from "./models.js";
|
|
8
|
+
/**
|
|
9
|
+
* Cryptographic primitive abstraction.
|
|
10
|
+
* Implemented by: @browsercore/crypto
|
|
11
|
+
*
|
|
12
|
+
* Why here: Every protocol package needs crypto operations.
|
|
13
|
+
*/
|
|
14
|
+
export interface CryptoProvider {
|
|
15
|
+
randomBytes(length: number): Uint8Array;
|
|
16
|
+
sha256(data: Uint8Array): Uint8Array;
|
|
17
|
+
sha384(data: Uint8Array): Uint8Array;
|
|
18
|
+
hkdf(hash: HashId, salt: Uint8Array, ikm: Uint8Array, info: Uint8Array, length: number): Uint8Array;
|
|
19
|
+
hmac(hash: HashId, key: Uint8Array, data: Uint8Array): Uint8Array;
|
|
20
|
+
aes128GcmEncrypt(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
21
|
+
aes128GcmDecrypt(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
22
|
+
aes256GcmEncrypt(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
23
|
+
aes256GcmDecrypt(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
24
|
+
aes128CcmEncrypt(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
25
|
+
aes128CcmDecrypt(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
26
|
+
chacha20Poly1305Encrypt(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
27
|
+
chacha20Poly1305Decrypt(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
28
|
+
x25519GenerateKeyPair(): X25519KeyPair;
|
|
29
|
+
x25519SharedSecret(secretKey: Uint8Array, peerPublicKey: Uint8Array): Uint8Array;
|
|
30
|
+
ecdhGenerateKeyPair(curve: EcdhCurve): EcdhKeyPair;
|
|
31
|
+
ecdhSharedSecret(curve: EcdhCurve, secretKey: Uint8Array, peerPublicKey: Uint8Array): Uint8Array;
|
|
32
|
+
verifySignature(scheme: string, publicKey: Uint8Array, signature: Uint8Array, data: Uint8Array): boolean;
|
|
33
|
+
aesEcbEncrypt(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compression/decompression abstraction.
|
|
37
|
+
* Implemented by: @browsercore/compression
|
|
38
|
+
*
|
|
39
|
+
* Why here: HTTP/1 and HTTP/2 both need compression.
|
|
40
|
+
*/
|
|
41
|
+
export interface CompressionProvider {
|
|
42
|
+
encode(encoding: ContentEncoding, data: Uint8Array): Promise<Uint8Array>;
|
|
43
|
+
decode(encoding: ContentEncoding, data: Uint8Array): Promise<Uint8Array>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reliable ordered byte stream abstraction (TCP).
|
|
47
|
+
* Implemented by: @browsercore/transport
|
|
48
|
+
*
|
|
49
|
+
* Why here: TLS, HTTP/1, HTTP/2 all consume Transport.
|
|
50
|
+
*/
|
|
51
|
+
export interface Transport {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly state: TransportState;
|
|
54
|
+
write(data: Uint8Array): Promise<void>;
|
|
55
|
+
read(): Promise<Uint8Array>;
|
|
56
|
+
close(reason?: CloseReason): Promise<void>;
|
|
57
|
+
on(event: "data", listener: (data: Uint8Array) => void): void;
|
|
58
|
+
on(event: "close", listener: (reason: CloseReason) => void): void;
|
|
59
|
+
on(event: "error", listener: (error: Error) => void): void;
|
|
60
|
+
once(event: "data", listener: (data: Uint8Array) => void): void;
|
|
61
|
+
once(event: "close", listener: (reason: CloseReason) => void): void;
|
|
62
|
+
once(event: "error", listener: (error: Error) => void): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Datagram transport abstraction (UDP).
|
|
66
|
+
* Implemented by: @browsercore/transport
|
|
67
|
+
*
|
|
68
|
+
* Why here: QUIC consumes DatagramTransport.
|
|
69
|
+
*/
|
|
70
|
+
export interface DatagramTransport {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
send(data: Uint8Array, address: UdpAddress): Promise<void>;
|
|
73
|
+
recv(): Promise<{
|
|
74
|
+
readonly data: Uint8Array;
|
|
75
|
+
readonly from: UdpAddress;
|
|
76
|
+
}>;
|
|
77
|
+
close(reason?: DatagramCloseReason): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* TLS connection abstraction.
|
|
81
|
+
* Implemented by: @browsercore/tls
|
|
82
|
+
*
|
|
83
|
+
* Why here: fetch consumes TlsConnection.
|
|
84
|
+
*/
|
|
85
|
+
export interface TlsConnection {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly state: TlsState;
|
|
88
|
+
handshake(): Promise<void>;
|
|
89
|
+
read(): Promise<Uint8Array>;
|
|
90
|
+
write(data: Uint8Array): Promise<void>;
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* HTTP/1 connection abstraction.
|
|
95
|
+
* Implemented by: @browsercore/http1
|
|
96
|
+
*
|
|
97
|
+
* Why here: fetch consumes Http1Connection.
|
|
98
|
+
*/
|
|
99
|
+
export interface Http1Connection {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
request(req: Request): Promise<Response>;
|
|
102
|
+
close(): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* HTTP/2 connection abstraction.
|
|
106
|
+
* Implemented by: @browsercore/http2
|
|
107
|
+
*
|
|
108
|
+
* Why here: fetch consumes Http2Connection.
|
|
109
|
+
*/
|
|
110
|
+
export interface Http2Connection {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
request(req: Request): Promise<Response>;
|
|
113
|
+
close(): Promise<void>;
|
|
114
|
+
goaway(): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* HTTP/3 connection abstraction.
|
|
118
|
+
* Implemented by: @browsercore/http3
|
|
119
|
+
*
|
|
120
|
+
* Why here: fetch consumes Http3Connection.
|
|
121
|
+
*/
|
|
122
|
+
export interface Http3Connection {
|
|
123
|
+
readonly id: string;
|
|
124
|
+
request(req: Request): Promise<Response>;
|
|
125
|
+
close(): Promise<void>;
|
|
126
|
+
goaway(streamId: bigint): Promise<void>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* QUIC connection abstraction.
|
|
130
|
+
* Implemented by: @browsercore/quic
|
|
131
|
+
*
|
|
132
|
+
* Why here: HTTP/3 consumes QuicConnection.
|
|
133
|
+
*/
|
|
134
|
+
export interface QuicConnection {
|
|
135
|
+
readonly id: string;
|
|
136
|
+
handshake(): Promise<void>;
|
|
137
|
+
openBidirectionalStream(): Promise<QuicStream>;
|
|
138
|
+
acceptBidirectionalStream(): Promise<QuicStream>;
|
|
139
|
+
openUnidirectionalStream(): Promise<QuicStream>;
|
|
140
|
+
acceptUnidirectionalStream(): Promise<QuicStream>;
|
|
141
|
+
close(errorCode: bigint, reason: string): Promise<void>;
|
|
142
|
+
sendPathChallenge(data: Uint8Array): void;
|
|
143
|
+
hasPendingPathChallenge(data: Uint8Array): boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* QUIC stream abstraction.
|
|
147
|
+
*
|
|
148
|
+
* Why here: QuicConnection returns QuicStream, HTTP/3 uses it.
|
|
149
|
+
*/
|
|
150
|
+
export interface QuicStream {
|
|
151
|
+
readonly id: bigint;
|
|
152
|
+
write(data: Uint8Array): Promise<void>;
|
|
153
|
+
read(): Promise<Uint8Array>;
|
|
154
|
+
close(): Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* High-level fetch client.
|
|
158
|
+
* Implemented by: @browsercore/fetch
|
|
159
|
+
*
|
|
160
|
+
* Why here: browsersmith consumes FetchClient.
|
|
161
|
+
*/
|
|
162
|
+
export interface FetchClient {
|
|
163
|
+
fetch(url: string, options?: FetchOptions): Promise<FetchResponse>;
|
|
164
|
+
close(): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Cookie jar abstraction.
|
|
168
|
+
* Implemented by: @browsercore/cookies
|
|
169
|
+
*
|
|
170
|
+
* Why here: fetch and browsersmith both use CookieJar.
|
|
171
|
+
*/
|
|
172
|
+
export interface CookieJar {
|
|
173
|
+
getCookies(url: string): readonly Cookie[];
|
|
174
|
+
setCookie(url: string, cookie: Cookie): void;
|
|
175
|
+
clear(): void;
|
|
176
|
+
serialize(): string;
|
|
177
|
+
deserialize(data: string): void;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Time-source abstraction.
|
|
181
|
+
* Injected for deterministic tests.
|
|
182
|
+
*
|
|
183
|
+
* Why here: Every protocol package needs time.
|
|
184
|
+
*/
|
|
185
|
+
export interface Clock {
|
|
186
|
+
now(): number;
|
|
187
|
+
setTimeout(callback: () => void, delayMs: number): () => void;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Packet inspection callback.
|
|
191
|
+
*
|
|
192
|
+
* Why here: Protocol packages emit frames, consumers receive them.
|
|
193
|
+
*/
|
|
194
|
+
export type PacketCallback = (frame: ProtocolFrame) => void;
|
|
195
|
+
/**
|
|
196
|
+
* Options mixin that adds packet inspection.
|
|
197
|
+
*/
|
|
198
|
+
export interface PacketInspectionOptions {
|
|
199
|
+
readonly onPacket?: PacketCallback;
|
|
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
|
+
//# sourceMappingURL=contracts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I,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;AAMD,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts — interfaces that define how BrowserCore components communicate.
|
|
3
|
+
*
|
|
4
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
5
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @browsercore/contracts — the public SDK surface for the browsercore stack.
|
|
3
|
+
*
|
|
4
|
+
* This package contains every type that defines how BrowserCore components
|
|
5
|
+
* communicate with each other. It is implementation-independent: no node:crypto,
|
|
6
|
+
* node:net, Buffer, curl, OpenSSL, ngtcp2, or any implementation details.
|
|
7
|
+
*
|
|
8
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
9
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
10
|
+
*
|
|
11
|
+
* Architecture:
|
|
12
|
+
*
|
|
13
|
+
* @browsercore/contracts (this package)
|
|
14
|
+
* ▲
|
|
15
|
+
* │
|
|
16
|
+
* ┌──────┼─────────────┐
|
|
17
|
+
* │ │ │
|
|
18
|
+
* ▼ ▼ ▼
|
|
19
|
+
* tls http2 transport
|
|
20
|
+
* │ │ │
|
|
21
|
+
* └───────┴─────────────┘
|
|
22
|
+
* ▼
|
|
23
|
+
* @browsercore/browsersmith
|
|
24
|
+
*/
|
|
25
|
+
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, TlsConnection, Http1Connection, Http2Connection, Http3Connection, QuicConnection, QuicStream, FetchClient, CookieJar, Clock, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
|
|
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
|
+
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";
|
|
29
|
+
export type { TlsOptions, Http1Options, Http2Options, Http3Options, QuicOptions, FetchClientOptions, } from "./options.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @browsercore/contracts — the public SDK surface for the browsercore stack.
|
|
3
|
+
*
|
|
4
|
+
* This package contains every type that defines how BrowserCore components
|
|
5
|
+
* communicate with each other. It is implementation-independent: no node:crypto,
|
|
6
|
+
* node:net, Buffer, curl, OpenSSL, ngtcp2, or any implementation details.
|
|
7
|
+
*
|
|
8
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
9
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
10
|
+
*
|
|
11
|
+
* Architecture:
|
|
12
|
+
*
|
|
13
|
+
* @browsercore/contracts (this package)
|
|
14
|
+
* ▲
|
|
15
|
+
* │
|
|
16
|
+
* ┌──────┼─────────────┐
|
|
17
|
+
* │ │ │
|
|
18
|
+
* ▼ ▼ ▼
|
|
19
|
+
* tls http2 transport
|
|
20
|
+
* │ │ │
|
|
21
|
+
* └───────┴─────────────┘
|
|
22
|
+
* ▼
|
|
23
|
+
* @browsercore/browsersmith
|
|
24
|
+
*/
|
|
25
|
+
// IANA TLS parameter registries — canonical wire code tables.
|
|
26
|
+
export { CIPHER_GREASE_PLACEHOLDER, CIPHER_SUITE_CODES, NAMED_GROUP_CODES, SIGNATURE_SCHEME_CODES, VERSION_CODES, } from "./models.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAgEH,8DAA8D;AAC9D,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC"}
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Models — shared data models that multiple packages agree on.
|
|
3
|
+
*
|
|
4
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
5
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
6
|
+
*/
|
|
7
|
+
/** Direction of a protocol frame. */
|
|
8
|
+
export type PacketDirection = "sent" | "received";
|
|
9
|
+
/**
|
|
10
|
+
* Base protocol frame — the common shape every frame variant extends.
|
|
11
|
+
*
|
|
12
|
+
* Protocol packages extend this with their specific fields.
|
|
13
|
+
* Consumers inspect the `protocol` field to narrow the type.
|
|
14
|
+
*
|
|
15
|
+
* Why here: Packet inspection callback needs this shape.
|
|
16
|
+
*/
|
|
17
|
+
export interface ProtocolFrame {
|
|
18
|
+
/** Protocol that emitted this frame. */
|
|
19
|
+
readonly protocol: string;
|
|
20
|
+
/** Whether this frame was sent or received. */
|
|
21
|
+
readonly direction: PacketDirection;
|
|
22
|
+
/** Timestamp (ms since epoch) when the frame was captured. */
|
|
23
|
+
readonly timestamp: number;
|
|
24
|
+
}
|
|
25
|
+
/** Branded profile identifier. */
|
|
26
|
+
export type ProfileId = string;
|
|
27
|
+
/**
|
|
28
|
+
* Complete browser fingerprint definition.
|
|
29
|
+
* Pure data — no protocol logic.
|
|
30
|
+
*
|
|
31
|
+
* Why here: browsersmith, fetch, tls, http1, http2 all use profiles.
|
|
32
|
+
*/
|
|
33
|
+
export interface BrowserProfile {
|
|
34
|
+
readonly id: ProfileId;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly tls: TlsProfile;
|
|
37
|
+
readonly http1?: Http1Profile;
|
|
38
|
+
readonly http2?: Http2Profile;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* TLS fingerprint signals.
|
|
42
|
+
*/
|
|
43
|
+
export interface TlsProfile {
|
|
44
|
+
readonly cipherSuites: readonly string[];
|
|
45
|
+
readonly namedGroups: readonly string[];
|
|
46
|
+
readonly signatureSchemes: readonly string[];
|
|
47
|
+
readonly supportedVersions: readonly number[];
|
|
48
|
+
readonly extensionOrder: readonly number[];
|
|
49
|
+
readonly grease: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* HTTP/1 fingerprint signals.
|
|
53
|
+
*/
|
|
54
|
+
export interface Http1Profile {
|
|
55
|
+
readonly userAgent: string;
|
|
56
|
+
readonly headerOrder: readonly string[];
|
|
57
|
+
readonly connectionSettings: ReadonlyMap<string, string>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* HTTP/2 fingerprint signals.
|
|
61
|
+
*/
|
|
62
|
+
export interface Http2Profile {
|
|
63
|
+
readonly settings: ReadonlyMap<string, number>;
|
|
64
|
+
readonly headerOrder: readonly string[];
|
|
65
|
+
readonly initialWindowSize: number;
|
|
66
|
+
readonly maxFrameSize: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* HTTP request — protocol-agnostic.
|
|
70
|
+
*
|
|
71
|
+
* Why here: fetch, http1, http2, http3 all handle requests.
|
|
72
|
+
*/
|
|
73
|
+
export interface Request {
|
|
74
|
+
readonly method: string;
|
|
75
|
+
readonly url: string;
|
|
76
|
+
readonly headers: Headers;
|
|
77
|
+
readonly body?: Uint8Array;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* HTTP response — protocol-agnostic.
|
|
81
|
+
*
|
|
82
|
+
* Why here: fetch, http1, http2, http3 all produce responses.
|
|
83
|
+
*/
|
|
84
|
+
export interface Response {
|
|
85
|
+
readonly status: number;
|
|
86
|
+
readonly statusText: string;
|
|
87
|
+
readonly headers: Headers;
|
|
88
|
+
readonly body: Uint8Array;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetch request options.
|
|
92
|
+
*
|
|
93
|
+
* Why here: fetch and browsersmith both use these options.
|
|
94
|
+
*/
|
|
95
|
+
export interface FetchOptions {
|
|
96
|
+
readonly method?: string;
|
|
97
|
+
readonly headers?: Headers;
|
|
98
|
+
readonly body?: Uint8Array;
|
|
99
|
+
readonly redirect?: "follow" | "manual" | "error";
|
|
100
|
+
readonly signal?: AbortSignal;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* High-level fetch response with convenience methods.
|
|
104
|
+
*
|
|
105
|
+
* Why here: browsersmith and fetch both use this.
|
|
106
|
+
*/
|
|
107
|
+
export interface FetchResponse {
|
|
108
|
+
readonly status: number;
|
|
109
|
+
readonly statusText: string;
|
|
110
|
+
readonly headers: Headers;
|
|
111
|
+
readonly body: Uint8Array;
|
|
112
|
+
json(): Promise<unknown>;
|
|
113
|
+
text(): Promise<string>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* HTTP headers — a case-insensitive multimap.
|
|
117
|
+
*
|
|
118
|
+
* Why here: Every HTTP protocol package uses headers.
|
|
119
|
+
*/
|
|
120
|
+
export interface Headers {
|
|
121
|
+
get(name: string): string | undefined;
|
|
122
|
+
set(name: string, value: string): void;
|
|
123
|
+
delete(name: string): void;
|
|
124
|
+
has(name: string): boolean;
|
|
125
|
+
entries(): IterableIterator<[string, string]>;
|
|
126
|
+
keys(): IterableIterator<string>;
|
|
127
|
+
values(): IterableIterator<string>;
|
|
128
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* HTTP cookie (RFC 6265).
|
|
132
|
+
*
|
|
133
|
+
* Why here: cookies, fetch, browsersmith all use cookies.
|
|
134
|
+
*/
|
|
135
|
+
export interface Cookie {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
readonly value: string;
|
|
138
|
+
readonly domain?: string;
|
|
139
|
+
readonly path?: string;
|
|
140
|
+
readonly expires?: number;
|
|
141
|
+
readonly maxAge?: number;
|
|
142
|
+
readonly secure?: boolean;
|
|
143
|
+
readonly httpOnly?: boolean;
|
|
144
|
+
readonly sameSite?: "Strict" | "Lax" | "None";
|
|
145
|
+
}
|
|
146
|
+
export type HashId = "SHA-256" | "SHA-384";
|
|
147
|
+
export type EcdhCurve = "secp256r1" | "secp384r1";
|
|
148
|
+
export interface X25519KeyPair {
|
|
149
|
+
readonly publicKey: Uint8Array;
|
|
150
|
+
readonly secretKey: Uint8Array;
|
|
151
|
+
}
|
|
152
|
+
export interface EcdhKeyPair {
|
|
153
|
+
readonly curve: EcdhCurve;
|
|
154
|
+
readonly publicKey: Uint8Array;
|
|
155
|
+
readonly secretKey: Uint8Array;
|
|
156
|
+
}
|
|
157
|
+
export interface UdpAddress {
|
|
158
|
+
readonly address: string;
|
|
159
|
+
readonly port: number;
|
|
160
|
+
readonly family: 4 | 6;
|
|
161
|
+
}
|
|
162
|
+
export type TransportState = {
|
|
163
|
+
readonly state: "connecting";
|
|
164
|
+
} | {
|
|
165
|
+
readonly state: "open";
|
|
166
|
+
readonly bytesTransferred: number;
|
|
167
|
+
} | {
|
|
168
|
+
readonly state: "closing";
|
|
169
|
+
} | {
|
|
170
|
+
readonly state: "closed";
|
|
171
|
+
readonly reason: CloseReason;
|
|
172
|
+
};
|
|
173
|
+
export type CloseReason = {
|
|
174
|
+
readonly kind: "client_close";
|
|
175
|
+
} | {
|
|
176
|
+
readonly kind: "remote_close";
|
|
177
|
+
} | {
|
|
178
|
+
readonly kind: "error";
|
|
179
|
+
readonly error: Error;
|
|
180
|
+
} | {
|
|
181
|
+
readonly kind: "timeout";
|
|
182
|
+
readonly afterMs: number;
|
|
183
|
+
};
|
|
184
|
+
export type DatagramCloseReason = {
|
|
185
|
+
readonly kind: "client_close";
|
|
186
|
+
} | {
|
|
187
|
+
readonly kind: "remote_close";
|
|
188
|
+
} | {
|
|
189
|
+
readonly kind: "error";
|
|
190
|
+
readonly error: Error;
|
|
191
|
+
} | {
|
|
192
|
+
readonly kind: "timeout";
|
|
193
|
+
readonly afterMs: number;
|
|
194
|
+
};
|
|
195
|
+
export type TlsState = {
|
|
196
|
+
readonly state: "connecting";
|
|
197
|
+
} | {
|
|
198
|
+
readonly state: "handshaking";
|
|
199
|
+
} | {
|
|
200
|
+
readonly state: "open";
|
|
201
|
+
} | {
|
|
202
|
+
readonly state: "closed";
|
|
203
|
+
readonly reason: CloseReason;
|
|
204
|
+
};
|
|
205
|
+
export type ContentEncoding = "gzip" | "deflate" | "br" | "identity";
|
|
206
|
+
/** The name Chrome/Edge use in their cipher list to mark a GREASE slot (RFC 8701). */
|
|
207
|
+
export declare const CIPHER_GREASE_PLACEHOLDER = "TLS_GREASE_RESERVED_0";
|
|
208
|
+
/**
|
|
209
|
+
* Selected IANA TLS Cipher Suite codes, keyed by canonical suite name.
|
|
210
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-4
|
|
211
|
+
*/
|
|
212
|
+
export declare const CIPHER_SUITE_CODES: Readonly<Record<string, number>>;
|
|
213
|
+
/**
|
|
214
|
+
* Selected IANA TLS Supported Groups (named groups) codes.
|
|
215
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-8
|
|
216
|
+
*/
|
|
217
|
+
export declare const NAMED_GROUP_CODES: Readonly<Record<string, number>>;
|
|
218
|
+
/**
|
|
219
|
+
* Selected IANA TLS Signature Scheme codes.
|
|
220
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-16
|
|
221
|
+
*/
|
|
222
|
+
export declare const SIGNATURE_SCHEME_CODES: Readonly<Record<string, number>>;
|
|
223
|
+
/** IANA TLS ProtocolVersion codes for the supported_versions extension. */
|
|
224
|
+
export declare const VERSION_CODES: Readonly<Record<string, number>>;
|
|
225
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +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,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAM/B;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC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AAC;AAMjE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU,CAAC;AASrE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,0BAA0B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6B/D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU9D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAanE,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK1D,CAAC"}
|
package/dist/models.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Models — shared data models that multiple packages agree on.
|
|
3
|
+
*
|
|
4
|
+
* Litmus test: "Could another package reasonably import this type?"
|
|
5
|
+
* If yes → belongs here. If only one protocol touches it → stays in that package.
|
|
6
|
+
*/
|
|
7
|
+
// ===========================================================================
|
|
8
|
+
// IANA TLS Parameter Registries — canonical wire code tables
|
|
9
|
+
// ===========================================================================
|
|
10
|
+
//
|
|
11
|
+
// Single source of truth for TLS protocol wire codes. Both @browsercore/tls
|
|
12
|
+
// and @browsercore/profiles import from here.
|
|
13
|
+
/** The name Chrome/Edge use in their cipher list to mark a GREASE slot (RFC 8701). */
|
|
14
|
+
export const CIPHER_GREASE_PLACEHOLDER = "TLS_GREASE_RESERVED_0";
|
|
15
|
+
/**
|
|
16
|
+
* Selected IANA TLS Cipher Suite codes, keyed by canonical suite name.
|
|
17
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-4
|
|
18
|
+
*/
|
|
19
|
+
export const CIPHER_SUITE_CODES = {
|
|
20
|
+
[CIPHER_GREASE_PLACEHOLDER]: 0x0a0a,
|
|
21
|
+
TLS_AES_128_GCM_SHA256: 0x1301,
|
|
22
|
+
TLS_AES_256_GCM_SHA384: 0x1302,
|
|
23
|
+
TLS_CHACHA20_POLY1305_SHA256: 0x1303,
|
|
24
|
+
TLS_AES_128_CCM_SHA256: 0x1304,
|
|
25
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: 0xc02b,
|
|
26
|
+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: 0xc02f,
|
|
27
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: 0xc02c,
|
|
28
|
+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: 0xc030,
|
|
29
|
+
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: 0xcca9,
|
|
30
|
+
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: 0xcca8,
|
|
31
|
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: 0xc013,
|
|
32
|
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: 0xc014,
|
|
33
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: 0xc009,
|
|
34
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: 0xc00a,
|
|
35
|
+
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: 0xc023,
|
|
36
|
+
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384: 0xc024,
|
|
37
|
+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: 0xc027,
|
|
38
|
+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384: 0xc028,
|
|
39
|
+
TLS_RSA_WITH_AES_128_GCM_SHA256: 0x009c,
|
|
40
|
+
TLS_RSA_WITH_AES_256_GCM_SHA384: 0x009d,
|
|
41
|
+
TLS_RSA_WITH_AES_128_CBC_SHA: 0x002f,
|
|
42
|
+
TLS_RSA_WITH_AES_256_CBC_SHA: 0x0035,
|
|
43
|
+
TLS_RSA_WITH_AES_128_CBC_SHA256: 0x003c,
|
|
44
|
+
TLS_RSA_WITH_AES_256_CBC_SHA256: 0x003d,
|
|
45
|
+
TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA: 0xc008,
|
|
46
|
+
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: 0xc012,
|
|
47
|
+
TLS_RSA_WITH_3DES_EDE_CBC_SHA: 0x000a,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Selected IANA TLS Supported Groups (named groups) codes.
|
|
51
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-8
|
|
52
|
+
*/
|
|
53
|
+
export const NAMED_GROUP_CODES = {
|
|
54
|
+
x25519: 0x001d,
|
|
55
|
+
x448: 0x001e,
|
|
56
|
+
secp256r1: 0x0017,
|
|
57
|
+
secp384r1: 0x0018,
|
|
58
|
+
secp521r1: 0x0019,
|
|
59
|
+
ffdhe2048: 0x0100,
|
|
60
|
+
ffdhe3072: 0x0101,
|
|
61
|
+
X25519Kyber768: 0x6399,
|
|
62
|
+
X25519MLKEM768: 0x11ec,
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Selected IANA TLS Signature Scheme codes.
|
|
66
|
+
* @see https://www.iana.org/assignments/tls-parameters/tls-parameters-16
|
|
67
|
+
*/
|
|
68
|
+
export const SIGNATURE_SCHEME_CODES = {
|
|
69
|
+
ecdsa_secp256r1_sha256: 0x0403,
|
|
70
|
+
ecdsa_secp384r1_sha384: 0x0503,
|
|
71
|
+
ecdsa_secp521r1_sha512: 0x0603,
|
|
72
|
+
ecdsa_sha1: 0x0203,
|
|
73
|
+
rsa_pss_rsae_sha256: 0x0804,
|
|
74
|
+
rsa_pss_rsae_sha384: 0x0805,
|
|
75
|
+
rsa_pss_rsae_sha512: 0x0806,
|
|
76
|
+
rsa_pkcs1_sha256: 0x0401,
|
|
77
|
+
rsa_pkcs1_sha384: 0x0501,
|
|
78
|
+
rsa_pkcs1_sha512: 0x0601,
|
|
79
|
+
rsa_pkcs1_sha1: 0x0201,
|
|
80
|
+
ed25519: 0x0807,
|
|
81
|
+
};
|
|
82
|
+
/** IANA TLS ProtocolVersion codes for the supported_versions extension. */
|
|
83
|
+
export const VERSION_CODES = {
|
|
84
|
+
"TLS 1.3": 0x0304,
|
|
85
|
+
"TLS 1.2": 0x0303,
|
|
86
|
+
"TLS 1.1": 0x0302,
|
|
87
|
+
"TLS 1.0": 0x0301,
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgPH,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAC9E,EAAE;AACF,4EAA4E;AAC5E,8CAA8C;AAE9C,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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|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe exactly what BrowserCore needs from a runtime —
|
|
5
|
+
* nothing more. They are implemented by thin adapters (e.g. `browsersmith/src/net/node/`)
|
|
6
|
+
* and injected into @browsercore/transport so the protocol stack stays
|
|
7
|
+
* runtime-agnostic (Node, Bun, Deno, Cloudflare Workers, mocks).
|
|
8
|
+
*
|
|
9
|
+
* Design rule: expose only what transport consumes. Don't mirror Node's API.
|
|
10
|
+
*/
|
|
11
|
+
/** Options for establishing a TCP connection. */
|
|
12
|
+
export interface ConnectOptions {
|
|
13
|
+
/** Target host (IP literal or resolved address). */
|
|
14
|
+
readonly host: string;
|
|
15
|
+
/** Target port. */
|
|
16
|
+
readonly port: number;
|
|
17
|
+
/** Disable Nagle's algorithm. */
|
|
18
|
+
readonly noDelay?: boolean;
|
|
19
|
+
/** Local address to bind. */
|
|
20
|
+
readonly localAddress?: string;
|
|
21
|
+
/** IP family: 4 or 6. */
|
|
22
|
+
readonly family?: 4 | 6;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A connected TCP socket — the minimal surface transport needs.
|
|
26
|
+
*
|
|
27
|
+
* This is a structural subset of `node:net.Socket`. Any runtime socket that
|
|
28
|
+
* satisfies these methods can be passed to BrowserCore.
|
|
29
|
+
*/
|
|
30
|
+
export interface Socket {
|
|
31
|
+
/**
|
|
32
|
+
* Write bytes. `cb` fires when data is accepted into the kernel buffer.
|
|
33
|
+
* Returns `false` if the kernel buffer is full (backpressure).
|
|
34
|
+
*/
|
|
35
|
+
write(data: Uint8Array, cb?: (err?: Error | null) => void): boolean;
|
|
36
|
+
/** Gracefully close the writing side. */
|
|
37
|
+
end(): void;
|
|
38
|
+
/** Forcefully destroy the socket (optionally with an error). */
|
|
39
|
+
destroy(error?: Error): void;
|
|
40
|
+
/** True once the socket is destroyed. */
|
|
41
|
+
readonly destroyed: boolean;
|
|
42
|
+
/** Register a one-time listener. */
|
|
43
|
+
once(event: "connect" | "close", listener: () => void): void;
|
|
44
|
+
once(event: "error", listener: (err: Error) => void): void;
|
|
45
|
+
/** Register a persistent listener. */
|
|
46
|
+
on(event: "data", listener: (chunk: Uint8Array) => void): void;
|
|
47
|
+
on(event: "drain" | "end", listener: () => void): void;
|
|
48
|
+
on(event: "error", listener: (err: Error) => void): void;
|
|
49
|
+
on(event: "close", listener: (hadError: boolean) => void): void;
|
|
50
|
+
}
|
|
51
|
+
/** Establish a TCP connection. */
|
|
52
|
+
export interface Net {
|
|
53
|
+
connect(options: ConnectOptions): Socket;
|
|
54
|
+
}
|
|
55
|
+
/** A resolved IP address. */
|
|
56
|
+
export interface IPAddress {
|
|
57
|
+
/** The resolved IP address. */
|
|
58
|
+
readonly address: string;
|
|
59
|
+
/** Address family: 4 for IPv4, 6 for IPv6. */
|
|
60
|
+
readonly family: 4 | 6;
|
|
61
|
+
}
|
|
62
|
+
/** DNS resolution abstraction. */
|
|
63
|
+
export interface DnsResolver {
|
|
64
|
+
/**
|
|
65
|
+
* Resolve a hostname to one or more IP addresses.
|
|
66
|
+
* @param hostname - DNS name to resolve.
|
|
67
|
+
* @param family - Preferred IP family (4 or 6).
|
|
68
|
+
* @returns Resolved addresses (at least one).
|
|
69
|
+
*/
|
|
70
|
+
lookup(hostname: string, family: 4 | 6): Promise<readonly IPAddress[]>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=net.d.ts.map
|
|
@@ -0,0 +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,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY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AAC;CAC5C;AAMD,6BAA6B;AAC7B,MAAM,WAAW,SAAS;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,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;CAC1E"}
|
package/dist/net.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic TCP and DNS contracts.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces describe exactly what BrowserCore needs from a runtime —
|
|
5
|
+
* nothing more. They are implemented by thin adapters (e.g. `browsersmith/src/net/node/`)
|
|
6
|
+
* and injected into @browsercore/transport so the protocol stack stays
|
|
7
|
+
* runtime-agnostic (Node, Bun, Deno, Cloudflare Workers, mocks).
|
|
8
|
+
*
|
|
9
|
+
* Design rule: expose only what transport consumes. Don't mirror Node's API.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=net.js.map
|
package/dist/net.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"net.js","sourceRoot":"","sources":["../src/net.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options — configuration for protocol packages.
|
|
3
|
+
*
|
|
4
|
+
* Each protocol package accepts an options object that implements one of
|
|
5
|
+
* these interfaces. Options are implementation-independent configuration
|
|
6
|
+
* that gets passed down from consumers like browsersmith.
|
|
7
|
+
*/
|
|
8
|
+
import type { Transport, DatagramTransport, QuicConnection, Clock, PacketCallback, CookieJar } from "./contracts.js";
|
|
9
|
+
import type { BrowserProfile, UdpAddress } from "./models.js";
|
|
10
|
+
export interface TlsOptions {
|
|
11
|
+
readonly transport: Transport;
|
|
12
|
+
readonly profile: BrowserProfile;
|
|
13
|
+
readonly serverName: string;
|
|
14
|
+
readonly clock?: Clock;
|
|
15
|
+
readonly onPacket?: PacketCallback;
|
|
16
|
+
}
|
|
17
|
+
export interface Http1Options {
|
|
18
|
+
readonly transport: Transport;
|
|
19
|
+
readonly profile: BrowserProfile;
|
|
20
|
+
readonly onPacket?: PacketCallback;
|
|
21
|
+
}
|
|
22
|
+
export interface Http2Options {
|
|
23
|
+
readonly transport: Transport;
|
|
24
|
+
readonly profile: BrowserProfile;
|
|
25
|
+
readonly onPacket?: PacketCallback;
|
|
26
|
+
}
|
|
27
|
+
export interface Http3Options {
|
|
28
|
+
readonly quic: QuicConnection;
|
|
29
|
+
readonly clock?: Clock;
|
|
30
|
+
readonly onPacket?: PacketCallback;
|
|
31
|
+
}
|
|
32
|
+
export interface QuicOptions {
|
|
33
|
+
readonly transport: DatagramTransport;
|
|
34
|
+
readonly peer: UdpAddress;
|
|
35
|
+
readonly serverName: string;
|
|
36
|
+
readonly initialDcid: Uint8Array;
|
|
37
|
+
readonly initialScid: Uint8Array;
|
|
38
|
+
readonly handshakeTimeoutMs?: number;
|
|
39
|
+
readonly clock?: Clock;
|
|
40
|
+
readonly onPacket?: PacketCallback;
|
|
41
|
+
}
|
|
42
|
+
export interface FetchClientOptions {
|
|
43
|
+
readonly profile?: BrowserProfile;
|
|
44
|
+
readonly cookieJar?: CookieJar;
|
|
45
|
+
readonly tls?: Partial<TlsOptions>;
|
|
46
|
+
readonly http2?: Partial<Http2Options>;
|
|
47
|
+
readonly http3?: Partial<Http3Options>;
|
|
48
|
+
readonly transport?: Transport;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],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AAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACtC;AAMD,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAClC"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options — configuration for protocol packages.
|
|
3
|
+
*
|
|
4
|
+
* Each protocol package accepts an options object that implements one of
|
|
5
|
+
* these interfaces. Options are implementation-independent configuration
|
|
6
|
+
* that gets passed down from consumers like browsersmith.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@browsercore/contracts",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Shared interfaces, models, and options for the browsercore stack",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"clean": "rm -rf dist"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^26.1.2",
|
|
28
|
+
"typescript": "^7.0.2"
|
|
29
|
+
}
|
|
30
|
+
}
|