@libp2p/circuit-relay-v2 4.1.6 → 4.1.7

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/src/pb/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { decodeMessage, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime'
1
+ import { decodeMessage, encodeMessage, enumeration, MaxLengthError, message, streamMessage } from 'protons-runtime'
2
2
  import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
3
3
  import type { Codec, DecodeOptions } from 'protons-runtime'
4
4
  import type { Uint8ArrayList } from 'uint8arraylist'
@@ -110,19 +110,143 @@ export namespace HopMessage {
110
110
  }
111
111
 
112
112
  return obj
113
+ }, function * (reader, length, prefix, opts = {}) {
114
+ const end = length == null ? reader.len : reader.pos + length
115
+
116
+ while (reader.pos < end) {
117
+ const tag = reader.uint32()
118
+
119
+ switch (tag >>> 3) {
120
+ case 1: {
121
+ yield {
122
+ field: `${prefix}.type`,
123
+ value: HopMessage.Type.codec().decode(reader)
124
+ }
125
+ break
126
+ }
127
+ case 2: {
128
+ yield * Peer.codec().stream(reader, reader.uint32(), `${prefix}.peer`, {
129
+ limits: opts.limits?.peer
130
+ })
131
+
132
+ break
133
+ }
134
+ case 3: {
135
+ yield * Reservation.codec().stream(reader, reader.uint32(), `${prefix}.reservation`, {
136
+ limits: opts.limits?.reservation
137
+ })
138
+
139
+ break
140
+ }
141
+ case 4: {
142
+ yield * Limit.codec().stream(reader, reader.uint32(), `${prefix}.limit`, {
143
+ limits: opts.limits?.limit
144
+ })
145
+
146
+ break
147
+ }
148
+ case 5: {
149
+ yield {
150
+ field: `${prefix}.status`,
151
+ value: Status.codec().decode(reader)
152
+ }
153
+ break
154
+ }
155
+ default: {
156
+ reader.skipType(tag & 7)
157
+ break
158
+ }
159
+ }
160
+ }
113
161
  })
114
162
  }
115
163
 
116
164
  return _codec
117
165
  }
118
166
 
119
- export const encode = (obj: Partial<HopMessage>): Uint8Array => {
167
+ export interface HopMessageTypeFieldEvent {
168
+ field: '$.type'
169
+ value: HopMessage.Type
170
+ }
171
+
172
+ export interface HopMessagePeerIdFieldEvent {
173
+ field: '$.peer.id'
174
+ value: Uint8Array
175
+ }
176
+
177
+ export interface HopMessagePeerAddrsFieldEvent {
178
+ field: '$.peer.addrs[]'
179
+ index: number
180
+ value: Uint8Array
181
+ }
182
+
183
+ export interface HopMessageReservationExpireFieldEvent {
184
+ field: '$.reservation.expire'
185
+ value: bigint
186
+ }
187
+
188
+ export interface HopMessageReservationAddrsFieldEvent {
189
+ field: '$.reservation.addrs[]'
190
+ index: number
191
+ value: Uint8Array
192
+ }
193
+
194
+ export interface HopMessageReservationVoucherPublicKeyFieldEvent {
195
+ field: '$.reservation.voucher.publicKey'
196
+ value: Uint8Array
197
+ }
198
+
199
+ export interface HopMessageReservationVoucherPayloadTypeFieldEvent {
200
+ field: '$.reservation.voucher.payloadType'
201
+ value: Uint8Array
202
+ }
203
+
204
+ export interface HopMessageReservationVoucherPayloadRelayFieldEvent {
205
+ field: '$.reservation.voucher.payload.relay'
206
+ value: Uint8Array
207
+ }
208
+
209
+ export interface HopMessageReservationVoucherPayloadPeerFieldEvent {
210
+ field: '$.reservation.voucher.payload.peer'
211
+ value: Uint8Array
212
+ }
213
+
214
+ export interface HopMessageReservationVoucherPayloadExpirationFieldEvent {
215
+ field: '$.reservation.voucher.payload.expiration'
216
+ value: bigint
217
+ }
218
+
219
+ export interface HopMessageReservationVoucherSignatureFieldEvent {
220
+ field: '$.reservation.voucher.signature'
221
+ value: Uint8Array
222
+ }
223
+
224
+ export interface HopMessageLimitDurationFieldEvent {
225
+ field: '$.limit.duration'
226
+ value: number
227
+ }
228
+
229
+ export interface HopMessageLimitDataFieldEvent {
230
+ field: '$.limit.data'
231
+ value: bigint
232
+ }
233
+
234
+ export interface HopMessageStatusFieldEvent {
235
+ field: '$.status'
236
+ value: Status
237
+ }
238
+
239
+ export function encode (obj: Partial<HopMessage>): Uint8Array {
120
240
  return encodeMessage(obj, HopMessage.codec())
121
241
  }
122
242
 
123
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HopMessage>): HopMessage => {
243
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HopMessage>): HopMessage {
124
244
  return decodeMessage(buf, HopMessage.codec(), opts)
125
245
  }
