@ac-kit/net-core 0.2.0 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @ac-kit/net-core
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5075202: HTTP/3, over a multiplexed connection contract.
8
+
9
+ - `net-core`: `IMultiplexedConnection` and `IMultiplexedStream` — a secure
10
+ connection carrying many streams, each a `Transport` that either side can
11
+ reset or stop on its own — with `MultiplexedStreamHandlers` and the errors a
12
+ reset, a stop or the connection's end report. `Connector` is now generic over
13
+ what it establishes, like `IListener`.
14
+ - `async`: `staggeredRace`, RFC 8305 connection racing for any candidates.
15
+ - `format-varint`: QUIC variable-length integers (RFC 9000 §16) —
16
+ `readQuicVarint`, `readBigQuicVarint` (the whole 62-bit range, as a
17
+ `bigint`), `writeQuicVarint`, `encodeQuicVarint`, `quicVarintByteLength` and
18
+ `quicVarintEncodedLength`.
19
+ - `format-http`: `QpackDecoder` (RFC 9204, dynamic table and blocked streams)
20
+ and `QpackEncoder` (static table and literals); `Http3FrameDecoder` and
21
+ `encodeHttp3Frame` for HTTP/3 frames (RFC 9114), with DATA streamed in
22
+ pieces; `Http3Settings`, `Http3StreamType`, `Http3Error` and
23
+ `Http3ErrorCode`. `parseAltSvc` and `tryParseAltSvc` read the `Alt-Svc`
24
+ field (RFC 7838), `AltSvcSyntaxError` reporting a malformed one.
25
+ - `net-http`: `Http3ServerConnection` and `Http3ClientConnection`, with
26
+ trailers, GOAWAY and extended `CONNECT` tunnels (RFC 9220). `HttpServer`
27
+ serves HTTP/3 on multiplexed listeners with its `http3` option; `HttpAgent`
28
+ reaches `https:` origins over HTTP/3 with its own: those advertising it
29
+ through `Alt-Svc`, raced against TCP and falling back to it, or every one
30
+ with `priorKnowledge`.
31
+ - `net-quic`: first release. `QuicListener` and `createQuicConnector` over a
32
+ native quiche binding; the binding of each platform is its own optional
33
+ package, `@ac-kit/net-quic-<platform>`. A client's UDP socket is connected,
34
+ so a refused port fails the attempt at once.
35
+ - `node`: `DgramSocket.connect`, `disconnect`, `remoteAddress` and
36
+ `sendConnected`, for a UDP socket bound to one remote endpoint.
37
+ - `integration-test-util`: `createSelfSignedCertificate` takes the names the
38
+ certificate is valid for.
39
+ - `net-websocket`: documented over HTTP/3, which needed no change.
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [5075202]
44
+ - @ac-kit/async@0.2.0
45
+
3
46
  ## 0.2.0
4
47
 
5
48
  ### Minor Changes
