@minip2p/core 0.1.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -1,306 +1,451 @@
1
+ import type { DriverFailedError } from "./errors.js";
2
+ import type { Stream } from "./sdk.js";
1
3
  /** Bytes accepted by the platform-neutral SDK. */
2
4
  export type Bytes = ArrayBuffer | Uint8Array;
3
- /** Signed-discovery settings. */
4
- export interface MiniP2pDiscoveryOptions {
5
- /** Pubsub topic carrying signed discovery beacons. */
5
+ /** Signed-discovery settings. The topic is intentionally application-scoped. */
6
+ export interface Minip2pDiscoveryOptions {
7
+ /** Application-scoped signed-beacon topic. */
6
8
  readonly topic: string;
7
- /** Milliseconds between local beacon announcements. */
8
- readonly beaconIntervalMs: number;
9
- /** Milliseconds before a signed peer observation expires. */
10
- readonly peerTtlMs: number;
11
- /** Whether accepted observations may trigger automatic dials. */
12
- readonly autoDial: boolean;
9
+ /** Beacon broadcast interval in milliseconds. */
10
+ readonly beaconIntervalMs?: number;
11
+ /** Time without observations before a peer expires. */
12
+ readonly peerTtlMs?: number;
13
+ /** Whether newly discovered peers should be dialed automatically. */
14
+ readonly autoDial?: boolean;
13
15
  }
14
- /** Local-link mDNS discovery settings. Omitted fields use Rust defaults. */
15
- export interface MiniP2pMdnsOptions {
16
+ /** Local-link mDNS discovery settings. Omitted fields use native defaults. */
17
+ export interface Minip2pMdnsOptions {
18
+ /** Enables IPv6 multicast in addition to IPv4. */
16
19
  readonly enableIpv6?: boolean;
20
+ /** TTL advertised in mDNS records. */
17
21
  readonly ttlMs?: number;
22
+ /** Period between discovery queries. */
18
23
  readonly queryIntervalMs?: number;
24
+ /** Maximum encoded DNS packet size. */
19
25
  readonly maxPacketBytes?: number;
26
+ /** Maximum addresses advertised per response. */
20
27
  readonly maxAnnouncedAddrs?: number;
28
+ /** Period between network-interface refreshes. */
21
29
  readonly interfaceRefreshMs?: number;
30
+ /** Socket polling interval used by the native driver. */
22
31
  readonly socketPollIntervalMs?: number;
32
+ /** Whether newly discovered peers should be dialed automatically. */
23
33
  readonly autoDial?: boolean;
24
34
  }
25
- /** Pubsub routing engine. */
26
- export declare enum PubsubRouter {
27
- Gossipsub = 0,
28
- Floodsub = 1
29
- }
35
+ /** Available pubsub routing strategies. */
36
+ export declare const PubsubRouter: {
37
+ readonly Floodsub: 1;
38
+ readonly Gossipsub: 0;
39
+ };
40
+ export type PubsubRouter = (typeof PubsubRouter)[keyof typeof PubsubRouter];
41
+ /** Coarse local reachability states. */
42
+ export declare const Reachability: {
43
+ readonly Private: 2;
44
+ readonly Public: 1;
45
+ readonly Unknown: 0;
46
+ };
47
+ export type Reachability = (typeof Reachability)[keyof typeof Reachability];
48
+ /** Sources contributing peer-discovery observations. */
49
+ export declare const DiscoverySource: {
50
+ readonly Mdns: 1;
51
+ readonly SignedBeacon: 0;
52
+ };
53
+ export type DiscoverySource = (typeof DiscoverySource)[keyof typeof DiscoverySource];
54
+ /** Fatal native-driver failure categories. */
55
+ export declare const DriverFailureKind: {
56
+ readonly Invariant: 2;
57
+ readonly Panic: 3;
58
+ readonly Swarm: 1;
59
+ readonly Transport: 0;
60
+ };
61
+ export type DriverFailureKind = (typeof DriverFailureKind)[keyof typeof DriverFailureKind];
62
+ /** Non-fatal endpoint runtime error categories. */
63
+ export declare const EndpointErrorKind: {
64
+ readonly Driver: 7;
65
+ readonly Identify: 2;
66
+ readonly IdentifyStreamRejected: 4;
67
+ readonly Multistream: 1;
68
+ readonly OpenStreamFailed: 5;
69
+ readonly Ping: 3;
70
+ readonly Transport: 0;
71
+ readonly UnsupportedProtocol: 6;
72
+ };
73
+ export type EndpointErrorKind = (typeof EndpointErrorKind)[keyof typeof EndpointErrorKind];
74
+ /** Terminal NAT connection failure categories. */
75
+ export declare const NatErrorKind: {
76
+ readonly DialFailed: 2;
77
+ readonly NoPathAvailable: 0;
78
+ readonly Protocol: 3;
79
+ readonly RelayRefused: 4;
80
+ readonly Timeout: 1;
81
+ };
82
+ export type NatErrorKind = (typeof NatErrorKind)[keyof typeof NatErrorKind];
30
83
  /** Configuration accepted by a platform minip2p endpoint. */
31
- export interface MiniP2pConfig {
32
- /** Raw 32-byte Ed25519 secret key material. */
84
+ export interface Minip2pConfig {
85
+ /** Raw 32-byte Ed25519 secret key. */
33
86
  readonly secretKey: Bytes;
34
- /** Identify agent version, or the native default when absent. */
87
+ /** Agent version advertised through Identify. */
35
88
  readonly agentVersion?: string;
36
- /** Direct QUIC relay peer addresses. */
89
+ /** Direct QUIC relay peer multiaddresses. */
37
90
  readonly relays?: readonly string[];
38
- /** Direct QUIC peers used as AutoNAT reachability servers. */
91
+ /** AutoNAT server peer multiaddresses. */
39
92
  readonly autonatServers?: readonly string[];
40
- /** QUIC listen multiaddress, or dual-stack wildcard binding when absent. */
93
+ /** Local QUIC listen multiaddress; native defaults apply when omitted. */
41
94
  readonly listenAddr?: string;
42
- /** Whether connection attempts must remain relayed. */
95
+ /** Routes outbound connectivity through relays only. */
43
96
  readonly forceRelay?: boolean;
44
- /** Whether unsigned pubsub messages are accepted. */
97
+ /** Accepts unsigned pubsub messages. */
45
98
  readonly allowUnsigned?: boolean;
46
- /** Pubsub router; defaults to gossipsub. */
99
+ /** Pubsub router to enable. */
47
100
  readonly pubsubRouter?: PubsubRouter;
48
- /** Custom application protocols registered before startup. */
101
+ /** Application protocol IDs accepted on inbound streams. */
49
102
  readonly protocols?: readonly string[];
50
- /** Signed-discovery settings, or no discovery when absent. */
51
- readonly discovery?: MiniP2pDiscoveryOptions;
52
- /** Enables mDNS with defaults (`true`) or explicit settings. */
53
- readonly mdns?: boolean | MiniP2pMdnsOptions;
103
+ /** Signed-beacon discovery configuration. */
104
+ readonly discovery?: Minip2pDiscoveryOptions;
105
+ /** Enables mDNS with defaults or explicit options. */
106
+ readonly mdns?: boolean | Minip2pMdnsOptions;
54
107
  }
55
- /** Coarse local reachability state. */
56
- export declare enum Reachability {
57
- Unknown = 0,
58
- Public = 1,
59
- Private = 2
108
+ /** Latest Identify information advertised by a remote peer. */
109
+ export interface IdentifyInfo {
110
+ /** Protobuf-encoded remote public key, when supplied. */
111
+ readonly publicKey?: ArrayBuffer;
112
+ /** Listen addresses advertised by the remote peer. */
113
+ readonly listenAddrs: readonly string[];
114
+ /** Protocols advertised by the remote peer. */
115
+ readonly protocols: readonly string[];
116
+ /** Address at which the remote observed this endpoint. */
117
+ readonly observedAddr?: string;
118
+ /** Remote libp2p protocol version. */
119
+ readonly protocolVersion?: string;
120
+ /** Remote agent version. */
121
+ readonly agentVersion?: string;
60
122
  }
61
- /** Source that contributed a discovery observation. */
62
- export declare enum DiscoverySource {
63
- SignedBeacon = 0,
64
- Mdns = 1
123
+ /** Merged discovery information for one peer. */
124
+ export interface KnownPeerInfo {
125
+ readonly peerId: string;
126
+ readonly addrs: readonly string[];
127
+ readonly beaconAddrs: readonly string[];
128
+ readonly mdnsAddrs: readonly string[];
129
+ readonly beaconLastSeenAgeMs?: number;
130
+ readonly mdnsLastSeenAgeMs?: number;
131
+ readonly connected: boolean;
132
+ }
133
+ /** Active relay reservation metadata. */
134
+ export interface RelayReservationInfo {
135
+ readonly relayPeerId: string;
136
+ readonly expiresUnixSecs?: number;
137
+ }
138
+ /** A usable NAT-orchestrated connection path. */
139
+ export type Path = {
140
+ readonly kind: "directDialed";
141
+ } | {
142
+ readonly kind: "directPunched";
143
+ } | {
144
+ readonly kind: "relayed";
145
+ readonly relayPeerId: string;
146
+ };
147
+ /** Serializable metadata for an inbound stream catch-all event. */
148
+ export interface InboundStreamMeta {
149
+ readonly peerId: string;
150
+ readonly protocolId: string;
151
+ readonly streamId: number;
152
+ readonly connId: number;
153
+ readonly initiatedLocally: boolean;
65
154
  }
66
- /** Category of a fatal background-driver failure. */
67
- export declare enum DriverFailureKind {
68
- Transport = 0,
69
- Swarm = 1,
70
- Invariant = 2,
71
- Panic = 3
155
+ /** Payload types keyed by high-level SDK event name. */
156
+ export interface Minip2pNamedEventMap {
157
+ eventsDropped: {
158
+ readonly dropped: number;
159
+ readonly totalDropped: number;
160
+ };
161
+ driverFailed: {
162
+ readonly kind: DriverFailureKind;
163
+ readonly detail: string;
164
+ };
165
+ connectionEstablished: {
166
+ readonly peerId: string;
167
+ readonly connId: number;
168
+ };
169
+ connectionClosed: {
170
+ readonly peerId: string;
171
+ readonly connId: number;
172
+ };
173
+ peerReady: {
174
+ readonly peerId: string;
175
+ readonly protocols: readonly string[];
176
+ };
177
+ identifyReceived: {
178
+ readonly peerId: string;
179
+ readonly info: IdentifyInfo;
180
+ };
181
+ pingRttMeasured: {
182
+ readonly peerId: string;
183
+ readonly rttMs: number;
184
+ };
185
+ pingTimeout: {
186
+ readonly peerId: string;
187
+ };
188
+ stream: Stream;
189
+ endpointError: {
190
+ readonly kind: EndpointErrorKind;
191
+ readonly peerId?: string;
192
+ readonly connId?: number;
193
+ readonly streamId?: number;
194
+ readonly detail: string;
195
+ };
196
+ reachabilityChanged: {
197
+ readonly previous: Reachability;
198
+ readonly current: Reachability;
199
+ readonly confirmedAddrs: readonly string[];
200
+ };
201
+ publicAddressesChanged: {
202
+ readonly addrs: readonly string[];
203
+ };
204
+ relayReserved: {
205
+ readonly relayPeerId: string;
206
+ readonly expiresUnixSecs?: number;
207
+ };
208
+ relayReservationLost: {
209
+ readonly relayPeerId: string;
210
+ };
211
+ pathEstablished: {
212
+ readonly connectId: number;
213
+ readonly peerId: string;
214
+ readonly path: Path;
215
+ };
216
+ inboundPathEstablished: {
217
+ readonly peerId: string;
218
+ readonly path: Path;
219
+ };
220
+ pathUpgraded: {
221
+ readonly connectId: number;
222
+ readonly peerId: string;
223
+ readonly from: Path;
224
+ readonly to: Path;
225
+ };
226
+ holePunchFailed: {
227
+ readonly connectId: number;
228
+ readonly attempt: number;
229
+ readonly reason: string;
230
+ };
231
+ fellBackToRelay: {
232
+ readonly connectId: number;
233
+ readonly peerId: string;
234
+ };
235
+ connectFailed: {
236
+ readonly connectId: number;
237
+ readonly peerId: string;
238
+ readonly kind: NatErrorKind;
239
+ readonly detail: string;
240
+ };
241
+ inboundDirectUpgrade: {
242
+ readonly peerId: string;
243
+ };
244
+ message: {
245
+ readonly fromPeerId: string;
246
+ readonly topics: readonly string[];
247
+ readonly data: ArrayBuffer;
248
+ readonly seqno: ArrayBuffer;
249
+ readonly signed: boolean;
250
+ };
251
+ peerSubscribed: {
252
+ readonly peerId: string;
253
+ readonly topic: string;
254
+ };
255
+ peerUnsubscribed: {
256
+ readonly peerId: string;
257
+ readonly topic: string;
258
+ };
259
+ pubsubOutboundFailure: {
260
+ readonly peerId: string;
261
+ readonly reason: string;
262
+ };
263
+ pubsubProtocolViolation: {
264
+ readonly peerId: string;
265
+ readonly reason: string;
266
+ };
267
+ peerDiscovered: {
268
+ readonly peerId: string;
269
+ readonly addrs: readonly string[];
270
+ readonly source: DiscoverySource;
271
+ };
272
+ peerUpdated: {
273
+ readonly peerId: string;
274
+ readonly addrs: readonly string[];
275
+ readonly source: DiscoverySource;
276
+ };
277
+ peerExpired: {
278
+ readonly peerId: string;
279
+ };
280
+ discoveryDialFailed: {
281
+ readonly peerId: string;
282
+ readonly reason: string;
283
+ };
284
+ discoveryProtocolViolation: {
285
+ readonly peerId?: string;
286
+ readonly source: DiscoverySource;
287
+ readonly reason: string;
288
+ readonly suppressed: number;
289
+ };
290
+ queueOverflow: {
291
+ readonly dropped: number;
292
+ };
293
+ handlerError: {
294
+ readonly eventType: keyof Minip2pNamedEventMap | "inboundStream";
295
+ readonly metadata: Record<string, unknown>;
296
+ readonly error: unknown;
297
+ };
72
298
  }
73
- /** Category of a non-fatal endpoint runtime error. */
74
- export declare enum EndpointErrorKind {
75
- Transport = 0,
76
- Multistream = 1,
77
- Identify = 2,
78
- Ping = 3,
79
- IdentifyStreamRejected = 4,
80
- OpenStreamFailed = 5,
81
- UnsupportedProtocol = 6,
82
- Driver = 7
299
+ /** Events available to the catch-all endpoint subscriber. */
300
+ export type Minip2pCatchAllEventMap = Omit<Minip2pNamedEventMap, "stream" | "handlerError"> & {
301
+ inboundStream: InboundStreamMeta;
302
+ handlerError: Minip2pNamedEventMap["handlerError"];
303
+ };
304
+ /** Discriminated union emitted to catch-all endpoint subscribers. */
305
+ export type Minip2pEvent = {
306
+ [Kind in keyof Minip2pCatchAllEventMap]: {
307
+ readonly type: Kind;
308
+ } & Minip2pCatchAllEventMap[Kind];
309
+ }[keyof Minip2pCatchAllEventMap];
310
+ /** Timeout and cancellation controls shared by Promise-based operations. */
311
+ export interface OpOptions {
312
+ /** Timeout in milliseconds; `0` disables the timeout. */
313
+ readonly timeoutMs?: number;
314
+ /** Abort signal that cancels only this caller's wait. */
315
+ readonly signal?: AbortSignal;
83
316
  }
84
- /** Category of a failed NAT connection attempt. */
85
- export declare enum NatErrorKind {
86
- NoPathAvailable = 0,
87
- Timeout = 1,
88
- DialFailed = 2,
89
- Protocol = 3,
90
- RelayRefused = 4
317
+ /** Options accepted by {@link Minip2pBase.once}. */
318
+ export type OnceOptions = OpOptions;
319
+ /** Options accepted by {@link Minip2pBase.waitFor}. */
320
+ export interface WaitForOptions<Event> extends OpOptions {
321
+ /** Optional filter applied before resolving the waiter. */
322
+ readonly predicate?: (event: Event) => boolean;
91
323
  }
92
- /** Tags for a usable connection path. */
93
- export declare enum PathKind_Tags {
94
- DirectDialed = "DirectDialed",
95
- DirectPunched = "DirectPunched",
96
- Relayed = "Relayed"
324
+ /** First usable path produced by a connection attempt. */
325
+ export interface ConnectResult {
326
+ readonly connectId: number;
327
+ readonly peerId: string;
328
+ readonly path: Path;
97
329
  }
98
- /** Kind of usable connection path. */
330
+ /** Reason reported to endpoint close observers. */
331
+ export type CloseReason = {
332
+ readonly reason: "close";
333
+ } | {
334
+ readonly reason: "driverFailed";
335
+ readonly error: DriverFailedError;
336
+ };
337
+ /** Idempotent callback that removes a subscription. */
338
+ export type Unsubscribe = () => void;
339
+ /** Raw backend-only path tags. */
340
+ export declare const PathKind_Tags: {
341
+ readonly DirectDialed: "DirectDialed";
342
+ readonly DirectPunched: "DirectPunched";
343
+ readonly Relayed: "Relayed";
344
+ };
345
+ export type PathKindTag = (typeof PathKind_Tags)[keyof typeof PathKind_Tags];
99
346
  export type PathKind = {
100
- readonly tag: PathKind_Tags.DirectDialed;
347
+ readonly tag: typeof PathKind_Tags.DirectDialed;
101
348
  } | {
102
- readonly tag: PathKind_Tags.DirectPunched;
349
+ readonly tag: typeof PathKind_Tags.DirectPunched;
103
350
  } | {
104
- readonly tag: PathKind_Tags.Relayed;
351
+ readonly tag: typeof PathKind_Tags.Relayed;
105
352
  readonly inner: {
106
353
  readonly relayPeerId: string;
107
354
  };
108
355
  };
109
- /** Tags for events delivered by a minip2p endpoint. */
110
- export declare enum P2pEvent_Tags {
111
- EventsDropped = "EventsDropped",
112
- DriverFailed = "DriverFailed",
113
- ConnectionEstablished = "ConnectionEstablished",
114
- ConnectionClosed = "ConnectionClosed",
115
- PeerReady = "PeerReady",
116
- IdentifyReceived = "IdentifyReceived",
117
- PingRttMeasured = "PingRttMeasured",
118
- PingTimeout = "PingTimeout",
119
- StreamReady = "StreamReady",
120
- StreamData = "StreamData",
121
- StreamRemoteWriteClosed = "StreamRemoteWriteClosed",
122
- StreamClosed = "StreamClosed",
123
- EndpointError = "EndpointError",
124
- ReachabilityChanged = "ReachabilityChanged",
125
- PublicAddressesChanged = "PublicAddressesChanged",
126
- RelayReserved = "RelayReserved",
127
- RelayReservationLost = "RelayReservationLost",
128
- PathEstablished = "PathEstablished",
129
- PathUpgraded = "PathUpgraded",
130
- HolePunchFailed = "HolePunchFailed",
131
- FellBackToRelay = "FellBackToRelay",
132
- ConnectFailed = "ConnectFailed",
133
- InboundDirectUpgrade = "InboundDirectUpgrade",
134
- Message = "Message",
135
- PeerSubscribed = "PeerSubscribed",
136
- PeerUnsubscribed = "PeerUnsubscribed",
137
- PubsubOutboundFailure = "PubsubOutboundFailure",
138
- PubsubProtocolViolation = "PubsubProtocolViolation",
139
- PeerDiscovered = "PeerDiscovered",
140
- PeerUpdated = "PeerUpdated",
141
- PeerExpired = "PeerExpired",
142
- DiscoveryDialFailed = "DiscoveryDialFailed",
143
- DiscoveryProtocolViolation = "DiscoveryProtocolViolation"
144
- }
145
- interface Event<Tag extends P2pEvent_Tags, Inner> {
356
+ /** Raw backend-only event tags. */
357
+ export declare const P2pEvent_Tags: {
358
+ readonly ConnectFailed: "ConnectFailed";
359
+ readonly ConnectionClosed: "ConnectionClosed";
360
+ readonly ConnectionEstablished: "ConnectionEstablished";
361
+ readonly DiscoveryDialFailed: "DiscoveryDialFailed";
362
+ readonly DiscoveryProtocolViolation: "DiscoveryProtocolViolation";
363
+ readonly DriverFailed: "DriverFailed";
364
+ readonly EndpointError: "EndpointError";
365
+ readonly EventsDropped: "EventsDropped";
366
+ readonly FellBackToRelay: "FellBackToRelay";
367
+ readonly HolePunchFailed: "HolePunchFailed";
368
+ readonly IdentifyReceived: "IdentifyReceived";
369
+ readonly InboundDirectUpgrade: "InboundDirectUpgrade";
370
+ readonly InboundPathEstablished: "InboundPathEstablished";
371
+ readonly Message: "Message";
372
+ readonly PathEstablished: "PathEstablished";
373
+ readonly PathUpgraded: "PathUpgraded";
374
+ readonly PeerDiscovered: "PeerDiscovered";
375
+ readonly PeerExpired: "PeerExpired";
376
+ readonly PeerReady: "PeerReady";
377
+ readonly PeerSubscribed: "PeerSubscribed";
378
+ readonly PeerUnsubscribed: "PeerUnsubscribed";
379
+ readonly PeerUpdated: "PeerUpdated";
380
+ readonly PingRttMeasured: "PingRttMeasured";
381
+ readonly PingTimeout: "PingTimeout";
382
+ readonly PublicAddressesChanged: "PublicAddressesChanged";
383
+ readonly PubsubOutboundFailure: "PubsubOutboundFailure";
384
+ readonly PubsubProtocolViolation: "PubsubProtocolViolation";
385
+ readonly ReachabilityChanged: "ReachabilityChanged";
386
+ readonly RelayReservationLost: "RelayReservationLost";
387
+ readonly RelayReserved: "RelayReserved";
388
+ readonly StreamClosed: "StreamClosed";
389
+ readonly StreamData: "StreamData";
390
+ readonly StreamReady: "StreamReady";
391
+ readonly StreamRemoteWriteClosed: "StreamRemoteWriteClosed";
392
+ };
393
+ export type P2pEventTag = (typeof P2pEvent_Tags)[keyof typeof P2pEvent_Tags];
394
+ interface RawEvent<Tag extends P2pEventTag, Inner> {
146
395
  readonly tag: Tag;
147
396
  readonly inner: Readonly<Inner>;
148
397
  }
149
- /** Latest Identify information advertised by a remote peer. */
150
- export interface IdentifyInfo {
151
- readonly publicKey?: ArrayBuffer;
152
- readonly listenAddrs: readonly string[];
153
- readonly protocols: readonly string[];
154
- readonly observedAddr?: string;
155
- readonly protocolVersion?: string;
156
- readonly agentVersion?: string;
157
- }
158
- /** A platform-independent event emitted by the minip2p driver. */
159
- export type P2pEvent = Event<P2pEvent_Tags.EventsDropped, {
398
+ export type P2pEvent = RawEvent<typeof P2pEvent_Tags.EventsDropped, {
160
399
  dropped: number;
161
400
  totalDropped: number;
162
- }> | Event<P2pEvent_Tags.DriverFailed, {
401
+ }> | RawEvent<typeof P2pEvent_Tags.DriverFailed, {
163
402
  kind: DriverFailureKind;
164
403
  detail: string;
165
- }> | Event<P2pEvent_Tags.ConnectionEstablished, {
404
+ }> | RawEvent<typeof P2pEvent_Tags.ConnectionEstablished, {
166
405
  peerId: string;
167
406
  connId: number;
168
- }> | Event<P2pEvent_Tags.ConnectionClosed, {
407
+ }> | RawEvent<typeof P2pEvent_Tags.ConnectionClosed, {
169
408
  peerId: string;
170
409
  connId: number;
171
- }> | Event<P2pEvent_Tags.PeerReady, {
410
+ }> | RawEvent<typeof P2pEvent_Tags.PeerReady, {
172
411
  peerId: string;
173
412
  protocols: readonly string[];
174
- }> | Event<P2pEvent_Tags.IdentifyReceived, {
413
+ }> | RawEvent<typeof P2pEvent_Tags.IdentifyReceived, {
175
414
  peerId: string;
176
415
  info: IdentifyInfo;
177
- }> | Event<P2pEvent_Tags.PingRttMeasured, {
416
+ }> | RawEvent<typeof P2pEvent_Tags.PingRttMeasured, {
178
417
  peerId: string;
179
418
  rttMs: number;
180
- }> | Event<P2pEvent_Tags.PingTimeout, {
419
+ }> | RawEvent<typeof P2pEvent_Tags.PingTimeout, {
181
420
  peerId: string;
182
- }> | Event<P2pEvent_Tags.StreamReady, {
183
- peerId: string;
184
- connId: number;
185
- streamId: number;
186
- protocolId: string;
187
- initiatedLocally: boolean;
188
- }> | Event<P2pEvent_Tags.StreamData, {
421
+ }> | RawEvent<typeof P2pEvent_Tags.StreamReady, InboundStreamMeta> | RawEvent<typeof P2pEvent_Tags.StreamData, {
189
422
  peerId: string;
190
423
  connId: number;
191
424
  streamId: number;
192
425
  data: ArrayBuffer;
193
- }> | Event<P2pEvent_Tags.StreamRemoteWriteClosed, {
426
+ }> | RawEvent<typeof P2pEvent_Tags.StreamRemoteWriteClosed, {
194
427
  peerId: string;
195
428
  connId: number;
196
429
  streamId: number;
197
- }> | Event<P2pEvent_Tags.StreamClosed, {
430
+ }> | RawEvent<typeof P2pEvent_Tags.StreamClosed, {
198
431
  peerId: string;
199
432
  connId: number;
200
433
  streamId: number;
201
- }> | Event<P2pEvent_Tags.EndpointError, {
202
- kind: EndpointErrorKind;
203
- peerId?: string;
204
- connId?: number;
205
- detail: string;
206
- }> | Event<P2pEvent_Tags.ReachabilityChanged, {
207
- previous: Reachability;
208
- current: Reachability;
209
- confirmedAddrs: readonly string[];
210
- }> | Event<P2pEvent_Tags.PublicAddressesChanged, {
211
- addrs: readonly string[];
212
- }> | Event<P2pEvent_Tags.RelayReserved, {
213
- relayPeerId: string;
214
- expiresUnixSecs?: number;
215
- }> | Event<P2pEvent_Tags.RelayReservationLost, {
216
- relayPeerId: string;
217
- }> | Event<P2pEvent_Tags.PathEstablished, {
434
+ }> | RawEvent<typeof P2pEvent_Tags.EndpointError, Minip2pNamedEventMap["endpointError"]> | RawEvent<typeof P2pEvent_Tags.ReachabilityChanged, Minip2pNamedEventMap["reachabilityChanged"]> | RawEvent<typeof P2pEvent_Tags.PublicAddressesChanged, Minip2pNamedEventMap["publicAddressesChanged"]> | RawEvent<typeof P2pEvent_Tags.RelayReserved, Minip2pNamedEventMap["relayReserved"]> | RawEvent<typeof P2pEvent_Tags.RelayReservationLost, Minip2pNamedEventMap["relayReservationLost"]> | RawEvent<typeof P2pEvent_Tags.PathEstablished, {
218
435
  connectId: number;
219
436
  peerId: string;
220
437
  path: PathKind;
221
- }> | Event<P2pEvent_Tags.PathUpgraded, {
438
+ }> | RawEvent<typeof P2pEvent_Tags.InboundPathEstablished, {
439
+ peerId: string;
440
+ path: PathKind;
441
+ }> | RawEvent<typeof P2pEvent_Tags.PathUpgraded, {
222
442
  connectId: number;
223
443
  peerId: string;
224
444
  from: PathKind;
225
445
  to: PathKind;
226
- }> | Event<P2pEvent_Tags.HolePunchFailed, {
227
- connectId: number;
228
- attempt: number;
229
- reason: string;
230
- }> | Event<P2pEvent_Tags.FellBackToRelay, {
231
- connectId: number;
232
- peerId: string;
233
- }> | Event<P2pEvent_Tags.ConnectFailed, {
234
- connectId: number;
235
- peerId: string;
236
- kind: NatErrorKind;
237
- detail: string;
238
- }> | Event<P2pEvent_Tags.InboundDirectUpgrade, {
239
- peerId: string;
240
- }> | Event<P2pEvent_Tags.Message, {
241
- fromPeerId: string;
242
- topics: readonly string[];
243
- data: ArrayBuffer;
244
- seqno: ArrayBuffer;
245
- signed: boolean;
246
- }> | Event<P2pEvent_Tags.PeerSubscribed, {
247
- peerId: string;
248
- topic: string;
249
- }> | Event<P2pEvent_Tags.PeerUnsubscribed, {
250
- peerId: string;
251
- topic: string;
252
- }> | Event<P2pEvent_Tags.PubsubOutboundFailure, {
253
- peerId: string;
254
- reason: string;
255
- }> | Event<P2pEvent_Tags.PubsubProtocolViolation, {
256
- peerId: string;
257
- reason: string;
258
- }> | Event<P2pEvent_Tags.PeerDiscovered, {
259
- peerId: string;
260
- addrs: readonly string[];
261
- source: DiscoverySource;
262
- }> | Event<P2pEvent_Tags.PeerUpdated, {
263
- peerId: string;
264
- addrs: readonly string[];
265
- source: DiscoverySource;
266
- }> | Event<P2pEvent_Tags.PeerExpired, {
267
- peerId: string;
268
- }> | Event<P2pEvent_Tags.DiscoveryDialFailed, {
269
- peerId: string;
270
- reason: string;
271
- }> | Event<P2pEvent_Tags.DiscoveryProtocolViolation, {
272
- peerId?: string;
273
- source: DiscoverySource;
274
- reason: string;
275
- suppressed: number;
276
- }>;
277
- /** Extracts one native event variant by its tag. */
278
- export type P2pEventByTag<Tag extends P2pEvent_Tags> = Extract<P2pEvent, {
279
- tag: Tag;
446
+ }> | RawEvent<typeof P2pEvent_Tags.HolePunchFailed, Minip2pNamedEventMap["holePunchFailed"]> | RawEvent<typeof P2pEvent_Tags.FellBackToRelay, Minip2pNamedEventMap["fellBackToRelay"]> | RawEvent<typeof P2pEvent_Tags.ConnectFailed, Minip2pNamedEventMap["connectFailed"]> | RawEvent<typeof P2pEvent_Tags.InboundDirectUpgrade, Minip2pNamedEventMap["inboundDirectUpgrade"]> | RawEvent<typeof P2pEvent_Tags.Message, Minip2pNamedEventMap["message"]> | RawEvent<typeof P2pEvent_Tags.PeerSubscribed, Minip2pNamedEventMap["peerSubscribed"]> | RawEvent<typeof P2pEvent_Tags.PeerUnsubscribed, Minip2pNamedEventMap["peerUnsubscribed"]> | RawEvent<typeof P2pEvent_Tags.PubsubOutboundFailure, Minip2pNamedEventMap["pubsubOutboundFailure"]> | RawEvent<typeof P2pEvent_Tags.PubsubProtocolViolation, Minip2pNamedEventMap["pubsubProtocolViolation"]> | RawEvent<typeof P2pEvent_Tags.PeerDiscovered, Minip2pNamedEventMap["peerDiscovered"]> | RawEvent<typeof P2pEvent_Tags.PeerUpdated, Minip2pNamedEventMap["peerUpdated"]> | RawEvent<typeof P2pEvent_Tags.PeerExpired, Minip2pNamedEventMap["peerExpired"]> | RawEvent<typeof P2pEvent_Tags.DiscoveryDialFailed, Minip2pNamedEventMap["discoveryDialFailed"]> | RawEvent<typeof P2pEvent_Tags.DiscoveryProtocolViolation, Minip2pNamedEventMap["discoveryProtocolViolation"]>;
447
+ export type P2pEventByTag<Tag extends P2pEventTag> = Extract<P2pEvent, {
448
+ readonly tag: Tag;
280
449
  }>;
281
- /** One peer in the shared discovery address book. */
282
- export interface KnownPeerInfo {
283
- readonly peerId: string;
284
- readonly addrs: readonly string[];
285
- readonly beaconAddrs: readonly string[];
286
- readonly mdnsAddrs: readonly string[];
287
- readonly beaconLastSeenAgeMs?: number;
288
- readonly mdnsLastSeenAgeMs?: number;
289
- readonly connected: boolean;
290
- }
291
- /** Snapshot of the active inbound relay reservation. */
292
- export interface RelayReservationInfo {
293
- readonly relayPeerId: string;
294
- readonly expiresUnixSecs?: number;
295
- }
296
- /** Host-side notification that the TypeScript event queue discarded events. */
297
- export interface QueueOverflowEvent {
298
- readonly type: "queueOverflow";
299
- readonly dropped: number;
300
- }
301
- /** An event emitted by the high-level SDK. */
302
- export type MiniP2pEvent = P2pEvent | QueueOverflowEvent;
303
- /** Removes an event subscription. */
304
- export type Unsubscribe = () => void;
305
450
  export {};
306
451
  //# sourceMappingURL=types.d.ts.map