@peerbit/pubsub 3.0.5 → 3.0.6-2b760c3

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 CHANGED
@@ -11,17 +11,18 @@ Features
11
11
 
12
12
  method based on aggregated subscriber info, not only from immediate peers.
13
13
 
14
- - Subscriptions with associated metadata. E.g. you can subscribe to topics and provide data that explains the purpose for peers
15
- ```typescript
16
- .subscribe(topic, new UInt8Array([1,2,3]))
17
- ```
18
-
19
- ```typescript
20
- .getSubscribersWithData(topic, data)
21
- ```
22
14
 
23
- - Efficient content routing through path-finding algorithms
15
+ - Efficient content routing through an approximate path finding algorithm
24
16
  ```typescript
25
17
  .publish(data, { topics: ["a","b"]})
26
18
  ```
27
19
  will try to find the subscribers of "a" and "b" and send messages with the shortest path in the network.
20
+
21
+ - Packet prioritization. Data packages can be sent with different priority. That allows some traffic to pass through the traffic faster than other. This is useful in case of congestion
22
+ - Mode'd delivery. Packages can be sent with different delivery mode 'Acknowledge' (wait for acknowledgement from all known subscribers), 'Seek' (find new subscribers for a topic), 'Silent' (just deliver).
23
+ - Redundancy in data delivery. Data packages can be sent with different redundancy. This means that you can choose to send some packages only in one path (the fastest) or send a package in the 'N' fastest paths (this gives you a redundancy degree of 'N'). This feature is useful when you want to adapt delivery for unstable networks or when you want to make sure that some messages are delivered with high probability (without waiting for Acknowledgemts and retry)
24
+
25
+
26
+ Protocol specification (TODO)
27
+
28
+ Currently the protocol itself is not specificed more than as in this implementation with messages types found [here](https://github.com/dao-xyz/peerbit/blob/master/packages/transport/stream-interface/src/messages.ts) and [here](https://github.com/dao-xyz/peerbit/blob/master/packages/transport/pubsub-interface/src/messages.ts). Message handling logic can be found [here](https://github.com/dao-xyz/peerbit/blob/aa577a5e5b2b4920662de5e0efb92fb97a5dc63c/packages/transport/pubsub/src/index.ts#L502) and [here](https://github.com/dao-xyz/peerbit/blob/aa577a5e5b2b4920662de5e0efb92fb97a5dc63c/packages/transport/stream/src/index.ts#L1057).
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../benchmark/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ import { tcp } from "@libp2p/tcp";
2
+ import { TestSession } from "@peerbit/libp2p-test-utils";
3
+ import { DataEvent } from "@peerbit/pubsub-interface";
4
+ import { waitForPeers } from "@peerbit/stream";
5
+ import B from "benchmark";
6
+ import crypto from "crypto";
7
+ import { DirectSub } from "../src/index.js";
8
+ // Run with "node --loader ts-node/esm ./benchmark/index.ts"
9
+ // size: 1kb x 1,722 ops/sec ±1.89% (82 runs sampled)
10
+ // size: 1000kb x 107 ops/sec ±2.02% (85 runs sampled)
11
+ const session = await TestSession.disconnected(4, {
12
+ transports: [tcp()],
13
+ services: {
14
+ pubsub: (c) => new DirectSub(c, {
15
+ canRelayMessage: true,
16
+ connectionManager: false,
17
+ }),
18
+ },
19
+ });
20
+ await session.connect([
21
+ [session.peers[0], session.peers[1]],
22
+ [session.peers[1], session.peers[2]],
23
+ [session.peers[2], session.peers[3]],
24
+ ]);
25
+ /*
26
+ ┌─┐
27
+ │1│
28
+ └┬┘
29
+ ┌▽┐
30
+ │2│
31
+ └┬┘
32
+ ┌▽┐
33
+ │3│
34
+ └┬┘
35
+ ┌▽┐
36
+ │4│
37
+ └─┘
38
+
39
+ */
40
+ const TOPIC = "world";
41
+ session.peers[session.peers.length - 1].services.pubsub.subscribe(TOPIC);
42
+ await waitForPeers(session.peers[0].services.pubsub, session.peers[1].services.pubsub);
43
+ await waitForPeers(session.peers[1].services.pubsub, session.peers[2].services.pubsub);
44
+ await waitForPeers(session.peers[2].services.pubsub, session.peers[3].services.pubsub);
45
+ let suite = new B.Suite();
46
+ let listener = undefined;
47
+ const msgMap = new Map();
48
+ const msgIdFn = (msg) => {
49
+ return crypto.createHash("sha1").update(msg.subarray(0, 20)).digest("base64");
50
+ };
51
+ const sizes = [1e3, 1e6];
52
+ for (const size of sizes) {
53
+ suite = suite.add("size: " + size / 1e3 + "kb", {
54
+ defer: true,
55
+ fn: (deferred) => {
56
+ const small = crypto.randomBytes(size); // 1kb
57
+ msgMap.set(msgIdFn(small), deferred);
58
+ session.peers[0].services.pubsub.publish(small, { topics: [TOPIC] });
59
+ },
60
+ setup: () => {
61
+ listener = (msg) => {
62
+ msgMap.get(msgIdFn(msg.detail.data.data)).resolve();
63
+ };
64
+ session.peers[session.peers.length - 1].services.pubsub.addEventListener("data", listener);
65
+ msgMap.clear();
66
+ },
67
+ teardown: () => {
68
+ session.peers[session.peers.length - 1].services.pubsub.removeEventListener("data", listener);
69
+ },
70
+ });
71
+ }
72
+ suite
73
+ .on("cycle", (event) => {
74
+ console.log(String(event.target));
75
+ })
76
+ .on("error", (e) => {
77
+ console.error(e);
78
+ throw e;
79
+ })
80
+ .on("complete", function (...args) {
81
+ session.stop();
82
+ })
83
+ .run({ async: true });
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../benchmark/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,CAAC,MAAM,WAAW,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,4DAA4D;AAC5D,qDAAqD;AACrD,sDAAsD;AAEtD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,CAAC,EAAE;IACjD,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC;IACnB,QAAQ,EAAE;QACT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,CAAC,MAAM,CAAC,gBAAgB,CACvE,MAAM,EACN,QAAQ,CACR,CAAC;YACF,MAAM,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACd,OAAO,CAAC,KAAK,CACZ,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CACxB,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AACD,KAAK;KACH,EAAE,CAAC,OAAO,EAAE,CAAC,KAAU,EAAE,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;KACD,EAAE,CAAC,OAAO,EAAE,CAAC,CAAM,EAAE,EAAE;IACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,MAAM,CAAC,CAAC;AACT,CAAC,CAAC;KACD,EAAE,CAAC,UAAU,EAAE,UAAqB,GAAG,IAAW;IAClD,OAAO,CAAC,IAAI,EAAE,CAAC;AAChB,CAAC,CAAC;KACD,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
- import type { PeerId as Libp2pPeerId } from "@libp2p/interface";
2
- import { AcknowledgeDelivery, DataMessage, SeekDelivery, SilentDelivery, IdentificationOptions, PriorityOptions } from "@peerbit/stream-interface";
3
- import { DirectStream, DirectStreamComponents, DirectStreamOptions, PeerStreams } from "@peerbit/stream";
4
- import { PubSub, SubscriptionData, PubSubEvents } from "@peerbit/pubsub-interface";
1
+ import { type PeerId as Libp2pPeerId } from "@libp2p/interface";
5
2
  import { PublicSignKey } from "@peerbit/crypto";
3
+ import { type PubSub, type PubSubEvents, SubscriptionData } from "@peerbit/pubsub-interface";
4
+ import { DirectStream, type DirectStreamComponents, type DirectStreamOptions, type PeerStreams } from "@peerbit/stream";
5
+ import { AcknowledgeDelivery, DataMessage, type IdentificationOptions, type PriorityOptions, SeekDelivery, SilentDelivery } from "@peerbit/stream-interface";
6
6
  import { Uint8ArrayList } from "uint8arraylist";
7
7
  export declare const toUint8Array: (arr: Uint8ArrayList | Uint8Array) => Uint8Array;
8
8
  export declare const logger: import("pino").Logger<never>;
@@ -34,7 +34,9 @@ export declare class DirectSub extends DirectStream<PubSubEvents> implements Pub
34
34
  /**
35
35
  *
36
36
  * @param topic
37
- * @param force
37
+ * @param options
38
+ * @param options.force
39
+ * @param options.data
38
40
  * @returns true unsubscribed completely
39
41
  */
40
42
  unsubscribe(topic: string, options?: {
@@ -60,7 +62,7 @@ export declare class DirectSub extends DirectStream<PubSubEvents> implements Pub
60
62
  private removeSubscriptions;
61
63
  private subscriptionMessageIsLatest;
62
64
  private addPeersOnTopic;
63
- onDataMessage(from: PublicSignKey, stream: PeerStreams, message: DataMessage, seenBefore: number): Promise<boolean | undefined>;
65
+ onDataMessage(from: PublicSignKey, stream: PeerStreams, message: DataMessage, seenBefore: number): Promise<boolean>;
64
66
  }
65
67
  export declare const waitForSubscribers: (libp2p: {
66
68
  services: {
@@ -71,3 +73,4 @@ export declare const waitForSubscribers: (libp2p: {
71
73
  } | {
72
74
  peerId: Libp2pPeerId;
73
75
  }[] | string | string[], topic: string) => Promise<void>;
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,MAAM,IAAI,YAAY,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAGN,KAAK,MAAM,EAEX,KAAK,YAAY,EAIjB,gBAAgB,EAIhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,m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AAE,MAAM,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,eAExC,MAAM,GACN,MAAM,EAAE,GACR;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,EAAE,GAC1B,MAAM,GACN,MAAM,EAAE,SACJ,MAAM,kBA+Cb,CAAC"}
@@ -1,10 +1,9 @@
1
+ import { CodeError, CustomEvent, } from "@libp2p/interface";
2
+ import { PublicSignKey, getPublicKeyFromPeerId } from "@peerbit/crypto";
1
3
  import { logger as logFn } from "@peerbit/logger";
2
- import { AcknowledgeDelivery, AnyWhere, DataMessage, MessageHeader, SeekDelivery, SilentDelivery, deliveryModeHasReceiver, NotStartedError, DeliveryError } from "@peerbit/stream-interface";
3
- import { DirectStream } from "@peerbit/stream";
4
- import { CodeError } from "@libp2p/interface";
5
- import { PubSubMessage, Subscribe, PubSubData, Unsubscribe, GetSubscribers, UnsubcriptionEvent, SubscriptionEvent, DataEvent, SubscriptionData, PublishEvent } from "@peerbit/pubsub-interface";
6
- import { getPublicKeyFromPeerId, PublicSignKey } from "@peerbit/crypto";
7
- import { CustomEvent } from "@libp2p/interface";
4
+ import { DataEvent, GetSubscribers, PubSubData, PubSubMessage, PublishEvent, Subscribe, SubscriptionData, SubscriptionEvent, UnsubcriptionEvent, Unsubscribe, } from "@peerbit/pubsub-interface";
5
+ import { DirectStream, } from "@peerbit/stream";
6
+ import { AcknowledgeDelivery, AnyWhere, DataMessage, DeliveryError, MessageHeader, NotStartedError, SeekDelivery, SilentDelivery, deliveryModeHasReceiver, } from "@peerbit/stream-interface";
8
7
  import { Uint8ArrayList } from "uint8arraylist";
9
8
  export const toUint8Array = (arr) => arr instanceof Uint8ArrayList ? arr.subarray() : arr;
10
9
  export const logger = logFn({ module: "lazysub", level: "warn" });
@@ -62,7 +61,7 @@ export class DirectSub extends DirectStream {
62
61
  }
63
62
  else {
64
63
  prev = {
65
- counter: 1
64
+ counter: 1,
66
65
  };
67
66
  this.subscriptions.set(topic, prev);
68
67
  newTopicsForTopicData.push(topic);
@@ -72,13 +71,13 @@ export class DirectSub extends DirectStream {
72
71
  const message = new DataMessage({
73
72
  data: toUint8Array(new Subscribe({
74
73
  topics: newTopicsForTopicData,
75
- requestSubscribers: true
74
+ requestSubscribers: true,
76
75
  }).bytes()),
77
76
  header: new MessageHeader({
78
77
  priority: 1,
79
78
  mode: new SeekDelivery({ redundancy: 2 }),
80
- session: this.session
81
- })
79
+ session: this.session,
80
+ }),
82
81
  });
83
82
  await this.publishMessage(this.publicKey, await message.sign(this.sign));
84
83
  }
@@ -86,7 +85,9 @@ export class DirectSub extends DirectStream {
86
85
  /**
87
86
  *
88
87
  * @param topic
89
- * @param force
88
+ * @param options
89
+ * @param options.force
90
+ * @param options.data
90
91
  * @returns true unsubscribed completely
91
92
  */
92
93
  async unsubscribe(topic, options) {
@@ -94,7 +95,7 @@ export class DirectSub extends DirectStream {
94
95
  throw new NotStartedError();
95
96
  }
96
97
  const subscriptions = this.subscriptions.get(topic);
97
- logger.debug(`unsubscribe from ${topic} - am subscribed with subscriptions ${subscriptions}`);
98
+ logger.debug(`unsubscribe from ${topic} - am subscribed with subscriptions ${JSON.stringify(subscriptions)}`);
98
99
  const peersOnTopic = this.topicsToPeers.get(topic);
99
100
  if (peersOnTopic) {
100
101
  for (const peer of peersOnTopic) {
@@ -112,11 +113,11 @@ export class DirectSub extends DirectStream {
112
113
  header: new MessageHeader({
113
114
  mode: new AnyWhere(), // TODO make this better
114
115
  session: this.session,
115
- priority: 1
116
+ priority: 1,
116
117
  }),
117
118
  data: toUint8Array(new Unsubscribe({
118
- topics: [topic]
119
- }).bytes())
119
+ topics: [topic],
120
+ }).bytes()),
120
121
  }).sign(this.sign));
121
122
  this.subscriptions.delete(topic);
122
123
  this.topics.delete(topic);
@@ -161,11 +162,11 @@ export class DirectSub extends DirectStream {
161
162
  header: new MessageHeader({
162
163
  mode: new SeekDelivery({
163
164
  to: to ? [to.hashcode()] : undefined,
164
- redundancy: 2
165
+ redundancy: 2,
165
166
  }),
166
167
  session: this.session,
167
- priority: 1
168
- })
168
+ priority: 1,
169
+ }),
169
170
  }).sign(this.sign));