246
+
247
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HopMessage>): Generator<HopMessageTypeFieldEvent | HopMessagePeerIdFieldEvent | HopMessagePeerAddrsFieldEvent | HopMessageReservationExpireFieldEvent | HopMessageReservationAddrsFieldEvent | HopMessageReservationVoucherPublicKeyFieldEvent | HopMessageReservationVoucherPayloadTypeFieldEvent | HopMessageReservationVoucherPayloadRelayFieldEvent | HopMessageReservationVoucherPayloadPeerFieldEvent | HopMessageReservationVoucherPayloadExpirationFieldEvent | HopMessageReservationVoucherSignatureFieldEvent | HopMessageLimitDurationFieldEvent | HopMessageLimitDataFieldEvent | HopMessageStatusFieldEvent> {
248
+ return streamMessage(buf, HopMessage.codec(), opts)
249
+ }
126
250
  }
127
251
 
128
252
  export interface StopMessage {
@@ -218,19 +342,95 @@ export namespace StopMessage {
218
342
  }
219
343
 
220
344
  return obj
345
+ }, function * (reader, length, prefix, opts = {}) {
346
+ const end = length == null ? reader.len : reader.pos + length
347
+
348
+ while (reader.pos < end) {
349
+ const tag = reader.uint32()
350
+
351
+ switch (tag >>> 3) {
352
+ case 1: {
353
+ yield {
354
+ field: `${prefix}.type`,
355
+ value: StopMessage.Type.codec().decode(reader)
356
+ }
357
+ break
358
+ }
359
+ case 2: {
360
+ yield * Peer.codec().stream(reader, reader.uint32(), `${prefix}.peer`, {
361
+ limits: opts.limits?.peer
362
+ })
363
+
364
+ break
365
+ }
366
+ case 3: {
367
+ yield * Limit.codec().stream(reader, reader.uint32(), `${prefix}.limit`, {
368
+ limits: opts.limits?.limit
369
+ })
370
+
371
+ break
372
+ }
373
+ case 4: {
374
+ yield {
375
+ field: `${prefix}.status`,
376
+ value: Status.codec().decode(reader)
377
+ }
378
+ break
379
+ }
380
+ default: {
381
+ reader.skipType(tag & 7)
382
+ break
383
+ }
384
+ }
385
+ }
221
386
  })
222
387
  }
223
388
 
224
389
  return _codec
225
390
  }
226
391
 
227
- export const encode = (obj: Partial<StopMessage>): Uint8Array => {
392
+ export interface StopMessageTypeFieldEvent {
393
+ field: '$.type'
394
+ value: StopMessage.Type
395
+ }
396
+
397
+ export interface StopMessagePeerIdFieldEvent {
398
+ field: '$.peer.id'
399
+ value: Uint8Array
400
+ }
401
+
402
+ export interface StopMessagePeerAddrsFieldEvent {
403
+ field: '$.peer.addrs[]'
404
+ index: number
405
+ value: Uint8Array
406
+ }
407
+
408
+ export interface StopMessageLimitDurationFieldEvent {
409
+ field: '$.limit.duration'
410
+ value: number
411
+ }
412
+
413
+ export interface StopMessageLimitDataFieldEvent {
414
+ field: '$.limit.data'
415
+ value: bigint
416
+ }
417
+
418
+ export interface StopMessageStatusFieldEvent {
419
+ field: '$.status'
420
+ value: Status
421
+ }
422
+
423
+ export function encode (obj: Partial<StopMessage>): Uint8Array {
228
424
  return encodeMessage(obj, StopMessage.codec())
229
425
  }
230
426
 
231
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<StopMessage>): StopMessage => {
427
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<StopMessage>): StopMessage {
232
428
  return decodeMessage(buf, StopMessage.codec(), opts)
233
429
  }
