@minip2p/core 0.10.0 → 0.10.2

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/src/types.ts CHANGED
@@ -36,6 +36,83 @@ export interface Minip2pMdnsOptions {
36
36
  readonly autoDial?: boolean;
37
37
  }
38
38
 
39
+ /**
40
+ * Transport limit overrides. Every field is optional and an omitted one keeps
41
+ * the native default. Limits for a transport the endpoint does not bind are
42
+ * ignored; an invalid limit makes `create` throw `InvalidConfigError` with
43
+ * capability `Transport`. Not available in `@minip2p/web`.
44
+ */
45
+ export interface Minip2pLimits {
46
+ /** QUIC (and WebTransport) limits. */
47
+ readonly quic?: Minip2pQuicLimits;
48
+ /** TCP limits, including each connection's Yamux limits. */
49
+ readonly tcp?: Minip2pTcpLimits;
50
+ /** Relay circuits' Yamux limits; independent of `tcp.yamux`. */
51
+ readonly circuit?: Minip2pYamuxLimits;
52
+ /** Most relayed circuits held at once. */
53
+ readonly maxCircuits?: number;
54
+ }
55
+
56
+ /** QUIC limit overrides, mirroring the native `QuicLimits`. */
57
+ export interface Minip2pQuicLimits {
58
+ /** Simultaneous connections, inbound and outbound. */
59
+ readonly maxConnections?: number;
60
+ /** Locally initiated bidirectional streams per connection. */
61
+ readonly maxStreamsPerConnection?: number;
62
+ /** Bytes queued per stream beyond what the engine accepts; non-zero. */
63
+ readonly maxPendingBytesPerStream?: number;
64
+ /** Bytes queued per connection; greater than `controlStreamReserveBytes`. */
65
+ readonly maxPendingConnectionBytes?: number;
66
+ /** Part of the connection queue only control streams may fill. */
67
+ readonly controlStreamReserveBytes?: number;
68
+ /** UDP datagrams retained while the socket would block; non-zero. */
69
+ readonly maxPendingDatagrams?: number;
70
+ /** Idle timeout advertised to peers, in milliseconds; non-zero. */
71
+ readonly idleTimeoutMs?: number;
72
+ /** Whether inbound connections need a stateless Retry first. */
73
+ readonly requireAddressValidation?: boolean;
74
+ /** Per-stream receive window in bytes; non-zero. */
75
+ readonly streamReceiveWindow?: number;
76
+ /** Per-connection receive window in bytes (unlimited by default). */
77
+ readonly connectionReceiveWindow?: number | "unlimited";
78
+ /** Bytes buffered per connection for sending; non-zero. */
79
+ readonly sendWindow?: number;
80
+ /** Time a WebTransport client has to complete Noise, in milliseconds. */
81
+ readonly webtransportHandshakeTimeoutMs?: number;
82
+ }
83
+
84
+ /** TCP limit overrides, mirroring the native `TcpConfig`. */
85
+ export interface Minip2pTcpLimits {
86
+ /** Connections held at once, dialed and accepted alike. */
87
+ readonly maxConnections?: number;
88
+ /** How long a connection may take to authenticate, in milliseconds. */
89
+ readonly handshakeTimeoutMs?: number | "never";
90
+ /** Encrypted bytes one connection holds for its socket. */
91
+ readonly maxBufferedSend?: number;
92
+ /** How long a connection may hold bytes its socket refuses, in milliseconds. */
93
+ readonly sendStallTimeoutMs?: number | "never";
94
+ /** Each TCP connection's Yamux limits. */
95
+ readonly yamux?: Minip2pYamuxLimits;
96
+ }
97
+
98
+ /** Yamux limit overrides, mirroring the native `YamuxConfig`. */
99
+ export interface Minip2pYamuxLimits {
100
+ /** Per-stream receive window in bytes; at least 256 KiB. */
101
+ readonly receiveWindow?: number;
102
+ /** Largest data-frame payload sent; non-zero. */
103
+ readonly maxFrameLen?: number;
104
+ /** Streams tracked at once, counting unsettled closed ones. */
105
+ readonly maxStreams?: number;
106
+ /** Per-stream cap on accepted, unsent bytes; non-zero. */
107
+ readonly maxBufferedSend?: number;
108
+ /** Session-wide cap on accepted, unsent bytes; greater than `controlStreamReserve`. */
109
+ readonly maxTotalBufferedSend?: number;
110
+ /** Part of the session-wide cap only control streams may fill. */
111
+ readonly controlStreamReserve?: number;
112
+ /** Control frames that may wait to be sent. */
113
+ readonly maxPendingControl?: number;
114
+ }
115
+
39
116
  /** Coarse local reachability states. */
40
117
  export const Reachability = {
41
118
  Private: "Private",
@@ -151,6 +228,8 @@ export interface Minip2pConfig {
151
228
  readonly discovery?: Minip2pDiscoveryOptions;
152
229
  /** Enables mDNS with defaults or explicit options. */
153
230
  readonly mdns?: boolean | Minip2pMdnsOptions;
231
+ /** Transport limit overrides; omit for the native defaults. */
232
+ readonly limits?: Minip2pLimits;
154
233
  }
155
234
 
156
235
  /** Latest Identify information advertised by a remote peer. */
@@ -289,6 +368,12 @@ export interface Minip2pNamedEventMap {
289
368
  readonly current: Reachability;
290
369
  readonly confirmedAddrs: readonly string[];
291
370
  };
371
+ /**
372
+ * The listen set changed without a `listen` call, as when a WebTransport
373
+ * listener's certificate rotates: `addrs` is the whole new set (what
374
+ * `listenAddrs()` now returns), for the app to republish.
375
+ */
376
+ listenAddressesChanged: { readonly addrs: readonly string[] };
292
377
  publicAddressesChanged: { readonly addrs: readonly string[] };
293
378
  relayReserved: {
294
379
  readonly relayPeerId: string;
@@ -575,6 +660,7 @@ export const P2pEvent_Tags = {
575
660
  IdentifyReceived: "IdentifyReceived",
576
661
  InboundDirectUpgrade: "InboundDirectUpgrade",
577
662
  InboundPathEstablished: "InboundPathEstablished",
663
+ ListenAddressesChanged: "ListenAddressesChanged",
578
664
  MdnsFailed: "MdnsFailed",
579
665
  MdnsRecovered: "MdnsRecovered",
580
666
  Message: "Message",
@@ -680,6 +766,10 @@ export type P2pEvent =
680
766
  typeof P2pEvent_Tags.ReachabilityChanged,
681
767
  Minip2pNamedEventMap["reachabilityChanged"]
682
768
  >
769
+ | RawEvent<
770
+ typeof P2pEvent_Tags.ListenAddressesChanged,
771
+ Minip2pNamedEventMap["listenAddressesChanged"]
772
+ >
683
773
  | RawEvent<
684
774
  typeof P2pEvent_Tags.PublicAddressesChanged,
685
775
  Minip2pNamedEventMap["publicAddressesChanged"]