@browsercore/contracts 0.2.4 → 0.2.6
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 +102 -14
- package/dist/config.d.ts +99 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +20 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts.d.ts +116 -145
- package/dist/contracts.d.ts.map +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +36 -3
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/platform.d.ts +33 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +6 -6
- package/dist/tcp-transport.d.ts +29 -5
- package/dist/tcp-transport.d.ts.map +1 -1
- package/dist/time.d.ts +75 -21
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +5 -4
- package/dist/time.js.map +1 -1
- package/dist/tls-engine.d.ts +317 -0
- package/dist/tls-engine.d.ts.map +1 -0
- package/dist/tls-engine.js +41 -0
- package/dist/tls-engine.js.map +1 -0
- package/package.json +3 -3
- package/dist/options.d.ts +0 -51
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js +0 -9
- package/dist/options.js.map +0 -1
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;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,CAA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AAO,CAAC;IACjD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACrC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IACnF,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/index.d.ts
CHANGED
|
@@ -22,15 +22,16 @@
|
|
|
22
22
|
* ▼
|
|
23
23
|
* browsersmith (composition root — builds & threads Platform)
|
|
24
24
|
*/
|
|
25
|
-
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport,
|
|
25
|
+
export type { CryptoProvider, CompressionProvider, Transport, DatagramTransport, UdpSocketFactory, CookieJar, PacketCallback, PacketInspectionOptions, } from "./contracts.js";
|
|
26
26
|
export type { ProfileId, BrowserProfile, TlsProfile, Http1Profile, Http2Profile, HpackProfile, Http2PriorityFrame, Request, Response, FetchOptions, FetchResponse, Headers, Cookie, HashId, EcdhCurve, X25519KeyPair, MLKEM768KeyPair, EcdhKeyPair, UdpAddress, TransportState, CloseReason, DatagramCloseReason, TlsState, ContentEncoding, } from "./models.js";
|
|
27
27
|
export { CIPHER_GREASE_PLACEHOLDER, CIPHER_SUITE_CODES, NAMED_GROUP_CODES, SIGNATURE_SCHEME_CODES, VERSION_CODES, } from "./models.js";
|
|
28
28
|
export type { ConnectOptions, Socket, Net, DnsResolver, IPAddress, Network, } from "./tcp-transport.js";
|
|
29
|
+
export type { AeadAlgorithm, CipherSuite, NamedGroup, SignatureScheme, ProtocolVersion, ClientHelloConfig, ServerHello, Certificate, KeyPair, TrafficSecrets, ApplicationTrafficSecrets, HandshakePhase, AlertLevel, TlsHandshakeContext, TlsHandshakeEngine, } from "./tls-engine.js";
|
|
30
|
+
export type { ProxyScheme, ProxyConfig, ProxyTarget, ProxyCredentials, CookieJarConsumer, } from "./config.js";
|
|
29
31
|
export type { EventProvider, TypedEventEmitter, } from "./events.js";
|
|
30
32
|
export type { Logger, Span, Tracer, Metrics, Telemetry, } from "./telemetry.js";
|
|
31
|
-
export type { Clock, Deadline, Scheduler, Time, } from "./time.js";
|
|
33
|
+
export type { Clock, TimerHandle, Deadline, Scheduler, Time, } from "./time.js";
|
|
32
34
|
/** Duration static factories — `Duration.seconds(5)`, `Duration.milliseconds(250)`. */
|
|
33
35
|
export { Duration } from "./time.js";
|
|
34
36
|
export type { Compression, Crypto, Platform, PlatformOptions, } from "./platform.js";
|
|
35
|
-
export type { TlsOptions, Http1Options, Http2Options, Http3Options, QuicOptions, FetchClientOptions, } from "./options.js";
|
|
36
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,YAAY,EAER,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAEhB,SAAS,EAET,cAAc,EACd,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAER,SAAS,EAET,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAElB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,aAAa,EAEb,OAAO,EAEP,MAAM,EAEN,MAAM,EACN,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EAEX,UAAU,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,QAAQ,EAER,eAAe,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,cAAc,EACd,MAAM,EACN,GAAG,EACH,WAAW,EACX,SAAS,EACT,OAAO,GACV,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EAER,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EAEf,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,UAAU,EAEV,mBAAmB,EACnB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AAMzB,YAAY,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,aAAa,EACb,iBAAiB,GACpB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACR,MAAM,EACN,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,GACZ,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EACR,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,IAAI,GACP,MAAM,WAAW,CAAC;AAEnB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAMrC,YAAY,EACR,WAAW,EACX,MAAM,EACN,QAAQ,EACR,eAAe,GAClB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -26,4 +26,9 @@
|
|
|
26
26
|
export { CIPHER_GREASE_PLACEHOLDER, CIPHER_SUITE_CODES, NAMED_GROUP_CODES, SIGNATURE_SCHEME_CODES, VERSION_CODES, } from "./models.js";
|
|
27
27
|
/** Duration static factories — `Duration.seconds(5)`, `Duration.milliseconds(250)`. */
|
|
28
28
|
export { Duration } from "./time.js";
|
|
29
|
+
// The former Options layer (TlsOptions/Http1Options/…/FetchClientOptions) and
|
|
30
|
+
// the Protocol Connection Contracts (TlsConnection/Http1Connection/…
|
|
31
|
+
// /QuicConnection/QuicStream/FetchClient) were removed: zero consumers
|
|
32
|
+
// repo-wide, every consumer binds implementation-local types
|
|
33
|
+
// (replaceability audit 2026-11-16).
|
|
29
34
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA2DH,8DAA8D;AAC9D,OAAO,EACH,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GAChB,MAAM,aAAa,CAAC;AAqFrB,uFAAuF;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAarC,8EAA8E;AAC9E,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,qCAAqC"}
|
package/dist/models.d.ts
CHANGED
|
@@ -22,8 +22,32 @@ export interface ProtocolFrame {
|
|
|
22
22
|
/** Timestamp (ms since epoch) when the frame was captured. */
|
|
23
23
|
readonly timestamp: number;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Profile identifier — the registry keys of @browsercore/profiles' built-in
|
|
27
|
+
* browser fingerprints.
|
|
28
|
+
*
|
|
29
|
+
* Canonical union (0.2.6), derived from the profiles registry
|
|
30
|
+
* (`@browsercore/profiles/src/registry.ts` indexes exactly these ids from the
|
|
31
|
+
* chrome/firefox/safari/edge profile sources — extend here when a new
|
|
32
|
+
* browser version lands). `@browsercore/profiles` currently keeps its own
|
|
33
|
+
* branded `ProfileId` (`string & { __brand: "ProfileId" }`); the two
|
|
34
|
+
* reconcile next wave (canonical-with-alias), where profiles also decides how
|
|
35
|
+
* runtime-registered custom ids (`registerProfile`) widen the set. Consumers
|
|
36
|
+
* passing a known registry id get literal autocomplete and typo protection
|
|
37
|
+
* here.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The closed set of registry-shipped profile ids. Literal autocomplete +
|
|
41
|
+
* typo protection; deliberately NOT exported alone — see {@link ProfileId}.
|
|
42
|
+
*/
|
|
43
|
+
export type RegisteredProfileId = "chrome-120" | "chrome-128" | "chrome-140" | "edge-120" | "edge-128" | "firefox-120" | "firefox-128" | "firefox-135" | "safari-17" | "safari-18";
|
|
44
|
+
/**
|
|
45
|
+
* ProfileId = the registry ids PLUS any runtime-registered custom id
|
|
46
|
+
* (`registerProfile`). The `(string & {})` widening keeps literal
|
|
47
|
+
* autocomplete and typo-flagging for the known ids while accepting custom
|
|
48
|
+
* registrations — a closed union would break the registry's extension point.
|
|
49
|
+
*/
|
|
50
|
+
export type ProfileId = RegisteredProfileId | (string & Record<never, never>);
|
|
27
51
|
/**
|
|
28
52
|
* Complete browser fingerprint definition.
|
|
29
53
|
* Pure data — no protocol logic.
|
|
@@ -284,11 +308,20 @@ export interface UdpAddress {
|
|
|
284
308
|
readonly port: number;
|
|
285
309
|
readonly family: 4 | 6;
|
|
286
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Lifecycle state of a transport connection.
|
|
313
|
+
*
|
|
314
|
+
* Canonical shape — identical to the one `@browsercore/transport` implements
|
|
315
|
+
* and every protocol package consumes. The `open` variant carries no byte
|
|
316
|
+
* counter: the former `bytesTransferred` field was implemented by nobody
|
|
317
|
+
* (only faked by @browsercore/proxy's socket adapter) and is gone
|
|
318
|
+
* (replaceability audit 2026-11-16). Extra state fields stay permitted via
|
|
319
|
+
* structural typing — implementations may keep richer internal states.
|
|
320
|
+
*/
|
|
287
321
|
export type TransportState = {
|
|
288
322
|
readonly state: "connecting";
|
|
289
323
|
} | {
|
|
290
324
|
readonly state: "open";
|
|
291
|
-
readonly bytesTransferred: number;
|
|
292
325
|
} | {
|
|
293
326
|
readonly state: "closing";
|
|
294
327
|
} | {
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,qCAAqC;AACrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAMD,
|
|
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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,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU,CAAC;AAYrE,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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgaH,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,sEAAsE;AACtE,0EAA0E;AAC1E,kBAAkB;AAElB,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAChE,CAAC,yBAAyB,CAAC,EAAE,MAAM;IACnC,sBAAsB,EAAE,MAAM;IAC9B,sBAAsB,EAAE,MAAM;IAC9B,4BAA4B,EAAE,MAAM;IACpC,sBAAsB,EAAE,MAAM;IAC9B,uCAAuC,EAAE,MAAM;IAC/C,qCAAqC,EAAE,MAAM;IAC7C,uCA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AAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC3D,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;CACpB,CAAC"}
|
package/dist/platform.d.ts
CHANGED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
* │
|
|
13
13
|
* ▼
|
|
14
14
|
* Platform
|
|
15
|
-
* ├── network
|
|
16
|
-
* ├── crypto
|
|
17
|
-
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
-
* ├── events
|
|
19
|
-
* ├── telemetry
|
|
20
|
-
* └── time
|
|
15
|
+
* ├── network? (TCP, DNS, UDP socket factory — each member optional)
|
|
16
|
+
* ├── crypto? (CryptoProvider)
|
|
17
|
+
* ├── compression? (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events? (EventProvider)
|
|
19
|
+
* ├── telemetry? (logger, tracer, metrics)
|
|
20
|
+
* └── time? (Clock — the canonical time contract)
|
|
21
21
|
*
|
|
22
22
|
* All fields are interfaces — this file has zero runtime behavior
|
|
23
23
|
* and zero node:* imports.
|
|
24
24
|
*/
|
|
25
25
|
import type { Network, Net, DnsResolver } from "./tcp-transport.js";
|
|
26
|
-
import type { CryptoProvider, CompressionProvider,
|
|
26
|
+
import type { CryptoProvider, CompressionProvider, UdpSocketFactory } from "./contracts.js";
|
|
27
27
|
import type { EventProvider } from "./events.js";
|
|
28
28
|
import type { Telemetry } from "./telemetry.js";
|
|
29
29
|
import type { Time } from "./time.js";
|
|
@@ -55,14 +55,33 @@ export interface Crypto {
|
|
|
55
55
|
* imports) and threaded down through options to every protocol package.
|
|
56
56
|
* No package hardwires runtime imports; all capabilities arrive via this
|
|
57
57
|
* object. This is the seam that makes BrowserCore portable and testable.
|
|
58
|
+
*
|
|
59
|
+
* Every bundle is OPTIONAL (replaceability audit 2026-11-16, remediation
|
|
60
|
+
* item #5: "Platform all-or-nothing with REQUIRED udp" forced consumers to
|
|
61
|
+
* lie to the type system). A platform now carries exactly the capabilities
|
|
62
|
+
* its runtime has — a UDP-less runtime (Cloudflare Workers) omits
|
|
63
|
+
* `network.udp`, a crypto-less test platform omits `crypto`. Consumers
|
|
64
|
+
* resolve the bundle they use and, when it is absent, throw a typed error
|
|
65
|
+
* that names the missing capability. The sanctioned pattern already exists:
|
|
66
|
+
* `@browsercore/fetch`'s `proxyDialPlatform` (`fetch/src/proxy.ts`) assembles
|
|
67
|
+
* a minimal platform whose untouched bundles are throwing getters naming the
|
|
68
|
+
* culprit — with optional bundles the same guarantee is expressed by simply
|
|
69
|
+
* omitting the field, and consumers write
|
|
70
|
+
* `platform.network?.tcp ?? throw new MissingCapabilityError("platform.network.tcp")`.
|
|
71
|
+
*
|
|
72
|
+
* Implementers may still provide every bundle (browsersmith's `createPlatform()`
|
|
73
|
+
* does) — an implementation that provides more than a consumer requires
|
|
74
|
+
* always satisfies the interface. Optionality only removes the obligation to
|
|
75
|
+
* FAKE capabilities a runtime lacks.
|
|
58
76
|
*/
|
|
59
77
|
export interface Platform {
|
|
60
|
-
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
readonly
|
|
78
|
+
/** Network bundle (TCP, DNS, UDP factory) — each member independently optional. */
|
|
79
|
+
readonly network?: Network;
|
|
80
|
+
readonly crypto?: Crypto;
|
|
81
|
+
readonly compression?: Compression;
|
|
82
|
+
readonly events?: EventProvider;
|
|
83
|
+
readonly telemetry?: Telemetry;
|
|
84
|
+
readonly time?: Time;
|
|
66
85
|
}
|
|
67
86
|
/**
|
|
68
87
|
* Options for overriding individual platform adapters.
|
|
@@ -74,7 +93,7 @@ export interface PlatformOptions {
|
|
|
74
93
|
readonly network?: {
|
|
75
94
|
readonly tcp?: Net;
|
|
76
95
|
readonly dns?: DnsResolver;
|
|
77
|
-
readonly udp?:
|
|
96
|
+
readonly udp?: UdpSocketFactory;
|
|
78
97
|
};
|
|
79
98
|
readonly crypto?: {
|
|
80
99
|
readonly provider?: CryptoProvider;
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,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;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAM9C;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACrC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,QAAQ;IACrB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;CACxB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE;QACf,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;QACnB,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;QAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC;KACnC,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE;QACd,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;KACtC,CAAC;IACF,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;CACxB"}
|
package/dist/platform.js
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* │
|
|
13
13
|
* ▼
|
|
14
14
|
* Platform
|
|
15
|
-
* ├── network
|
|
16
|
-
* ├── crypto
|
|
17
|
-
* ├── compression (gzip, deflate, brotli, etc.)
|
|
18
|
-
* ├── events
|
|
19
|
-
* ├── telemetry
|
|
20
|
-
* └── time
|
|
15
|
+
* ├── network? (TCP, DNS, UDP socket factory — each member optional)
|
|
16
|
+
* ├── crypto? (CryptoProvider)
|
|
17
|
+
* ├── compression? (gzip, deflate, brotli, etc.)
|
|
18
|
+
* ├── events? (EventProvider)
|
|
19
|
+
* ├── telemetry? (logger, tracer, metrics)
|
|
20
|
+
* └── time? (Clock — the canonical time contract)
|
|
21
21
|
*
|
|
22
22
|
* All fields are interfaces — this file has zero runtime behavior
|
|
23
23
|
* and zero node:* imports.
|
package/dist/tcp-transport.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* what any one runtime provides. Packages depend on this contract; runtimes
|
|
12
12
|
* adapt to it.
|
|
13
13
|
*/
|
|
14
|
-
import type {
|
|
14
|
+
import type { UdpSocketFactory } from "./contracts.js";
|
|
15
15
|
/** Options for establishing a TCP connection. */
|
|
16
16
|
export interface ConnectOptions {
|
|
17
17
|
/** Target host (IP literal or resolved address). */
|
|
@@ -82,14 +82,38 @@ export interface DnsResolver {
|
|
|
82
82
|
/**
|
|
83
83
|
* `Network` — the injected network bundle (part of `Platform`).
|
|
84
84
|
*
|
|
85
|
-
* Aggregates `Net`, `DnsResolver`, and `
|
|
85
|
+
* Aggregates `Net`, `DnsResolver`, and the `UdpSocketFactory` into a single
|
|
86
86
|
* object that `browsersmith` assembles and passes down through
|
|
87
87
|
* `Platform.network`. Protocol packages never import `node:net` /
|
|
88
88
|
* `node:dgram` directly.
|
|
89
|
+
*
|
|
90
|
+
* Every member is OPTIONAL (replaceability audit 2026-11-16, remediation
|
|
91
|
+
* item #5): a platform provides exactly the capabilities its runtime has,
|
|
92
|
+
* and a consumer resolves the member it needs before use — a missing member
|
|
93
|
+
* is a typed, named failure at the point of use, never a silent stub. The
|
|
94
|
+
* sanctioned pattern is `@browsercore/fetch`'s `proxyDialPlatform`
|
|
95
|
+
* (`fetch/src/proxy.ts`): it reads only `network.tcp` (all schemes) and
|
|
96
|
+
* `network.dns` (socks5 with a hostname target) and raises its own typed
|
|
97
|
+
* error naming the missing capability when a required member is absent —
|
|
98
|
+
* which is why `dns` stays genuinely `undefined` there instead of being
|
|
99
|
+
* faked. Consumers should do the same: dereference defensively
|
|
100
|
+
* (`platform.network?.tcp`) and throw an explicit error such as
|
|
101
|
+
* `"platform.network.udp is not available on this runtime"` that names the
|
|
102
|
+
* missing capability, so a wiring gap is diagnosable at the call site.
|
|
89
103
|
*/
|
|
90
104
|
export interface Network {
|
|
91
|
-
|
|
92
|
-
readonly
|
|
93
|
-
|
|
105
|
+
/** TCP connect capability. Omitted by datagram-only or connectionless runtimes. */
|
|
106
|
+
readonly tcp?: Net;
|
|
107
|
+
/** DNS resolution capability. Omitted when the runtime cannot resolve (proxy remote-DNS paths). */
|
|
108
|
+
readonly dns?: DnsResolver;
|
|
109
|
+
/**
|
|
110
|
+
* UDP datagram factory. A FACTORY, not a shared instance: `connect()`
|
|
111
|
+
* returns a per-connection {@link UdpSocketFactory} socket so nothing is
|
|
112
|
+
* bound at module-import time (the former instance shape forced
|
|
113
|
+
* `browsersmith`'s import-time `createSocket("udp4")` singleton —
|
|
114
|
+
* replaceability audit 2026-11-16). Omitted by runtimes without UDP
|
|
115
|
+
* (e.g. Cloudflare Workers — HTTP/3 is unavailable there, HTTP/2 is not).
|
|
116
|
+
*/
|
|
117
|
+
readonly udp?: UdpSocketFactory;
|
|
94
118
|
}
|
|
95
119
|
//# sourceMappingURL=tcp-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../src/tcp-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../src/tcp-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMvD,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,yBAAyB;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CA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,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;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"}
|
package/dist/time.d.ts
CHANGED
|
@@ -3,26 +3,80 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These interfaces describe what BrowserCore needs from a runtime's time and
|
|
5
5
|
* scheduling facilities. They are implemented by thin adapters (e.g.
|
|
6
|
-
* `browsersmith/src/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
-
* packages call `clock.now()` / `
|
|
8
|
-
* never against `setTimeout` or `performance.now`
|
|
9
|
-
* stays runtime-agnostic and deterministically
|
|
6
|
+
* `browsersmith/src/platform/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
+
* Protocol packages call `clock.now()` / `clock.sleep()` against these
|
|
8
|
+
* interfaces — never against `setTimeout`, `Date.now`, or `performance.now`
|
|
9
|
+
* directly — so the stack stays runtime-agnostic and deterministically
|
|
10
|
+
* testable.
|
|
10
11
|
*
|
|
11
12
|
* Design rule: the interface is defined by what packages *consume*, not by
|
|
12
13
|
* what any one runtime provides.
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* An opaque timer handle returned by {@link Clock.setTimeout}.
|
|
16
17
|
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
18
|
+
* Deliberately `object`, NOT `NodeJS.Timeout`/`number`: the runtime-coupling
|
|
19
|
+
* audit (2026-11-16) flagged `NodeJS.Timeout` leaking into published `.d.ts`
|
|
20
|
+
* (`transport/src/timers.ts` — the only `NodeJS.` reference polyrepo-wide) as
|
|
21
|
+
* a platform-independence loss. Every runtime's timer token (Node's
|
|
22
|
+
* `Timeout`, a browser's numeric id, a Workers `ScheduledController`) is an
|
|
23
|
+
* `object` or boxes into one, so `object` is the maximal-width opaque token:
|
|
24
|
+
* implementations hand back whatever they want, callers hand it to
|
|
25
|
+
* {@link Clock.clearTimeout} and nothing else. Treating it as anything more
|
|
26
|
+
* specific is a contract violation.
|
|
27
|
+
*/
|
|
28
|
+
export type TimerHandle = object;
|
|
29
|
+
/**
|
|
30
|
+
* `Clock` — THE canonical time source for the entire stack.
|
|
31
|
+
*
|
|
32
|
+
* Supersedes (replaceability audit 2026-11-16, remediation item #6 +
|
|
33
|
+
* runtime-coupling audit fact #3: "five incompatible sibling Clock interfaces
|
|
34
|
+
* exist — tls/http1/http2/http3/quic each define their own"): the five
|
|
35
|
+
* package-local shapes were —
|
|
36
|
+
*
|
|
37
|
+
* tls : { now(): number; sleep(ms): Promise<void> }
|
|
38
|
+
* http1 : { now(): number }
|
|
39
|
+
* http2 : { now(): number; setTimeout(cb, ms); clearTimeout(t) }
|
|
40
|
+
* http3 : { now(): number; setTimeout(cb, ms): () => void } (disposer)
|
|
41
|
+
* quic : { now(): number }
|
|
42
|
+
*
|
|
43
|
+
* This interface is the single shape all of them migrate onto (next wave):
|
|
44
|
+
* their `options.clock` seams switch to importing this type, their local
|
|
45
|
+
* declarations are deleted, and their bare `setTimeout`/`Date.now` call
|
|
46
|
+
* sites route through an injected Clock. `@browsercore/transport`'s bare
|
|
47
|
+
* timers (`timers.ts`) and `@browsercore/fetch`'s bare `setTimeout`
|
|
48
|
+
* (`client.ts`, `pool.ts`) — the audit's top two behavioral-coupling
|
|
49
|
+
* findings — migrate onto the same seam.
|
|
50
|
+
*
|
|
51
|
+
* Unit contract:
|
|
52
|
+
* - `now()` is WALL time (epoch ms, `Date.now()`-comparable) — for
|
|
53
|
+
* timestamps, logging, certificate validity. It CAN jump (NTP).
|
|
54
|
+
* - `monotonic()` is MONOTONIC time in ms — for elapsed/deadline math.
|
|
55
|
+
* Never compare `now()` against `monotonic()`; never use `Date.now()`
|
|
56
|
+
* deltas for deadlines (wall-clock drift corrupts timeouts).
|
|
19
57
|
*/
|
|
20
58
|
export interface Clock {
|
|
21
|
-
/** Wall-clock time, epoch milliseconds. */
|
|
59
|
+
/** Wall-clock time, epoch milliseconds (comparable with `Date.now()`). */
|
|
22
60
|
now(): number;
|
|
23
|
-
/**
|
|
24
|
-
monotonic():
|
|
61
|
+
/** Monotonic time in milliseconds — never goes backwards; for elapsed/deadline math. */
|
|
62
|
+
monotonic(): number;
|
|
63
|
+
/** Resolve after `ms` milliseconds (replacement for bare `setTimeout`-as-sleep). */
|
|
64
|
+
sleep(ms: number): Promise<void>;
|
|
65
|
+
/** Run `fn` once after `ms` milliseconds; cancel via {@link clearTimeout}. */
|
|
66
|
+
setTimeout(ms: number, fn: () => void): TimerHandle;
|
|
67
|
+
/** Cancel a pending timer obtained from {@link setTimeout}. */
|
|
68
|
+
clearTimeout(handle: TimerHandle): void;
|
|
25
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* `Time` — the `Platform` bundle name for {@link Clock}.
|
|
72
|
+
*
|
|
73
|
+
* Alias kept so `Platform.time` reads as a bundle alongside
|
|
74
|
+
* `network`/`crypto`; the underlying contract is THE Clock above (the former
|
|
75
|
+
* `{ clock, scheduler }` bundle shape was implemented by zero protocol
|
|
76
|
+
* packages — runtime-coupling audit 2026-11-16 — and the five sibling clocks
|
|
77
|
+
* all bind the Clock surface directly, so the Clock IS the bundle).
|
|
78
|
+
*/
|
|
79
|
+
export type Time = Clock;
|
|
26
80
|
/**
|
|
27
81
|
* A duration interval.
|
|
28
82
|
*
|
|
@@ -35,29 +89,29 @@ export interface Duration {
|
|
|
35
89
|
}
|
|
36
90
|
/**
|
|
37
91
|
* A deadline bound to an AbortSignal.
|
|
92
|
+
*
|
|
93
|
+
* `expiresAt` is in {@link Clock.monotonic} milliseconds (reconciled with the
|
|
94
|
+
* canonical Clock in 0.2.6 — it was a `bigint` nanosecond value tied to the
|
|
95
|
+
* old superseded Clock whose `monotonic()` returned ns; with `monotonic()`
|
|
96
|
+
* now in ms, the deadline unit matches so `scheduler.deadline()` results stay
|
|
97
|
+
* comparable against the injected clock).
|
|
38
98
|
*/
|
|
39
99
|
export interface Deadline {
|
|
40
100
|
readonly signal: AbortSignal;
|
|
41
|
-
readonly expiresAt:
|
|
101
|
+
readonly expiresAt: number;
|
|
42
102
|
}
|
|
43
103
|
/**
|
|
44
104
|
* Scheduler — creates delays, timeouts, and deadlines.
|
|
105
|
+
*
|
|
106
|
+
* Kept for callers that compose `Duration`-based scheduling; the five sibling
|
|
107
|
+
* clock migrations bind {@link Clock} directly (`sleep`/`setTimeout` cover
|
|
108
|
+
* the same ground without pre-wrapping durations).
|
|
45
109
|
*/
|
|
46
110
|
export interface Scheduler {
|
|
47
111
|
delay(duration: Duration, signal?: AbortSignal): Promise<void>;
|
|
48
112
|
timeout(duration: Duration): AbortSignal;
|
|
49
113
|
deadline(duration: Duration): Deadline;
|
|
50
114
|
}
|
|
51
|
-
/**
|
|
52
|
-
* `Time` — the injected time bundle (part of `Platform`).
|
|
53
|
-
*
|
|
54
|
-
* Aggregates `Clock` and `Scheduler` into a single object that `browsersmith`
|
|
55
|
-
* assembles and passes down through `Platform.time`.
|
|
56
|
-
*/
|
|
57
|
-
export interface Time {
|
|
58
|
-
readonly clock: Clock;
|
|
59
|
-
readonly scheduler: Scheduler;
|
|
60
|
-
}
|
|
61
115
|
/**
|
|
62
116
|
* `Duration` factory — pure function object, no runtime deps.
|
|
63
117
|
*
|
package/dist/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,KAAK;IAClB,0EAA0E;IAC1E,GAAG,IAAI,MAAM,CAAC;IACd,wFAAwF;IACxF,SAAS,IAAI,MAAM,CAAC;IACpB,oFAAoF;IACpF,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IACpD,+DAA+D;IAC/D,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,OAAO,IAAI,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC1C;AAMD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;IACjB,OAAO,MAAM,MAAM,KAAG,QAAQ;IAC9B,YAAY,MAAM,MAAM,KAAG,QAAQ;CACtC,CAAC"}
|
package/dist/time.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These interfaces describe what BrowserCore needs from a runtime's time and
|
|
5
5
|
* scheduling facilities. They are implemented by thin adapters (e.g.
|
|
6
|
-
* `browsersmith/src/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
-
* packages call `clock.now()` / `
|
|
8
|
-
* never against `setTimeout` or `performance.now`
|
|
9
|
-
* stays runtime-agnostic and deterministically
|
|
6
|
+
* `browsersmith/src/platform/time/node/`) and **injected** as `Platform.time`.
|
|
7
|
+
* Protocol packages call `clock.now()` / `clock.sleep()` against these
|
|
8
|
+
* interfaces — never against `setTimeout`, `Date.now`, or `performance.now`
|
|
9
|
+
* directly — so the stack stays runtime-agnostic and deterministically
|
|
10
|
+
* testable.
|
|
10
11
|
*
|
|
11
12
|
* Design rule: the interface is defined by what packages *consume*, not by
|
|
12
13
|
* what any one runtime provides.
|
package/dist/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA4GH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IAChF,YAAY,EAAE,CAAC,CAAS,EAAY,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC;CACxF,CAAC"}
|