430
+
431
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<StopMessage>): Generator<StopMessageTypeFieldEvent | StopMessagePeerIdFieldEvent | StopMessagePeerAddrsFieldEvent | StopMessageLimitDurationFieldEvent | StopMessageLimitDataFieldEvent | StopMessageStatusFieldEvent> {
432
+ return streamMessage(buf, StopMessage.codec(), opts)
433
+ }
234
434
  }
235
435
 
236
436
  export interface Peer {
@@ -253,7 +453,7 @@ export namespace Peer {
253
453
  w.bytes(obj.id)
254
454
  }
255
455
 
256
- if (obj.addrs != null) {
456
+ if (obj.addrs != null && obj.addrs.length > 0) {
257
457
  for (const value of obj.addrs) {
258
458
  w.uint32(18)
259
459
  w.bytes(value)
@@ -281,7 +481,7 @@ export namespace Peer {
281
481
  }
282
482
  case 2: {
283
483
  if (opts.limits?.addrs != null && obj.addrs.length === opts.limits.addrs) {
284
- throw new MaxLengthError('Decode error - map field "addrs" had too many elements')
484
+ throw new MaxLengthError('Decode error - repeated field "addrs" had too many elements')
285
485
  }
286
486
 
287
487
  obj.addrs.push(reader.bytes())
@@ -295,19 +495,73 @@ export namespace Peer {
295
495
  }
296
496
 
297
497
  return obj
498
+ }, function * (reader, length, prefix, opts = {}) {
499
+ const obj = {
500
+ addrs: 0
501
+ }
502
+
503
+ const end = length == null ? reader.len : reader.pos + length
504
+
505
+ while (reader.pos < end) {
506
+ const tag = reader.uint32()
507
+
508
+ switch (tag >>> 3) {
509
+ case 1: {
510
+ yield {
511
+ field: `${prefix}.id`,
512
+ value: reader.bytes()
513
+ }
514
+ break
515
+ }
516
+ case 2: {
517
+ if (opts.limits?.addrs != null && obj.addrs === opts.limits.addrs) {
518
+ throw new MaxLengthError('Streaming decode error - repeated field "addrs" had too many elements')
519
+ }
520
+
521
+ yield {
522
+ field: `${prefix}.addrs[]`,
523
+ index: obj.addrs,
524
+ value: reader.bytes()
525
+ }
526
+
527
+ obj.addrs++
528
+
529
+ break
530
+ }
531
+ default: {
532
+ reader.skipType(tag & 7)
533
+ break
534
+ }
535
+ }
536
+ }
298
537
  })
299
538
  }
300
539
 
301
540
  return _codec
302
541
  }
303
542
 
304
- export const encode = (obj: Partial<Peer>): Uint8Array => {
543
+ export interface PeerIdFieldEvent {
544
+ field: '$.id'
545
+ value: Uint8Array
546
+ }
547
+
548
+ export interface PeerAddrsFieldEvent {
549
+ field: '$.addrs[]'
550
+ index: number
551
+ value: Uint8Array
552
+ }
553
+
554
+ export function encode (obj: Partial<Peer>): Uint8Array {
305
555
  return encodeMessage(obj, Peer.codec())
306
556
  }
307
557
 
308
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Peer>): Peer => {
558
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Peer>): Peer {
309
559
  return decodeMessage(buf, Peer.codec(), opts)
310
560
  }
561
+
562
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Peer>): Generator<PeerIdFieldEvent | PeerAddrsFieldEvent> {
563
+ return streamMessage(buf, Peer.codec(), opts)
564
+ }
311
565
  }
312
566
 