170
171
  }
171
172
  getPeersOnTopics(topics) {
@@ -202,7 +203,7 @@ export class DirectSub extends DirectStream {
202
203
  ? new PubSubData({
203
204
  topics: topics.map((x) => x.toString()),
204
205
  data,
205
- strict: hasExplicitTOs
206
+ strict: hasExplicitTOs,
206
207
  })
207
208
  : undefined;
208
209
  const bytes = dataMessage?.bytes();
@@ -213,8 +214,8 @@ export class DirectSub extends DirectStream {
213
214
  detail: new PublishEvent({
214
215
  client: options?.client,
215
216
  data: dataMessage,
216
- message
217
- })
217
+ message,
218
+ }),
218
219
  }));
219
220
  }
220
221
  // send to all the other peers
@@ -279,7 +280,7 @@ export class DirectSub extends DirectStream {
279
280
  this.publishMessage(this.publicKey, await new DataMessage({
280
281
  data: toUint8Array(new Subscribe({
281
282
  topics: this.getSubscriptionOverlap(), // TODO make the protocol more efficient, do we really need to share *everything* ?
282
- requestSubscribers: true
283
+ requestSubscribers: true,
283
284
  }).bytes()),
284
285
  header: new MessageHeader({
285
286
  // is new neighbour ? then send to all, though that connection (potentially find new peers)
@@ -287,10 +288,10 @@ export class DirectSub extends DirectStream {
287
288
  priority: 1,
288
289
  mode: new SeekDelivery({
289
290
  redundancy: 2,
290
- to: isNeigbour ? undefined : [publicKey.hashcode()]
291
+ to: isNeigbour ? undefined : [publicKey.hashcode()],
291
292
  }),
292
- session: this.session
293
- })
293
+ session: this.session,
294
+ }),
294
295
  }).sign(this.sign)).catch(dontThrowIfDeliveryError); // peer might have become unreachable immediately
