@minip2p/core 0.1.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/backend.d.ts +44 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +2 -0
- package/dist/backend.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +55 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk.d.ts +89 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +520 -0
- package/dist/sdk.js.map +1 -0
- package/dist/types.d.ts +306 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +93 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
- package/src/backend.ts +53 -0
- package/src/errors.ts +65 -0
- package/src/index.ts +33 -0
- package/src/sdk.ts +669 -0
- package/src/types.ts +336 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/** Bytes accepted by the platform-neutral SDK. */
|
|
2
|
+
export type Bytes = ArrayBuffer | Uint8Array;
|
|
3
|
+
/** Signed-discovery settings. */
|
|
4
|
+
export interface MiniP2pDiscoveryOptions {
|
|
5
|
+
/** Pubsub topic carrying signed discovery beacons. */
|
|
6
|
+
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;
|
|
13
|
+
}
|
|
14
|
+
/** Local-link mDNS discovery settings. Omitted fields use Rust defaults. */
|
|
15
|
+
export interface MiniP2pMdnsOptions {
|
|
16
|
+
readonly enableIpv6?: boolean;
|
|
17
|
+
readonly ttlMs?: number;
|
|
18
|
+
readonly queryIntervalMs?: number;
|
|
19
|
+
readonly maxPacketBytes?: number;
|
|
20
|
+
readonly maxAnnouncedAddrs?: number;
|
|
21
|
+
readonly interfaceRefreshMs?: number;
|
|
22
|
+
readonly socketPollIntervalMs?: number;
|
|
23
|
+
readonly autoDial?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Pubsub routing engine. */
|
|
26
|
+
export declare enum PubsubRouter {
|
|
27
|
+
Gossipsub = 0,
|
|
28
|
+
Floodsub = 1
|
|
29
|
+
}
|
|
30
|
+
/** Configuration accepted by a platform minip2p endpoint. */
|
|
31
|
+
export interface MiniP2pConfig {
|
|
32
|
+
/** Raw 32-byte Ed25519 secret key material. */
|
|
33
|
+
readonly secretKey: Bytes;
|
|
34
|
+
/** Identify agent version, or the native default when absent. */
|
|
35
|
+
readonly agentVersion?: string;
|
|
36
|
+
/** Direct QUIC relay peer addresses. */
|
|
37
|
+
readonly relays?: readonly string[];
|
|
38
|
+
/** Direct QUIC peers used as AutoNAT reachability servers. */
|
|
39
|
+
readonly autonatServers?: readonly string[];
|
|
40
|
+
/** QUIC listen multiaddress, or dual-stack wildcard binding when absent. */
|
|
41
|
+
readonly listenAddr?: string;
|
|
42
|
+
/** Whether connection attempts must remain relayed. */
|
|
43
|
+
readonly forceRelay?: boolean;
|
|
44
|
+
/** Whether unsigned pubsub messages are accepted. */
|
|
45
|
+
readonly allowUnsigned?: boolean;
|
|
46
|
+
/** Pubsub router; defaults to gossipsub. */
|
|
47
|
+
readonly pubsubRouter?: PubsubRouter;
|
|
48
|
+
/** Custom application protocols registered before startup. */
|
|
49
|
+
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;
|
|
54
|
+
}
|
|
55
|
+
/** Coarse local reachability state. */
|
|
56
|
+
export declare enum Reachability {
|
|
57
|
+
Unknown = 0,
|
|
58
|
+
Public = 1,
|
|
59
|
+
Private = 2
|
|
60
|
+
}
|
|
61
|
+
/** Source that contributed a discovery observation. */
|
|
62
|
+
export declare enum DiscoverySource {
|
|
63
|
+
SignedBeacon = 0,
|
|
64
|
+
Mdns = 1
|
|
65
|
+
}
|
|
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
|
|
72
|
+
}
|
|
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
|
|
83
|
+
}
|
|
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
|
|
91
|
+
}
|
|
92
|
+
/** Tags for a usable connection path. */
|
|
93
|
+
export declare enum PathKind_Tags {
|
|
94
|
+
DirectDialed = "DirectDialed",
|
|
95
|
+
DirectPunched = "DirectPunched",
|
|
96
|
+
Relayed = "Relayed"
|
|
97
|
+
}
|
|
98
|
+
/** Kind of usable connection path. */
|
|
99
|
+
export type PathKind = {
|
|
100
|
+
readonly tag: PathKind_Tags.DirectDialed;
|
|
101
|
+
} | {
|
|
102
|
+
readonly tag: PathKind_Tags.DirectPunched;
|
|
103
|
+
} | {
|
|
104
|
+
readonly tag: PathKind_Tags.Relayed;
|
|
105
|
+
readonly inner: {
|
|
106
|
+
readonly relayPeerId: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
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> {
|
|
146
|
+
readonly tag: Tag;
|
|
147
|
+
readonly inner: Readonly<Inner>;
|
|
148
|
+
}
|
|
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, {
|
|
160
|
+
dropped: number;
|
|
161
|
+
totalDropped: number;
|
|
162
|
+
}> | Event<P2pEvent_Tags.DriverFailed, {
|
|
163
|
+
kind: DriverFailureKind;
|
|
164
|
+
detail: string;
|
|
165
|
+
}> | Event<P2pEvent_Tags.ConnectionEstablished, {
|
|
166
|
+
peerId: string;
|
|
167
|
+
connId: number;
|
|
168
|
+
}> | Event<P2pEvent_Tags.ConnectionClosed, {
|
|
169
|
+
peerId: string;
|
|
170
|
+
connId: number;
|
|
171
|
+
}> | Event<P2pEvent_Tags.PeerReady, {
|
|
172
|
+
peerId: string;
|
|
173
|
+
protocols: readonly string[];
|
|
174
|
+
}> | Event<P2pEvent_Tags.IdentifyReceived, {
|
|
175
|
+
peerId: string;
|
|
176
|
+
info: IdentifyInfo;
|
|
177
|
+
}> | Event<P2pEvent_Tags.PingRttMeasured, {
|
|
178
|
+
peerId: string;
|
|
179
|
+
rttMs: number;
|
|
180
|
+
}> | Event<P2pEvent_Tags.PingTimeout, {
|
|
181
|
+
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, {
|
|
189
|
+
peerId: string;
|
|
190
|
+
connId: number;
|
|
191
|
+
streamId: number;
|
|
192
|
+
data: ArrayBuffer;
|
|
193
|
+
}> | Event<P2pEvent_Tags.StreamRemoteWriteClosed, {
|
|
194
|
+
peerId: string;
|
|
195
|
+
connId: number;
|
|
196
|
+
streamId: number;
|
|
197
|
+
}> | Event<P2pEvent_Tags.StreamClosed, {
|
|
198
|
+
peerId: string;
|
|
199
|
+
connId: number;
|
|
200
|
+
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, {
|
|
218
|
+
connectId: number;
|
|
219
|
+
peerId: string;
|
|
220
|
+
path: PathKind;
|
|
221
|
+
}> | Event<P2pEvent_Tags.PathUpgraded, {
|
|
222
|
+
connectId: number;
|
|
223
|
+
peerId: string;
|
|
224
|
+
from: PathKind;
|
|
225
|
+
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;
|
|
280
|
+
}>;
|
|
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
|
+
export {};
|
|
306
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","s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F,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,wDAAwD;AACxD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,kBAAkB,CAAC;AAEzD,qCAAqC;AACrC,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Pubsub routing engine. */
|
|
2
|
+
export var PubsubRouter;
|
|
3
|
+
(function (PubsubRouter) {
|
|
4
|
+
PubsubRouter[PubsubRouter["Gossipsub"] = 0] = "Gossipsub";
|
|
5
|
+
PubsubRouter[PubsubRouter["Floodsub"] = 1] = "Floodsub";
|
|
6
|
+
})(PubsubRouter || (PubsubRouter = {}));
|
|
7
|
+
/** Coarse local reachability state. */
|
|
8
|
+
export var Reachability;
|
|
9
|
+
(function (Reachability) {
|
|
10
|
+
Reachability[Reachability["Unknown"] = 0] = "Unknown";
|
|
11
|
+
Reachability[Reachability["Public"] = 1] = "Public";
|
|
12
|
+
Reachability[Reachability["Private"] = 2] = "Private";
|
|
13
|
+
})(Reachability || (Reachability = {}));
|
|
14
|
+
/** Source that contributed a discovery observation. */
|
|
15
|
+
export var DiscoverySource;
|
|
16
|
+
(function (DiscoverySource) {
|
|
17
|
+
DiscoverySource[DiscoverySource["SignedBeacon"] = 0] = "SignedBeacon";
|
|
18
|
+
DiscoverySource[DiscoverySource["Mdns"] = 1] = "Mdns";
|
|
19
|
+
})(DiscoverySource || (DiscoverySource = {}));
|
|
20
|
+
/** Category of a fatal background-driver failure. */
|
|
21
|
+
export var DriverFailureKind;
|
|
22
|
+
(function (DriverFailureKind) {
|
|
23
|
+
DriverFailureKind[DriverFailureKind["Transport"] = 0] = "Transport";
|
|
24
|
+
DriverFailureKind[DriverFailureKind["Swarm"] = 1] = "Swarm";
|
|
25
|
+
DriverFailureKind[DriverFailureKind["Invariant"] = 2] = "Invariant";
|
|
26
|
+
DriverFailureKind[DriverFailureKind["Panic"] = 3] = "Panic";
|
|
27
|
+
})(DriverFailureKind || (DriverFailureKind = {}));
|
|
28
|
+
/** Category of a non-fatal endpoint runtime error. */
|
|
29
|
+
export var EndpointErrorKind;
|
|
30
|
+
(function (EndpointErrorKind) {
|
|
31
|
+
EndpointErrorKind[EndpointErrorKind["Transport"] = 0] = "Transport";
|
|
32
|
+
EndpointErrorKind[EndpointErrorKind["Multistream"] = 1] = "Multistream";
|
|
33
|
+
EndpointErrorKind[EndpointErrorKind["Identify"] = 2] = "Identify";
|
|
34
|
+
EndpointErrorKind[EndpointErrorKind["Ping"] = 3] = "Ping";
|
|
35
|
+
EndpointErrorKind[EndpointErrorKind["IdentifyStreamRejected"] = 4] = "IdentifyStreamRejected";
|
|
36
|
+
EndpointErrorKind[EndpointErrorKind["OpenStreamFailed"] = 5] = "OpenStreamFailed";
|
|
37
|
+
EndpointErrorKind[EndpointErrorKind["UnsupportedProtocol"] = 6] = "UnsupportedProtocol";
|
|
38
|
+
EndpointErrorKind[EndpointErrorKind["Driver"] = 7] = "Driver";
|
|
39
|
+
})(EndpointErrorKind || (EndpointErrorKind = {}));
|
|
40
|
+
/** Category of a failed NAT connection attempt. */
|
|
41
|
+
export var NatErrorKind;
|
|
42
|
+
(function (NatErrorKind) {
|
|
43
|
+
NatErrorKind[NatErrorKind["NoPathAvailable"] = 0] = "NoPathAvailable";
|
|
44
|
+
NatErrorKind[NatErrorKind["Timeout"] = 1] = "Timeout";
|
|
45
|
+
NatErrorKind[NatErrorKind["DialFailed"] = 2] = "DialFailed";
|
|
46
|
+
NatErrorKind[NatErrorKind["Protocol"] = 3] = "Protocol";
|
|
47
|
+
NatErrorKind[NatErrorKind["RelayRefused"] = 4] = "RelayRefused";
|
|
48
|
+
})(NatErrorKind || (NatErrorKind = {}));
|
|
49
|
+
/** Tags for a usable connection path. */
|
|
50
|
+
export var PathKind_Tags;
|
|
51
|
+
(function (PathKind_Tags) {
|
|
52
|
+
PathKind_Tags["DirectDialed"] = "DirectDialed";
|
|
53
|
+
PathKind_Tags["DirectPunched"] = "DirectPunched";
|
|
54
|
+
PathKind_Tags["Relayed"] = "Relayed";
|
|
55
|
+
})(PathKind_Tags || (PathKind_Tags = {}));
|
|
56
|
+
/** Tags for events delivered by a minip2p endpoint. */
|
|
57
|
+
export var P2pEvent_Tags;
|
|
58
|
+
(function (P2pEvent_Tags) {
|
|
59
|
+
P2pEvent_Tags["EventsDropped"] = "EventsDropped";
|
|
60
|
+
P2pEvent_Tags["DriverFailed"] = "DriverFailed";
|
|
61
|
+
P2pEvent_Tags["ConnectionEstablished"] = "ConnectionEstablished";
|
|
62
|
+
P2pEvent_Tags["ConnectionClosed"] = "ConnectionClosed";
|
|
63
|
+
P2pEvent_Tags["PeerReady"] = "PeerReady";
|
|
64
|
+
P2pEvent_Tags["IdentifyReceived"] = "IdentifyReceived";
|
|
65
|
+
P2pEvent_Tags["PingRttMeasured"] = "PingRttMeasured";
|
|
66
|
+
P2pEvent_Tags["PingTimeout"] = "PingTimeout";
|
|
67
|
+
P2pEvent_Tags["StreamReady"] = "StreamReady";
|
|
68
|
+
P2pEvent_Tags["StreamData"] = "StreamData";
|
|
69
|
+
P2pEvent_Tags["StreamRemoteWriteClosed"] = "StreamRemoteWriteClosed";
|
|
70
|
+
P2pEvent_Tags["StreamClosed"] = "StreamClosed";
|
|
71
|
+
P2pEvent_Tags["EndpointError"] = "EndpointError";
|
|
72
|
+
P2pEvent_Tags["ReachabilityChanged"] = "ReachabilityChanged";
|
|
73
|
+
P2pEvent_Tags["PublicAddressesChanged"] = "PublicAddressesChanged";
|
|
74
|
+
P2pEvent_Tags["RelayReserved"] = "RelayReserved";
|
|
75
|
+
P2pEvent_Tags["RelayReservationLost"] = "RelayReservationLost";
|
|
76
|
+
P2pEvent_Tags["PathEstablished"] = "PathEstablished";
|
|
77
|
+
P2pEvent_Tags["PathUpgraded"] = "PathUpgraded";
|
|
78
|
+
P2pEvent_Tags["HolePunchFailed"] = "HolePunchFailed";
|
|
79
|
+
P2pEvent_Tags["FellBackToRelay"] = "FellBackToRelay";
|
|
80
|
+
P2pEvent_Tags["ConnectFailed"] = "ConnectFailed";
|
|
81
|
+
P2pEvent_Tags["InboundDirectUpgrade"] = "InboundDirectUpgrade";
|
|
82
|
+
P2pEvent_Tags["Message"] = "Message";
|
|
83
|
+
P2pEvent_Tags["PeerSubscribed"] = "PeerSubscribed";
|
|
84
|
+
P2pEvent_Tags["PeerUnsubscribed"] = "PeerUnsubscribed";
|
|
85
|
+
P2pEvent_Tags["PubsubOutboundFailure"] = "PubsubOutboundFailure";
|
|
86
|
+
P2pEvent_Tags["PubsubProtocolViolation"] = "PubsubProtocolViolation";
|
|
87
|
+
P2pEvent_Tags["PeerDiscovered"] = "PeerDiscovered";
|
|
88
|
+
P2pEvent_Tags["PeerUpdated"] = "PeerUpdated";
|
|
89
|
+
P2pEvent_Tags["PeerExpired"] = "PeerExpired";
|
|
90
|
+
P2pEvent_Tags["DiscoveryDialFailed"] = "DiscoveryDialFailed";
|
|
91
|
+
P2pEvent_Tags["DiscoveryProtocolViolation"] = "DiscoveryProtocolViolation";
|
|
92
|
+
})(P2pEvent_Tags || (P2pEvent_Tags = {}));
|
|
93
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2BA,6BAA6B;AAC7B,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,yDAAa,CAAA;IACb,uDAAY,CAAA;AACd,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AA4BD,uCAAuC;AACvC,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,uDAAuD;AACvD,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,qEAAgB,CAAA;IAChB,qDAAQ,CAAA;AACV,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED,qDAAqD;AACrD,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,mEAAa,CAAA;IACb,2DAAS,CAAA;IACT,mEAAa,CAAA;IACb,2DAAS,CAAA;AACX,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAED,sDAAsD;AACtD,MAAM,CAAN,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,mEAAa,CAAA;IACb,uEAAe,CAAA;IACf,iEAAY,CAAA;IACZ,yDAAQ,CAAA;IACR,6FAA0B,CAAA;IAC1B,iFAAoB,CAAA;IACpB,uFAAuB,CAAA;IACvB,6DAAU,CAAA;AACZ,CAAC,EATW,iBAAiB,KAAjB,iBAAiB,QAS5B;AAED,mDAAmD;AACnD,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,qEAAmB,CAAA;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eScript SDK for minip2p",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"libp2p",
|
|
7
|
+
"p2p",
|
|
8
|
+
"peer-to-peer",
|
|
9
|
+
"quic",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/deepso7/minip2p#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/deepso7/minip2p/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Deepso <deeps.o7o8.y@gmail.com> (https://github.com/deepso7)",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/deepso7/minip2p.git",
|
|
21
|
+
"directory": "bindings/ts/core"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"minip2p-source": "./src/index.ts",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./backend": {
|
|
38
|
+
"minip2p-source": "./src/backend.ts",
|
|
39
|
+
"types": "./dist/backend.d.ts",
|
|
40
|
+
"default": "./dist/backend.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"del-cli": "^7.0.0",
|
|
50
|
+
"typescript": "^6.0.3"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "del-cli dist && tsc -p tsconfig.build.json",
|
|
54
|
+
"clean": "del-cli dist",
|
|
55
|
+
"test": "pnpm build && node --test tests/*.test.mjs",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/backend.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Bytes,
|
|
3
|
+
IdentifyInfo,
|
|
4
|
+
KnownPeerInfo,
|
|
5
|
+
MiniP2pConfig,
|
|
6
|
+
P2pEvent,
|
|
7
|
+
Reachability,
|
|
8
|
+
RelayReservationInfo,
|
|
9
|
+
} from "./types.js";
|
|
10
|
+
|
|
11
|
+
/** Native endpoint operations required by the platform-neutral SDK. */
|
|
12
|
+
export interface MiniP2pBackend {
|
|
13
|
+
start: (listener: (event: P2pEvent) => void) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
peerId: () => string;
|
|
16
|
+
listenAddrs: () => string[];
|
|
17
|
+
connectedPeers: () => string[];
|
|
18
|
+
isPeerReady: (peerId: string) => boolean;
|
|
19
|
+
peerInfo: (peerId: string) => IdentifyInfo | undefined;
|
|
20
|
+
knownPeers: () => KnownPeerInfo[];
|
|
21
|
+
discoveryNowMs: () => number | undefined;
|
|
22
|
+
activeReservation: () => RelayReservationInfo | undefined;
|
|
23
|
+
circuitAddress: (relayAddress: string, peerId: string) => string;
|
|
24
|
+
reachability: () => Reachability;
|
|
25
|
+
isRunning: () => boolean;
|
|
26
|
+
setActive: (active: boolean) => void;
|
|
27
|
+
subscribe: (topic: string) => boolean;
|
|
28
|
+
unsubscribe: (topic: string) => boolean;
|
|
29
|
+
publish: (topic: string, data: Uint8Array) => void;
|
|
30
|
+
ping: (peerId: string) => void;
|
|
31
|
+
addProtocol: (protocolId: string) => void;
|
|
32
|
+
openStream: (peerId: string, protocolId: string) => number;
|
|
33
|
+
sendStream: (peerId: string, streamId: number, data: Uint8Array) => void;
|
|
34
|
+
closeStreamWrite: (peerId: string, streamId: number) => void;
|
|
35
|
+
resetStream: (peerId: string, streamId: number) => void;
|
|
36
|
+
abandonStream: (peerId: string, streamId: number) => void;
|
|
37
|
+
connect: (peerId: string) => number;
|
|
38
|
+
connectWithAddrs: (peerId: string, addresses: readonly string[]) => number;
|
|
39
|
+
connectAddr: (address: string) => number;
|
|
40
|
+
dial: (address: string) => number[];
|
|
41
|
+
dialIp4: (address: string) => number;
|
|
42
|
+
dialIp6: (address: string) => number;
|
|
43
|
+
cancelConnect: (id: number) => void;
|
|
44
|
+
disconnect: (peerId: string) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Platform implementation used to construct endpoints and identity helpers. */
|
|
48
|
+
export interface MiniP2pBackendFactory {
|
|
49
|
+
create: (config: MiniP2pConfig) => MiniP2pBackend;
|
|
50
|
+
generateSecretKey: () => Uint8Array;
|
|
51
|
+
peerIdFromSecretKey: (secretKey: Bytes) => string;
|
|
52
|
+
circuitAddress: (relayAddress: string, peerId: string) => string;
|
|
53
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* oxlint-disable max-classes-per-file -- The small public SDK error family is intentionally colocated and exported from one module. */
|
|
2
|
+
|
|
3
|
+
import type { DriverFailureKind } from "./types.js";
|
|
4
|
+
|
|
5
|
+
/** The native pubsub queue rejected work because it is full. */
|
|
6
|
+
export class BackpressureError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("The native pubsub queue is full");
|
|
9
|
+
this.name = "BackpressureError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The payload exceeds the native pubsub protocol limit. */
|
|
14
|
+
export class MessageTooLargeError extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("The message exceeds the native pubsub size limit");
|
|
17
|
+
this.name = "MessageTooLargeError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A valid operation was rejected by endpoint policy. */
|
|
22
|
+
export class NotPermittedError extends Error {
|
|
23
|
+
constructor(message = "The operation is not permitted") {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "NotPermittedError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A bounded SDK wait elapsed without a matching event. */
|
|
30
|
+
export class TimeoutError extends Error {
|
|
31
|
+
constructor(timeoutMs: number) {
|
|
32
|
+
super(`Timed out after ${timeoutMs} ms`);
|
|
33
|
+
this.name = "TimeoutError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The SDK was closed before an operation could complete. */
|
|
38
|
+
export class ClosedError extends Error {
|
|
39
|
+
constructor() {
|
|
40
|
+
super("The minip2p endpoint is closed");
|
|
41
|
+
this.name = "ClosedError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The native background driver terminated with a fatal failure. */
|
|
46
|
+
export class DriverFailedError extends Error {
|
|
47
|
+
readonly kind: DriverFailureKind;
|
|
48
|
+
|
|
49
|
+
constructor(kind: DriverFailureKind, detail: string) {
|
|
50
|
+
super(detail.length > 0 ? detail : "The minip2p driver failed");
|
|
51
|
+
this.name = "DriverFailedError";
|
|
52
|
+
this.kind = kind;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A peer disconnected before the awaited operation could complete. */
|
|
57
|
+
export class PeerDisconnectedError extends Error {
|
|
58
|
+
readonly peerId: string;
|
|
59
|
+
|
|
60
|
+
constructor(peerId: string) {
|
|
61
|
+
super(`Peer ${peerId} disconnected before becoming ready`);
|
|
62
|
+
this.name = "PeerDisconnectedError";
|
|
63
|
+
this.peerId = peerId;
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export {
|
|
2
|
+
BackpressureError,
|
|
3
|
+
ClosedError,
|
|
4
|
+
DriverFailedError,
|
|
5
|
+
MessageTooLargeError,
|
|
6
|
+
NotPermittedError,
|
|
7
|
+
PeerDisconnectedError,
|
|
8
|
+
TimeoutError,
|
|
9
|
+
} from "./errors.js";
|
|
10
|
+
export { MiniP2pBase } from "./sdk.js";
|
|
11
|
+
export {
|
|
12
|
+
DiscoverySource,
|
|
13
|
+
DriverFailureKind,
|
|
14
|
+
EndpointErrorKind,
|
|
15
|
+
NatErrorKind,
|
|
16
|
+
P2pEvent_Tags,
|
|
17
|
+
PathKind_Tags,
|
|
18
|
+
PubsubRouter,
|
|
19
|
+
Reachability,
|
|
20
|
+
type Bytes,
|
|
21
|
+
type IdentifyInfo,
|
|
22
|
+
type KnownPeerInfo,
|
|
23
|
+
type MiniP2pConfig,
|
|
24
|
+
type MiniP2pDiscoveryOptions,
|
|
25
|
+
type MiniP2pMdnsOptions,
|
|
26
|
+
type MiniP2pEvent,
|
|
27
|
+
type P2pEvent,
|
|
28
|
+
type P2pEventByTag,
|
|
29
|
+
type PathKind,
|
|
30
|
+
type QueueOverflowEvent,
|
|
31
|
+
type RelayReservationInfo,
|
|
32
|
+
type Unsubscribe,
|
|
33
|
+
} from "./types.js";
|