313
567
  export interface Reservation {
@@ -331,7 +585,7 @@ export namespace Reservation {
331
585
  w.uint64(obj.expire)
332
586
  }
333
587
 
334
- if (obj.addrs != null) {
588
+ if (obj.addrs != null && obj.addrs.length > 0) {
335
589
  for (const value of obj.addrs) {
336
590
  w.uint32(18)
337
591
  w.bytes(value)
@@ -364,7 +618,7 @@ export namespace Reservation {
364
618
  }
365
619
  case 2: {
366
620
  if (opts.limits?.addrs != null && obj.addrs.length === opts.limits.addrs) {
367
- throw new MaxLengthError('Decode error - map field "addrs" had too many elements')
621
+ throw new MaxLengthError('Decode error - repeated field "addrs" had too many elements')
368
622
  }
369
623
 
370
624
  obj.addrs.push(reader.bytes())
@@ -384,19 +638,110 @@ export namespace Reservation {
384
638
  }
385
639
 
386
640
  return obj
641
+ }, function * (reader, length, prefix, opts = {}) {
642
+ const obj = {
643
+ addrs: 0
644
+ }
645
+
646
+ const end = length == null ? reader.len : reader.pos + length
647
+
648
+ while (reader.pos < end) {
649
+ const tag = reader.uint32()
650
+
651
+ switch (tag >>> 3) {
652
+ case 1: {
653
+ yield {
654
+ field: `${prefix}.expire`,
655
+ value: reader.uint64()
656
+ }
657
+ break
658
+ }
659
+ case 2: {
660
+ if (opts.limits?.addrs != null && obj.addrs === opts.limits.addrs) {
661
+ throw new MaxLengthError('Streaming decode error - repeated field "addrs" had too many elements')
662
+ }
663
+
664
+ yield {
665
+ field: `${prefix}.addrs[]`,
666
+ index: obj.addrs,
667
+ value: reader.bytes()
668
+ }
669
+
670
+ obj.addrs++
671
+
672
+ break
673
+ }
674
+ case 3: {
675
+ yield * Envelope.codec().stream(reader, reader.uint32(), `${prefix}.voucher`, {
676
+ limits: opts.limits?.voucher
677
+ })
678
+
679
+ break
680
+ }
681
+ default: {
682
+ reader.skipType(tag & 7)
683
+ break
684
+ }
685
+ }
686
+ }
387
687
  })
388
688
  }
389
689
 
390
690
  return _codec
391
691
  }
392
692
 
393
- export const encode = (obj: Partial<Reservation>): Uint8Array => {
693
+ export interface ReservationExpireFieldEvent {
694
+ field: '$.expire'
695
+ value: bigint
696
+ }
697
+
698
+ export interface ReservationAddrsFieldEvent {
699
+ field: '$.addrs[]'
700
+ index: number
701
+ value: Uint8Array
702
+ }
703
+
704
+ export interface ReservationVoucherPublicKeyFieldEvent {
705
+ field: '$.voucher.publicKey'
706
+ value: Uint8Array
707
+ }
708
+
709
+ export interface ReservationVoucherPayloadTypeFieldEvent {
710
+ field: '$.voucher.payloadType'
711
+ value: Uint8Array
712
+ }
713
+
714
+ export interface ReservationVoucherPayloadRelayFieldEvent {
715
+ field: '$.voucher.payload.relay'
716
+ value: Uint8Array
717
+ }
718
+
719
+ export interface ReservationVoucherPayloadPeerFieldEvent {
720
+ field: '$.voucher.payload.peer'
721
+ value: Uint8Array
722
+ }
723
+
724
+ export interface ReservationVoucherPayloadExpirationFieldEvent {
725
+ field: '$.voucher.payload.expiration'
726
+ value: bigint
727
+ }
728
+
729
+ export interface ReservationVoucherSignatureFieldEvent {
730
+ field: '$.voucher.signature'
731
+ value: Uint8Array
732
+ }
733
+
734
+ export function encode (obj: Partial<Reservation>): Uint8Array {
394
735
  return encodeMessage(obj, Reservation.codec())
395
736
  }
396
737
 
397
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Reservation>): Reservation => {
738
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Reservation>): Reservation {
398
739
  return decodeMessage(buf, Reservation.codec(), opts)
399
740
  }
741
+
742
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Reservation>): Generator<ReservationExpireFieldEvent | ReservationAddrsFieldEvent | ReservationVoucherPublicKeyFieldEvent | ReservationVoucherPayloadTypeFieldEvent | ReservationVoucherPayloadRelayFieldEvent | ReservationVoucherPayloadPeerFieldEvent | ReservationVoucherPayloadExpirationFieldEvent | ReservationVoucherSignatureFieldEvent> {
743
+ return streamMessage(buf, Reservation.codec(), opts)
744
+ }
400
745
  }