295
296
  }
296
297
  return resp;
@@ -313,7 +314,7 @@ export class DirectSub extends DirectStream {
313
314
  this.lastSubscriptionMessages.delete(publicKey.hashcode());
314
315
  if (changed.length > 0) {
315
316
  this.dispatchEvent(new CustomEvent("unsubscribe", {
316
- detail: new UnsubcriptionEvent(publicKey, changed)
317
+ detail: new UnsubcriptionEvent(publicKey, changed),
317
318
  }));
318
319
  }
319
320
  }
@@ -383,8 +384,8 @@ export class DirectSub extends DirectStream {
383
384
  this.dispatchEvent(new CustomEvent("data", {
384
385
  detail: new DataEvent({
385
386
  data: pubsubMessage,
386
- message
387
- })
387
+ message,
388
+ }),
388
389
  }));
389
390
  }
390
391
  }
@@ -433,7 +434,7 @@ export class DirectSub extends DirectStream {
433
434
  peers.set(senderKey, new SubscriptionData({
434
435
  session: message.header.session,
435
436
  timestamp: message.header.timestamp, // TODO update timestamps on all messages?
436
- publicKey: sender
437
+ publicKey: sender,
437
438
  }));
438
439
  changed.push(topic);
439
440
  }
@@ -444,7 +445,7 @@ export class DirectSub extends DirectStream {
444
445
  });
