@libp2p/floodsub 9.1.5-50b897139 → 9.1.5-71e5f7a5b
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.min.js +2 -3
- package/dist/src/message/rpc.d.ts +10 -10
- package/dist/src/message/rpc.d.ts.map +1 -1
- package/dist/src/message/rpc.js +145 -69
- package/dist/src/message/rpc.js.map +1 -1
- package/package.json +8 -7
- package/src/message/rpc.ts +154 -70
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@libp2p/floodsub",
|
3
|
-
"version": "9.1.5-
|
3
|
+
"version": "9.1.5-71e5f7a5b",
|
4
4
|
"description": "libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).",
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub#readme",
|
@@ -60,17 +60,18 @@
|
|
60
60
|
"test:electron-main": "aegir test -t electron-main"
|
61
61
|
},
|
62
62
|
"dependencies": {
|
63
|
-
"@libp2p/interface": "1.7.0-
|
64
|
-
"@libp2p/pubsub": "9.0.26-
|
63
|
+
"@libp2p/interface": "1.7.0-71e5f7a5b",
|
64
|
+
"@libp2p/pubsub": "9.0.26-71e5f7a5b",
|
65
65
|
"protons-runtime": "^5.4.0",
|
66
66
|
"uint8arraylist": "^2.4.8",
|
67
67
|
"uint8arrays": "^5.1.0"
|
68
68
|
},
|
69
69
|
"devDependencies": {
|
70
|
-
"@libp2p/
|
71
|
-
"@libp2p/
|
72
|
-
"@libp2p/
|
73
|
-
"@libp2p/peer-
|
70
|
+
"@libp2p/crypto": "4.1.9-71e5f7a5b",
|
71
|
+
"@libp2p/interface-compliance-tests": "5.4.12-71e5f7a5b",
|
72
|
+
"@libp2p/logger": "4.0.20-71e5f7a5b",
|
73
|
+
"@libp2p/peer-collections": "5.2.9-71e5f7a5b",
|
74
|
+
"@libp2p/peer-id": "4.2.4-71e5f7a5b",
|
74
75
|
"@multiformats/multiaddr": "^12.2.3",
|
75
76
|
"@types/sinon": "^17.0.3",
|
76
77
|
"aegir": "^44.0.1",
|
package/src/message/rpc.ts
CHANGED
@@ -4,8 +4,7 @@
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
6
6
|
|
7
|
-
import {
|
8
|
-
import type { Codec } from 'protons-runtime'
|
7
|
+
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, MaxLengthError, message } from 'protons-runtime'
|
9
8
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
10
9
|
|
11
10
|
export interface RPC {
|
@@ -43,7 +42,7 @@ export namespace RPC {
|
|
43
42
|
if (opts.lengthDelimited !== false) {
|
44
43
|
w.ldelim()
|
45
44
|
}
|
46
|
-
}, (reader, length) => {
|
45
|
+
}, (reader, length, opts = {}) => {
|
47
46
|
const obj: any = {}
|
48
47
|
|
49
48
|
const end = length == null ? reader.len : reader.pos + length
|
@@ -52,15 +51,18 @@ export namespace RPC {
|
|
52
51
|
const tag = reader.uint32()
|
53
52
|
|
54
53
|
switch (tag >>> 3) {
|
55
|
-
case 1:
|
54
|
+
case 1: {
|
56
55
|
obj.subscribe = reader.bool()
|
57
56
|
break
|
58
|
-
|
57
|
+
}
|
58
|
+
case 2: {
|
59
59
|
obj.topic = reader.string()
|
60
60
|
break
|
61
|
-
|
61
|
+
}
|
62
|
+
default: {
|
62
63
|
reader.skipType(tag & 7)
|
63
64
|
break
|
65
|
+
}
|
64
66
|
}
|
65
67
|
}
|
66
68
|
|
@@ -75,8 +77,8 @@ export namespace RPC {
|
|
75
77
|
return encodeMessage(obj, SubOpts.codec())
|
76
78
|
}
|
77
79
|
|
78
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): SubOpts => {
|
79
|
-
return decodeMessage(buf, SubOpts.codec())
|
80
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<SubOpts>): SubOpts => {
|
81
|
+
return decodeMessage(buf, SubOpts.codec(), opts)
|
80
82
|
}
|
81
83
|
}
|
82
84
|
|
@@ -132,7 +134,7 @@ export namespace RPC {
|
|
132
134
|
if (opts.lengthDelimited !== false) {
|
133
135
|
w.ldelim()
|
134
136
|
}
|
135
|
-
}, (reader, length) => {
|
137
|
+
}, (reader, length, opts = {}) => {
|
136
138
|
const obj: any = {}
|
137
139
|
|
138
140
|
const end = length == null ? reader.len : reader.pos + length
|
@@ -141,27 +143,34 @@ export namespace RPC {
|
|
141
143
|
const tag = reader.uint32()
|
142
144
|
|
143
145
|
switch (tag >>> 3) {
|
144
|
-
case 1:
|
146
|
+
case 1: {
|
145
147
|
obj.from = reader.bytes()
|
146
148
|
break
|
147
|
-
|
149
|
+
}
|
150
|
+
case 2: {
|
148
151
|
obj.data = reader.bytes()
|
149
152
|
break
|
150
|
-
|
153
|
+
}
|
154
|
+
case 3: {
|
151
155
|
obj.sequenceNumber = reader.bytes()
|
152
156
|
break
|
153
|
-
|
157
|
+
}
|
158
|
+
case 4: {
|
154
159
|
obj.topic = reader.string()
|
155
160
|
break
|
156
|
-
|
161
|
+
}
|
162
|
+
case 5: {
|
157
163
|
obj.signature = reader.bytes()
|
158
164
|
break
|
159
|
-
|
165
|
+
}
|
166
|
+
case 6: {
|
160
167
|
obj.key = reader.bytes()
|
161
168
|
break
|
162
|
-
|
169
|
+
}
|
170
|
+
default: {
|
163
171
|
reader.skipType(tag & 7)
|
164
172
|
break
|
173
|
+
}
|
165
174
|
}
|
166
175
|
}
|
167
176
|
|
@@ -176,8 +185,8 @@ export namespace RPC {
|
|
176
185
|
return encodeMessage(obj, Message.codec())
|
177
186
|
}
|
178
187
|
|
179
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): Message => {
|
180
|
-
return decodeMessage(buf, Message.codec())
|
188
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Message>): Message => {
|
189
|
+
return decodeMessage(buf, Message.codec(), opts)
|
181
190
|
}
|
182
191
|
}
|
183
192
|
|
@@ -212,7 +221,7 @@ export namespace RPC {
|
|
212
221
|
if (opts.lengthDelimited !== false) {
|
213
222
|
w.ldelim()
|
214
223
|
}
|
215
|
-
}, (reader, length) => {
|
224
|
+
}, (reader, length, opts = {}) => {
|
216
225
|
const obj: any = {
|
217
226
|
subscriptions: [],
|
218
227
|
messages: []
|
@@ -224,18 +233,36 @@ export namespace RPC {
|
|
224
233
|
const tag = reader.uint32()
|
225
234
|
|
226
235
|
switch (tag >>> 3) {
|
227
|
-
case 1:
|
228
|
-
obj.subscriptions.
|
236
|
+
case 1: {
|
237
|
+
if (opts.limits?.subscriptions != null && obj.subscriptions.length === opts.limits.subscriptions) {
|
238
|
+
throw new MaxLengthError('Decode error - map field "subscriptions" had too many elements')
|
239
|
+
}
|
240
|
+
|
241
|
+
obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32(), {
|
242
|
+
limits: opts.limits?.subscriptions$
|
243
|
+
}))
|
229
244
|
break
|
230
|
-
|
231
|
-
|
245
|
+
}
|
246
|
+
case 2: {
|
247
|
+
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
248
|
+
throw new MaxLengthError('Decode error - map field "messages" had too many elements')
|
249
|
+
}
|
250
|
+
|
251
|
+
obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32(), {
|
252
|
+
limits: opts.limits?.messages$
|
253
|
+
}))
|
232
254
|
break
|
233
|
-
|
234
|
-
|
255
|
+
}
|
256
|
+
case 3: {
|
257
|
+
obj.control = ControlMessage.codec().decode(reader, reader.uint32(), {
|
258
|
+
limits: opts.limits?.control
|
259
|
+
})
|
235
260
|
break
|
236
|
-
|
261
|
+
}
|
262
|
+
default: {
|
237
263
|
reader.skipType(tag & 7)
|
238
264
|
break
|
265
|
+
}
|
239
266
|
}
|
240
267
|
}
|
241
268
|
|
@@ -250,8 +277,8 @@ export namespace RPC {
|
|
250
277
|
return encodeMessage(obj, RPC.codec())
|
251
278
|
}
|
252
279
|
|
253
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): RPC => {
|
254
|
-
return decodeMessage(buf, RPC.codec())
|
280
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RPC>): RPC => {
|
281
|
+
return decodeMessage(buf, RPC.codec(), opts)
|
255
282
|
}
|
256
283
|
}
|
257
284
|
|
@@ -303,7 +330,7 @@ export namespace ControlMessage {
|
|
303
330
|
if (opts.lengthDelimited !== false) {
|
304
331
|
w.ldelim()
|
305
332
|
}
|
306
|
-
}, (reader, length) => {
|
333
|
+
}, (reader, length, opts = {}) => {
|
307
334
|
const obj: any = {
|
308
335
|
ihave: [],
|
309
336
|
iwant: [],
|
@@ -317,21 +344,50 @@ export namespace ControlMessage {
|
|
317
344
|
const tag = reader.uint32()
|
318
345
|
|
319
346
|
switch (tag >>> 3) {
|
320
|
-
case 1:
|
321
|
-
obj.ihave.
|
347
|
+
case 1: {
|
348
|
+
if (opts.limits?.ihave != null && obj.ihave.length === opts.limits.ihave) {
|
349
|
+
throw new MaxLengthError('Decode error - map field "ihave" had too many elements')
|
350
|
+
}
|
351
|
+
|
352
|
+
obj.ihave.push(ControlIHave.codec().decode(reader, reader.uint32(), {
|
353
|
+
limits: opts.limits?.ihave$
|
354
|
+
}))
|
322
355
|
break
|
323
|
-
|
324
|
-
|
356
|
+
}
|
357
|
+
case 2: {
|
358
|
+
if (opts.limits?.iwant != null && obj.iwant.length === opts.limits.iwant) {
|
359
|
+
throw new MaxLengthError('Decode error - map field "iwant" had too many elements')
|
360
|
+
}
|
361
|
+
|
362
|
+
obj.iwant.push(ControlIWant.codec().decode(reader, reader.uint32(), {
|
363
|
+
limits: opts.limits?.iwant$
|
364
|
+
}))
|
325
365
|
break
|
326
|
-
|
327
|
-
|
366
|
+
}
|
367
|
+
case 3: {
|
368
|
+
if (opts.limits?.graft != null && obj.graft.length === opts.limits.graft) {
|
369
|
+
throw new MaxLengthError('Decode error - map field "graft" had too many elements')
|
370
|
+
}
|
371
|
+
|
372
|
+
obj.graft.push(ControlGraft.codec().decode(reader, reader.uint32(), {
|
373
|
+
limits: opts.limits?.graft$
|
374
|
+
}))
|
328
375
|
break
|
329
|
-
|
330
|
-
|
376
|
+
}
|
377
|
+
case 4: {
|
378
|
+
if (opts.limits?.prune != null && obj.prune.length === opts.limits.prune) {
|
379
|
+
throw new MaxLengthError('Decode error - map field "prune" had too many elements')
|
380
|
+
}
|
381
|
+
|
382
|
+
obj.prune.push(ControlPrune.codec().decode(reader, reader.uint32(), {
|
383
|
+
limits: opts.limits?.prune$
|
384
|
+
}))
|
331
385
|
break
|
332
|
-
|
386
|
+
}
|
387
|
+
default: {
|
333
388
|
reader.skipType(tag & 7)
|
334
389
|
break
|
390
|
+
}
|
335
391
|
}
|
336
392
|
}
|
337
393
|
|
@@ -346,8 +402,8 @@ export namespace ControlMessage {
|
|
346
402
|
return encodeMessage(obj, ControlMessage.codec())
|
347
403
|
}
|
348
404
|
|
349
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlMessage => {
|
350
|
-
return decodeMessage(buf, ControlMessage.codec())
|
405
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ControlMessage>): ControlMessage => {
|
406
|
+
return decodeMessage(buf, ControlMessage.codec(), opts)
|
351
407
|
}
|
352
408
|
}
|
353
409
|
|
@@ -381,7 +437,7 @@ export namespace ControlIHave {
|
|
381
437
|
if (opts.lengthDelimited !== false) {
|
382
438
|
w.ldelim()
|
383
439
|
}
|
384
|
-
}, (reader, length) => {
|
440
|
+
}, (reader, length, opts = {}) => {
|
385
441
|
const obj: any = {
|
386
442
|
messageIDs: []
|
387
443
|
}
|
@@ -392,15 +448,22 @@ export namespace ControlIHave {
|
|
392
448
|
const tag = reader.uint32()
|
393
449
|
|
394
450
|
switch (tag >>> 3) {
|
395
|
-
case 1:
|
451
|
+
case 1: {
|
396
452
|
obj.topic = reader.string()
|
397
453
|
break
|
398
|
-
|
454
|
+
}
|
455
|
+
case 2: {
|
456
|
+
if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {
|
457
|
+
throw new MaxLengthError('Decode error - map field "messageIDs" had too many elements')
|
458
|
+
}
|
459
|
+
|
399
460
|
obj.messageIDs.push(reader.bytes())
|
400
461
|
break
|
401
|
-
|
462
|
+
}
|
463
|
+
default: {
|
402
464
|
reader.skipType(tag & 7)
|
403
465
|
break
|
466
|
+
}
|
404
467
|
}
|
405
468
|
}
|
406
469
|
|
@@ -415,8 +478,8 @@ export namespace ControlIHave {
|
|
415
478
|
return encodeMessage(obj, ControlIHave.codec())
|
416
479
|
}
|
417
480
|
|
418
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlIHave => {
|
419
|
-
return decodeMessage(buf, ControlIHave.codec())
|
481
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ControlIHave>): ControlIHave => {
|
482
|
+
return decodeMessage(buf, ControlIHave.codec(), opts)
|
420
483
|
}
|
421
484
|
}
|
422
485
|
|
@@ -444,7 +507,7 @@ export namespace ControlIWant {
|
|
444
507
|
if (opts.lengthDelimited !== false) {
|
445
508
|
w.ldelim()
|
446
509
|
}
|
447
|
-
}, (reader, length) => {
|
510
|
+
}, (reader, length, opts = {}) => {
|
448
511
|
const obj: any = {
|
449
512
|
messageIDs: []
|
450
513
|
}
|
@@ -455,12 +518,18 @@ export namespace ControlIWant {
|
|
455
518
|
const tag = reader.uint32()
|
456
519
|
|
457
520
|
switch (tag >>> 3) {
|
458
|
-
case 1:
|
521
|
+
case 1: {
|
522
|
+
if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {
|
523
|
+
throw new MaxLengthError('Decode error - map field "messageIDs" had too many elements')
|
524
|
+
}
|
525
|
+
|
459
526
|
obj.messageIDs.push(reader.bytes())
|
460
527
|
break
|
461
|
-
|
528
|
+
}
|
529
|
+
default: {
|
462
530
|
reader.skipType(tag & 7)
|
463
531
|
break
|
532
|
+
}
|
464
533
|
}
|
465
534
|
}
|
466
535
|
|
@@ -475,8 +544,8 @@ export namespace ControlIWant {
|
|
475
544
|
return encodeMessage(obj, ControlIWant.codec())
|
476
545
|
}
|
477
546
|
|
478
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlIWant => {
|
479
|
-
return decodeMessage(buf, ControlIWant.codec())
|
547
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ControlIWant>): ControlIWant => {
|
548
|
+
return decodeMessage(buf, ControlIWant.codec(), opts)
|
480
549
|
}
|
481
550
|
}
|
482
551
|
|
@@ -502,7 +571,7 @@ export namespace ControlGraft {
|
|
502
571
|
if (opts.lengthDelimited !== false) {
|
503
572
|
w.ldelim()
|
504
573
|
}
|
505
|
-
}, (reader, length) => {
|
574
|
+
}, (reader, length, opts = {}) => {
|
506
575
|
const obj: any = {}
|
507
576
|
|
508
577
|
const end = length == null ? reader.len : reader.pos + length
|
@@ -511,12 +580,14 @@ export namespace ControlGraft {
|
|
511
580
|
const tag = reader.uint32()
|
512
581
|
|
513
582
|
switch (tag >>> 3) {
|
514
|
-
case 1:
|
583
|
+
case 1: {
|
515
584
|
obj.topic = reader.string()
|
516
585
|
break
|
517
|
-
|
586
|
+
}
|
587
|
+
default: {
|
518
588
|
reader.skipType(tag & 7)
|
519
589
|
break
|
590
|
+
}
|
520
591
|
}
|
521
592
|
}
|
522
593
|
|
@@ -531,8 +602,8 @@ export namespace ControlGraft {
|
|
531
602
|
return encodeMessage(obj, ControlGraft.codec())
|
532
603
|
}
|
533
604
|
|
534
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlGraft => {
|
535
|
-
return decodeMessage(buf, ControlGraft.codec())
|
605
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ControlGraft>): ControlGraft => {
|
606
|
+
return decodeMessage(buf, ControlGraft.codec(), opts)
|
536
607
|
}
|
537
608
|
}
|
538
609
|
|
@@ -572,7 +643,7 @@ export namespace ControlPrune {
|
|
572
643
|
if (opts.lengthDelimited !== false) {
|
573
644
|
w.ldelim()
|
574
645
|
}
|
575
|
-
}, (reader, length) => {
|
646
|
+
}, (reader, length, opts = {}) => {
|
576
647
|
const obj: any = {
|
577
648
|
peers: []
|
578
649
|
}
|
@@ -583,18 +654,28 @@ export namespace ControlPrune {
|
|
583
654
|
const tag = reader.uint32()
|
584
655
|
|
585
656
|
switch (tag >>> 3) {
|
586
|
-
case 1:
|
657
|
+
case 1: {
|
587
658
|
obj.topic = reader.string()
|
588
659
|
break
|
589
|
-
|
590
|
-
|
660
|
+
}
|
661
|
+
case 2: {
|
662
|
+
if (opts.limits?.peers != null && obj.peers.length === opts.limits.peers) {
|
663
|
+
throw new MaxLengthError('Decode error - map field "peers" had too many elements')
|
664
|
+
}
|
665
|
+
|
666
|
+
obj.peers.push(PeerInfo.codec().decode(reader, reader.uint32(), {
|
667
|
+
limits: opts.limits?.peers$
|
668
|
+
}))
|
591
669
|
break
|
592
|
-
|
670
|
+
}
|
671
|
+
case 3: {
|
593
672
|
obj.backoff = reader.uint64()
|
594
673
|
break
|
595
|
-
|
674
|
+
}
|
675
|
+
default: {
|
596
676
|
reader.skipType(tag & 7)
|
597
677
|
break
|
678
|
+
}
|
598
679
|
}
|
599
680
|
}
|
600
681
|
|
@@ -609,8 +690,8 @@ export namespace ControlPrune {
|
|
609
690
|
return encodeMessage(obj, ControlPrune.codec())
|
610
691
|
}
|
611
692
|
|
612
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlPrune => {
|
613
|
-
return decodeMessage(buf, ControlPrune.codec())
|
693
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ControlPrune>): ControlPrune => {
|
694
|
+
return decodeMessage(buf, ControlPrune.codec(), opts)
|
614
695
|
}
|
615
696
|
}
|
616
697
|
|
@@ -642,7 +723,7 @@ export namespace PeerInfo {
|
|
642
723
|
if (opts.lengthDelimited !== false) {
|
643
724
|
w.ldelim()
|
644
725
|
}
|
645
|
-
}, (reader, length) => {
|
726
|
+
}, (reader, length, opts = {}) => {
|
646
727
|
const obj: any = {}
|
647
728
|
|
648
729
|
const end = length == null ? reader.len : reader.pos + length
|
@@ -651,15 +732,18 @@ export namespace PeerInfo {
|
|
651
732
|
const tag = reader.uint32()
|
652
733
|
|
653
734
|
switch (tag >>> 3) {
|
654
|
-
case 1:
|
735
|
+
case 1: {
|
655
736
|
obj.peerID = reader.bytes()
|
656
737
|
break
|
657
|
-
|
738
|
+
}
|
739
|
+
case 2: {
|
658
740
|
obj.signedPeerRecord = reader.bytes()
|
659
741
|
break
|
660
|
-
|
742
|
+
}
|
743
|
+
default: {
|
661
744
|
reader.skipType(tag & 7)
|
662
745
|
break
|
746
|
+
}
|
663
747
|
}
|
664
748
|
}
|
665
749
|
|
@@ -674,7 +758,7 @@ export namespace PeerInfo {
|
|
674
758
|
return encodeMessage(obj, PeerInfo.codec())
|
675
759
|
}
|
676
760
|
|
677
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerInfo => {
|
678
|
-
return decodeMessage(buf, PeerInfo.codec())
|
761
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerInfo>): PeerInfo => {
|
762
|
+
return decodeMessage(buf, PeerInfo.codec(), opts)
|
679
763
|
}
|
680
764
|
}
|