401
746
 
402
747
  export interface Limit {
@@ -452,19 +797,60 @@ export namespace Limit {
452
797
  }
453
798
 
454
799
  return obj
800
+ }, function * (reader, length, prefix, opts = {}) {
801
+ const end = length == null ? reader.len : reader.pos + length
802
+
803
+ while (reader.pos < end) {
804
+ const tag = reader.uint32()
805
+
806
+ switch (tag >>> 3) {
807
+ case 1: {
808
+ yield {
809
+ field: `${prefix}.duration`,
810
+ value: reader.uint32()
811
+ }
812
+ break
813
+ }
814
+ case 2: {
815
+ yield {
816
+ field: `${prefix}.data`,
817
+ value: reader.uint64()
818
+ }
819
+ break
820
+ }
821
+ default: {
822
+ reader.skipType(tag & 7)
823
+ break
824
+ }
825
+ }
826
+ }
455
827
  })
456
828
  }
457
829
 
458
830
  return _codec
459
831
  }
460
832
 
461
- export const encode = (obj: Partial<Limit>): Uint8Array => {
833
+ export interface LimitDurationFieldEvent {
834
+ field: '$.duration'
835
+ value: number
836
+ }
837
+
838
+ export interface LimitDataFieldEvent {
839
+ field: '$.data'
840
+ value: bigint
841
+ }
842
+
843
+ export function encode (obj: Partial<Limit>): Uint8Array {
462
844
  return encodeMessage(obj, Limit.codec())
463
845
  }
464
846
 
465
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Limit>): Limit => {
847
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Limit>): Limit {
466
848
  return decodeMessage(buf, Limit.codec(), opts)
467
849
  }
850
+
851
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Limit>): Generator<LimitDurationFieldEvent | LimitDataFieldEvent> {
852
+ return streamMessage(buf, Limit.codec(), opts)
853
+ }
468
854
  }
469
855
 
470
856
  export enum Status {
@@ -496,6 +882,7 @@ export namespace Status {
496
882
  return enumeration<Status>(__StatusValues)
497
883
  }
498
884
  }
885
+
499
886
  export interface ReservationVoucher {
500
887
  relay: Uint8Array
501
888
  peer: Uint8Array
@@ -563,19 +950,72 @@ export namespace ReservationVoucher {
563
950
  }
564
951
 
565
952
  return obj
953
+ }, function * (reader, length, prefix, opts = {}) {
954
+ const end = length == null ? reader.len : reader.pos + length
955
+
956
+ while (reader.pos < end) {
957
+ const tag = reader.uint32()
958
+
959
+ switch (tag >>> 3) {
960
+ case 1: {
961
+ yield {
962
+ field: `${prefix}.relay`,
963
+ value: reader.bytes()
964
+ }
965
+ break
966
+ }
967
+ case 2: {
968
+ yield {
969
+ field: `${prefix}.peer`,
970
+ value: reader.bytes()
971
+ }
972
+ break
973
+ }
974
+ case 3: {
975
+ yield {
976
+ field: `${prefix}.expiration`,
977
+ value: reader.uint64()
978
+ }
979
+ break
980
+ }
981
+ default: {
982
+ reader.skipType(tag & 7)
983
+ break
984
+ }
985
+ }
986
+ }
566
987
  })
567
988
  }
568
989
 
569
990
  return _codec
570
991
  }
571
992
 
572
- export const encode = (obj: Partial<ReservationVoucher>): Uint8Array => {
993
+ export interface ReservationVoucherRelayFieldEvent {
994
+ field: '$.relay'
995
+ value: Uint8Array
996
+ }
997
+
998
+ export interface ReservationVoucherPeerFieldEvent {
999
+ field: '$.peer'
1000
+ value: Uint8Array
1001
+ }
1002
+
1003
+ export interface ReservationVoucherExpirationFieldEvent {
1004
+ field: '$.expiration'
1005
+ value: bigint
1006
+ }
1007
+
1008
+ export function encode (obj: Partial<ReservationVoucher>): Uint8Array {
573
1009
  return encodeMessage(obj, ReservationVoucher.codec())
574
1010
  }
575
1011
 
576
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ReservationVoucher>): ReservationVoucher => {
1012
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ReservationVoucher>): ReservationVoucher {
577
1013
  return decodeMessage(buf, ReservationVoucher.codec(), opts)
578
1014
  }