445
446
  if (changed.length > 0) {
446
447
  this.dispatchEvent(new CustomEvent("subscribe", {
447
- detail: new SubscriptionEvent(sender, changed)
448
+ detail: new SubscriptionEvent(sender, changed),
448
449
  }));
449
450
  }
450
451
  if (pubsubMessage.requestSubscribers) {
@@ -454,7 +455,7 @@ export class DirectSub extends DirectStream {
454
455
  const response = new DataMessage({
455
456
  data: toUint8Array(new Subscribe({
456
457
  topics: mySubscriptions,
457
- requestSubscribers: false
458
+ requestSubscribers: false,
458
459
  }).bytes()),
459
460
  // needs to be Ack or Silent else we will run into a infite message loop
460
461
  header: new MessageHeader({
@@ -462,9 +463,9 @@ export class DirectSub extends DirectStream {
462
463
  priority: 1,
463
464
  mode: new SeekDelivery({
464
465
  redundancy: 2,
465
- to: [senderKey]
466
- })
467
- })
466
+ to: [senderKey],
467
+ }),
468
+ }),
468
469
  });
469
470
  this.publishMessage(this.publicKey, await response.sign(this.sign)).catch(dontThrowIfDeliveryError);
470
471
  }
@@ -485,7 +486,7 @@ export class DirectSub extends DirectStream {
485
486
  }
486
487
  if (changed.length > 0 && seenBefore === 0) {
487
488
  this.dispatchEvent(new CustomEvent("unsubscribe", {
488
- detail: new UnsubcriptionEvent(sender, changed)
489
+ detail: new UnsubcriptionEvent(sender, changed),
489
490
  }));
490
491
  }
491
492
  // Forwarding
@@ -505,16 +506,16 @@ export class DirectSub extends DirectStream {
505
506
  this.publishMessage(this.publicKey, await new DataMessage({
506
507
  data: toUint8Array(new Subscribe({
507
508
  topics: subscriptionsToSend,
508
- requestSubscribers: false
509
+ requestSubscribers: false,
509
510
  }).bytes()),
510
511
  header: new MessageHeader({
511
512
  priority: 1,
512
513
  mode: new SilentDelivery({
513
514
  redundancy: 2,
514
- to: [sender.hashcode()]
515
+ to: [sender.hashcode()],
515
516
  }),
516
- session: this.session
517
- })
517
+ session: this.session,
518
+ }),
518
519
  }).sign(this.sign), [stream]).catch(dontThrowIfDeliveryError); // send back to same stream
519
520
  }
520
521
  // Forward
@@ -552,9 +553,8 @@ export const waitForSubscribers = async (libp2p, peersToWait, topic) => {
552
553
  }
