@minip2p/node 0.9.1 → 0.10.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/README.md +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +14 -506
- package/dist/adapter.js.map +1 -1
- package/dist/addon.d.ts +11 -4
- package/dist/native-shape.d.ts +4 -18
- package/dist/native-shape.d.ts.map +1 -1
- package/dist/native-shape.js +3 -5
- package/dist/native-shape.js.map +1 -1
- package/package.json +9 -9
- package/src/adapter.ts +25 -670
- package/src/addon.d.ts +11 -4
- package/src/native-shape.ts +12 -35
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ console.log(endpoint.peerId(), endpoint.listenAddrs());
|
|
|
14
14
|
endpoint.close();
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
`Minip2p.create()` starts the endpoint. A running endpoint keeps the Node.js process alive until `close()` shuts it down. Promise-returning operations such as `connect()` and `openStream()` resolve as their network work completes.
|
|
17
|
+
`Minip2p.create()` starts the endpoint. A running endpoint keeps the Node.js process alive until `close()` shuts it down and its bounded drain (500 ms by default, `close(timeoutMs)` to choose) finishes. Promise-returning operations such as `connect()` and `openStream()` resolve as their network work completes.
|
|
18
18
|
|
|
19
19
|
The Node binding accepts the same TCP, QUIC, circuit-relay, signed-discovery, and mDNS configuration as `@minip2p/react-native`.
|
|
20
20
|
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAyB1D,gEAAgE;AAChE,qBAAa,OAAQ,SAAQ,WAAW;IACtC,OAAO,eAEN;IAED,gDAAgD;IAChD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAE5C;CACF;AAED,kDAAkD;AAClD,wBAAgB,iBAAiB,IAAI,UAAU,CAE9C;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAI5D;AAED,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI3E"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,206 +1,18 @@
|
|
|
1
|
-
/* oxlint-disable
|
|
2
|
-
import { Minip2pBase
|
|
3
|
-
import {
|
|
1
|
+
/* oxlint-disable func-style, no-use-before-define -- Hoisted helpers keep the public entry points first. */
|
|
2
|
+
import { Minip2pBase } from "@minip2p/core";
|
|
3
|
+
import { resolveEndpointConfig } from "@minip2p/core/backend";
|
|
4
|
+
import { SerdeBackend, typedNativeCall } from "@minip2p/core/serde-backend";
|
|
4
5
|
import { nativeBinding } from "./native.js";
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#endpoint;
|
|
10
|
-
#events;
|
|
11
|
-
#streamIds = new StreamIdMap();
|
|
12
|
-
/** Native stream identities while their events are in flight (ADR 0012). */
|
|
13
|
-
#settleHandles = new SettleHandles();
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this.#endpoint = translateErrors(() => new nativeBinding.NodeEndpoint(toUint8Array(config.secretKey), resolveEndpointConfig(config)));
|
|
16
|
-
}
|
|
17
|
-
start(listener) {
|
|
18
|
-
const events = new EventDrain((limit) => this.#endpoint.drainEvents(limit), (event) => {
|
|
19
|
-
const normalized = normalizeEvent(event, this.#connectionIds, this.#streamIds);
|
|
20
|
-
const stream = eventStream(normalized);
|
|
21
|
-
const native = nativeStreamOf(event);
|
|
22
|
-
if (stream !== undefined && native !== undefined) {
|
|
23
|
-
this.#settleHandles.hold(stream.connId, stream.streamId, native);
|
|
24
|
-
}
|
|
25
|
-
listener(normalized);
|
|
26
|
-
}, DRAIN_LIMIT,
|
|
6
|
+
function nodeBackend(config) {
|
|
7
|
+
const endpoint = typedNativeCall(() => new nativeBinding.NodeEndpoint(toUint8Array(config.secretKey), resolveEndpointConfig(config)));
|
|
8
|
+
return new SerdeBackend(endpoint, {
|
|
9
|
+
circuitAddress,
|
|
27
10
|
// One check-phase turn keeps native callbacks out of the caller's stack
|
|
28
11
|
// without paying the timer granularity for every bounded batch.
|
|
29
|
-
(task) => {
|
|
12
|
+
schedule: (task) => {
|
|
30
13
|
setImmediate(task);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
translateErrors(() => {
|
|
34
|
-
this.#endpoint.start(() => {
|
|
35
|
-
events.ring();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
eventHandled(event) {
|
|
40
|
-
releaseTerminalIds(event, this.#streamIds);
|
|
41
|
-
const stream = eventStream(event);
|
|
42
|
-
if (stream !== undefined) {
|
|
43
|
-
this.#settleHandles.release(stream.connId, stream.streamId);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
close() {
|
|
47
|
-
this.#endpoint.close();
|
|
48
|
-
this.#events?.stop();
|
|
49
|
-
}
|
|
50
|
-
peerId() {
|
|
51
|
-
return this.#endpoint.peerId();
|
|
52
|
-
}
|
|
53
|
-
listenAddrs() {
|
|
54
|
-
return this.#endpoint.listenAddrs();
|
|
55
|
-
}
|
|
56
|
-
isRunning() {
|
|
57
|
-
return this.#endpoint.isRunning();
|
|
58
|
-
}
|
|
59
|
-
connectedPeers() {
|
|
60
|
-
return translateErrors(() => this.#endpoint.connectedPeers());
|
|
61
|
-
}
|
|
62
|
-
isPeerReady(peerId) {
|
|
63
|
-
return translateErrors(() => this.#endpoint.isPeerReady(peerId));
|
|
64
|
-
}
|
|
65
|
-
peerInfo(peerId) {
|
|
66
|
-
const info = translateErrors(() => this.#endpoint.peerInfo(peerId));
|
|
67
|
-
return info === null ? undefined : identifyInfo(info);
|
|
68
|
-
}
|
|
69
|
-
knownPeers() {
|
|
70
|
-
return translateErrors(() => this.#endpoint.knownPeers()).map(knownPeer);
|
|
71
|
-
}
|
|
72
|
-
discoveryNowMs() {
|
|
73
|
-
const value = translateErrors(() => this.#endpoint.discoveryNowMs());
|
|
74
|
-
return value === null ? undefined : u64ToNumber(value, "clock");
|
|
75
|
-
}
|
|
76
|
-
activeReservation() {
|
|
77
|
-
const reservation = translateErrors(() => this.#endpoint.activeReservation());
|
|
78
|
-
return reservation === null ? undefined : relayReservation(reservation);
|
|
79
|
-
}
|
|
80
|
-
path(peerId) {
|
|
81
|
-
return translateErrors(() => this.#endpoint.path(peerId)) ?? undefined;
|
|
82
|
-
}
|
|
83
|
-
connectionInfo(peerId) {
|
|
84
|
-
const info = translateErrors(() => this.#endpoint.connectionInfo(peerId));
|
|
85
|
-
if (info === null) {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
const { connId, ...rest } = info;
|
|
89
|
-
return {
|
|
90
|
-
...rest,
|
|
91
|
-
connId: this.#connectionIds.toPublic(BigInt(connId)),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
circuitAddress(relayAddress, peerId) {
|
|
95
|
-
return circuitAddress(relayAddress, peerId);
|
|
96
|
-
}
|
|
97
|
-
reachability() {
|
|
98
|
-
return translateErrors(() => this.#endpoint.reachability());
|
|
99
|
-
}
|
|
100
|
-
setActive(active) {
|
|
101
|
-
this.#endpoint.setActive(active);
|
|
102
|
-
}
|
|
103
|
-
subscribe(topic) {
|
|
104
|
-
return translateErrors(() => this.#endpoint.subscribe(topic));
|
|
105
|
-
}
|
|
106
|
-
unsubscribe(topic) {
|
|
107
|
-
return translateErrors(() => this.#endpoint.unsubscribe(topic));
|
|
108
|
-
}
|
|
109
|
-
publish(topic, data) {
|
|
110
|
-
translateErrors(() => {
|
|
111
|
-
this.#endpoint.publish(topic, data);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
ping(peerId) {
|
|
115
|
-
translateErrors(() => {
|
|
116
|
-
this.#endpoint.ping(peerId);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
addProtocol(protocolId) {
|
|
120
|
-
translateErrors(() => {
|
|
121
|
-
this.#endpoint.addProtocol(protocolId);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
openStream(peerId, protocolId) {
|
|
125
|
-
const stream = translateErrors(() => this.#endpoint.openStream(peerId, protocolId));
|
|
126
|
-
const connId = this.#connectionIds.toPublic(BigInt(stream.connId));
|
|
127
|
-
return {
|
|
128
|
-
connId,
|
|
129
|
-
streamId: this.#streamIds.toPublic(connId, BigInt(stream.streamId)),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
sendStream(connId, streamId, data) {
|
|
133
|
-
return translateErrors(() => this.#endpoint.sendStream(...this.#nativeStream(connId, streamId), data));
|
|
134
|
-
}
|
|
135
|
-
closeStreamWrite(connId, streamId) {
|
|
136
|
-
translateErrors(() => {
|
|
137
|
-
this.#endpoint.closeStreamWrite(...this.#nativeStream(connId, streamId));
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
resetStream(connId, streamId) {
|
|
141
|
-
translateErrors(() => {
|
|
142
|
-
this.#endpoint.resetStream(...this.#nativeStream(connId, streamId));
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
abandonStream(connId, streamId) {
|
|
146
|
-
translateErrors(() => {
|
|
147
|
-
this.#endpoint.abandonStream(...this.#settleStream(connId, streamId));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
streamConsumer(connId, streamId) {
|
|
151
|
-
const [nativeConn, nativeStream] = this.#settleStream(connId, streamId);
|
|
152
|
-
return (bytes) => {
|
|
153
|
-
translateErrors(() => {
|
|
154
|
-
this.#endpoint.streamConsumed(nativeConn, nativeStream, bytes);
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Native connection and stream IDs for a public stream. Native names the
|
|
160
|
-
* stream by both, so an operation for a connection that native already
|
|
161
|
-
* replaced fails there instead of reaching a stream on the new connection.
|
|
162
|
-
* A connection whose close or replacement this adapter has already drained
|
|
163
|
-
* has no native ID, so the operation throws `StreamClosedError`.
|
|
164
|
-
*/
|
|
165
|
-
#nativeStream(connId, streamId) {
|
|
166
|
-
return [
|
|
167
|
-
this.#connectionIds.toNative(connId),
|
|
168
|
-
this.#streamIds.toNative(streamId),
|
|
169
|
-
];
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Native IDs for settling a stream: acknowledging or abandoning its bytes.
|
|
173
|
-
* Those still hold the native slot of a connection whose end this adapter
|
|
174
|
-
* already drained, so a stream with events in flight resolves through its
|
|
175
|
-
* settle handle once the live mapping is gone.
|
|
176
|
-
*/
|
|
177
|
-
#settleStream(connId, streamId) {
|
|
178
|
-
try {
|
|
179
|
-
return this.#nativeStream(connId, streamId);
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
const handle = this.#settleHandles.get(connId, streamId);
|
|
183
|
-
if (handle === undefined) {
|
|
184
|
-
throw error;
|
|
185
|
-
}
|
|
186
|
-
return handle;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Connect IDs are not mapped because they round-trip into native calls,
|
|
190
|
-
// and native allocates them well inside the safe integer range.
|
|
191
|
-
connect(target) {
|
|
192
|
-
return u64ToNumber(translateErrors(() => this.#endpoint.connect(target.kind === "peer" ? target.peerId : [...target.addresses])), "connectId");
|
|
193
|
-
}
|
|
194
|
-
cancelConnect(id) {
|
|
195
|
-
translateErrors(() => {
|
|
196
|
-
this.#endpoint.cancelConnect(BigInt(id));
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
disconnect(peerId) {
|
|
200
|
-
translateErrors(() => {
|
|
201
|
-
this.#endpoint.disconnect(peerId);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
14
|
+
},
|
|
15
|
+
});
|
|
204
16
|
}
|
|
205
17
|
/** High-level Node.js owner for one native minip2p endpoint. */
|
|
206
18
|
export class Minip2p extends Minip2pBase {
|
|
@@ -209,7 +21,7 @@ export class Minip2p extends Minip2pBase {
|
|
|
209
21
|
}
|
|
210
22
|
/** Constructs and starts a Node.js endpoint. */
|
|
211
23
|
static create(config) {
|
|
212
|
-
return new Minip2p(
|
|
24
|
+
return new Minip2p(nodeBackend(config), config.relays ?? []);
|
|
213
25
|
}
|
|
214
26
|
}
|
|
215
27
|
/** Generates a new 32-byte Ed25519 secret key. */
|
|
@@ -218,318 +30,14 @@ export function generateSecretKey() {
|
|
|
218
30
|
}
|
|
219
31
|
/** Derives a peer ID from raw Ed25519 secret key material. */
|
|
220
32
|
export function peerIdFromSecretKey(secretKey) {
|
|
221
|
-
return
|
|
33
|
+
return typedNativeCall(() => nativeBinding.peerIdFromSecretKey(toUint8Array(secretKey)));
|
|
222
34
|
}
|
|
223
35
|
/** Builds a circuit multiaddress through a direct relay address. */
|
|
224
36
|
export function circuitAddress(relayAddress, peerId) {
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Rethrows a native `FfiError` as its typed SDK error. The addon tags each
|
|
229
|
-
* error with the variant name as `code`, its detail field as `detail`, and
|
|
230
|
-
* an `InvalidConfig`'s capability name as `capability`; untyped variants are
|
|
231
|
-
* rethrown unchanged with those properties intact.
|
|
232
|
-
*/
|
|
233
|
-
function translateErrors(operation) {
|
|
234
|
-
try {
|
|
235
|
-
return operation();
|
|
236
|
-
}
|
|
237
|
-
catch (error) {
|
|
238
|
-
throw (typedFfiError({
|
|
239
|
-
capability: stringProperty(error, "capability"),
|
|
240
|
-
detail: stringProperty(error, "detail"),
|
|
241
|
-
tag: stringProperty(error, "code"),
|
|
242
|
-
}) ?? error);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function stringProperty(value, key) {
|
|
246
|
-
if (value === null || typeof value !== "object") {
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
const property = Reflect.get(value, key);
|
|
250
|
-
return typeof property === "string" ? property : undefined;
|
|
37
|
+
return typedNativeCall(() => nativeBinding.circuitAddress(relayAddress, peerId));
|
|
251
38
|
}
|
|
252
39
|
/** A view napi-rs can read; the addon copies it before the call returns. */
|
|
253
40
|
function toUint8Array(value) {
|
|
254
41
|
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
255
42
|
}
|
|
256
|
-
/** Converts an Identify snapshot, copying its public key into an `ArrayBuffer`. */
|
|
257
|
-
function identifyInfo({ publicKey, ...info }) {
|
|
258
|
-
return {
|
|
259
|
-
...info,
|
|
260
|
-
...(publicKey !== undefined && { publicKey: toArrayBuffer(publicKey) }),
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function knownPeer({ beaconLastSeenAgeMs, mdnsLastSeenAgeMs, ...peer }) {
|
|
264
|
-
return {
|
|
265
|
-
...peer,
|
|
266
|
-
...(beaconLastSeenAgeMs !== undefined && {
|
|
267
|
-
beaconLastSeenAgeMs: u64ToNumber(beaconLastSeenAgeMs, "beaconLastSeenAgeMs"),
|
|
268
|
-
}),
|
|
269
|
-
...(mdnsLastSeenAgeMs !== undefined && {
|
|
270
|
-
mdnsLastSeenAgeMs: u64ToNumber(mdnsLastSeenAgeMs, "mdnsLastSeenAgeMs"),
|
|
271
|
-
}),
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
function relayReservation({ expiresUnixSecs, relayPeerId, }) {
|
|
275
|
-
return {
|
|
276
|
-
relayPeerId,
|
|
277
|
-
...(expiresUnixSecs !== undefined && {
|
|
278
|
-
expiresUnixSecs: u64ToNumber(expiresUnixSecs, "expiresUnixSecs"),
|
|
279
|
-
}),
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
/** Event fields carrying a native connection ID. */
|
|
283
|
-
const CONNECTION_ID_KEYS = new Set([
|
|
284
|
-
"connId",
|
|
285
|
-
"oldConnId",
|
|
286
|
-
"newConnId",
|
|
287
|
-
]);
|
|
288
|
-
/**
|
|
289
|
-
* Converts one value of a native `tag` event: integers to numbers, connection
|
|
290
|
-
* IDs through the connection map, and bytes to `ArrayBuffer`s. A stream ID is
|
|
291
|
-
* mapped together with the connection of the record that carries it.
|
|
292
|
-
*/
|
|
293
|
-
function normalizeNativeValue(value, maps, tag, key) {
|
|
294
|
-
if (typeof value === "bigint" || typeof value === "number") {
|
|
295
|
-
if (key !== undefined && CONNECTION_ID_KEYS.has(key)) {
|
|
296
|
-
return maps.connectionIds.toPublicInEvent(tag, key, BigInt(value));
|
|
297
|
-
}
|
|
298
|
-
// A QUIC stop code is a 62-bit varint the remote picks: keep it whole.
|
|
299
|
-
if (key === "errorCode") {
|
|
300
|
-
return BigInt(value);
|
|
301
|
-
}
|
|
302
|
-
return key === "streamId" ? value : u64ToNumber(value, key ?? "native u64");
|
|
303
|
-
}
|
|
304
|
-
if (value instanceof Uint8Array) {
|
|
305
|
-
return toArrayBuffer(value);
|
|
306
|
-
}
|
|
307
|
-
if (Array.isArray(value)) {
|
|
308
|
-
return value.map((item) => normalizeNativeValue(item, maps, tag));
|
|
309
|
-
}
|
|
310
|
-
if (value === null || typeof value !== "object") {
|
|
311
|
-
return value;
|
|
312
|
-
}
|
|
313
|
-
const record = Object.fromEntries(Object.entries(value).map(([itemKey, item]) => [
|
|
314
|
-
itemKey,
|
|
315
|
-
normalizeNativeValue(item, maps, tag, itemKey),
|
|
316
|
-
]));
|
|
317
|
-
const { connId, streamId } = record;
|
|
318
|
-
if (typeof streamId === "bigint" || typeof streamId === "number") {
|
|
319
|
-
// Public stream IDs are allocated per connection. A record without a
|
|
320
|
-
// connection (an endpoint error, say) cannot name a public stream.
|
|
321
|
-
if (typeof connId === "number") {
|
|
322
|
-
record.streamId = maps.streamIds.toPublic(connId, BigInt(streamId));
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
delete record.streamId;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return record;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Converts one native event to its SDK backend form, then retires the IDs it
|
|
332
|
-
* ends.
|
|
333
|
-
*/
|
|
334
|
-
function normalizeEvent(event, connectionIds, streamIds) {
|
|
335
|
-
const normalized = convertEvent(event, { connectionIds, streamIds });
|
|
336
|
-
retireTerminalIds(normalized, connectionIds, streamIds);
|
|
337
|
-
return normalized;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Per-chunk and per-write events, and pubsub messages, convert field by
|
|
341
|
-
* field. Identify snapshots go through the typed {@link identifyInfo}, and a
|
|
342
|
-
* field-less event passes through by tag. The rest share the generic walk: the addon's serde shape is the SDK shape with
|
|
343
|
-
* napi-rs integers and buffers (see `native-shape.ts`).
|
|
344
|
-
*/
|
|
345
|
-
function convertEvent(event, maps) {
|
|
346
|
-
switch (event.tag) {
|
|
347
|
-
case P2pEvent_Tags.StreamData: {
|
|
348
|
-
return {
|
|
349
|
-
inner: {
|
|
350
|
-
...streamRef(event.inner, maps),
|
|
351
|
-
data: toArrayBuffer(event.inner.data),
|
|
352
|
-
},
|
|
353
|
-
tag: event.tag,
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
case P2pEvent_Tags.StreamWriteAccepted:
|
|
357
|
-
case P2pEvent_Tags.StreamRemoteWriteClosed:
|
|
358
|
-
case P2pEvent_Tags.StreamClosed: {
|
|
359
|
-
return { inner: streamRef(event.inner, maps), tag: event.tag };
|
|
360
|
-
}
|
|
361
|
-
case P2pEvent_Tags.Message: {
|
|
362
|
-
const { data, fromPeerId, seqno, signed, topics } = event.inner;
|
|
363
|
-
return {
|
|
364
|
-
inner: {
|
|
365
|
-
data: toArrayBuffer(data),
|
|
366
|
-
fromPeerId,
|
|
367
|
-
seqno: toArrayBuffer(seqno),
|
|
368
|
-
signed,
|
|
369
|
-
topics,
|
|
370
|
-
},
|
|
371
|
-
tag: event.tag,
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
case P2pEvent_Tags.IdentifyReceived: {
|
|
375
|
-
return {
|
|
376
|
-
inner: {
|
|
377
|
-
connId: maps.connectionIds.toPublic(BigInt(event.inner.connId)),
|
|
378
|
-
info: identifyInfo(event.inner.info),
|
|
379
|
-
peerId: event.inner.peerId,
|
|
380
|
-
},
|
|
381
|
-
tag: event.tag,
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
case P2pEvent_Tags.MdnsRecovered: {
|
|
385
|
-
return { tag: event.tag };
|
|
386
|
-
}
|
|
387
|
-
default: {
|
|
388
|
-
return {
|
|
389
|
-
inner: normalizeNativeValue(event.inner, maps, event.tag),
|
|
390
|
-
tag: event.tag,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
/** The native identity of the stream a native stream event names. */
|
|
396
|
-
function nativeStreamOf(event) {
|
|
397
|
-
switch (event.tag) {
|
|
398
|
-
case P2pEvent_Tags.StreamReady:
|
|
399
|
-
case P2pEvent_Tags.StreamData:
|
|
400
|
-
case P2pEvent_Tags.StreamWriteAccepted:
|
|
401
|
-
case P2pEvent_Tags.StreamWriteStopped:
|
|
402
|
-
case P2pEvent_Tags.StreamRemoteWriteClosed:
|
|
403
|
-
case P2pEvent_Tags.StreamClosed: {
|
|
404
|
-
return [BigInt(event.inner.connId), BigInt(event.inner.streamId)];
|
|
405
|
-
}
|
|
406
|
-
default: {
|
|
407
|
-
return undefined;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
/** The public identity of the stream a native stream event names. */
|
|
412
|
-
function streamRef(inner, maps) {
|
|
413
|
-
const connId = maps.connectionIds.toPublic(BigInt(inner.connId));
|
|
414
|
-
return {
|
|
415
|
-
connId,
|
|
416
|
-
peerId: inner.peerId,
|
|
417
|
-
streamId: maps.streamIds.toPublic(connId, BigInt(inner.streamId)),
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Stops new native events from reaching identifiers this event ends, so a
|
|
422
|
-
* reused native ID gets a fresh public number. An ended connection is
|
|
423
|
-
* released at once, so a stream operation queued behind its event throws
|
|
424
|
-
* `StreamClosedError` without reaching native; stream numbers stay resolvable
|
|
425
|
-
* until {@link releaseTerminalIds} runs after dispatch.
|
|
426
|
-
*/
|
|
427
|
-
function retireTerminalIds(event, connectionIds, streamIds) {
|
|
428
|
-
const connId = endedConnection(event);
|
|
429
|
-
if (connId !== undefined) {
|
|
430
|
-
connectionIds.release(connId);
|
|
431
|
-
streamIds.retireConnection(connId);
|
|
432
|
-
}
|
|
433
|
-
if (event.tag === P2pEvent_Tags.StreamClosed) {
|
|
434
|
-
streamIds.retirePublic(event.inner.streamId);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
/** Frees stream identifiers this event ended, once the SDK dispatched it. */
|
|
438
|
-
function releaseTerminalIds(event, streamIds) {
|
|
439
|
-
const connId = endedConnection(event);
|
|
440
|
-
if (connId !== undefined) {
|
|
441
|
-
streamIds.deleteConnection(connId);
|
|
442
|
-
}
|
|
443
|
-
if (event.tag === P2pEvent_Tags.StreamClosed) {
|
|
444
|
-
streamIds.deletePublic(event.inner.streamId);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* The connection this event ends. A closed or replaced connection reports no
|
|
449
|
-
* per-stream terminal events, so its streams end with it.
|
|
450
|
-
*/
|
|
451
|
-
function endedConnection(event) {
|
|
452
|
-
if (event.tag === P2pEvent_Tags.ConnectionClosed) {
|
|
453
|
-
return event.inner.connId;
|
|
454
|
-
}
|
|
455
|
-
if (event.tag === P2pEvent_Tags.ConnectionReplaced) {
|
|
456
|
-
return event.inner.oldConnId;
|
|
457
|
-
}
|
|
458
|
-
return undefined;
|
|
459
|
-
}
|
|
460
|
-
/** Copies native bytes unless they already own their whole `ArrayBuffer`. */
|
|
461
|
-
function toArrayBuffer(bytes) {
|
|
462
|
-
if (bytes.buffer instanceof ArrayBuffer &&
|
|
463
|
-
bytes.byteOffset === 0 &&
|
|
464
|
-
bytes.byteLength === bytes.buffer.byteLength) {
|
|
465
|
-
return bytes.buffer;
|
|
466
|
-
}
|
|
467
|
-
return Uint8Array.from(bytes).buffer;
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Maps native stream IDs, which are unique only within their connection, to
|
|
471
|
-
* public numbers that never repeat. Each stream remembers its public
|
|
472
|
-
* connection, so a closed or replaced connection frees every stream on it.
|
|
473
|
-
*/
|
|
474
|
-
class StreamIdMap {
|
|
475
|
-
/** Live public IDs by public connection, then native stream ID. */
|
|
476
|
-
#publicByNative = new Map();
|
|
477
|
-
#streams = new Map();
|
|
478
|
-
#next = 1;
|
|
479
|
-
toPublic(connId, native) {
|
|
480
|
-
let byNative = this.#publicByNative.get(connId);
|
|
481
|
-
const existing = byNative?.get(native);
|
|
482
|
-
if (existing !== undefined) {
|
|
483
|
-
return existing;
|
|
484
|
-
}
|
|
485
|
-
if (byNative === undefined) {
|
|
486
|
-
byNative = new Map();
|
|
487
|
-
this.#publicByNative.set(connId, byNative);
|
|
488
|
-
}
|
|
489
|
-
const publicId = this.#next;
|
|
490
|
-
this.#next += 1;
|
|
491
|
-
byNative.set(native, publicId);
|
|
492
|
-
this.#streams.set(publicId, { connId, native });
|
|
493
|
-
return publicId;
|
|
494
|
-
}
|
|
495
|
-
toNative(publicId) {
|
|
496
|
-
const stream = this.#streams.get(publicId);
|
|
497
|
-
if (stream === undefined) {
|
|
498
|
-
throw new StreamClosedError("The stream closed");
|
|
499
|
-
}
|
|
500
|
-
return stream.native;
|
|
501
|
-
}
|
|
502
|
-
deletePublic(publicId) {
|
|
503
|
-
this.retirePublic(publicId);
|
|
504
|
-
this.#streams.delete(publicId);
|
|
505
|
-
}
|
|
506
|
-
retirePublic(publicId) {
|
|
507
|
-
const stream = this.#streams.get(publicId);
|
|
508
|
-
if (stream === undefined) {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
const byNative = this.#publicByNative.get(stream.connId);
|
|
512
|
-
if (byNative?.get(stream.native) === publicId) {
|
|
513
|
-
byNative.delete(stream.native);
|
|
514
|
-
if (byNative.size === 0) {
|
|
515
|
-
this.#publicByNative.delete(stream.connId);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
deleteConnection(connId) {
|
|
520
|
-
for (const publicId of this.#onConnection(connId)) {
|
|
521
|
-
this.deletePublic(publicId);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
retireConnection(connId) {
|
|
525
|
-
for (const publicId of this.#onConnection(connId)) {
|
|
526
|
-
this.retirePublic(publicId);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
#onConnection(connId) {
|
|
530
|
-
return [...this.#streams]
|
|
531
|
-
.filter(([, stream]) => stream.connId === connId)
|
|
532
|
-
.map(([publicId]) => publicId);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
43
|
//# sourceMappingURL=adapter.js.map
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,mOAAmO;AAEnO,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAU/D,OAAO,EACL,eAAe,EACf,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAe/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,+BAA+B;AAC/B,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,WAAW;IACN,cAAc,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,SAAS,CAAiB;IACnC,OAAO,CAAsC;IACpC,UAAU,GAAG,IAAI,WAAW,EAAE,CAAC;IACxC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D,MAAM,UAAU,iBAAiB;IAC/B,OAAO,aAAa,CAAC,iBAAiB,EAAE,CAAC;AAC3C,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,mBAAmB,CAAC,SAAgB;IAClD,OAAO,eAAe,CAAC,GAAG,EAAE,CAC1B,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAAC,YAAoB,EAAE,MAAc;IACjE,OAAO,eAAe,CAAC,GAAG,EAAE,CAC1B,aAAa,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CAAC,KAAY;IAChC,OAAO,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/addon.d.ts
CHANGED
|
@@ -17,8 +17,12 @@ export declare class NodeEndpoint {
|
|
|
17
17
|
constructor(secretKey: Uint8Array, config: NodeEndpointConfig)
|
|
18
18
|
/** Starts the detached driver with a strong event-loop doorbell. */
|
|
19
19
|
start(doorbell: () => void): void
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Requests shutdown without waiting for the driver thread, which drains
|
|
22
|
+
* for up to `timeoutMs` and then delivers `EndpointClosed` as its last
|
|
23
|
+
* event.
|
|
24
|
+
*/
|
|
25
|
+
close(timeoutMs: number): void
|
|
22
26
|
/** Returns the local peer ID. */
|
|
23
27
|
peerId(): string
|
|
24
28
|
/** Returns bound peer addresses. */
|
|
@@ -78,9 +82,12 @@ export declare class NodeEndpoint {
|
|
|
78
82
|
cancelConnect(id: bigint): void
|
|
79
83
|
/** Disconnects one peer. */
|
|
80
84
|
disconnect(peerId: string): void
|
|
81
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Returns the path of a peer's established connection; `null` only
|
|
87
|
+
* while the peer is not connected.
|
|
88
|
+
*/
|
|
82
89
|
path(peerId: string): NativePathKind | null
|
|
83
|
-
/** Returns
|
|
90
|
+
/** Returns a snapshot of a peer's established connection. */
|
|
84
91
|
connectionInfo(peerId: string): NativeConnectionInfo | null
|
|
85
92
|
/** Returns the discovery address book. */
|
|
86
93
|
knownPeers(): Array<NativeKnownPeerInfo>
|
package/dist/native-shape.d.ts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of the values the native addon returns
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* SDK type with napi-rs's value encoding: `u64` arrives as `number`, or as a
|
|
6
|
-
* `bigint` above `u32::MAX`, and bytes arrive as a `Buffer`.
|
|
2
|
+
* Types of the values the native addon returns: `minip2p-ffi-core`'s serde
|
|
3
|
+
* shape, with napi-rs's value encoding (`u64` as `number`, or `bigint` above
|
|
4
|
+
* `u32::MAX`; bytes as a `Buffer`). The shared serde backend defines them.
|
|
7
5
|
*
|
|
8
6
|
* The generated `addon.d.ts` imports these names through its header.
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
import type { BackendOpenStream, P2pEvent, PathKind } from "@minip2p/core/backend";
|
|
12
|
-
/** One SDK backend value as the addon encodes it. */
|
|
13
|
-
export type NativeShape<Value> = Value extends ArrayBuffer ? Uint8Array : Value extends number ? number | bigint : Value extends string | boolean ? Value : Value extends readonly (infer Item)[] ? readonly NativeShape<Item>[] : {
|
|
14
|
-
readonly [Key in keyof Value]: NativeShape<Value[Key]>;
|
|
15
|
-
};
|
|
16
|
-
export type NativeEvent = NativeShape<P2pEvent>;
|
|
17
|
-
export type NativeIdentifyInfo = NativeShape<IdentifyInfo>;
|
|
18
|
-
export type NativeKnownPeerInfo = NativeShape<KnownPeerInfo>;
|
|
19
|
-
export type NativeRelayReservationInfo = NativeShape<RelayReservationInfo>;
|
|
20
|
-
export type NativeConnectionInfo = NativeShape<ConnectionInfo>;
|
|
21
|
-
export type NativeOpenStream = NativeShape<BackendOpenStream>;
|
|
22
|
-
export type NativePathKind = NativeShape<PathKind>;
|
|
8
|
+
export type { NativeConnectionInfo, NativeEvent, NativeIdentifyInfo, NativeKnownPeerInfo, NativeOpenStream, NativePathKind, NativeRelayReservationInfo, } from "@minip2p/core/serde-backend";
|
|
23
9
|
export type { Reachability } from "@minip2p/core";
|
|
24
10
|
//# sourceMappingURL=native-shape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-shape.d.ts","sourceRoot":"","sources":["../src/native-shape.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"native-shape.d.ts","sourceRoot":"","sources":["../src/native-shape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|