1015
+
1016
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ReservationVoucher>): Generator<ReservationVoucherRelayFieldEvent | ReservationVoucherPeerFieldEvent | ReservationVoucherExpirationFieldEvent> {
1017
+ return streamMessage(buf, ReservationVoucher.codec(), opts)
1018
+ }
579
1019
  }
580
1020
 
581
1021
  export interface Envelope {
@@ -657,17 +1097,92 @@ export namespace Envelope {
657
1097
  }
658
1098
 
659
1099
  return obj
1100
+ }, function * (reader, length, prefix, opts = {}) {
1101
+ const end = length == null ? reader.len : reader.pos + length
1102
+
1103
+ while (reader.pos < end) {
1104
+ const tag = reader.uint32()
1105
+
1106
+ switch (tag >>> 3) {
1107
+ case 1: {
1108
+ yield {
1109
+ field: `${prefix}.publicKey`,
1110
+ value: reader.bytes()
1111
+ }
1112
+ break
1113
+ }
1114
+ case 2: {
1115
+ yield {
1116
+ field: `${prefix}.payloadType`,
1117
+ value: reader.bytes()
1118
+ }
1119
+ break
1120
+ }
1121
+ case 3: {
1122
+ yield * ReservationVoucher.codec().stream(reader, reader.uint32(), `${prefix}.payload`, {
1123
+ limits: opts.limits?.payload
1124
+ })
1125
+
1126
+ break
1127
+ }
1128
+ case 5: {
1129
+ yield {
1130
+ field: `${prefix}.signature`,
1131
+ value: reader.bytes()
1132
+ }
1133
+ break
1134
+ }
1135
+ default: {
1136
+ reader.skipType(tag & 7)
1137
+ break
1138
+ }
1139
+ }
1140
+ }
660
1141
  })
661
1142
  }
662
1143
 
663
1144
  return _codec
664
1145
  }
665
1146
 
666
- export const encode = (obj: Partial<Envelope>): Uint8Array => {
1147
+ export interface EnvelopePublicKeyFieldEvent {
1148
+ field: '$.publicKey'
1149
+ value: Uint8Array
1150
+ }
1151
+
1152
+ export interface EnvelopePayloadTypeFieldEvent {
1153
+ field: '$.payloadType'
1154
+ value: Uint8Array
1155
+ }
1156
+
1157
+ export interface EnvelopePayloadRelayFieldEvent {
1158
+ field: '$.payload.relay'
1159
+ value: Uint8Array
1160
+ }
1161
+
1162
+ export interface EnvelopePayloadPeerFieldEvent {
1163
+ field: '$.payload.peer'
1164
+ value: Uint8Array
1165
+ }
1166
+
1167
+ export interface EnvelopePayloadExpirationFieldEvent {
1168
+ field: '$.payload.expiration'
1169
+ value: bigint
1170
+ }
1171
+
1172
+ export interface EnvelopeSignatureFieldEvent {
1173
+ field: '$.signature'
1174
+ value: Uint8Array
1175
+ }
1176
+
1177
+ export function encode (obj: Partial<Envelope>): Uint8Array {
667
1178
  return encodeMessage(obj, Envelope.codec())
668
1179
  }
669
1180
 
670
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Envelope => {
1181
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Envelope {
671
1182
  return decodeMessage(buf, Envelope.codec(), opts)
672
1183
  }
1184
+
1185
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Generator<EnvelopePublicKeyFieldEvent | EnvelopePayloadTypeFieldEvent | EnvelopePayloadRelayFieldEvent | EnvelopePayloadPeerFieldEvent | EnvelopePayloadExpirationFieldEvent | EnvelopeSignatureFieldEvent> {
1186
+ return streamMessage(buf, Envelope.codec(), opts)
1187
+ }
673
1188
  }