553
554
  try {
554
555
  const peers = await libp2p.services.pubsub.topics.get(topic);
555
- const hasAllPeers = peerIdsToWait
556
- .map((e) => peers && peers.has(e))
557
- .filter((e) => e === false).length === 0;
556
+ const hasAllPeers = peerIdsToWait.map((e) => peers?.has(e)).filter((e) => e === false)
557
+ .length === 0;
558
558
  // FIXME: Does not fail on timeout, not easily fixable
559
559
  if (hasAllPeers) {
560
560
  clearInterval(interval);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,WAAW,GAEX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,SAAS,EACT,cAAc,EAEd,UAAU,EAEV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,YAAY,GAIZ,MAAM,iBAAiB,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AO,EAAE,MAAM,EAAE,EAAE;QAC5C,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;YACvC,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,OAAO,GAAG,GAAG,EAAE,CAAC;gBACnB,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxB,MAAM,CACL,IAAI,KAAK,CAAC,iDAAiD,GAAG,KAAK,CAAC,CACpE,CAAC;YACH,CAAC;YACD,IAAI,CAAC;gBACJ,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC7D,MAAM,WAAW,GAChB,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;qBAChE,MAAM,KAAK,CAAC,CAAC;gBAEhB,sDAAsD;gBACtD,IAAI,WAAW,EAAE,CAAC;oBACjB,aAAa,CAAC,QAAQ,CAAC,CAAC;oBACxB,OAAO,EAAE,CAAC;gBACX,CAAC;YACF,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACxB,MAAM,CAAC,CAAC,CAAC,CAAC;YACX,CAAC;QACF,CAAC,EAAE,GAAG,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,61 +1,84 @@
1
1
  {
2
- "name": "@peerbit/pubsub",
3
- "version": "3.0.5",
4
- "description": "Direct streaming for libp2p",
5
- "type": "module",
6
- "sideEffects": false,
7
- "private": false,
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "module": "lib/esm/index.js",
12
- "types": "lib/esm/index.d.ts",
13
- "exports": {
14
- "import": "./lib/esm/index.js"
15
- },
16
- "scripts": {
17
- "clean": "shx rm -rf lib/*",
18
- "build": "yarn clean && tsc -p tsconfig.json",
19
- "test": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.ts --runInBand --forceExit",
20
- "test:unit": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.unit.ts --runInBand --forceExit",
21
- "test:integration": "node ../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit"
22
- },
23
- "files": [
24
- "lib",
25
- "src",
26
- "!src/**/__tests__",
27
- "!lib/**/__tests__",
28
- "!src/**/__benchmark__",
29
- "!lib/**/__benchmark__",
30
- "LICENSE"
31
- ],
32
- "engines": {
33
- "node": ">=16.15.1"
34
- },
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/dao-xyz/peerbit.git"
38
- },
39
- "keywords": [
40
- "peerbit"
41
- ],
42
- "author": "dao.xyz",
43
- "license": "MIT",
44
- "bugs": {
45
- "url": "https://github.com/dao-xyz/peerbit/issues"
46
- },
47
- "homepage": "https://github.com/dao-xyz/peerbit#readme",
48
- "localMaintainers": [
49
- "dao.xyz"
50
- ],
51
- "devDependencies": {
52
- "@peerbit/libp2p-test-utils": "2.1.3"
53
- },
54
- "dependencies": {
55
- "@peerbit/logger": "1.0.2",
56
- "@peerbit/stream": "4.0.5",
57
- "@peerbit/uint8arrays": "3.0.1",
58
- "libp2p": "^1.2.3"
59
- },
60
- "gitHead": "fcd486b9a5c3b7d94e2ae14f1b06ab2a0f7841ad"
2
+ "name": "@peerbit/pubsub",
3
+ "version": "3.0.6-2b760c3",
4
+ "description": "Direct streaming for libp2p",
5
+ "type": "module",
6
+ "types": "./dist/src/index.d.ts",
7
+ "typesVersions": {
8
+ "*": {
9
+ "*": [
10
+ "*",
11
+ "dist/*",
12
+ "dist/src/*",
13
+ "dist/src/*/index"
14
+ ],
15
+ "src/*": [
16
+ "*",
17
+ "dist/*",
18
+ "dist/src/*",
19
+ "dist/src/*/index"
20
+ ]
21
+ }
22
+ },
23
+ "files": [
24
+ "src",
25
+ "dist",
26
+ "!dist/e2e",
27
+ "!dist/test",
28
+ "!**/*.tsbuildinfo"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/src/index.d.ts",
33
+ "import": "./dist/src/index.js"
34
+ }
35
+ },
36
+ "eslintConfig": {
37
+ "extends": "peerbit",
38
+ "parserOptions": {
39
+ "project": true,
40
+ "sourceType": "module"
41
+ },
42
+ "ignorePatterns": [
43
+ "!.aegir.js",
44
+ "test/ts-use",
45
+ "*.d.ts"
46
+ ]
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "clean": "aegir clean",
53
+ "build": "aegir build --no-bundle",
54
+ "test": "aegir test --target node",
55
+ "lint": "aegir lint"
56
+ },
57
+ "engines": {
58
+ "node": ">=16.15.1"
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/dao-xyz/peerbit.git"
63
+ },
64
+ "keywords": [
65
+ "peerbit"
66
+ ],
67
+ "author": "dao.xyz",
68
+ "license": "MIT",
69
+ "bugs": {
70
+ "url": "https://github.com/dao-xyz/peerbit/issues"
71
+ },
72
+ "homepage": "https://github.com/dao-xyz/peerbit#readme",
73
+ "localMaintainers": [
74
+ "dao.xyz"
75
+ ],
76
+ "devDependencies": {
77
+ "@peerbit/libp2p-test-utils": "2.1.4-2b760c3"
78
+ },
79
+ "dependencies": {
80
+ "@peerbit/stream": "4.0.6-2b760c3",
81
+ "@peerbit/logger": "1.0.3-2b760c3",
82
+ "libp2p": "^1.8.1"
83
+ }
61
84
  }
package/src/index.ts CHANGED
@@ -1,42 +1,45 @@
1
- import type { PeerId as Libp2pPeerId } from "@libp2p/interface";
1
+ import {
2
+ CodeError,
3
+ CustomEvent,
4
+ type PeerId as Libp2pPeerId,
5
+ } from "@libp2p/interface";
6
+ import { PublicSignKey, getPublicKeyFromPeerId } from "@peerbit/crypto";
2
7
  import { logger as logFn } from "@peerbit/logger";