package/README.md CHANGED
@@ -36,6 +36,11 @@ class MyClient extends Session<string, string, BaseSessionEvents> {
36
36
  - `IListener`, `Connector` and `TransportConnection` — accepting and opening
37
37
  connections without knowing which host API provides them, with the
38
38
  endpoints and the ALPN protocol each one settled on.
39
+ - `IMultiplexedConnection` and `IMultiplexedStream` — a secure connection
40
+ carrying many independent streams (QUIC), each a `Transport` that either side
41
+ can reset or stop on its own, with the error each failure reports. A
42
+ listener and a connector of them are `IListener<IMultiplexedConnection>` and
43
+ `Connector<IMultiplexedConnection>`; `@ac-kit/net-quic` provides both.
39
44
  - `peekTransport` — looks at a connection's first bytes without consuming
40
45
  them, to choose the protocol that will read it, as a server telling HTTP/2's
41
46
  connection preface from HTTP/1.1.
@@ -82,9 +82,11 @@ export type ConnectTarget = {
82
82
  * Establishes outbound connections, so a protocol client can open as many as it
83
83
  * needs without knowing which host API provides them.
84
84
  *
85
+ * @template Established - What one established connection is: a
86
+ * {@link TransportConnection}, or a connection carrying many streams.
85
87
  * @param target Where to connect.
86
88
  * @param signal Abandons the attempt.
87
89
  * @returns The established connection.
88
90
  */
89
- export type Connector = (target: ConnectTarget, signal?: AbortSignal) => Promise<TransportConnection>;
91
+ export type Connector<Established = TransportConnection> = (target: ConnectTarget, signal?: AbortSignal) => Promise<Established>;
90
92
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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,QAAQ,GAAG,mBAAmB,IAAI;IAC5D;;;;OAIG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEnC,6DAA6D;IAC7D,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAExB,gDAAgD;IAChD,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS,CACzB,QAAQ,GAAG,mBAAmB,CAC7B,SAAQ,mBAAmB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACtD,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAElC;;;;;;;OAOG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,kDAAkD;AAClD,MAAM,MAAM,aAAa,GAAG;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,CAAC,WAAW,GAAG,mBAAmB,IAAI,CAC1D,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,WAAW,KAChB,OAAO,CAAC,WAAW,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./exchange-registry.js";
3
3
  export * from "./frame-link.js";
4
4
  export * from "./frame-sink.js";
5
5
  export * from "./keyed-registry.js";
6
+ export * from "./multiplexed-connection.js";
6
7
  export * from "./peek-transport.js";
7
8
  export * from "./pending-exchange.js";
8
9
  export * from "./scanning-registry.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export * from "./exchange-registry.js";
3
3
  export * from "./frame-link.js";
4
4
  export * from "./frame-sink.js";
5
5
  export * from "./keyed-registry.js";
6
+ export * from "./multiplexed-connection.js";
6
7
  export * from "./peek-transport.js";
7
8
  export * from "./pending-exchange.js";
8
9
  export * from "./scanning-registry.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,168 @@
1
+ import type { IEventDispatcherMap } from "@ac-kit/async";
2
+ import type { TransportEndpoint } from "./connection.js";
3
+ import type { Transport, TransportHandlers } from "./transport.js";
4
+ /**
5
+ * Whether a stream carries bytes both ways or only from the side that opened
6
+ * it.
7
+ */
8
+ export type MultiplexedStreamDirection = "bidirectional" | "unidirectional";
9
+ /** Which side opened a stream. */
10
+ export type MultiplexedStreamInitiator = "local" | "remote";
11
+ /**
12
+ * The peer abandoned the bytes it was sending on a stream (QUIC
13
+ * `RESET_STREAM`). Reported through the stream's error handler.
14
+ */
15
+ export declare class MultiplexedStreamResetError extends Error {
16
+ /** The application error code the peer gave. */
17
+ readonly code: number;
18
+ constructor(code: number);
19
+ }
20
+ /**
21
+ * The peer asked this side to stop sending on a stream (QUIC `STOP_SENDING`).
22
+ * Rejects the stream's pending and later writes.
23
+ */
24
+ export declare class MultiplexedStreamStoppedError extends Error {
25
+ /** The application error code the peer gave. */
26
+ readonly code: number;
27
+ constructor(code: number);
28
+ }
29
+ /** What ended a {@link IMultiplexedConnection}. */
30
+ export type MultiplexedConnectionCloseOrigin =
31
+ /** This side closed it, or destroyed it. */
32
+ "local"
33
+ /** The peer closed it. */
34
+ | "remote"
35
+ /** Neither side sent anything for longer than the idle timeout. */
36
+ | "idle";
37
+ /**
38
+ * A multiplexed connection ended. Carried by its `close` event and reported to
39
+ * every stream still open.
40
+ */
41
+ export declare class MultiplexedConnectionClosedError extends Error {
42
+ readonly origin: MultiplexedConnectionCloseOrigin;
43
+ /**
44
+ * Whether {@link code} belongs to the application protocol rather than the
45
+ * carrier.
46
+ */
47
+ readonly application: boolean;
48
+ /** The close code; `0` for an idle timeout. */
49
+ readonly code: number;
50
+ /** The close reason phrase, possibly empty. */
51
+ readonly reason: string;
52
+ constructor(origin: MultiplexedConnectionCloseOrigin, application: boolean, code: number, reason: string, options?: ErrorOptions);
53
+ }
54
+ /**
55
+ * Callbacks a consumer installs on a {@link IMultiplexedStream}: a
56
+ * {@link Transport}'s, and one for the peer abandoning what this side sends.
57
+ */
58
+ export type MultiplexedStreamHandlers = TransportHandlers & {
59
+ /**
60
+ * The peer asked this side to stop sending, with `code` (QUIC
61
+ * `STOP_SENDING`): the sending side is abandoned, and pending and later
62
+ * writes reject with {@link MultiplexedStreamStoppedError}. Data keeps
63
+ * arriving. Not terminal: a peer that read all it wanted stops the rest this
64
+ * way.
65
+ */
66
+ stopped?(code: number): void;
67
+ };
68
+ /**
69
+ * One stream of a {@link IMultiplexedConnection}: an ordered, reliable byte
70
+ * stream with its own flow control, which either side can abort without
71
+ * affecting the others.
72
+ *
73
+ * Each direction ends on its own: {@link Transport.end} finishes the sending
74
+ * side, {@link reset} abandons it, {@link stopSending} abandons the receiving
75
+ * side. A unidirectional stream has only one of them — a locally opened one
76
+ * never delivers data, and writing to a remotely opened one rejects.
77
+ *
78
+ * {@link Transport.destroy} abandons both directions with the connection's
79
+ * generic abort code.
80
+ */
81
+ export interface IMultiplexedStream extends Transport {
82
+ /** The stream's identifier, unique within its connection. */
83
+ readonly id: number;
84
+ readonly direction: MultiplexedStreamDirection;
85
+ readonly initiator: MultiplexedStreamInitiator;
86
+ /**
87
+ * Begin delivering data to `handlers`, which may also follow the peer
88
+ * abandoning what this side sends.
89
+ */
90
+ start(handlers: MultiplexedStreamHandlers): void;
91
+ /**
92
+ * Abandon the sending side: unsent bytes are discarded, pending writes
93
+ * reject, and the peer learns `code` (QUIC `RESET_STREAM`). Does nothing once
94
+ * the sending side ended.
95
+ *
96
+ * @param code Application error code.
97
+ */
98
+ reset(code: number): void;
99
+ /**
100
+ * Abandon the receiving side: no more data is delivered and the peer is asked
101
+ * to stop sending with `code` (QUIC `STOP_SENDING`). Does nothing once the
102
+ * receiving side ended.
103
+ *
104
+ * @param code Application error code.
105
+ */
106
+ stopSending(code: number): void;
107
+ }
108
+ /** Events emitted by an {@link IMultiplexedConnection}. */
109
+ export type MultiplexedConnectionEvents = {
110
+ /**
111
+ * The peer opened a stream. It belongs to the subscriber, which must start or
112
+ * destroy it. Data the peer sends waits, under flow control, until it is
113
+ * started.
114
+ *
115
+ * Subscribe in the same task that received the connection: a stream the peer
116
+ * opened before then is not dispatched again.
117
+ */
118
+ stream: [stream: IMultiplexedStream];
119
+ /**
120
+ * The connection ended, for good. Every stream still open failed with
121
+ * `error`.
122
+ */
123
+ close: [error: MultiplexedConnectionClosedError];
124
+ };
125
+ /**
126
+ * A secure connection carrying many independent streams (QUIC).
127
+ *
128
+ * Neither a {@link Transport} nor a {@link TransportConnection}: a protocol over
129
+ * it opens and accepts streams rather than reading one byte stream. The
130
+ * negotiated details mirror {@link TransportConnection} so a protocol layer
131
+ * reads them the same way.
132
+ */
133
+ export interface IMultiplexedConnection extends IEventDispatcherMap<MultiplexedConnectionEvents> {
134
+ /** The local end, or `null` when the carrier has no addresses. */
135
+ readonly local: TransportEndpoint | null;
136
+ /** The remote end, or `null` when the carrier has no addresses. */
137
+ readonly remote: TransportEndpoint | null;
138
+ /** Whether the bytes are protected by TLS (always, over QUIC). */
139
+ readonly secure: boolean;
140
+ /** The application protocol ALPN settled on, or `null` when none was. */
141
+ readonly alpnProtocol: string | null;
142
+ /** Whether the connection ended; {@link openStream} then rejects. */
143
+ readonly closed: boolean;
144
+ /**
145
+ * Open a stream.
146
+ *
147
+ * @param direction Whether the peer may send on it too.
148
+ * @param signal Abandons the wait.
149
+ * @returns The stream, once the peer allows one more in that direction.
150
+ */
151
+ openStream(direction: MultiplexedStreamDirection, signal?: AbortSignal): Promise<IMultiplexedStream>;
152
+ /**
153
+ * Close the connection gracefully with an application code: streams still
154
+ * open fail, and the peer learns `code` and `reason`. Idempotent.
155
+ *
156
+ * @param code Application error code.
157
+ * @param reason Human-readable reason.
158
+ * @returns Resolves once the connection ended.
159
+ */
160
+ close(code: number, reason?: string): Promise<void>;
161
+ /**
162
+ * Tear the connection down at once with the connection's generic abort code.
163
+ *
164
+ * @param error Optional cause, carried by the `close` event's error.
165
+ */
166
+ destroy(error?: unknown): void;
167
+ }
168
+ //# sourceMappingURL=multiplexed-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexed-connection.d.ts","sourceRoot":"","sources":["../src/multiplexed-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE5E,kCAAkC;AAClC,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5D;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACrD,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAIvB;CACD;AAED;;;GAGG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IACvD,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAIvB;CACD;AAED,mDAAmD;AACnD,MAAM,MAAM,gCAAgC;AAC3C,4CAA4C;AAC1C,OAAO;AACT,0BAA0B;GACxB,QAAQ;AACV,mEAAmE;G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;;;;;GAOG;AACH,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB,CAAC,2BAA2B,CAAC;IAC/F,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEzC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE1C,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB;;;;;;OAMG;IACH,UAAU,CACT,SAAS,EAAE,0BAA0B,EACrC,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE/B;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The peer abandoned the bytes it was sending on a stream (QUIC
3
+ * `RESET_STREAM`). Reported through the stream's error handler.
4
+ */
5
+ export class MultiplexedStreamResetError extends Error {
6
+ /** The application error code the peer gave. */
7
+ code;
8
+ constructor(code) {
9
+ super(`Stream reset by the peer with code ${code}`);
10
+ this.name = "MultiplexedStreamResetError";
11
+ this.code = code;
12
+ }
13
+ }
14
+ /**
15
+ * The peer asked this side to stop sending on a stream (QUIC `STOP_SENDING`).
16
+ * Rejects the stream's pending and later writes.
17
+ */
18
+ export class MultiplexedStreamStoppedError extends Error {
19
+ /** The application error code the peer gave. */
20
+ code;
21
+ constructor(code) {
22
+ super(`Stream stopped by the peer with code ${code}`);
23
+ this.name = "MultiplexedStreamStoppedError";
24
+ this.code = code;
25
+ }
26
+ }
27
+ /**
28
+ * A multiplexed connection ended. Carried by its `close` event and reported to
29
+ * every stream still open.
30
+ */
31
+ export class MultiplexedConnectionClosedError extends Error {
32
+ origin;
33
+ /**
34
+ * Whether {@link code} belongs to the application protocol rather than the
35
+ * carrier.
36
+ */
37
+ application;
38
+ /** The close code; `0` for an idle timeout. */
39
+ code;
40
+ /** The close reason phrase, possibly empty. */
41
+ reason;
42
+ constructor(origin, application, code, reason, options) {
43
+ super(origin === "idle"
44
+ ? "Connection idle timeout"
45
+ : `Connection closed by the ${origin} side with ${application ? "application" : "transport"} code ${code}${reason ? `: ${reason}` : ""}`, options);
46
+ this.name = "MultiplexedConnectionClosedError";
47
+ this.origin = origin;
48
+ this.application = application;
49
+ this.code = code;
50
+ this.reason = reason;
51
+ }
52
+ }
53
+ //# sourceMappingURL=multiplexed-connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexed-connection.js","sourceRoot":"","sources":["../src/multiplexed-connection.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACrD,gDAAgD;IACvC,IAAI,CAAS;IAEtB,YAAY,IAAY;QACvB,KAAK,CAAC,sCAAsC,IAAI,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACvD,gDAAgD;IACvC,IAAI,CAAS;IAEtB,YAAY,IAAY;QACvB,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAWD;;;GAGG;AACH,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACjD,MAAM,CAAmC;IAElD;;;OAGG;IACM,WAAW,CAAU;IAE9B,+CAA+C;IACtC,IAAI,CAAS;IAEtB,+CAA+C;IACtC,MAAM,CAAS;IAExB,YACC,MAAwC,EACxC,WAAoB,EACpB,IAAY,EACZ,MAAc,EACd,OAAsB;QAEtB,KAAK,CACJ,MAAM,KAAK,MAAM;YAChB,CAAC,CAAC,yBAAyB;YAC3B,CAAC,CAAC,4BAA4B,MAAM,cAAc,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,SAAS,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EACzI,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ac-kit/net-core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The shared network-protocol substrate: framing, codecs, session handling, an exchange registry, and the Transport type protocol packages build on instead of talking to sockets.",
5
5
  "keywords": [
6
6
  "framing",
@@ -45,7 +45,7 @@
45
45
  "prepack": "yarn build"
46
46
  },
47
47
  "dependencies": {
48
- "@ac-kit/async": "^0.1.4",
48
+ "@ac-kit/async": "^0.2.0",
49
49
  "@ac-kit/core": "^0.5.0",
50
50
  "@ac-kit/format-core": "^0.1.6",
51
51
  "@types/node": "^26.5.1"