8
+ import {
9
+ DataEvent,
10
+ GetSubscribers,
11
+ type PubSub,
12
+ PubSubData,
13
+ type PubSubEvents,
14
+ PubSubMessage,
15
+ PublishEvent,
16
+ Subscribe,
17
+ SubscriptionData,
18
+ SubscriptionEvent,
19
+ UnsubcriptionEvent,
20
+ Unsubscribe,
21
+ } from "@peerbit/pubsub-interface";
22
+ import {
23
+ DirectStream,
24
+ type DirectStreamComponents,
25
+ type DirectStreamOptions,
26
+ type PeerStreams,
27
+ } from "@peerbit/stream";
3
28
  import {
4
29
  AcknowledgeDelivery,
5
30
  AnyWhere,
6
31
  DataMessage,
32
+ DeliveryError,
33
+ type IdentificationOptions,
7
34
  MessageHeader,
35
+ NotStartedError,
36
+ type PriorityOptions,
8
37
  SeekDelivery,
9
38
  SilentDelivery,
10
39
  deliveryModeHasReceiver,
11
- NotStartedError,
12
- DeliveryError,
13
- IdentificationOptions,
14
- PriorityOptions
15
40
  } from "@peerbit/stream-interface";
16
- import {
17
- DirectStream,
18
- DirectStreamComponents,
19
- DirectStreamOptions,
20
- PeerStreams
21
- } from "@peerbit/stream";
22
- import { CodeError } from "@libp2p/interface";
23
- import {
24
- PubSubMessage,
25
- Subscribe,
26
- PubSubData,
27
- Unsubscribe,
28
- GetSubscribers,
29
- UnsubcriptionEvent,
30
- SubscriptionEvent,
31
- PubSub,
32
- DataEvent,
33
- SubscriptionData,
34
- PublishEvent,
35
- PubSubEvents
36
- } from "@peerbit/pubsub-interface";
37
- import { getPublicKeyFromPeerId, PublicSignKey } from "@peerbit/crypto";
38
- import { CustomEvent } from "@libp2p/interface";
39
41
  import { Uint8ArrayList } from "uint8arraylist";
42
+
40
43
  export const toUint8Array = (arr: Uint8ArrayList | Uint8Array) =>
41
44
  arr instanceof Uint8ArrayList ? arr.subarray() : arr;
42
45
 
@@ -116,7 +119,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
116
119
  prev.counter += 1;
117
120
  } else {
118
121
  prev = {
119
- counter: 1
122
+ counter: 1,
120
123
  };
121
124
  this.subscriptions.set(topic, prev);
122
125
 
@@ -129,14 +132,14 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
129
132
  data: toUint8Array(
130
133
  new Subscribe({
131
134
  topics: newTopicsForTopicData,
132
- requestSubscribers: true
133
- }).bytes()
135
+ requestSubscribers: true,
136
+ }).bytes(),
134
137
  ),
135
138
  header: new MessageHeader({
136
139
  priority: 1,
137
140
  mode: new SeekDelivery({ redundancy: 2 }),
138
- session: this.session
139
- })
141
+ session: this.session,
142
+ }),
140
143
  });
141
144
 
142
145
  await this.publishMessage(this.publicKey, await message.sign(this.sign));
@@ -146,12 +149,14 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
146
149
  /**
147
150
  *
148
151
  * @param topic
149
- * @param force
152
+ * @param options
153
+ * @param options.force
154
+ * @param options.data
150
155
  * @returns true unsubscribed completely
151
156
  */
152
157
  async unsubscribe(
153
158
  topic: string,
154
- options?: { force: boolean; data: Uint8Array }
159
+ options?: { force: boolean; data: Uint8Array },
155
160
  ) {
156
161
  if (!this.started) {
157
162
  throw new NotStartedError();
@@ -160,7 +165,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
160
165
  const subscriptions = this.subscriptions.get(topic);
161
166
 
162
167
  logger.debug(
163
- `unsubscribe from ${topic} - am subscribed with subscriptions ${subscriptions}`
168
+ `unsubscribe from ${topic} - am subscribed with subscriptions ${JSON.stringify(subscriptions)}`,
164
169
  );
165
170
 
166
171
  const peersOnTopic = this.topicsToPeers.get(topic);
@@ -185,14 +190,14 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
185
190
  header: new MessageHeader({
186
191
  mode: new AnyWhere(), // TODO make this better
187
192
  session: this.session,
188
- priority: 1
193
+ priority: 1,
189
194
  }),
190
195
  data: toUint8Array(
191
196
  new Unsubscribe({
192
- topics: [topic]
193
- }).bytes()
194
- )
195
- }).sign(this.sign)
197
+ topics: [topic],
198
+ }).bytes(),
199
+ ),
200
+ }).sign(this.sign),
196
201
  );
197
202
 
198
203
  this.subscriptions.delete(topic);
@@ -226,7 +231,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
226
231
 
227
232
  async requestSubscribers(
228
233
  topic: string | string[],
229
- to?: PublicSignKey
234
+ to?: PublicSignKey,
230
235
  ): Promise<void> {
231
236
  if (!this.started) {
232
237
  throw new CodeError("not started yet", "ERR_NOT_STARTED_YET");
@@ -252,12 +257,12 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
252
257
  header: new MessageHeader({
253
258
  mode: new SeekDelivery({
254
259
  to: to ? [to.hashcode()] : undefined,
255
- redundancy: 2
260
+ redundancy: 2,
256
261
  }),
257
262
  session: this.session,
258
- priority: 1
259
- })
260
- }).sign(this.sign)
263
+ priority: 1,
264
+ }),
265
+ }).sign(this.sign),
261
266
  );
262
267
  }
263
268
 
@@ -290,7 +295,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
290
295
  } & { client?: string } & {
291
296
  mode?: SilentDelivery | AcknowledgeDelivery | SeekDelivery;
292
297
  } & PriorityOptions &
293
- IdentificationOptions
298
+ IdentificationOptions,
294
299
  ): Promise<Uint8Array> {
295
300
  if (!this.started) {
296
301
  throw new NotStartedError();
@@ -310,7 +315,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
310
315
  ? new PubSubData({
311
316
  topics: topics.map((x) => x.toString()),
312
317
  data,
313
- strict: hasExplicitTOs
318
+ strict: hasExplicitTOs,
314
319
  })
315
320
  : undefined;
316
321
 
@@ -324,9 +329,9 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
324
329
  detail: new PublishEvent({
325
330
  client: options?.client,
326
331
  data: dataMessage,
327
- message
328
- })
329
- })
332
+ message,
333
+ }),
334
+ }),
330
335
  );
331
336
  }
332
337
 
@@ -404,8 +409,8 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
404
409
  data: toUint8Array(
405
410
  new Subscribe({
406
411
  topics: this.getSubscriptionOverlap(), // TODO make the protocol more efficient, do we really need to share *everything* ?
407
- requestSubscribers: true
408
- }).bytes()
412
+ requestSubscribers: true,
413
+ }).bytes(),
409
414
  ),
410
415
  header: new MessageHeader({
411
416
  // is new neighbour ? then send to all, though that connection (potentially find new peers)
@@ -413,11 +418,11 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
413
418
  priority: 1,
414
419
  mode: new SeekDelivery({
415
420
  redundancy: 2,
416
- to: isNeigbour ? undefined : [publicKey.hashcode()]
421
+ to: isNeigbour ? undefined : [publicKey.hashcode()],
417
422
  }),
418
- session: this.session
419
- })
420
- }).sign(this.sign)
423
+ session: this.session,
424
+ }),
425
+ }).sign(this.sign),
421
426
  ).catch(dontThrowIfDeliveryError); // peer might have become unreachable immediately
422
427
  }
423
428
 
@@ -446,15 +451,15 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
446
451
  if (changed.length > 0) {
447
452
  this.dispatchEvent(
448
453
  new CustomEvent<UnsubcriptionEvent>("unsubscribe", {
449
- detail: new UnsubcriptionEvent(publicKey, changed)
450
- })
454
+ detail: new UnsubcriptionEvent(publicKey, changed),
455
+ }),
451
456
  );
452
457
  }
453
458
  }
454
459
 
455
460
  private subscriptionMessageIsLatest(
456
461
  message: DataMessage,
457
- pubsubMessage: Subscribe | Unsubscribe
462
+ pubsubMessage: Subscribe | Unsubscribe,
458
463
  ) {
459
464
  const subscriber = message.header.signatures!.signatures[0].publicKey!;
460
465
  const subscriberKey = subscriber.hashcode(); // Assume first signature is the one who is signing
@@ -479,7 +484,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
479
484
 
480
485
  private addPeersOnTopic(
481
486
  message: DataMessage<AcknowledgeDelivery | SilentDelivery | SeekDelivery>,
482
- topics: string[]
487
+ topics: string[],
483
488
  ) {
484
489
  const existingPeers: Set<string> = new Set(message.header.mode.to);
485
490
  const allPeersOnTopic = this.getPeersOnTopics(topics);
@@ -496,7 +501,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
496
501
  from: PublicSignKey,
497
502
  stream: PeerStreams,
498
503
  message: DataMessage,
499
- seenBefore: number
504
+ seenBefore: number,
500
505
  ) {
501
506
  if (!message.data || message.data.length === 0) {
502
507
  return super.onDataMessage(from, stream, message, seenBefore);
@@ -517,19 +522,19 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
517
522
  */
518
523
 
519
524
  const meInTOs = !!message.header.mode.to?.find(
520
- (x) => this.publicKeyHash === x
525
+ (x) => this.publicKeyHash === x,
521
526
  );
522
527
 
523
528
  let isForMe: boolean;
524
529
  if (pubsubMessage.strict) {
525
530
  isForMe =
526
531
  !!pubsubMessage.topics.find((topic) =>
527
- this.subscriptions.has(topic)
532
+ this.subscriptions.has(topic),
528
533
  ) && meInTOs;
529
534
  } else {
530
535
  isForMe =
531
536
  !!pubsubMessage.topics.find((topic) =>
532
- this.subscriptions.has(topic)
537
+ this.subscriptions.has(topic),
533
538
  ) ||
534
539
  (pubsubMessage.topics.length === 0 && meInTOs);
535
540
  }
@@ -549,9 +554,9 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
549
554
  new CustomEvent("data", {
550
555
  detail: new DataEvent({
551
556
  data: pubsubMessage,
552
- message
553
- })
554
- })
557
+ message,
558
+ }),
559
+ }),
555
560
  );
556
561
  }
557
562
  }
@@ -562,7 +567,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
562
567
  message as DataMessage<
563
568
  SeekDelivery | SilentDelivery | AcknowledgeDelivery
564
569
  >,
565
- pubsubMessage.topics
570
+ pubsubMessage.topics,
566
571
  );
567
572
  }
568
573
 
@@ -621,8 +626,8 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
621
626
  new SubscriptionData({
622
627
  session: message.header.session,
623
628
  timestamp: message.header.timestamp, // TODO update timestamps on all messages?
624
- publicKey: sender
625
- })
629
+ publicKey: sender,
630
+ }),
626
631
  );
627
632
 
628
633
  changed.push(topic);
@@ -637,23 +642,23 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
637
642
  if (changed.length > 0) {
638
643
  this.dispatchEvent(
639
644
  new CustomEvent<SubscriptionEvent>("subscribe", {
640
- detail: new SubscriptionEvent(sender, changed)
641
- })
645
+ detail: new SubscriptionEvent(sender, changed),
646
+ }),
642
647
  );
643
648
  }
644
649
 
645
650
  if (pubsubMessage.requestSubscribers) {
646
651
  // respond if we are subscribing
647
652
  const mySubscriptions = this.getSubscriptionOverlap(
648
- pubsubMessage.topics
653
+ pubsubMessage.topics,
649
654
  );
650
655
  if (mySubscriptions.length > 0) {
651
656
  const response = new DataMessage({
652
657
  data: toUint8Array(
653
658
  new Subscribe({
654
659
  topics: mySubscriptions,
655
- requestSubscribers: false
656
- }).bytes()
660
+ requestSubscribers: false,
661
+ }).bytes(),
657
662
  ),
658
663
  // needs to be Ack or Silent else we will run into a infite message loop
659
664
  header: new MessageHeader({
@@ -661,14 +666,14 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
661
666
  priority: 1,
662
667
  mode: new SeekDelivery({
663
668
  redundancy: 2,
664
- to: [senderKey]
665
- })
666
- })
669
+ to: [senderKey],
670
+ }),
671
+ }),
667
672
  });
668
673
 
669
674
  this.publishMessage(
670
675
  this.publicKey,
671
- await response.sign(this.sign)
676
+ await response.sign(this.sign),
672
677
  ).catch(dontThrowIfDeliveryError);
673
678
  }
674
679
  }
@@ -691,8 +696,8 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
691
696
  if (changed.length > 0 && seenBefore === 0) {
692
697
  this.dispatchEvent(
693
698
  new CustomEvent<UnsubcriptionEvent>("unsubscribe", {
694
- detail: new UnsubcriptionEvent(sender, changed)
695
- })
699
+ detail: new UnsubcriptionEvent(sender, changed),
700
+ }),
696
701
  );
697
702
  }
698
703
 
@@ -706,7 +711,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
706
711
  message as DataMessage<
707
712
  SeekDelivery | SilentDelivery | AcknowledgeDelivery
708
713
  >,
709
- pubsubMessage.topics
714
+ pubsubMessage.topics,
710
715
  );
711
716
  }
712
717
  }
@@ -715,7 +720,7 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
715
720
  this.relayMessage(from, message).catch(logErrorIfStarted);
716
721
  } else if (pubsubMessage instanceof GetSubscribers) {
717
722
  const subscriptionsToSend: string[] = this.getSubscriptionOverlap(
718
- pubsubMessage.topics
723
+ pubsubMessage.topics,
719
724
  );
720
725
  if (subscriptionsToSend.length > 0) {
721
726
  // respond
@@ -725,19 +730,19 @@ export class DirectSub extends DirectStream<PubSubEvents> implements PubSub {
725
730
  data: toUint8Array(
726
731
  new Subscribe({
727
732
  topics: subscriptionsToSend,
728
- requestSubscribers: false
729
- }).bytes()
733
+ requestSubscribers: false,
734
+ }).bytes(),
730
735
  ),
731
736
  header: new MessageHeader({
732
737
  priority: 1,
733
738
  mode: new SilentDelivery({
734
739
  redundancy: 2,
735
- to: [sender.hashcode()]
740
+ to: [sender.hashcode()],
736
741
  }),
737
- session: this.session
738
- })
742
+ session: this.session,
743
+ }),
739
744
  }).sign(this.sign),
740
- [stream]
745
+ [stream],
741
746
  ).catch(dontThrowIfDeliveryError); // send back to same stream
742
747
  }
743
748
 
@@ -759,7 +764,7 @@ export const waitForSubscribers = async (
759
764
  | { peerId: Libp2pPeerId }[]
760
765
  | string
761
766
  | string[],
762
- topic: string
767
+ topic: string,
763
768
  ) => {
764
769
  const peersToWaitArr = Array.isArray(peersToWait)
765
770
  ? peersToWait
@@ -769,7 +774,7 @@ export const waitForSubscribers = async (
769
774
  if (typeof peer === "string") {
770
775
  return peer;
771
776
  }
772
- const id: PublicSignKey | Libp2pPeerId = peer["peerId"] || peer;
777
+ const id: PublicSignKey | Libp2pPeerId = (peer as any)["peerId"] || peer;
773
778
  if (typeof id === "string") {
774
779
  return id;
775
780
  }
@@ -786,15 +791,14 @@ export const waitForSubscribers = async (
786
791
  if (counter > 100) {
787
792
  clearInterval(interval);
788
793
  reject(
789
- new Error("Failed to find expected subscribers for topic: " + topic)
794
+ new Error("Failed to find expected subscribers for topic: " + topic),
790
795
  );
791
796
  }
792
797
  try {
793
798
  const peers = await libp2p.services.pubsub.topics.get(topic);
794
799
  const hasAllPeers =
795
- peerIdsToWait
796
- .map((e) => peers && peers.has(e))
797
- .filter((e) => e === false).length === 0;
800
+ peerIdsToWait.map((e) => peers?.has(e)).filter((e) => e === false)
801
+ .length === 0;
798
802
 
799
803
  // FIXME: Does not fail on timeout, not easily fixable
800
804
  if (hasAllPeers) {
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright 2022 dao.xyz
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,aAAa,EAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,YAAY,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACN,aAAa,EACb,SAAS,EACT,UAAU,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EAEjB,SAAS,EACT,gBAAgB,EAChB,YAAY,EAEZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAgC,EAAE,EAAE,CAChE,GAAG,YAAY,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAEtD,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EA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