UNPKG

255 kBJavaScriptView Raw
1/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
2import * as $protobuf from "protobufjs/minimal";
3
4// Common aliases
5const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
6
7// Exported root namespace
8const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
9
10export const Hello = $root.Hello = (() => {
11
12 /**
13 * Properties of a Hello.
14 * @exports IHello
15 * @interface IHello
16 * @property {number|null} [version] Hello version
17 * @property {Uint8Array|null} [peerId] Hello peerId
18 */
19
20 /**
21 * Constructs a new Hello.
22 * @exports Hello
23 * @classdesc Represents a Hello.
24 * @implements IHello
25 * @constructor
26 * @param {IHello=} [properties] Properties to set
27 */
28 function Hello(properties) {
29 if (properties)
30 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
31 if (properties[keys[i]] != null)
32 this[keys[i]] = properties[keys[i]];
33 }
34
35 /**
36 * Hello version.
37 * @member {number} version
38 * @memberof Hello
39 * @instance
40 */
41 Hello.prototype.version = 0;
42
43 /**
44 * Hello peerId.
45 * @member {Uint8Array} peerId
46 * @memberof Hello
47 * @instance
48 */
49 Hello.prototype.peerId = $util.newBuffer([]);
50
51 /**
52 * Creates a new Hello instance using the specified properties.
53 * @function create
54 * @memberof Hello
55 * @static
56 * @param {IHello=} [properties] Properties to set
57 * @returns {Hello} Hello instance
58 */
59 Hello.create = function create(properties) {
60 return new Hello(properties);
61 };
62
63 /**
64 * Encodes the specified Hello message. Does not implicitly {@link Hello.verify|verify} messages.
65 * @function encode
66 * @memberof Hello
67 * @static
68 * @param {IHello} message Hello message or plain object to encode
69 * @param {$protobuf.Writer} [writer] Writer to encode to
70 * @returns {$protobuf.Writer} Writer
71 */
72 Hello.encode = function encode(message, writer) {
73 if (!writer)
74 writer = $Writer.create();
75 if (message.version != null && message.hasOwnProperty("version"))
76 writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.version);
77 if (message.peerId != null && message.hasOwnProperty("peerId"))
78 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.peerId);
79 return writer;
80 };
81
82 /**
83 * Encodes the specified Hello message, length delimited. Does not implicitly {@link Hello.verify|verify} messages.
84 * @function encodeDelimited
85 * @memberof Hello
86 * @static
87 * @param {IHello} message Hello message or plain object to encode
88 * @param {$protobuf.Writer} [writer] Writer to encode to
89 * @returns {$protobuf.Writer} Writer
90 */
91 Hello.encodeDelimited = function encodeDelimited(message, writer) {
92 return this.encode(message, writer).ldelim();
93 };
94
95 /**
96 * Decodes a Hello message from the specified reader or buffer.
97 * @function decode
98 * @memberof Hello
99 * @static
100 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
101 * @param {number} [length] Message length if known beforehand
102 * @returns {Hello} Hello
103 * @throws {Error} If the payload is not a reader or valid buffer
104 * @throws {$protobuf.util.ProtocolError} If required fields are missing
105 */
106 Hello.decode = function decode(reader, length) {
107 if (!(reader instanceof $Reader))
108 reader = $Reader.create(reader);
109 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Hello();
110 while (reader.pos < end) {
111 let tag = reader.uint32();
112 switch (tag >>> 3) {
113 case 1:
114 message.version = reader.uint32();
115 break;
116 case 2:
117 message.peerId = reader.bytes();
118 break;
119 default:
120 reader.skipType(tag & 7);
121 break;
122 }
123 }
124 return message;
125 };
126
127 /**
128 * Decodes a Hello message from the specified reader or buffer, length delimited.
129 * @function decodeDelimited
130 * @memberof Hello
131 * @static
132 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
133 * @returns {Hello} Hello
134 * @throws {Error} If the payload is not a reader or valid buffer
135 * @throws {$protobuf.util.ProtocolError} If required fields are missing
136 */
137 Hello.decodeDelimited = function decodeDelimited(reader) {
138 if (!(reader instanceof $Reader))
139 reader = new $Reader(reader);
140 return this.decode(reader, reader.uint32());
141 };
142
143 /**
144 * Verifies a Hello message.
145 * @function verify
146 * @memberof Hello
147 * @static
148 * @param {Object.<string,*>} message Plain object to verify
149 * @returns {string|null} `null` if valid, otherwise the reason why it is not
150 */
151 Hello.verify = function verify(message) {
152 if (typeof message !== "object" || message === null)
153 return "object expected";
154 if (message.version != null && message.hasOwnProperty("version"))
155 if (!$util.isInteger(message.version))
156 return "version: integer expected";
157 if (message.peerId != null && message.hasOwnProperty("peerId"))
158 if (!(message.peerId && typeof message.peerId.length === "number" || $util.isString(message.peerId)))
159 return "peerId: buffer expected";
160 return null;
161 };
162
163 /**
164 * Creates a Hello message from a plain object. Also converts values to their respective internal types.
165 * @function fromObject
166 * @memberof Hello
167 * @static
168 * @param {Object.<string,*>} object Plain object
169 * @returns {Hello} Hello
170 */
171 Hello.fromObject = function fromObject(object) {
172 if (object instanceof $root.Hello)
173 return object;
174 let message = new $root.Hello();
175 if (object.version != null)
176 message.version = object.version >>> 0;
177 if (object.peerId != null)
178 if (typeof object.peerId === "string")
179 $util.base64.decode(object.peerId, message.peerId = $util.newBuffer($util.base64.length(object.peerId)), 0);
180 else if (object.peerId.length)
181 message.peerId = object.peerId;
182 return message;
183 };
184
185 /**
186 * Creates a plain object from a Hello message. Also converts values to other types if specified.
187 * @function toObject
188 * @memberof Hello
189 * @static
190 * @param {Hello} message Hello
191 * @param {$protobuf.IConversionOptions} [options] Conversion options
192 * @returns {Object.<string,*>} Plain object
193 */
194 Hello.toObject = function toObject(message, options) {
195 if (!options)
196 options = {};
197 let object = {};
198 if (options.defaults) {
199 object.version = 0;
200 if (options.bytes === String)
201 object.peerId = "";
202 else {
203 object.peerId = [];
204 if (options.bytes !== Array)
205 object.peerId = $util.newBuffer(object.peerId);
206 }
207 }
208 if (message.version != null && message.hasOwnProperty("version"))
209 object.version = message.version;
210 if (message.peerId != null && message.hasOwnProperty("peerId"))
211 object.peerId = options.bytes === String ? $util.base64.encode(message.peerId, 0, message.peerId.length) : options.bytes === Array ? Array.prototype.slice.call(message.peerId) : message.peerId;
212 return object;
213 };
214
215 /**
216 * Converts this Hello to JSON.
217 * @function toJSON
218 * @memberof Hello
219 * @instance
220 * @returns {Object.<string,*>} JSON object
221 */
222 Hello.prototype.toJSON = function toJSON() {
223 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
224 };
225
226 return Hello;
227})();
228
229export const Shake = $root.Shake = (() => {
230
231 /**
232 * Properties of a Shake.
233 * @exports IShake
234 * @interface IShake
235 * @property {boolean|null} [isDuplicate] Shake isDuplicate
236 */
237
238 /**
239 * Constructs a new Shake.
240 * @exports Shake
241 * @classdesc Represents a Shake.
242 * @implements IShake
243 * @constructor
244 * @param {IShake=} [properties] Properties to set
245 */
246 function Shake(properties) {
247 if (properties)
248 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
249 if (properties[keys[i]] != null)
250 this[keys[i]] = properties[keys[i]];
251 }
252
253 /**
254 * Shake isDuplicate.
255 * @member {boolean} isDuplicate
256 * @memberof Shake
257 * @instance
258 */
259 Shake.prototype.isDuplicate = false;
260
261 /**
262 * Creates a new Shake instance using the specified properties.
263 * @function create
264 * @memberof Shake
265 * @static
266 * @param {IShake=} [properties] Properties to set
267 * @returns {Shake} Shake instance
268 */
269 Shake.create = function create(properties) {
270 return new Shake(properties);
271 };
272
273 /**
274 * Encodes the specified Shake message. Does not implicitly {@link Shake.verify|verify} messages.
275 * @function encode
276 * @memberof Shake
277 * @static
278 * @param {IShake} message Shake message or plain object to encode
279 * @param {$protobuf.Writer} [writer] Writer to encode to
280 * @returns {$protobuf.Writer} Writer
281 */
282 Shake.encode = function encode(message, writer) {
283 if (!writer)
284 writer = $Writer.create();
285 if (message.isDuplicate != null && message.hasOwnProperty("isDuplicate"))
286 writer.uint32(/* id 1, wireType 0 =*/8).bool(message.isDuplicate);
287 return writer;
288 };
289
290 /**
291 * Encodes the specified Shake message, length delimited. Does not implicitly {@link Shake.verify|verify} messages.
292 * @function encodeDelimited
293 * @memberof Shake
294 * @static
295 * @param {IShake} message Shake message or plain object to encode
296 * @param {$protobuf.Writer} [writer] Writer to encode to
297 * @returns {$protobuf.Writer} Writer
298 */
299 Shake.encodeDelimited = function encodeDelimited(message, writer) {
300 return this.encode(message, writer).ldelim();
301 };
302
303 /**
304 * Decodes a Shake message from the specified reader or buffer.
305 * @function decode
306 * @memberof Shake
307 * @static
308 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
309 * @param {number} [length] Message length if known beforehand
310 * @returns {Shake} Shake
311 * @throws {Error} If the payload is not a reader or valid buffer
312 * @throws {$protobuf.util.ProtocolError} If required fields are missing
313 */
314 Shake.decode = function decode(reader, length) {
315 if (!(reader instanceof $Reader))
316 reader = $Reader.create(reader);
317 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Shake();
318 while (reader.pos < end) {
319 let tag = reader.uint32();
320 switch (tag >>> 3) {
321 case 1:
322 message.isDuplicate = reader.bool();
323 break;
324 default:
325 reader.skipType(tag & 7);
326 break;
327 }
328 }
329 return message;
330 };
331
332 /**
333 * Decodes a Shake message from the specified reader or buffer, length delimited.
334 * @function decodeDelimited
335 * @memberof Shake
336 * @static
337 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
338 * @returns {Shake} Shake
339 * @throws {Error} If the payload is not a reader or valid buffer
340 * @throws {$protobuf.util.ProtocolError} If required fields are missing
341 */
342 Shake.decodeDelimited = function decodeDelimited(reader) {
343 if (!(reader instanceof $Reader))
344 reader = new $Reader(reader);
345 return this.decode(reader, reader.uint32());
346 };
347
348 /**
349 * Verifies a Shake message.
350 * @function verify
351 * @memberof Shake
352 * @static
353 * @param {Object.<string,*>} message Plain object to verify
354 * @returns {string|null} `null` if valid, otherwise the reason why it is not
355 */
356 Shake.verify = function verify(message) {
357 if (typeof message !== "object" || message === null)
358 return "object expected";
359 if (message.isDuplicate != null && message.hasOwnProperty("isDuplicate"))
360 if (typeof message.isDuplicate !== "boolean")
361 return "isDuplicate: boolean expected";
362 return null;
363 };
364
365 /**
366 * Creates a Shake message from a plain object. Also converts values to their respective internal types.
367 * @function fromObject
368 * @memberof Shake
369 * @static
370 * @param {Object.<string,*>} object Plain object
371 * @returns {Shake} Shake
372 */
373 Shake.fromObject = function fromObject(object) {
374 if (object instanceof $root.Shake)
375 return object;
376 let message = new $root.Shake();
377 if (object.isDuplicate != null)
378 message.isDuplicate = Boolean(object.isDuplicate);
379 return message;
380 };
381
382 /**
383 * Creates a plain object from a Shake message. Also converts values to other types if specified.
384 * @function toObject
385 * @memberof Shake
386 * @static
387 * @param {Shake} message Shake
388 * @param {$protobuf.IConversionOptions} [options] Conversion options
389 * @returns {Object.<string,*>} Plain object
390 */
391 Shake.toObject = function toObject(message, options) {
392 if (!options)
393 options = {};
394 let object = {};
395 if (options.defaults)
396 object.isDuplicate = false;
397 if (message.isDuplicate != null && message.hasOwnProperty("isDuplicate"))
398 object.isDuplicate = message.isDuplicate;
399 return object;
400 };
401
402 /**
403 * Converts this Shake to JSON.
404 * @function toJSON
405 * @memberof Shake
406 * @instance
407 * @returns {Object.<string,*>} JSON object
408 */
409 Shake.prototype.toJSON = function toJSON() {
410 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
411 };
412
413 return Shake;
414})();
415
416export const Link = $root.Link = (() => {
417
418 /**
419 * Properties of a Link.
420 * @exports ILink
421 * @interface ILink
422 * @property {Link.ITBS|null} [tbs] Link tbs
423 * @property {Uint8Array|null} [signature] Link signature
424 */
425
426 /**
427 * Constructs a new Link.
428 * @exports Link
429 * @classdesc Represents a Link.
430 * @implements ILink
431 * @constructor
432 * @param {ILink=} [properties] Properties to set
433 */
434 function Link(properties) {
435 if (properties)
436 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
437 if (properties[keys[i]] != null)
438 this[keys[i]] = properties[keys[i]];
439 }
440
441 /**
442 * Link tbs.
443 * @member {Link.ITBS|null|undefined} tbs
444 * @memberof Link
445 * @instance
446 */
447 Link.prototype.tbs = null;
448
449 /**
450 * Link signature.
451 * @member {Uint8Array} signature
452 * @memberof Link
453 * @instance
454 */
455 Link.prototype.signature = $util.newBuffer([]);
456
457 /**
458 * Creates a new Link instance using the specified properties.
459 * @function create
460 * @memberof Link
461 * @static
462 * @param {ILink=} [properties] Properties to set
463 * @returns {Link} Link instance
464 */
465 Link.create = function create(properties) {
466 return new Link(properties);
467 };
468
469 /**
470 * Encodes the specified Link message. Does not implicitly {@link Link.verify|verify} messages.
471 * @function encode
472 * @memberof Link
473 * @static
474 * @param {ILink} message Link message or plain object to encode
475 * @param {$protobuf.Writer} [writer] Writer to encode to
476 * @returns {$protobuf.Writer} Writer
477 */
478 Link.encode = function encode(message, writer) {
479 if (!writer)
480 writer = $Writer.create();
481 if (message.tbs != null && message.hasOwnProperty("tbs"))
482 $root.Link.TBS.encode(message.tbs, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
483 if (message.signature != null && message.hasOwnProperty("signature"))
484 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.signature);
485 return writer;
486 };
487
488 /**
489 * Encodes the specified Link message, length delimited. Does not implicitly {@link Link.verify|verify} messages.
490 * @function encodeDelimited
491 * @memberof Link
492 * @static
493 * @param {ILink} message Link message or plain object to encode
494 * @param {$protobuf.Writer} [writer] Writer to encode to
495 * @returns {$protobuf.Writer} Writer
496 */
497 Link.encodeDelimited = function encodeDelimited(message, writer) {
498 return this.encode(message, writer).ldelim();
499 };
500
501 /**
502 * Decodes a Link message from the specified reader or buffer.
503 * @function decode
504 * @memberof Link
505 * @static
506 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
507 * @param {number} [length] Message length if known beforehand
508 * @returns {Link} Link
509 * @throws {Error} If the payload is not a reader or valid buffer
510 * @throws {$protobuf.util.ProtocolError} If required fields are missing
511 */
512 Link.decode = function decode(reader, length) {
513 if (!(reader instanceof $Reader))
514 reader = $Reader.create(reader);
515 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Link();
516 while (reader.pos < end) {
517 let tag = reader.uint32();
518 switch (tag >>> 3) {
519 case 1:
520 message.tbs = $root.Link.TBS.decode(reader, reader.uint32());
521 break;
522 case 2:
523 message.signature = reader.bytes();
524 break;
525 default:
526 reader.skipType(tag & 7);
527 break;
528 }
529 }
530 return message;
531 };
532
533 /**
534 * Decodes a Link message from the specified reader or buffer, length delimited.
535 * @function decodeDelimited
536 * @memberof Link
537 * @static
538 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
539 * @returns {Link} Link
540 * @throws {Error} If the payload is not a reader or valid buffer
541 * @throws {$protobuf.util.ProtocolError} If required fields are missing
542 */
543 Link.decodeDelimited = function decodeDelimited(reader) {
544 if (!(reader instanceof $Reader))
545 reader = new $Reader(reader);
546 return this.decode(reader, reader.uint32());
547 };
548
549 /**
550 * Verifies a Link message.
551 * @function verify
552 * @memberof Link
553 * @static
554 * @param {Object.<string,*>} message Plain object to verify
555 * @returns {string|null} `null` if valid, otherwise the reason why it is not
556 */
557 Link.verify = function verify(message) {
558 if (typeof message !== "object" || message === null)
559 return "object expected";
560 if (message.tbs != null && message.hasOwnProperty("tbs")) {
561 let error = $root.Link.TBS.verify(message.tbs);
562 if (error)
563 return "tbs." + error;
564 }
565 if (message.signature != null && message.hasOwnProperty("signature"))
566 if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature)))
567 return "signature: buffer expected";
568 return null;
569 };
570
571 /**
572 * Creates a Link message from a plain object. Also converts values to their respective internal types.
573 * @function fromObject
574 * @memberof Link
575 * @static
576 * @param {Object.<string,*>} object Plain object
577 * @returns {Link} Link
578 */
579 Link.fromObject = function fromObject(object) {
580 if (object instanceof $root.Link)
581 return object;
582 let message = new $root.Link();
583 if (object.tbs != null) {
584 if (typeof object.tbs !== "object")
585 throw TypeError(".Link.tbs: object expected");
586 message.tbs = $root.Link.TBS.fromObject(object.tbs);
587 }
588 if (object.signature != null)
589 if (typeof object.signature === "string")
590 $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0);
591 else if (object.signature.length)
592 message.signature = object.signature;
593 return message;
594 };
595
596 /**
597 * Creates a plain object from a Link message. Also converts values to other types if specified.
598 * @function toObject
599 * @memberof Link
600 * @static
601 * @param {Link} message Link
602 * @param {$protobuf.IConversionOptions} [options] Conversion options
603 * @returns {Object.<string,*>} Plain object
604 */
605 Link.toObject = function toObject(message, options) {
606 if (!options)
607 options = {};
608 let object = {};
609 if (options.defaults) {
610 object.tbs = null;
611 if (options.bytes === String)
612 object.signature = "";
613 else {
614 object.signature = [];
615 if (options.bytes !== Array)
616 object.signature = $util.newBuffer(object.signature);
617 }
618 }
619 if (message.tbs != null && message.hasOwnProperty("tbs"))
620 object.tbs = $root.Link.TBS.toObject(message.tbs, options);
621 if (message.signature != null && message.hasOwnProperty("signature"))
622 object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature;
623 return object;
624 };
625
626 /**
627 * Converts this Link to JSON.
628 * @function toJSON
629 * @memberof Link
630 * @instance
631 * @returns {Object.<string,*>} JSON object
632 */
633 Link.prototype.toJSON = function toJSON() {
634 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
635 };
636
637 Link.TBS = (function() {
638
639 /**
640 * Properties of a TBS.
641 * @memberof Link
642 * @interface ITBS
643 * @property {Uint8Array|null} [trusteePubKey] TBS trusteePubKey
644 * @property {string|null} [trusteeDisplayName] TBS trusteeDisplayName
645 * @property {number|null} [validFrom] TBS validFrom
646 * @property {number|null} [validTo] TBS validTo
647 * @property {Uint8Array|null} [channelId] TBS channelId
648 */
649
650 /**
651 * Constructs a new TBS.
652 * @memberof Link
653 * @classdesc Represents a TBS.
654 * @implements ITBS
655 * @constructor
656 * @param {Link.ITBS=} [properties] Properties to set
657 */
658 function TBS(properties) {
659 if (properties)
660 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
661 if (properties[keys[i]] != null)
662 this[keys[i]] = properties[keys[i]];
663 }
664
665 /**
666 * TBS trusteePubKey.
667 * @member {Uint8Array} trusteePubKey
668 * @memberof Link.TBS
669 * @instance
670 */
671 TBS.prototype.trusteePubKey = $util.newBuffer([]);
672
673 /**
674 * TBS trusteeDisplayName.
675 * @member {string} trusteeDisplayName
676 * @memberof Link.TBS
677 * @instance
678 */
679 TBS.prototype.trusteeDisplayName = "";
680
681 /**
682 * TBS validFrom.
683 * @member {number} validFrom
684 * @memberof Link.TBS
685 * @instance
686 */
687 TBS.prototype.validFrom = 0;
688
689 /**
690 * TBS validTo.
691 * @member {number} validTo
692 * @memberof Link.TBS
693 * @instance
694 */
695 TBS.prototype.validTo = 0;
696
697 /**
698 * TBS channelId.
699 * @member {Uint8Array} channelId
700 * @memberof Link.TBS
701 * @instance
702 */
703 TBS.prototype.channelId = $util.newBuffer([]);
704
705 /**
706 * Creates a new TBS instance using the specified properties.
707 * @function create
708 * @memberof Link.TBS
709 * @static
710 * @param {Link.ITBS=} [properties] Properties to set
711 * @returns {Link.TBS} TBS instance
712 */
713 TBS.create = function create(properties) {
714 return new TBS(properties);
715 };
716
717 /**
718 * Encodes the specified TBS message. Does not implicitly {@link Link.TBS.verify|verify} messages.
719 * @function encode
720 * @memberof Link.TBS
721 * @static
722 * @param {Link.ITBS} message TBS message or plain object to encode
723 * @param {$protobuf.Writer} [writer] Writer to encode to
724 * @returns {$protobuf.Writer} Writer
725 */
726 TBS.encode = function encode(message, writer) {
727 if (!writer)
728 writer = $Writer.create();
729 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
730 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.trusteePubKey);
731 if (message.trusteeDisplayName != null && message.hasOwnProperty("trusteeDisplayName"))
732 writer.uint32(/* id 2, wireType 2 =*/18).string(message.trusteeDisplayName);
733 if (message.validFrom != null && message.hasOwnProperty("validFrom"))
734 writer.uint32(/* id 4, wireType 1 =*/33).double(message.validFrom);
735 if (message.validTo != null && message.hasOwnProperty("validTo"))
736 writer.uint32(/* id 5, wireType 1 =*/41).double(message.validTo);
737 if (message.channelId != null && message.hasOwnProperty("channelId"))
738 writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.channelId);
739 return writer;
740 };
741
742 /**
743 * Encodes the specified TBS message, length delimited. Does not implicitly {@link Link.TBS.verify|verify} messages.
744 * @function encodeDelimited
745 * @memberof Link.TBS
746 * @static
747 * @param {Link.ITBS} message TBS message or plain object to encode
748 * @param {$protobuf.Writer} [writer] Writer to encode to
749 * @returns {$protobuf.Writer} Writer
750 */
751 TBS.encodeDelimited = function encodeDelimited(message, writer) {
752 return this.encode(message, writer).ldelim();
753 };
754
755 /**
756 * Decodes a TBS message from the specified reader or buffer.
757 * @function decode
758 * @memberof Link.TBS
759 * @static
760 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
761 * @param {number} [length] Message length if known beforehand
762 * @returns {Link.TBS} TBS
763 * @throws {Error} If the payload is not a reader or valid buffer
764 * @throws {$protobuf.util.ProtocolError} If required fields are missing
765 */
766 TBS.decode = function decode(reader, length) {
767 if (!(reader instanceof $Reader))
768 reader = $Reader.create(reader);
769 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Link.TBS();
770 while (reader.pos < end) {
771 let tag = reader.uint32();
772 switch (tag >>> 3) {
773 case 1:
774 message.trusteePubKey = reader.bytes();
775 break;
776 case 2:
777 message.trusteeDisplayName = reader.string();
778 break;
779 case 4:
780 message.validFrom = reader.double();
781 break;
782 case 5:
783 message.validTo = reader.double();
784 break;
785 case 6:
786 message.channelId = reader.bytes();
787 break;
788 default:
789 reader.skipType(tag & 7);
790 break;
791 }
792 }
793 return message;
794 };
795
796 /**
797 * Decodes a TBS message from the specified reader or buffer, length delimited.
798 * @function decodeDelimited
799 * @memberof Link.TBS
800 * @static
801 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
802 * @returns {Link.TBS} TBS
803 * @throws {Error} If the payload is not a reader or valid buffer
804 * @throws {$protobuf.util.ProtocolError} If required fields are missing
805 */
806 TBS.decodeDelimited = function decodeDelimited(reader) {
807 if (!(reader instanceof $Reader))
808 reader = new $Reader(reader);
809 return this.decode(reader, reader.uint32());
810 };
811
812 /**
813 * Verifies a TBS message.
814 * @function verify
815 * @memberof Link.TBS
816 * @static
817 * @param {Object.<string,*>} message Plain object to verify
818 * @returns {string|null} `null` if valid, otherwise the reason why it is not
819 */
820 TBS.verify = function verify(message) {
821 if (typeof message !== "object" || message === null)
822 return "object expected";
823 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
824 if (!(message.trusteePubKey && typeof message.trusteePubKey.length === "number" || $util.isString(message.trusteePubKey)))
825 return "trusteePubKey: buffer expected";
826 if (message.trusteeDisplayName != null && message.hasOwnProperty("trusteeDisplayName"))
827 if (!$util.isString(message.trusteeDisplayName))
828 return "trusteeDisplayName: string expected";
829 if (message.validFrom != null && message.hasOwnProperty("validFrom"))
830 if (typeof message.validFrom !== "number")
831 return "validFrom: number expected";
832 if (message.validTo != null && message.hasOwnProperty("validTo"))
833 if (typeof message.validTo !== "number")
834 return "validTo: number expected";
835 if (message.channelId != null && message.hasOwnProperty("channelId"))
836 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
837 return "channelId: buffer expected";
838 return null;
839 };
840
841 /**
842 * Creates a TBS message from a plain object. Also converts values to their respective internal types.
843 * @function fromObject
844 * @memberof Link.TBS
845 * @static
846 * @param {Object.<string,*>} object Plain object
847 * @returns {Link.TBS} TBS
848 */
849 TBS.fromObject = function fromObject(object) {
850 if (object instanceof $root.Link.TBS)
851 return object;
852 let message = new $root.Link.TBS();
853 if (object.trusteePubKey != null)
854 if (typeof object.trusteePubKey === "string")
855 $util.base64.decode(object.trusteePubKey, message.trusteePubKey = $util.newBuffer($util.base64.length(object.trusteePubKey)), 0);
856 else if (object.trusteePubKey.length)
857 message.trusteePubKey = object.trusteePubKey;
858 if (object.trusteeDisplayName != null)
859 message.trusteeDisplayName = String(object.trusteeDisplayName);
860 if (object.validFrom != null)
861 message.validFrom = Number(object.validFrom);
862 if (object.validTo != null)
863 message.validTo = Number(object.validTo);
864 if (object.channelId != null)
865 if (typeof object.channelId === "string")
866 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
867 else if (object.channelId.length)
868 message.channelId = object.channelId;
869 return message;
870 };
871
872 /**
873 * Creates a plain object from a TBS message. Also converts values to other types if specified.
874 * @function toObject
875 * @memberof Link.TBS
876 * @static
877 * @param {Link.TBS} message TBS
878 * @param {$protobuf.IConversionOptions} [options] Conversion options
879 * @returns {Object.<string,*>} Plain object
880 */
881 TBS.toObject = function toObject(message, options) {
882 if (!options)
883 options = {};
884 let object = {};
885 if (options.defaults) {
886 if (options.bytes === String)
887 object.trusteePubKey = "";
888 else {
889 object.trusteePubKey = [];
890 if (options.bytes !== Array)
891 object.trusteePubKey = $util.newBuffer(object.trusteePubKey);
892 }
893 object.trusteeDisplayName = "";
894 object.validFrom = 0;
895 object.validTo = 0;
896 if (options.bytes === String)
897 object.channelId = "";
898 else {
899 object.channelId = [];
900 if (options.bytes !== Array)
901 object.channelId = $util.newBuffer(object.channelId);
902 }
903 }
904 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
905 object.trusteePubKey = options.bytes === String ? $util.base64.encode(message.trusteePubKey, 0, message.trusteePubKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.trusteePubKey) : message.trusteePubKey;
906 if (message.trusteeDisplayName != null && message.hasOwnProperty("trusteeDisplayName"))
907 object.trusteeDisplayName = message.trusteeDisplayName;
908 if (message.validFrom != null && message.hasOwnProperty("validFrom"))
909 object.validFrom = options.json && !isFinite(message.validFrom) ? String(message.validFrom) : message.validFrom;
910 if (message.validTo != null && message.hasOwnProperty("validTo"))
911 object.validTo = options.json && !isFinite(message.validTo) ? String(message.validTo) : message.validTo;
912 if (message.channelId != null && message.hasOwnProperty("channelId"))
913 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
914 return object;
915 };
916
917 /**
918 * Converts this TBS to JSON.
919 * @function toJSON
920 * @memberof Link.TBS
921 * @instance
922 * @returns {Object.<string,*>} JSON object
923 */
924 TBS.prototype.toJSON = function toJSON() {
925 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
926 };
927
928 return TBS;
929 })();
930
931 return Link;
932})();
933
934export const Invite = $root.Invite = (() => {
935
936 /**
937 * Properties of an Invite.
938 * @exports IInvite
939 * @interface IInvite
940 * @property {Uint8Array|null} [channelPubKey] Invite channelPubKey
941 * @property {string|null} [channelName] Invite channelName
942 * @property {Array.<ILink>|null} [chain] Invite chain
943 */
944
945 /**
946 * Constructs a new Invite.
947 * @exports Invite
948 * @classdesc Represents an Invite.
949 * @implements IInvite
950 * @constructor
951 * @param {IInvite=} [properties] Properties to set
952 */
953 function Invite(properties) {
954 this.chain = [];
955 if (properties)
956 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
957 if (properties[keys[i]] != null)
958 this[keys[i]] = properties[keys[i]];
959 }
960
961 /**
962 * Invite channelPubKey.
963 * @member {Uint8Array} channelPubKey
964 * @memberof Invite
965 * @instance
966 */
967 Invite.prototype.channelPubKey = $util.newBuffer([]);
968
969 /**
970 * Invite channelName.
971 * @member {string} channelName
972 * @memberof Invite
973 * @instance
974 */
975 Invite.prototype.channelName = "";
976
977 /**
978 * Invite chain.
979 * @member {Array.<ILink>} chain
980 * @memberof Invite
981 * @instance
982 */
983 Invite.prototype.chain = $util.emptyArray;
984
985 /**
986 * Creates a new Invite instance using the specified properties.
987 * @function create
988 * @memberof Invite
989 * @static
990 * @param {IInvite=} [properties] Properties to set
991 * @returns {Invite} Invite instance
992 */
993 Invite.create = function create(properties) {
994 return new Invite(properties);
995 };
996
997 /**
998 * Encodes the specified Invite message. Does not implicitly {@link Invite.verify|verify} messages.
999 * @function encode
1000 * @memberof Invite
1001 * @static
1002 * @param {IInvite} message Invite message or plain object to encode
1003 * @param {$protobuf.Writer} [writer] Writer to encode to
1004 * @returns {$protobuf.Writer} Writer
1005 */
1006 Invite.encode = function encode(message, writer) {
1007 if (!writer)
1008 writer = $Writer.create();
1009 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
1010 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelPubKey);
1011 if (message.channelName != null && message.hasOwnProperty("channelName"))
1012 writer.uint32(/* id 2, wireType 2 =*/18).string(message.channelName);
1013 if (message.chain != null && message.chain.length)
1014 for (let i = 0; i < message.chain.length; ++i)
1015 $root.Link.encode(message.chain[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
1016 return writer;
1017 };
1018
1019 /**
1020 * Encodes the specified Invite message, length delimited. Does not implicitly {@link Invite.verify|verify} messages.
1021 * @function encodeDelimited
1022 * @memberof Invite
1023 * @static
1024 * @param {IInvite} message Invite message or plain object to encode
1025 * @param {$protobuf.Writer} [writer] Writer to encode to
1026 * @returns {$protobuf.Writer} Writer
1027 */
1028 Invite.encodeDelimited = function encodeDelimited(message, writer) {
1029 return this.encode(message, writer).ldelim();
1030 };
1031
1032 /**
1033 * Decodes an Invite message from the specified reader or buffer.
1034 * @function decode
1035 * @memberof Invite
1036 * @static
1037 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1038 * @param {number} [length] Message length if known beforehand
1039 * @returns {Invite} Invite
1040 * @throws {Error} If the payload is not a reader or valid buffer
1041 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1042 */
1043 Invite.decode = function decode(reader, length) {
1044 if (!(reader instanceof $Reader))
1045 reader = $Reader.create(reader);
1046 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Invite();
1047 while (reader.pos < end) {
1048 let tag = reader.uint32();
1049 switch (tag >>> 3) {
1050 case 1:
1051 message.channelPubKey = reader.bytes();
1052 break;
1053 case 2:
1054 message.channelName = reader.string();
1055 break;
1056 case 4:
1057 if (!(message.chain && message.chain.length))
1058 message.chain = [];
1059 message.chain.push($root.Link.decode(reader, reader.uint32()));
1060 break;
1061 default:
1062 reader.skipType(tag & 7);
1063 break;
1064 }
1065 }
1066 return message;
1067 };
1068
1069 /**
1070 * Decodes an Invite message from the specified reader or buffer, length delimited.
1071 * @function decodeDelimited
1072 * @memberof Invite
1073 * @static
1074 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1075 * @returns {Invite} Invite
1076 * @throws {Error} If the payload is not a reader or valid buffer
1077 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1078 */
1079 Invite.decodeDelimited = function decodeDelimited(reader) {
1080 if (!(reader instanceof $Reader))
1081 reader = new $Reader(reader);
1082 return this.decode(reader, reader.uint32());
1083 };
1084
1085 /**
1086 * Verifies an Invite message.
1087 * @function verify
1088 * @memberof Invite
1089 * @static
1090 * @param {Object.<string,*>} message Plain object to verify
1091 * @returns {string|null} `null` if valid, otherwise the reason why it is not
1092 */
1093 Invite.verify = function verify(message) {
1094 if (typeof message !== "object" || message === null)
1095 return "object expected";
1096 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
1097 if (!(message.channelPubKey && typeof message.channelPubKey.length === "number" || $util.isString(message.channelPubKey)))
1098 return "channelPubKey: buffer expected";
1099 if (message.channelName != null && message.hasOwnProperty("channelName"))
1100 if (!$util.isString(message.channelName))
1101 return "channelName: string expected";
1102 if (message.chain != null && message.hasOwnProperty("chain")) {
1103 if (!Array.isArray(message.chain))
1104 return "chain: array expected";
1105 for (let i = 0; i < message.chain.length; ++i) {
1106 let error = $root.Link.verify(message.chain[i]);
1107 if (error)
1108 return "chain." + error;
1109 }
1110 }
1111 return null;
1112 };
1113
1114 /**
1115 * Creates an Invite message from a plain object. Also converts values to their respective internal types.
1116 * @function fromObject
1117 * @memberof Invite
1118 * @static
1119 * @param {Object.<string,*>} object Plain object
1120 * @returns {Invite} Invite
1121 */
1122 Invite.fromObject = function fromObject(object) {
1123 if (object instanceof $root.Invite)
1124 return object;
1125 let message = new $root.Invite();
1126 if (object.channelPubKey != null)
1127 if (typeof object.channelPubKey === "string")
1128 $util.base64.decode(object.channelPubKey, message.channelPubKey = $util.newBuffer($util.base64.length(object.channelPubKey)), 0);
1129 else if (object.channelPubKey.length)
1130 message.channelPubKey = object.channelPubKey;
1131 if (object.channelName != null)
1132 message.channelName = String(object.channelName);
1133 if (object.chain) {
1134 if (!Array.isArray(object.chain))
1135 throw TypeError(".Invite.chain: array expected");
1136 message.chain = [];
1137 for (let i = 0; i < object.chain.length; ++i) {
1138 if (typeof object.chain[i] !== "object")
1139 throw TypeError(".Invite.chain: object expected");
1140 message.chain[i] = $root.Link.fromObject(object.chain[i]);
1141 }
1142 }
1143 return message;
1144 };
1145
1146 /**
1147 * Creates a plain object from an Invite message. Also converts values to other types if specified.
1148 * @function toObject
1149 * @memberof Invite
1150 * @static
1151 * @param {Invite} message Invite
1152 * @param {$protobuf.IConversionOptions} [options] Conversion options
1153 * @returns {Object.<string,*>} Plain object
1154 */
1155 Invite.toObject = function toObject(message, options) {
1156 if (!options)
1157 options = {};
1158 let object = {};
1159 if (options.arrays || options.defaults)
1160 object.chain = [];
1161 if (options.defaults) {
1162 if (options.bytes === String)
1163 object.channelPubKey = "";
1164 else {
1165 object.channelPubKey = [];
1166 if (options.bytes !== Array)
1167 object.channelPubKey = $util.newBuffer(object.channelPubKey);
1168 }
1169 object.channelName = "";
1170 }
1171 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
1172 object.channelPubKey = options.bytes === String ? $util.base64.encode(message.channelPubKey, 0, message.channelPubKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelPubKey) : message.channelPubKey;
1173 if (message.channelName != null && message.hasOwnProperty("channelName"))
1174 object.channelName = message.channelName;
1175 if (message.chain && message.chain.length) {
1176 object.chain = [];
1177 for (let j = 0; j < message.chain.length; ++j)
1178 object.chain[j] = $root.Link.toObject(message.chain[j], options);
1179 }
1180 return object;
1181 };
1182
1183 /**
1184 * Converts this Invite to JSON.
1185 * @function toJSON
1186 * @memberof Invite
1187 * @instance
1188 * @returns {Object.<string,*>} JSON object
1189 */
1190 Invite.prototype.toJSON = function toJSON() {
1191 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1192 };
1193
1194 return Invite;
1195})();
1196
1197export const EncryptedInvite = $root.EncryptedInvite = (() => {
1198
1199 /**
1200 * Properties of an EncryptedInvite.
1201 * @exports IEncryptedInvite
1202 * @interface IEncryptedInvite
1203 * @property {Uint8Array|null} [requestId] EncryptedInvite requestId
1204 * @property {Uint8Array|null} [box] EncryptedInvite box
1205 */
1206
1207 /**
1208 * Constructs a new EncryptedInvite.
1209 * @exports EncryptedInvite
1210 * @classdesc Represents an EncryptedInvite.
1211 * @implements IEncryptedInvite
1212 * @constructor
1213 * @param {IEncryptedInvite=} [properties] Properties to set
1214 */
1215 function EncryptedInvite(properties) {
1216 if (properties)
1217 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1218 if (properties[keys[i]] != null)
1219 this[keys[i]] = properties[keys[i]];
1220 }
1221
1222 /**
1223 * EncryptedInvite requestId.
1224 * @member {Uint8Array} requestId
1225 * @memberof EncryptedInvite
1226 * @instance
1227 */
1228 EncryptedInvite.prototype.requestId = $util.newBuffer([]);
1229
1230 /**
1231 * EncryptedInvite box.
1232 * @member {Uint8Array} box
1233 * @memberof EncryptedInvite
1234 * @instance
1235 */
1236 EncryptedInvite.prototype.box = $util.newBuffer([]);
1237
1238 /**
1239 * Creates a new EncryptedInvite instance using the specified properties.
1240 * @function create
1241 * @memberof EncryptedInvite
1242 * @static
1243 * @param {IEncryptedInvite=} [properties] Properties to set
1244 * @returns {EncryptedInvite} EncryptedInvite instance
1245 */
1246 EncryptedInvite.create = function create(properties) {
1247 return new EncryptedInvite(properties);
1248 };
1249
1250 /**
1251 * Encodes the specified EncryptedInvite message. Does not implicitly {@link EncryptedInvite.verify|verify} messages.
1252 * @function encode
1253 * @memberof EncryptedInvite
1254 * @static
1255 * @param {IEncryptedInvite} message EncryptedInvite message or plain object to encode
1256 * @param {$protobuf.Writer} [writer] Writer to encode to
1257 * @returns {$protobuf.Writer} Writer
1258 */
1259 EncryptedInvite.encode = function encode(message, writer) {
1260 if (!writer)
1261 writer = $Writer.create();
1262 if (message.requestId != null && message.hasOwnProperty("requestId"))
1263 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.requestId);
1264 if (message.box != null && message.hasOwnProperty("box"))
1265 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.box);
1266 return writer;
1267 };
1268
1269 /**
1270 * Encodes the specified EncryptedInvite message, length delimited. Does not implicitly {@link EncryptedInvite.verify|verify} messages.
1271 * @function encodeDelimited
1272 * @memberof EncryptedInvite
1273 * @static
1274 * @param {IEncryptedInvite} message EncryptedInvite message or plain object to encode
1275 * @param {$protobuf.Writer} [writer] Writer to encode to
1276 * @returns {$protobuf.Writer} Writer
1277 */
1278 EncryptedInvite.encodeDelimited = function encodeDelimited(message, writer) {
1279 return this.encode(message, writer).ldelim();
1280 };
1281
1282 /**
1283 * Decodes an EncryptedInvite message from the specified reader or buffer.
1284 * @function decode
1285 * @memberof EncryptedInvite
1286 * @static
1287 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1288 * @param {number} [length] Message length if known beforehand
1289 * @returns {EncryptedInvite} EncryptedInvite
1290 * @throws {Error} If the payload is not a reader or valid buffer
1291 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1292 */
1293 EncryptedInvite.decode = function decode(reader, length) {
1294 if (!(reader instanceof $Reader))
1295 reader = $Reader.create(reader);
1296 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.EncryptedInvite();
1297 while (reader.pos < end) {
1298 let tag = reader.uint32();
1299 switch (tag >>> 3) {
1300 case 1:
1301 message.requestId = reader.bytes();
1302 break;
1303 case 2:
1304 message.box = reader.bytes();
1305 break;
1306 default:
1307 reader.skipType(tag & 7);
1308 break;
1309 }
1310 }
1311 return message;
1312 };
1313
1314 /**
1315 * Decodes an EncryptedInvite message from the specified reader or buffer, length delimited.
1316 * @function decodeDelimited
1317 * @memberof EncryptedInvite
1318 * @static
1319 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1320 * @returns {EncryptedInvite} EncryptedInvite
1321 * @throws {Error} If the payload is not a reader or valid buffer
1322 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1323 */
1324 EncryptedInvite.decodeDelimited = function decodeDelimited(reader) {
1325 if (!(reader instanceof $Reader))
1326 reader = new $Reader(reader);
1327 return this.decode(reader, reader.uint32());
1328 };
1329
1330 /**
1331 * Verifies an EncryptedInvite message.
1332 * @function verify
1333 * @memberof EncryptedInvite
1334 * @static
1335 * @param {Object.<string,*>} message Plain object to verify
1336 * @returns {string|null} `null` if valid, otherwise the reason why it is not
1337 */
1338 EncryptedInvite.verify = function verify(message) {
1339 if (typeof message !== "object" || message === null)
1340 return "object expected";
1341 if (message.requestId != null && message.hasOwnProperty("requestId"))
1342 if (!(message.requestId && typeof message.requestId.length === "number" || $util.isString(message.requestId)))
1343 return "requestId: buffer expected";
1344 if (message.box != null && message.hasOwnProperty("box"))
1345 if (!(message.box && typeof message.box.length === "number" || $util.isString(message.box)))
1346 return "box: buffer expected";
1347 return null;
1348 };
1349
1350 /**
1351 * Creates an EncryptedInvite message from a plain object. Also converts values to their respective internal types.
1352 * @function fromObject
1353 * @memberof EncryptedInvite
1354 * @static
1355 * @param {Object.<string,*>} object Plain object
1356 * @returns {EncryptedInvite} EncryptedInvite
1357 */
1358 EncryptedInvite.fromObject = function fromObject(object) {
1359 if (object instanceof $root.EncryptedInvite)
1360 return object;
1361 let message = new $root.EncryptedInvite();
1362 if (object.requestId != null)
1363 if (typeof object.requestId === "string")
1364 $util.base64.decode(object.requestId, message.requestId = $util.newBuffer($util.base64.length(object.requestId)), 0);
1365 else if (object.requestId.length)
1366 message.requestId = object.requestId;
1367 if (object.box != null)
1368 if (typeof object.box === "string")
1369 $util.base64.decode(object.box, message.box = $util.newBuffer($util.base64.length(object.box)), 0);
1370 else if (object.box.length)
1371 message.box = object.box;
1372 return message;
1373 };
1374
1375 /**
1376 * Creates a plain object from an EncryptedInvite message. Also converts values to other types if specified.
1377 * @function toObject
1378 * @memberof EncryptedInvite
1379 * @static
1380 * @param {EncryptedInvite} message EncryptedInvite
1381 * @param {$protobuf.IConversionOptions} [options] Conversion options
1382 * @returns {Object.<string,*>} Plain object
1383 */
1384 EncryptedInvite.toObject = function toObject(message, options) {
1385 if (!options)
1386 options = {};
1387 let object = {};
1388 if (options.defaults) {
1389 if (options.bytes === String)
1390 object.requestId = "";
1391 else {
1392 object.requestId = [];
1393 if (options.bytes !== Array)
1394 object.requestId = $util.newBuffer(object.requestId);
1395 }
1396 if (options.bytes === String)
1397 object.box = "";
1398 else {
1399 object.box = [];
1400 if (options.bytes !== Array)
1401 object.box = $util.newBuffer(object.box);
1402 }
1403 }
1404 if (message.requestId != null && message.hasOwnProperty("requestId"))
1405 object.requestId = options.bytes === String ? $util.base64.encode(message.requestId, 0, message.requestId.length) : options.bytes === Array ? Array.prototype.slice.call(message.requestId) : message.requestId;
1406 if (message.box != null && message.hasOwnProperty("box"))
1407 object.box = options.bytes === String ? $util.base64.encode(message.box, 0, message.box.length) : options.bytes === Array ? Array.prototype.slice.call(message.box) : message.box;
1408 return object;
1409 };
1410
1411 /**
1412 * Converts this EncryptedInvite to JSON.
1413 * @function toJSON
1414 * @memberof EncryptedInvite
1415 * @instance
1416 * @returns {Object.<string,*>} JSON object
1417 */
1418 EncryptedInvite.prototype.toJSON = function toJSON() {
1419 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1420 };
1421
1422 return EncryptedInvite;
1423})();
1424
1425export const InviteRequest = $root.InviteRequest = (() => {
1426
1427 /**
1428 * Properties of an InviteRequest.
1429 * @exports IInviteRequest
1430 * @interface IInviteRequest
1431 * @property {Uint8Array|null} [peerId] InviteRequest peerId
1432 * @property {Uint8Array|null} [trusteePubKey] InviteRequest trusteePubKey
1433 * @property {Uint8Array|null} [boxPubKey] InviteRequest boxPubKey
1434 */
1435
1436 /**
1437 * Constructs a new InviteRequest.
1438 * @exports InviteRequest
1439 * @classdesc Represents an InviteRequest.
1440 * @implements IInviteRequest
1441 * @constructor
1442 * @param {IInviteRequest=} [properties] Properties to set
1443 */
1444 function InviteRequest(properties) {
1445 if (properties)
1446 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1447 if (properties[keys[i]] != null)
1448 this[keys[i]] = properties[keys[i]];
1449 }
1450
1451 /**
1452 * InviteRequest peerId.
1453 * @member {Uint8Array} peerId
1454 * @memberof InviteRequest
1455 * @instance
1456 */
1457 InviteRequest.prototype.peerId = $util.newBuffer([]);
1458
1459 /**
1460 * InviteRequest trusteePubKey.
1461 * @member {Uint8Array} trusteePubKey
1462 * @memberof InviteRequest
1463 * @instance
1464 */
1465 InviteRequest.prototype.trusteePubKey = $util.newBuffer([]);
1466
1467 /**
1468 * InviteRequest boxPubKey.
1469 * @member {Uint8Array} boxPubKey
1470 * @memberof InviteRequest
1471 * @instance
1472 */
1473 InviteRequest.prototype.boxPubKey = $util.newBuffer([]);
1474
1475 /**
1476 * Creates a new InviteRequest instance using the specified properties.
1477 * @function create
1478 * @memberof InviteRequest
1479 * @static
1480 * @param {IInviteRequest=} [properties] Properties to set
1481 * @returns {InviteRequest} InviteRequest instance
1482 */
1483 InviteRequest.create = function create(properties) {
1484 return new InviteRequest(properties);
1485 };
1486
1487 /**
1488 * Encodes the specified InviteRequest message. Does not implicitly {@link InviteRequest.verify|verify} messages.
1489 * @function encode
1490 * @memberof InviteRequest
1491 * @static
1492 * @param {IInviteRequest} message InviteRequest message or plain object to encode
1493 * @param {$protobuf.Writer} [writer] Writer to encode to
1494 * @returns {$protobuf.Writer} Writer
1495 */
1496 InviteRequest.encode = function encode(message, writer) {
1497 if (!writer)
1498 writer = $Writer.create();
1499 if (message.peerId != null && message.hasOwnProperty("peerId"))
1500 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.peerId);
1501 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
1502 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.trusteePubKey);
1503 if (message.boxPubKey != null && message.hasOwnProperty("boxPubKey"))
1504 writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.boxPubKey);
1505 return writer;
1506 };
1507
1508 /**
1509 * Encodes the specified InviteRequest message, length delimited. Does not implicitly {@link InviteRequest.verify|verify} messages.
1510 * @function encodeDelimited
1511 * @memberof InviteRequest
1512 * @static
1513 * @param {IInviteRequest} message InviteRequest message or plain object to encode
1514 * @param {$protobuf.Writer} [writer] Writer to encode to
1515 * @returns {$protobuf.Writer} Writer
1516 */
1517 InviteRequest.encodeDelimited = function encodeDelimited(message, writer) {
1518 return this.encode(message, writer).ldelim();
1519 };
1520
1521 /**
1522 * Decodes an InviteRequest message from the specified reader or buffer.
1523 * @function decode
1524 * @memberof InviteRequest
1525 * @static
1526 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1527 * @param {number} [length] Message length if known beforehand
1528 * @returns {InviteRequest} InviteRequest
1529 * @throws {Error} If the payload is not a reader or valid buffer
1530 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1531 */
1532 InviteRequest.decode = function decode(reader, length) {
1533 if (!(reader instanceof $Reader))
1534 reader = $Reader.create(reader);
1535 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.InviteRequest();
1536 while (reader.pos < end) {
1537 let tag = reader.uint32();
1538 switch (tag >>> 3) {
1539 case 1:
1540 message.peerId = reader.bytes();
1541 break;
1542 case 2:
1543 message.trusteePubKey = reader.bytes();
1544 break;
1545 case 3:
1546 message.boxPubKey = reader.bytes();
1547 break;
1548 default:
1549 reader.skipType(tag & 7);
1550 break;
1551 }
1552 }
1553 return message;
1554 };
1555
1556 /**
1557 * Decodes an InviteRequest message from the specified reader or buffer, length delimited.
1558 * @function decodeDelimited
1559 * @memberof InviteRequest
1560 * @static
1561 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1562 * @returns {InviteRequest} InviteRequest
1563 * @throws {Error} If the payload is not a reader or valid buffer
1564 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1565 */
1566 InviteRequest.decodeDelimited = function decodeDelimited(reader) {
1567 if (!(reader instanceof $Reader))
1568 reader = new $Reader(reader);
1569 return this.decode(reader, reader.uint32());
1570 };
1571
1572 /**
1573 * Verifies an InviteRequest message.
1574 * @function verify
1575 * @memberof InviteRequest
1576 * @static
1577 * @param {Object.<string,*>} message Plain object to verify
1578 * @returns {string|null} `null` if valid, otherwise the reason why it is not
1579 */
1580 InviteRequest.verify = function verify(message) {
1581 if (typeof message !== "object" || message === null)
1582 return "object expected";
1583 if (message.peerId != null && message.hasOwnProperty("peerId"))
1584 if (!(message.peerId && typeof message.peerId.length === "number" || $util.isString(message.peerId)))
1585 return "peerId: buffer expected";
1586 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
1587 if (!(message.trusteePubKey && typeof message.trusteePubKey.length === "number" || $util.isString(message.trusteePubKey)))
1588 return "trusteePubKey: buffer expected";
1589 if (message.boxPubKey != null && message.hasOwnProperty("boxPubKey"))
1590 if (!(message.boxPubKey && typeof message.boxPubKey.length === "number" || $util.isString(message.boxPubKey)))
1591 return "boxPubKey: buffer expected";
1592 return null;
1593 };
1594
1595 /**
1596 * Creates an InviteRequest message from a plain object. Also converts values to their respective internal types.
1597 * @function fromObject
1598 * @memberof InviteRequest
1599 * @static
1600 * @param {Object.<string,*>} object Plain object
1601 * @returns {InviteRequest} InviteRequest
1602 */
1603 InviteRequest.fromObject = function fromObject(object) {
1604 if (object instanceof $root.InviteRequest)
1605 return object;
1606 let message = new $root.InviteRequest();
1607 if (object.peerId != null)
1608 if (typeof object.peerId === "string")
1609 $util.base64.decode(object.peerId, message.peerId = $util.newBuffer($util.base64.length(object.peerId)), 0);
1610 else if (object.peerId.length)
1611 message.peerId = object.peerId;
1612 if (object.trusteePubKey != null)
1613 if (typeof object.trusteePubKey === "string")
1614 $util.base64.decode(object.trusteePubKey, message.trusteePubKey = $util.newBuffer($util.base64.length(object.trusteePubKey)), 0);
1615 else if (object.trusteePubKey.length)
1616 message.trusteePubKey = object.trusteePubKey;
1617 if (object.boxPubKey != null)
1618 if (typeof object.boxPubKey === "string")
1619 $util.base64.decode(object.boxPubKey, message.boxPubKey = $util.newBuffer($util.base64.length(object.boxPubKey)), 0);
1620 else if (object.boxPubKey.length)
1621 message.boxPubKey = object.boxPubKey;
1622 return message;
1623 };
1624
1625 /**
1626 * Creates a plain object from an InviteRequest message. Also converts values to other types if specified.
1627 * @function toObject
1628 * @memberof InviteRequest
1629 * @static
1630 * @param {InviteRequest} message InviteRequest
1631 * @param {$protobuf.IConversionOptions} [options] Conversion options
1632 * @returns {Object.<string,*>} Plain object
1633 */
1634 InviteRequest.toObject = function toObject(message, options) {
1635 if (!options)
1636 options = {};
1637 let object = {};
1638 if (options.defaults) {
1639 if (options.bytes === String)
1640 object.peerId = "";
1641 else {
1642 object.peerId = [];
1643 if (options.bytes !== Array)
1644 object.peerId = $util.newBuffer(object.peerId);
1645 }
1646 if (options.bytes === String)
1647 object.trusteePubKey = "";
1648 else {
1649 object.trusteePubKey = [];
1650 if (options.bytes !== Array)
1651 object.trusteePubKey = $util.newBuffer(object.trusteePubKey);
1652 }
1653 if (options.bytes === String)
1654 object.boxPubKey = "";
1655 else {
1656 object.boxPubKey = [];
1657 if (options.bytes !== Array)
1658 object.boxPubKey = $util.newBuffer(object.boxPubKey);
1659 }
1660 }
1661 if (message.peerId != null && message.hasOwnProperty("peerId"))
1662 object.peerId = options.bytes === String ? $util.base64.encode(message.peerId, 0, message.peerId.length) : options.bytes === Array ? Array.prototype.slice.call(message.peerId) : message.peerId;
1663 if (message.trusteePubKey != null && message.hasOwnProperty("trusteePubKey"))
1664 object.trusteePubKey = options.bytes === String ? $util.base64.encode(message.trusteePubKey, 0, message.trusteePubKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.trusteePubKey) : message.trusteePubKey;
1665 if (message.boxPubKey != null && message.hasOwnProperty("boxPubKey"))
1666 object.boxPubKey = options.bytes === String ? $util.base64.encode(message.boxPubKey, 0, message.boxPubKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.boxPubKey) : message.boxPubKey;
1667 return object;
1668 };
1669
1670 /**
1671 * Converts this InviteRequest to JSON.
1672 * @function toJSON
1673 * @memberof InviteRequest
1674 * @instance
1675 * @returns {Object.<string,*>} JSON object
1676 */
1677 InviteRequest.prototype.toJSON = function toJSON() {
1678 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1679 };
1680
1681 return InviteRequest;
1682})();
1683
1684export const ChannelMessage = $root.ChannelMessage = (() => {
1685
1686 /**
1687 * Properties of a ChannelMessage.
1688 * @exports IChannelMessage
1689 * @interface IChannelMessage
1690 * @property {Uint8Array|null} [channelId] ChannelMessage channelId
1691 * @property {Array.<Uint8Array>|null} [parents] ChannelMessage parents
1692 * @property {number|Long|null} [height] ChannelMessage height
1693 * @property {Uint8Array|null} [nonce] ChannelMessage nonce
1694 * @property {Uint8Array|null} [encryptedContent] ChannelMessage encryptedContent
1695 */
1696
1697 /**
1698 * Constructs a new ChannelMessage.
1699 * @exports ChannelMessage
1700 * @classdesc Represents a ChannelMessage.
1701 * @implements IChannelMessage
1702 * @constructor
1703 * @param {IChannelMessage=} [properties] Properties to set
1704 */
1705 function ChannelMessage(properties) {
1706 this.parents = [];
1707 if (properties)
1708 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
1709 if (properties[keys[i]] != null)
1710 this[keys[i]] = properties[keys[i]];
1711 }
1712
1713 /**
1714 * ChannelMessage channelId.
1715 * @member {Uint8Array} channelId
1716 * @memberof ChannelMessage
1717 * @instance
1718 */
1719 ChannelMessage.prototype.channelId = $util.newBuffer([]);
1720
1721 /**
1722 * ChannelMessage parents.
1723 * @member {Array.<Uint8Array>} parents
1724 * @memberof ChannelMessage
1725 * @instance
1726 */
1727 ChannelMessage.prototype.parents = $util.emptyArray;
1728
1729 /**
1730 * ChannelMessage height.
1731 * @member {number|Long} height
1732 * @memberof ChannelMessage
1733 * @instance
1734 */
1735 ChannelMessage.prototype.height = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
1736
1737 /**
1738 * ChannelMessage nonce.
1739 * @member {Uint8Array} nonce
1740 * @memberof ChannelMessage
1741 * @instance
1742 */
1743 ChannelMessage.prototype.nonce = $util.newBuffer([]);
1744
1745 /**
1746 * ChannelMessage encryptedContent.
1747 * @member {Uint8Array} encryptedContent
1748 * @memberof ChannelMessage
1749 * @instance
1750 */
1751 ChannelMessage.prototype.encryptedContent = $util.newBuffer([]);
1752
1753 /**
1754 * Creates a new ChannelMessage instance using the specified properties.
1755 * @function create
1756 * @memberof ChannelMessage
1757 * @static
1758 * @param {IChannelMessage=} [properties] Properties to set
1759 * @returns {ChannelMessage} ChannelMessage instance
1760 */
1761 ChannelMessage.create = function create(properties) {
1762 return new ChannelMessage(properties);
1763 };
1764
1765 /**
1766 * Encodes the specified ChannelMessage message. Does not implicitly {@link ChannelMessage.verify|verify} messages.
1767 * @function encode
1768 * @memberof ChannelMessage
1769 * @static
1770 * @param {IChannelMessage} message ChannelMessage message or plain object to encode
1771 * @param {$protobuf.Writer} [writer] Writer to encode to
1772 * @returns {$protobuf.Writer} Writer
1773 */
1774 ChannelMessage.encode = function encode(message, writer) {
1775 if (!writer)
1776 writer = $Writer.create();
1777 if (message.channelId != null && message.hasOwnProperty("channelId"))
1778 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
1779 if (message.parents != null && message.parents.length)
1780 for (let i = 0; i < message.parents.length; ++i)
1781 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.parents[i]);
1782 if (message.height != null && message.hasOwnProperty("height"))
1783 writer.uint32(/* id 3, wireType 0 =*/24).int64(message.height);
1784 if (message.nonce != null && message.hasOwnProperty("nonce"))
1785 writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.nonce);
1786 if (message.encryptedContent != null && message.hasOwnProperty("encryptedContent"))
1787 writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.encryptedContent);
1788 return writer;
1789 };
1790
1791 /**
1792 * Encodes the specified ChannelMessage message, length delimited. Does not implicitly {@link ChannelMessage.verify|verify} messages.
1793 * @function encodeDelimited
1794 * @memberof ChannelMessage
1795 * @static
1796 * @param {IChannelMessage} message ChannelMessage message or plain object to encode
1797 * @param {$protobuf.Writer} [writer] Writer to encode to
1798 * @returns {$protobuf.Writer} Writer
1799 */
1800 ChannelMessage.encodeDelimited = function encodeDelimited(message, writer) {
1801 return this.encode(message, writer).ldelim();
1802 };
1803
1804 /**
1805 * Decodes a ChannelMessage message from the specified reader or buffer.
1806 * @function decode
1807 * @memberof ChannelMessage
1808 * @static
1809 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1810 * @param {number} [length] Message length if known beforehand
1811 * @returns {ChannelMessage} ChannelMessage
1812 * @throws {Error} If the payload is not a reader or valid buffer
1813 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1814 */
1815 ChannelMessage.decode = function decode(reader, length) {
1816 if (!(reader instanceof $Reader))
1817 reader = $Reader.create(reader);
1818 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage();
1819 while (reader.pos < end) {
1820 let tag = reader.uint32();
1821 switch (tag >>> 3) {
1822 case 1:
1823 message.channelId = reader.bytes();
1824 break;
1825 case 2:
1826 if (!(message.parents && message.parents.length))
1827 message.parents = [];
1828 message.parents.push(reader.bytes());
1829 break;
1830 case 3:
1831 message.height = reader.int64();
1832 break;
1833 case 4:
1834 message.nonce = reader.bytes();
1835 break;
1836 case 5:
1837 message.encryptedContent = reader.bytes();
1838 break;
1839 default:
1840 reader.skipType(tag & 7);
1841 break;
1842 }
1843 }
1844 return message;
1845 };
1846
1847 /**
1848 * Decodes a ChannelMessage message from the specified reader or buffer, length delimited.
1849 * @function decodeDelimited
1850 * @memberof ChannelMessage
1851 * @static
1852 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
1853 * @returns {ChannelMessage} ChannelMessage
1854 * @throws {Error} If the payload is not a reader or valid buffer
1855 * @throws {$protobuf.util.ProtocolError} If required fields are missing
1856 */
1857 ChannelMessage.decodeDelimited = function decodeDelimited(reader) {
1858 if (!(reader instanceof $Reader))
1859 reader = new $Reader(reader);
1860 return this.decode(reader, reader.uint32());
1861 };
1862
1863 /**
1864 * Verifies a ChannelMessage message.
1865 * @function verify
1866 * @memberof ChannelMessage
1867 * @static
1868 * @param {Object.<string,*>} message Plain object to verify
1869 * @returns {string|null} `null` if valid, otherwise the reason why it is not
1870 */
1871 ChannelMessage.verify = function verify(message) {
1872 if (typeof message !== "object" || message === null)
1873 return "object expected";
1874 if (message.channelId != null && message.hasOwnProperty("channelId"))
1875 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
1876 return "channelId: buffer expected";
1877 if (message.parents != null && message.hasOwnProperty("parents")) {
1878 if (!Array.isArray(message.parents))
1879 return "parents: array expected";
1880 for (let i = 0; i < message.parents.length; ++i)
1881 if (!(message.parents[i] && typeof message.parents[i].length === "number" || $util.isString(message.parents[i])))
1882 return "parents: buffer[] expected";
1883 }
1884 if (message.height != null && message.hasOwnProperty("height"))
1885 if (!$util.isInteger(message.height) && !(message.height && $util.isInteger(message.height.low) && $util.isInteger(message.height.high)))
1886 return "height: integer|Long expected";
1887 if (message.nonce != null && message.hasOwnProperty("nonce"))
1888 if (!(message.nonce && typeof message.nonce.length === "number" || $util.isString(message.nonce)))
1889 return "nonce: buffer expected";
1890 if (message.encryptedContent != null && message.hasOwnProperty("encryptedContent"))
1891 if (!(message.encryptedContent && typeof message.encryptedContent.length === "number" || $util.isString(message.encryptedContent)))
1892 return "encryptedContent: buffer expected";
1893 return null;
1894 };
1895
1896 /**
1897 * Creates a ChannelMessage message from a plain object. Also converts values to their respective internal types.
1898 * @function fromObject
1899 * @memberof ChannelMessage
1900 * @static
1901 * @param {Object.<string,*>} object Plain object
1902 * @returns {ChannelMessage} ChannelMessage
1903 */
1904 ChannelMessage.fromObject = function fromObject(object) {
1905 if (object instanceof $root.ChannelMessage)
1906 return object;
1907 let message = new $root.ChannelMessage();
1908 if (object.channelId != null)
1909 if (typeof object.channelId === "string")
1910 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
1911 else if (object.channelId.length)
1912 message.channelId = object.channelId;
1913 if (object.parents) {
1914 if (!Array.isArray(object.parents))
1915 throw TypeError(".ChannelMessage.parents: array expected");
1916 message.parents = [];
1917 for (let i = 0; i < object.parents.length; ++i)
1918 if (typeof object.parents[i] === "string")
1919 $util.base64.decode(object.parents[i], message.parents[i] = $util.newBuffer($util.base64.length(object.parents[i])), 0);
1920 else if (object.parents[i].length)
1921 message.parents[i] = object.parents[i];
1922 }
1923 if (object.height != null)
1924 if ($util.Long)
1925 (message.height = $util.Long.fromValue(object.height)).unsigned = false;
1926 else if (typeof object.height === "string")
1927 message.height = parseInt(object.height, 10);
1928 else if (typeof object.height === "number")
1929 message.height = object.height;
1930 else if (typeof object.height === "object")
1931 message.height = new $util.LongBits(object.height.low >>> 0, object.height.high >>> 0).toNumber();
1932 if (object.nonce != null)
1933 if (typeof object.nonce === "string")
1934 $util.base64.decode(object.nonce, message.nonce = $util.newBuffer($util.base64.length(object.nonce)), 0);
1935 else if (object.nonce.length)
1936 message.nonce = object.nonce;
1937 if (object.encryptedContent != null)
1938 if (typeof object.encryptedContent === "string")
1939 $util.base64.decode(object.encryptedContent, message.encryptedContent = $util.newBuffer($util.base64.length(object.encryptedContent)), 0);
1940 else if (object.encryptedContent.length)
1941 message.encryptedContent = object.encryptedContent;
1942 return message;
1943 };
1944
1945 /**
1946 * Creates a plain object from a ChannelMessage message. Also converts values to other types if specified.
1947 * @function toObject
1948 * @memberof ChannelMessage
1949 * @static
1950 * @param {ChannelMessage} message ChannelMessage
1951 * @param {$protobuf.IConversionOptions} [options] Conversion options
1952 * @returns {Object.<string,*>} Plain object
1953 */
1954 ChannelMessage.toObject = function toObject(message, options) {
1955 if (!options)
1956 options = {};
1957 let object = {};
1958 if (options.arrays || options.defaults)
1959 object.parents = [];
1960 if (options.defaults) {
1961 if (options.bytes === String)
1962 object.channelId = "";
1963 else {
1964 object.channelId = [];
1965 if (options.bytes !== Array)
1966 object.channelId = $util.newBuffer(object.channelId);
1967 }
1968 if ($util.Long) {
1969 let long = new $util.Long(0, 0, false);
1970 object.height = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
1971 } else
1972 object.height = options.longs === String ? "0" : 0;
1973 if (options.bytes === String)
1974 object.nonce = "";
1975 else {
1976 object.nonce = [];
1977 if (options.bytes !== Array)
1978 object.nonce = $util.newBuffer(object.nonce);
1979 }
1980 if (options.bytes === String)
1981 object.encryptedContent = "";
1982 else {
1983 object.encryptedContent = [];
1984 if (options.bytes !== Array)
1985 object.encryptedContent = $util.newBuffer(object.encryptedContent);
1986 }
1987 }
1988 if (message.channelId != null && message.hasOwnProperty("channelId"))
1989 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
1990 if (message.parents && message.parents.length) {
1991 object.parents = [];
1992 for (let j = 0; j < message.parents.length; ++j)
1993 object.parents[j] = options.bytes === String ? $util.base64.encode(message.parents[j], 0, message.parents[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.parents[j]) : message.parents[j];
1994 }
1995 if (message.height != null && message.hasOwnProperty("height"))
1996 if (typeof message.height === "number")
1997 object.height = options.longs === String ? String(message.height) : message.height;
1998 else
1999 object.height = options.longs === String ? $util.Long.prototype.toString.call(message.height) : options.longs === Number ? new $util.LongBits(message.height.low >>> 0, message.height.high >>> 0).toNumber() : message.height;
2000 if (message.nonce != null && message.hasOwnProperty("nonce"))
2001 object.nonce = options.bytes === String ? $util.base64.encode(message.nonce, 0, message.nonce.length) : options.bytes === Array ? Array.prototype.slice.call(message.nonce) : message.nonce;
2002 if (message.encryptedContent != null && message.hasOwnProperty("encryptedContent"))
2003 object.encryptedContent = options.bytes === String ? $util.base64.encode(message.encryptedContent, 0, message.encryptedContent.length) : options.bytes === Array ? Array.prototype.slice.call(message.encryptedContent) : message.encryptedContent;
2004 return object;
2005 };
2006
2007 /**
2008 * Converts this ChannelMessage to JSON.
2009 * @function toJSON
2010 * @memberof ChannelMessage
2011 * @instance
2012 * @returns {Object.<string,*>} JSON object
2013 */
2014 ChannelMessage.prototype.toJSON = function toJSON() {
2015 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
2016 };
2017
2018 ChannelMessage.Root = (function() {
2019
2020 /**
2021 * Properties of a Root.
2022 * @memberof ChannelMessage
2023 * @interface IRoot
2024 */
2025
2026 /**
2027 * Constructs a new Root.
2028 * @memberof ChannelMessage
2029 * @classdesc Represents a Root.
2030 * @implements IRoot
2031 * @constructor
2032 * @param {ChannelMessage.IRoot=} [properties] Properties to set
2033 */
2034 function Root(properties) {
2035 if (properties)
2036 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
2037 if (properties[keys[i]] != null)
2038 this[keys[i]] = properties[keys[i]];
2039 }
2040
2041 /**
2042 * Creates a new Root instance using the specified properties.
2043 * @function create
2044 * @memberof ChannelMessage.Root
2045 * @static
2046 * @param {ChannelMessage.IRoot=} [properties] Properties to set
2047 * @returns {ChannelMessage.Root} Root instance
2048 */
2049 Root.create = function create(properties) {
2050 return new Root(properties);
2051 };
2052
2053 /**
2054 * Encodes the specified Root message. Does not implicitly {@link ChannelMessage.Root.verify|verify} messages.
2055 * @function encode
2056 * @memberof ChannelMessage.Root
2057 * @static
2058 * @param {ChannelMessage.IRoot} message Root message or plain object to encode
2059 * @param {$protobuf.Writer} [writer] Writer to encode to
2060 * @returns {$protobuf.Writer} Writer
2061 */
2062 Root.encode = function encode(message, writer) {
2063 if (!writer)
2064 writer = $Writer.create();
2065 return writer;
2066 };
2067
2068 /**
2069 * Encodes the specified Root message, length delimited. Does not implicitly {@link ChannelMessage.Root.verify|verify} messages.
2070 * @function encodeDelimited
2071 * @memberof ChannelMessage.Root
2072 * @static
2073 * @param {ChannelMessage.IRoot} message Root message or plain object to encode
2074 * @param {$protobuf.Writer} [writer] Writer to encode to
2075 * @returns {$protobuf.Writer} Writer
2076 */
2077 Root.encodeDelimited = function encodeDelimited(message, writer) {
2078 return this.encode(message, writer).ldelim();
2079 };
2080
2081 /**
2082 * Decodes a Root message from the specified reader or buffer.
2083 * @function decode
2084 * @memberof ChannelMessage.Root
2085 * @static
2086 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2087 * @param {number} [length] Message length if known beforehand
2088 * @returns {ChannelMessage.Root} Root
2089 * @throws {Error} If the payload is not a reader or valid buffer
2090 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2091 */
2092 Root.decode = function decode(reader, length) {
2093 if (!(reader instanceof $Reader))
2094 reader = $Reader.create(reader);
2095 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage.Root();
2096 while (reader.pos < end) {
2097 let tag = reader.uint32();
2098 switch (tag >>> 3) {
2099 default:
2100 reader.skipType(tag & 7);
2101 break;
2102 }
2103 }
2104 return message;
2105 };
2106
2107 /**
2108 * Decodes a Root message from the specified reader or buffer, length delimited.
2109 * @function decodeDelimited
2110 * @memberof ChannelMessage.Root
2111 * @static
2112 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2113 * @returns {ChannelMessage.Root} Root
2114 * @throws {Error} If the payload is not a reader or valid buffer
2115 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2116 */
2117 Root.decodeDelimited = function decodeDelimited(reader) {
2118 if (!(reader instanceof $Reader))
2119 reader = new $Reader(reader);
2120 return this.decode(reader, reader.uint32());
2121 };
2122
2123 /**
2124 * Verifies a Root message.
2125 * @function verify
2126 * @memberof ChannelMessage.Root
2127 * @static
2128 * @param {Object.<string,*>} message Plain object to verify
2129 * @returns {string|null} `null` if valid, otherwise the reason why it is not
2130 */
2131 Root.verify = function verify(message) {
2132 if (typeof message !== "object" || message === null)
2133 return "object expected";
2134 return null;
2135 };
2136
2137 /**
2138 * Creates a Root message from a plain object. Also converts values to their respective internal types.
2139 * @function fromObject
2140 * @memberof ChannelMessage.Root
2141 * @static
2142 * @param {Object.<string,*>} object Plain object
2143 * @returns {ChannelMessage.Root} Root
2144 */
2145 Root.fromObject = function fromObject(object) {
2146 if (object instanceof $root.ChannelMessage.Root)
2147 return object;
2148 return new $root.ChannelMessage.Root();
2149 };
2150
2151 /**
2152 * Creates a plain object from a Root message. Also converts values to other types if specified.
2153 * @function toObject
2154 * @memberof ChannelMessage.Root
2155 * @static
2156 * @param {ChannelMessage.Root} message Root
2157 * @param {$protobuf.IConversionOptions} [options] Conversion options
2158 * @returns {Object.<string,*>} Plain object
2159 */
2160 Root.toObject = function toObject() {
2161 return {};
2162 };
2163
2164 /**
2165 * Converts this Root to JSON.
2166 * @function toJSON
2167 * @memberof ChannelMessage.Root
2168 * @instance
2169 * @returns {Object.<string,*>} JSON object
2170 */
2171 Root.prototype.toJSON = function toJSON() {
2172 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
2173 };
2174
2175 return Root;
2176 })();
2177
2178 ChannelMessage.Body = (function() {
2179
2180 /**
2181 * Properties of a Body.
2182 * @memberof ChannelMessage
2183 * @interface IBody
2184 * @property {ChannelMessage.IRoot|null} [root] Body root
2185 * @property {string|null} [json] Body json
2186 */
2187
2188 /**
2189 * Constructs a new Body.
2190 * @memberof ChannelMessage
2191 * @classdesc Represents a Body.
2192 * @implements IBody
2193 * @constructor
2194 * @param {ChannelMessage.IBody=} [properties] Properties to set
2195 */
2196 function Body(properties) {
2197 if (properties)
2198 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
2199 if (properties[keys[i]] != null)
2200 this[keys[i]] = properties[keys[i]];
2201 }
2202
2203 /**
2204 * Body root.
2205 * @member {ChannelMessage.IRoot|null|undefined} root
2206 * @memberof ChannelMessage.Body
2207 * @instance
2208 */
2209 Body.prototype.root = null;
2210
2211 /**
2212 * Body json.
2213 * @member {string} json
2214 * @memberof ChannelMessage.Body
2215 * @instance
2216 */
2217 Body.prototype.json = "";
2218
2219 // OneOf field names bound to virtual getters and setters
2220 let $oneOfFields;
2221
2222 /**
2223 * Body body.
2224 * @member {"root"|"json"|undefined} body
2225 * @memberof ChannelMessage.Body
2226 * @instance
2227 */
2228 Object.defineProperty(Body.prototype, "body", {
2229 get: $util.oneOfGetter($oneOfFields = ["root", "json"]),
2230 set: $util.oneOfSetter($oneOfFields)
2231 });
2232
2233 /**
2234 * Creates a new Body instance using the specified properties.
2235 * @function create
2236 * @memberof ChannelMessage.Body
2237 * @static
2238 * @param {ChannelMessage.IBody=} [properties] Properties to set
2239 * @returns {ChannelMessage.Body} Body instance
2240 */
2241 Body.create = function create(properties) {
2242 return new Body(properties);
2243 };
2244
2245 /**
2246 * Encodes the specified Body message. Does not implicitly {@link ChannelMessage.Body.verify|verify} messages.
2247 * @function encode
2248 * @memberof ChannelMessage.Body
2249 * @static
2250 * @param {ChannelMessage.IBody} message Body message or plain object to encode
2251 * @param {$protobuf.Writer} [writer] Writer to encode to
2252 * @returns {$protobuf.Writer} Writer
2253 */
2254 Body.encode = function encode(message, writer) {
2255 if (!writer)
2256 writer = $Writer.create();
2257 if (message.root != null && message.hasOwnProperty("root"))
2258 $root.ChannelMessage.Root.encode(message.root, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
2259 if (message.json != null && message.hasOwnProperty("json"))
2260 writer.uint32(/* id 2, wireType 2 =*/18).string(message.json);
2261 return writer;
2262 };
2263
2264 /**
2265 * Encodes the specified Body message, length delimited. Does not implicitly {@link ChannelMessage.Body.verify|verify} messages.
2266 * @function encodeDelimited
2267 * @memberof ChannelMessage.Body
2268 * @static
2269 * @param {ChannelMessage.IBody} message Body message or plain object to encode
2270 * @param {$protobuf.Writer} [writer] Writer to encode to
2271 * @returns {$protobuf.Writer} Writer
2272 */
2273 Body.encodeDelimited = function encodeDelimited(message, writer) {
2274 return this.encode(message, writer).ldelim();
2275 };
2276
2277 /**
2278 * Decodes a Body message from the specified reader or buffer.
2279 * @function decode
2280 * @memberof ChannelMessage.Body
2281 * @static
2282 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2283 * @param {number} [length] Message length if known beforehand
2284 * @returns {ChannelMessage.Body} Body
2285 * @throws {Error} If the payload is not a reader or valid buffer
2286 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2287 */
2288 Body.decode = function decode(reader, length) {
2289 if (!(reader instanceof $Reader))
2290 reader = $Reader.create(reader);
2291 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage.Body();
2292 while (reader.pos < end) {
2293 let tag = reader.uint32();
2294 switch (tag >>> 3) {
2295 case 1:
2296 message.root = $root.ChannelMessage.Root.decode(reader, reader.uint32());
2297 break;
2298 case 2:
2299 message.json = reader.string();
2300 break;
2301 default:
2302 reader.skipType(tag & 7);
2303 break;
2304 }
2305 }
2306 return message;
2307 };
2308
2309 /**
2310 * Decodes a Body message from the specified reader or buffer, length delimited.
2311 * @function decodeDelimited
2312 * @memberof ChannelMessage.Body
2313 * @static
2314 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2315 * @returns {ChannelMessage.Body} Body
2316 * @throws {Error} If the payload is not a reader or valid buffer
2317 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2318 */
2319 Body.decodeDelimited = function decodeDelimited(reader) {
2320 if (!(reader instanceof $Reader))
2321 reader = new $Reader(reader);
2322 return this.decode(reader, reader.uint32());
2323 };
2324
2325 /**
2326 * Verifies a Body message.
2327 * @function verify
2328 * @memberof ChannelMessage.Body
2329 * @static
2330 * @param {Object.<string,*>} message Plain object to verify
2331 * @returns {string|null} `null` if valid, otherwise the reason why it is not
2332 */
2333 Body.verify = function verify(message) {
2334 if (typeof message !== "object" || message === null)
2335 return "object expected";
2336 let properties = {};
2337 if (message.root != null && message.hasOwnProperty("root")) {
2338 properties.body = 1;
2339 {
2340 let error = $root.ChannelMessage.Root.verify(message.root);
2341 if (error)
2342 return "root." + error;
2343 }
2344 }
2345 if (message.json != null && message.hasOwnProperty("json")) {
2346 if (properties.body === 1)
2347 return "body: multiple values";
2348 properties.body = 1;
2349 if (!$util.isString(message.json))
2350 return "json: string expected";
2351 }
2352 return null;
2353 };
2354
2355 /**
2356 * Creates a Body message from a plain object. Also converts values to their respective internal types.
2357 * @function fromObject
2358 * @memberof ChannelMessage.Body
2359 * @static
2360 * @param {Object.<string,*>} object Plain object
2361 * @returns {ChannelMessage.Body} Body
2362 */
2363 Body.fromObject = function fromObject(object) {
2364 if (object instanceof $root.ChannelMessage.Body)
2365 return object;
2366 let message = new $root.ChannelMessage.Body();
2367 if (object.root != null) {
2368 if (typeof object.root !== "object")
2369 throw TypeError(".ChannelMessage.Body.root: object expected");
2370 message.root = $root.ChannelMessage.Root.fromObject(object.root);
2371 }
2372 if (object.json != null)
2373 message.json = String(object.json);
2374 return message;
2375 };
2376
2377 /**
2378 * Creates a plain object from a Body message. Also converts values to other types if specified.
2379 * @function toObject
2380 * @memberof ChannelMessage.Body
2381 * @static
2382 * @param {ChannelMessage.Body} message Body
2383 * @param {$protobuf.IConversionOptions} [options] Conversion options
2384 * @returns {Object.<string,*>} Plain object
2385 */
2386 Body.toObject = function toObject(message, options) {
2387 if (!options)
2388 options = {};
2389 let object = {};
2390 if (message.root != null && message.hasOwnProperty("root")) {
2391 object.root = $root.ChannelMessage.Root.toObject(message.root, options);
2392 if (options.oneofs)
2393 object.body = "root";
2394 }
2395 if (message.json != null && message.hasOwnProperty("json")) {
2396 object.json = message.json;
2397 if (options.oneofs)
2398 object.body = "json";
2399 }
2400 return object;
2401 };
2402
2403 /**
2404 * Converts this Body to JSON.
2405 * @function toJSON
2406 * @memberof ChannelMessage.Body
2407 * @instance
2408 * @returns {Object.<string,*>} JSON object
2409 */
2410 Body.prototype.toJSON = function toJSON() {
2411 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
2412 };
2413
2414 return Body;
2415 })();
2416
2417 ChannelMessage.Content = (function() {
2418
2419 /**
2420 * Properties of a Content.
2421 * @memberof ChannelMessage
2422 * @interface IContent
2423 * @property {Array.<ILink>|null} [chain] Content chain
2424 * @property {number|null} [timestamp] Content timestamp
2425 * @property {ChannelMessage.IBody|null} [body] Content body
2426 * @property {Uint8Array|null} [signature] Content signature
2427 */
2428
2429 /**
2430 * Constructs a new Content.
2431 * @memberof ChannelMessage
2432 * @classdesc Represents a Content.
2433 * @implements IContent
2434 * @constructor
2435 * @param {ChannelMessage.IContent=} [properties] Properties to set
2436 */
2437 function Content(properties) {
2438 this.chain = [];
2439 if (properties)
2440 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
2441 if (properties[keys[i]] != null)
2442 this[keys[i]] = properties[keys[i]];
2443 }
2444
2445 /**
2446 * Content chain.
2447 * @member {Array.<ILink>} chain
2448 * @memberof ChannelMessage.Content
2449 * @instance
2450 */
2451 Content.prototype.chain = $util.emptyArray;
2452
2453 /**
2454 * Content timestamp.
2455 * @member {number} timestamp
2456 * @memberof ChannelMessage.Content
2457 * @instance
2458 */
2459 Content.prototype.timestamp = 0;
2460
2461 /**
2462 * Content body.
2463 * @member {ChannelMessage.IBody|null|undefined} body
2464 * @memberof ChannelMessage.Content
2465 * @instance
2466 */
2467 Content.prototype.body = null;
2468
2469 /**
2470 * Content signature.
2471 * @member {Uint8Array} signature
2472 * @memberof ChannelMessage.Content
2473 * @instance
2474 */
2475 Content.prototype.signature = $util.newBuffer([]);
2476
2477 /**
2478 * Creates a new Content instance using the specified properties.
2479 * @function create
2480 * @memberof ChannelMessage.Content
2481 * @static
2482 * @param {ChannelMessage.IContent=} [properties] Properties to set
2483 * @returns {ChannelMessage.Content} Content instance
2484 */
2485 Content.create = function create(properties) {
2486 return new Content(properties);
2487 };
2488
2489 /**
2490 * Encodes the specified Content message. Does not implicitly {@link ChannelMessage.Content.verify|verify} messages.
2491 * @function encode
2492 * @memberof ChannelMessage.Content
2493 * @static
2494 * @param {ChannelMessage.IContent} message Content message or plain object to encode
2495 * @param {$protobuf.Writer} [writer] Writer to encode to
2496 * @returns {$protobuf.Writer} Writer
2497 */
2498 Content.encode = function encode(message, writer) {
2499 if (!writer)
2500 writer = $Writer.create();
2501 if (message.chain != null && message.chain.length)
2502 for (let i = 0; i < message.chain.length; ++i)
2503 $root.Link.encode(message.chain[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
2504 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
2505 writer.uint32(/* id 2, wireType 1 =*/17).double(message.timestamp);
2506 if (message.body != null && message.hasOwnProperty("body"))
2507 $root.ChannelMessage.Body.encode(message.body, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
2508 if (message.signature != null && message.hasOwnProperty("signature"))
2509 writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.signature);
2510 return writer;
2511 };
2512
2513 /**
2514 * Encodes the specified Content message, length delimited. Does not implicitly {@link ChannelMessage.Content.verify|verify} messages.
2515 * @function encodeDelimited
2516 * @memberof ChannelMessage.Content
2517 * @static
2518 * @param {ChannelMessage.IContent} message Content message or plain object to encode
2519 * @param {$protobuf.Writer} [writer] Writer to encode to
2520 * @returns {$protobuf.Writer} Writer
2521 */
2522 Content.encodeDelimited = function encodeDelimited(message, writer) {
2523 return this.encode(message, writer).ldelim();
2524 };
2525
2526 /**
2527 * Decodes a Content message from the specified reader or buffer.
2528 * @function decode
2529 * @memberof ChannelMessage.Content
2530 * @static
2531 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2532 * @param {number} [length] Message length if known beforehand
2533 * @returns {ChannelMessage.Content} Content
2534 * @throws {Error} If the payload is not a reader or valid buffer
2535 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2536 */
2537 Content.decode = function decode(reader, length) {
2538 if (!(reader instanceof $Reader))
2539 reader = $Reader.create(reader);
2540 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage.Content();
2541 while (reader.pos < end) {
2542 let tag = reader.uint32();
2543 switch (tag >>> 3) {
2544 case 1:
2545 if (!(message.chain && message.chain.length))
2546 message.chain = [];
2547 message.chain.push($root.Link.decode(reader, reader.uint32()));
2548 break;
2549 case 2:
2550 message.timestamp = reader.double();
2551 break;
2552 case 3:
2553 message.body = $root.ChannelMessage.Body.decode(reader, reader.uint32());
2554 break;
2555 case 4:
2556 message.signature = reader.bytes();
2557 break;
2558 default:
2559 reader.skipType(tag & 7);
2560 break;
2561 }
2562 }
2563 return message;
2564 };
2565
2566 /**
2567 * Decodes a Content message from the specified reader or buffer, length delimited.
2568 * @function decodeDelimited
2569 * @memberof ChannelMessage.Content
2570 * @static
2571 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2572 * @returns {ChannelMessage.Content} Content
2573 * @throws {Error} If the payload is not a reader or valid buffer
2574 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2575 */
2576 Content.decodeDelimited = function decodeDelimited(reader) {
2577 if (!(reader instanceof $Reader))
2578 reader = new $Reader(reader);
2579 return this.decode(reader, reader.uint32());
2580 };
2581
2582 /**
2583 * Verifies a Content message.
2584 * @function verify
2585 * @memberof ChannelMessage.Content
2586 * @static
2587 * @param {Object.<string,*>} message Plain object to verify
2588 * @returns {string|null} `null` if valid, otherwise the reason why it is not
2589 */
2590 Content.verify = function verify(message) {
2591 if (typeof message !== "object" || message === null)
2592 return "object expected";
2593 if (message.chain != null && message.hasOwnProperty("chain")) {
2594 if (!Array.isArray(message.chain))
2595 return "chain: array expected";
2596 for (let i = 0; i < message.chain.length; ++i) {
2597 let error = $root.Link.verify(message.chain[i]);
2598 if (error)
2599 return "chain." + error;
2600 }
2601 }
2602 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
2603 if (typeof message.timestamp !== "number")
2604 return "timestamp: number expected";
2605 if (message.body != null && message.hasOwnProperty("body")) {
2606 let error = $root.ChannelMessage.Body.verify(message.body);
2607 if (error)
2608 return "body." + error;
2609 }
2610 if (message.signature != null && message.hasOwnProperty("signature"))
2611 if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature)))
2612 return "signature: buffer expected";
2613 return null;
2614 };
2615
2616 /**
2617 * Creates a Content message from a plain object. Also converts values to their respective internal types.
2618 * @function fromObject
2619 * @memberof ChannelMessage.Content
2620 * @static
2621 * @param {Object.<string,*>} object Plain object
2622 * @returns {ChannelMessage.Content} Content
2623 */
2624 Content.fromObject = function fromObject(object) {
2625 if (object instanceof $root.ChannelMessage.Content)
2626 return object;
2627 let message = new $root.ChannelMessage.Content();
2628 if (object.chain) {
2629 if (!Array.isArray(object.chain))
2630 throw TypeError(".ChannelMessage.Content.chain: array expected");
2631 message.chain = [];
2632 for (let i = 0; i < object.chain.length; ++i) {
2633 if (typeof object.chain[i] !== "object")
2634 throw TypeError(".ChannelMessage.Content.chain: object expected");
2635 message.chain[i] = $root.Link.fromObject(object.chain[i]);
2636 }
2637 }
2638 if (object.timestamp != null)
2639 message.timestamp = Number(object.timestamp);
2640 if (object.body != null) {
2641 if (typeof object.body !== "object")
2642 throw TypeError(".ChannelMessage.Content.body: object expected");
2643 message.body = $root.ChannelMessage.Body.fromObject(object.body);
2644 }
2645 if (object.signature != null)
2646 if (typeof object.signature === "string")
2647 $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0);
2648 else if (object.signature.length)
2649 message.signature = object.signature;
2650 return message;
2651 };
2652
2653 /**
2654 * Creates a plain object from a Content message. Also converts values to other types if specified.
2655 * @function toObject
2656 * @memberof ChannelMessage.Content
2657 * @static
2658 * @param {ChannelMessage.Content} message Content
2659 * @param {$protobuf.IConversionOptions} [options] Conversion options
2660 * @returns {Object.<string,*>} Plain object
2661 */
2662 Content.toObject = function toObject(message, options) {
2663 if (!options)
2664 options = {};
2665 let object = {};
2666 if (options.arrays || options.defaults)
2667 object.chain = [];
2668 if (options.defaults) {
2669 object.timestamp = 0;
2670 object.body = null;
2671 if (options.bytes === String)
2672 object.signature = "";
2673 else {
2674 object.signature = [];
2675 if (options.bytes !== Array)
2676 object.signature = $util.newBuffer(object.signature);
2677 }
2678 }
2679 if (message.chain && message.chain.length) {
2680 object.chain = [];
2681 for (let j = 0; j < message.chain.length; ++j)
2682 object.chain[j] = $root.Link.toObject(message.chain[j], options);
2683 }
2684 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
2685 object.timestamp = options.json && !isFinite(message.timestamp) ? String(message.timestamp) : message.timestamp;
2686 if (message.body != null && message.hasOwnProperty("body"))
2687 object.body = $root.ChannelMessage.Body.toObject(message.body, options);
2688 if (message.signature != null && message.hasOwnProperty("signature"))
2689 object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature;
2690 return object;
2691 };
2692
2693 /**
2694 * Converts this Content to JSON.
2695 * @function toJSON
2696 * @memberof ChannelMessage.Content
2697 * @instance
2698 * @returns {Object.<string,*>} JSON object
2699 */
2700 Content.prototype.toJSON = function toJSON() {
2701 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
2702 };
2703
2704 Content.TBS = (function() {
2705
2706 /**
2707 * Properties of a TBS.
2708 * @memberof ChannelMessage.Content
2709 * @interface ITBS
2710 * @property {Array.<ILink>|null} [chain] TBS chain
2711 * @property {number|null} [timestamp] TBS timestamp
2712 * @property {ChannelMessage.IBody|null} [body] TBS body
2713 * @property {Array.<Uint8Array>|null} [parents] TBS parents
2714 * @property {number|Long|null} [height] TBS height
2715 */
2716
2717 /**
2718 * Constructs a new TBS.
2719 * @memberof ChannelMessage.Content
2720 * @classdesc Represents a TBS.
2721 * @implements ITBS
2722 * @constructor
2723 * @param {ChannelMessage.Content.ITBS=} [properties] Properties to set
2724 */
2725 function TBS(properties) {
2726 this.chain = [];
2727 this.parents = [];
2728 if (properties)
2729 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
2730 if (properties[keys[i]] != null)
2731 this[keys[i]] = properties[keys[i]];
2732 }
2733
2734 /**
2735 * TBS chain.
2736 * @member {Array.<ILink>} chain
2737 * @memberof ChannelMessage.Content.TBS
2738 * @instance
2739 */
2740 TBS.prototype.chain = $util.emptyArray;
2741
2742 /**
2743 * TBS timestamp.
2744 * @member {number} timestamp
2745 * @memberof ChannelMessage.Content.TBS
2746 * @instance
2747 */
2748 TBS.prototype.timestamp = 0;
2749
2750 /**
2751 * TBS body.
2752 * @member {ChannelMessage.IBody|null|undefined} body
2753 * @memberof ChannelMessage.Content.TBS
2754 * @instance
2755 */
2756 TBS.prototype.body = null;
2757
2758 /**
2759 * TBS parents.
2760 * @member {Array.<Uint8Array>} parents
2761 * @memberof ChannelMessage.Content.TBS
2762 * @instance
2763 */
2764 TBS.prototype.parents = $util.emptyArray;
2765
2766 /**
2767 * TBS height.
2768 * @member {number|Long} height
2769 * @memberof ChannelMessage.Content.TBS
2770 * @instance
2771 */
2772 TBS.prototype.height = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
2773
2774 /**
2775 * Creates a new TBS instance using the specified properties.
2776 * @function create
2777 * @memberof ChannelMessage.Content.TBS
2778 * @static
2779 * @param {ChannelMessage.Content.ITBS=} [properties] Properties to set
2780 * @returns {ChannelMessage.Content.TBS} TBS instance
2781 */
2782 TBS.create = function create(properties) {
2783 return new TBS(properties);
2784 };
2785
2786 /**
2787 * Encodes the specified TBS message. Does not implicitly {@link ChannelMessage.Content.TBS.verify|verify} messages.
2788 * @function encode
2789 * @memberof ChannelMessage.Content.TBS
2790 * @static
2791 * @param {ChannelMessage.Content.ITBS} message TBS message or plain object to encode
2792 * @param {$protobuf.Writer} [writer] Writer to encode to
2793 * @returns {$protobuf.Writer} Writer
2794 */
2795 TBS.encode = function encode(message, writer) {
2796 if (!writer)
2797 writer = $Writer.create();
2798 if (message.chain != null && message.chain.length)
2799 for (let i = 0; i < message.chain.length; ++i)
2800 $root.Link.encode(message.chain[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
2801 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
2802 writer.uint32(/* id 2, wireType 1 =*/17).double(message.timestamp);
2803 if (message.body != null && message.hasOwnProperty("body"))
2804 $root.ChannelMessage.Body.encode(message.body, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
2805 if (message.parents != null && message.parents.length)
2806 for (let i = 0; i < message.parents.length; ++i)
2807 writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.parents[i]);
2808 if (message.height != null && message.hasOwnProperty("height"))
2809 writer.uint32(/* id 5, wireType 0 =*/40).int64(message.height);
2810 return writer;
2811 };
2812
2813 /**
2814 * Encodes the specified TBS message, length delimited. Does not implicitly {@link ChannelMessage.Content.TBS.verify|verify} messages.
2815 * @function encodeDelimited
2816 * @memberof ChannelMessage.Content.TBS
2817 * @static
2818 * @param {ChannelMessage.Content.ITBS} message TBS message or plain object to encode
2819 * @param {$protobuf.Writer} [writer] Writer to encode to
2820 * @returns {$protobuf.Writer} Writer
2821 */
2822 TBS.encodeDelimited = function encodeDelimited(message, writer) {
2823 return this.encode(message, writer).ldelim();
2824 };
2825
2826 /**
2827 * Decodes a TBS message from the specified reader or buffer.
2828 * @function decode
2829 * @memberof ChannelMessage.Content.TBS
2830 * @static
2831 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2832 * @param {number} [length] Message length if known beforehand
2833 * @returns {ChannelMessage.Content.TBS} TBS
2834 * @throws {Error} If the payload is not a reader or valid buffer
2835 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2836 */
2837 TBS.decode = function decode(reader, length) {
2838 if (!(reader instanceof $Reader))
2839 reader = $Reader.create(reader);
2840 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage.Content.TBS();
2841 while (reader.pos < end) {
2842 let tag = reader.uint32();
2843 switch (tag >>> 3) {
2844 case 1:
2845 if (!(message.chain && message.chain.length))
2846 message.chain = [];
2847 message.chain.push($root.Link.decode(reader, reader.uint32()));
2848 break;
2849 case 2:
2850 message.timestamp = reader.double();
2851 break;
2852 case 3:
2853 message.body = $root.ChannelMessage.Body.decode(reader, reader.uint32());
2854 break;
2855 case 4:
2856 if (!(message.parents && message.parents.length))
2857 message.parents = [];
2858 message.parents.push(reader.bytes());
2859 break;
2860 case 5:
2861 message.height = reader.int64();
2862 break;
2863 default:
2864 reader.skipType(tag & 7);
2865 break;
2866 }
2867 }
2868 return message;
2869 };
2870
2871 /**
2872 * Decodes a TBS message from the specified reader or buffer, length delimited.
2873 * @function decodeDelimited
2874 * @memberof ChannelMessage.Content.TBS
2875 * @static
2876 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
2877 * @returns {ChannelMessage.Content.TBS} TBS
2878 * @throws {Error} If the payload is not a reader or valid buffer
2879 * @throws {$protobuf.util.ProtocolError} If required fields are missing
2880 */
2881 TBS.decodeDelimited = function decodeDelimited(reader) {
2882 if (!(reader instanceof $Reader))
2883 reader = new $Reader(reader);
2884 return this.decode(reader, reader.uint32());
2885 };
2886
2887 /**
2888 * Verifies a TBS message.
2889 * @function verify
2890 * @memberof ChannelMessage.Content.TBS
2891 * @static
2892 * @param {Object.<string,*>} message Plain object to verify
2893 * @returns {string|null} `null` if valid, otherwise the reason why it is not
2894 */
2895 TBS.verify = function verify(message) {
2896 if (typeof message !== "object" || message === null)
2897 return "object expected";
2898 if (message.chain != null && message.hasOwnProperty("chain")) {
2899 if (!Array.isArray(message.chain))
2900 return "chain: array expected";
2901 for (let i = 0; i < message.chain.length; ++i) {
2902 let error = $root.Link.verify(message.chain[i]);
2903 if (error)
2904 return "chain." + error;
2905 }
2906 }
2907 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
2908 if (typeof message.timestamp !== "number")
2909 return "timestamp: number expected";
2910 if (message.body != null && message.hasOwnProperty("body")) {
2911 let error = $root.ChannelMessage.Body.verify(message.body);
2912 if (error)
2913 return "body." + error;
2914 }
2915 if (message.parents != null && message.hasOwnProperty("parents")) {
2916 if (!Array.isArray(message.parents))
2917 return "parents: array expected";
2918 for (let i = 0; i < message.parents.length; ++i)
2919 if (!(message.parents[i] && typeof message.parents[i].length === "number" || $util.isString(message.parents[i])))
2920 return "parents: buffer[] expected";
2921 }
2922 if (message.height != null && message.hasOwnProperty("height"))
2923 if (!$util.isInteger(message.height) && !(message.height && $util.isInteger(message.height.low) && $util.isInteger(message.height.high)))
2924 return "height: integer|Long expected";
2925 return null;
2926 };
2927
2928 /**
2929 * Creates a TBS message from a plain object. Also converts values to their respective internal types.
2930 * @function fromObject
2931 * @memberof ChannelMessage.Content.TBS
2932 * @static
2933 * @param {Object.<string,*>} object Plain object
2934 * @returns {ChannelMessage.Content.TBS} TBS
2935 */
2936 TBS.fromObject = function fromObject(object) {
2937 if (object instanceof $root.ChannelMessage.Content.TBS)
2938 return object;
2939 let message = new $root.ChannelMessage.Content.TBS();
2940 if (object.chain) {
2941 if (!Array.isArray(object.chain))
2942 throw TypeError(".ChannelMessage.Content.TBS.chain: array expected");
2943 message.chain = [];
2944 for (let i = 0; i < object.chain.length; ++i) {
2945 if (typeof object.chain[i] !== "object")
2946 throw TypeError(".ChannelMessage.Content.TBS.chain: object expected");
2947 message.chain[i] = $root.Link.fromObject(object.chain[i]);
2948 }
2949 }
2950 if (object.timestamp != null)
2951 message.timestamp = Number(object.timestamp);
2952 if (object.body != null) {
2953 if (typeof object.body !== "object")
2954 throw TypeError(".ChannelMessage.Content.TBS.body: object expected");
2955 message.body = $root.ChannelMessage.Body.fromObject(object.body);
2956 }
2957 if (object.parents) {
2958 if (!Array.isArray(object.parents))
2959 throw TypeError(".ChannelMessage.Content.TBS.parents: array expected");
2960 message.parents = [];
2961 for (let i = 0; i < object.parents.length; ++i)
2962 if (typeof object.parents[i] === "string")
2963 $util.base64.decode(object.parents[i], message.parents[i] = $util.newBuffer($util.base64.length(object.parents[i])), 0);
2964 else if (object.parents[i].length)
2965 message.parents[i] = object.parents[i];
2966 }
2967 if (object.height != null)
2968 if ($util.Long)
2969 (message.height = $util.Long.fromValue(object.height)).unsigned = false;
2970 else if (typeof object.height === "string")
2971 message.height = parseInt(object.height, 10);
2972 else if (typeof object.height === "number")
2973 message.height = object.height;
2974 else if (typeof object.height === "object")
2975 message.height = new $util.LongBits(object.height.low >>> 0, object.height.high >>> 0).toNumber();
2976 return message;
2977 };
2978
2979 /**
2980 * Creates a plain object from a TBS message. Also converts values to other types if specified.
2981 * @function toObject
2982 * @memberof ChannelMessage.Content.TBS
2983 * @static
2984 * @param {ChannelMessage.Content.TBS} message TBS
2985 * @param {$protobuf.IConversionOptions} [options] Conversion options
2986 * @returns {Object.<string,*>} Plain object
2987 */
2988 TBS.toObject = function toObject(message, options) {
2989 if (!options)
2990 options = {};
2991 let object = {};
2992 if (options.arrays || options.defaults) {
2993 object.chain = [];
2994 object.parents = [];
2995 }
2996 if (options.defaults) {
2997 object.timestamp = 0;
2998 object.body = null;
2999 if ($util.Long) {
3000 let long = new $util.Long(0, 0, false);
3001 object.height = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
3002 } else
3003 object.height = options.longs === String ? "0" : 0;
3004 }
3005 if (message.chain && message.chain.length) {
3006 object.chain = [];
3007 for (let j = 0; j < message.chain.length; ++j)
3008 object.chain[j] = $root.Link.toObject(message.chain[j], options);
3009 }
3010 if (message.timestamp != null && message.hasOwnProperty("timestamp"))
3011 object.timestamp = options.json && !isFinite(message.timestamp) ? String(message.timestamp) : message.timestamp;
3012 if (message.body != null && message.hasOwnProperty("body"))
3013 object.body = $root.ChannelMessage.Body.toObject(message.body, options);
3014 if (message.parents && message.parents.length) {
3015 object.parents = [];
3016 for (let j = 0; j < message.parents.length; ++j)
3017 object.parents[j] = options.bytes === String ? $util.base64.encode(message.parents[j], 0, message.parents[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.parents[j]) : message.parents[j];
3018 }
3019 if (message.height != null && message.hasOwnProperty("height"))
3020 if (typeof message.height === "number")
3021 object.height = options.longs === String ? String(message.height) : message.height;
3022 else
3023 object.height = options.longs === String ? $util.Long.prototype.toString.call(message.height) : options.longs === Number ? new $util.LongBits(message.height.low >>> 0, message.height.high >>> 0).toNumber() : message.height;
3024 return object;
3025 };
3026
3027 /**
3028 * Converts this TBS to JSON.
3029 * @function toJSON
3030 * @memberof ChannelMessage.Content.TBS
3031 * @instance
3032 * @returns {Object.<string,*>} JSON object
3033 */
3034 TBS.prototype.toJSON = function toJSON() {
3035 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
3036 };
3037
3038 return TBS;
3039 })();
3040
3041 return Content;
3042 })();
3043
3044 ChannelMessage.EncryptionKeyInput = (function() {
3045
3046 /**
3047 * Properties of an EncryptionKeyInput.
3048 * @memberof ChannelMessage
3049 * @interface IEncryptionKeyInput
3050 * @property {Uint8Array|null} [channelPubKey] EncryptionKeyInput channelPubKey
3051 */
3052
3053 /**
3054 * Constructs a new EncryptionKeyInput.
3055 * @memberof ChannelMessage
3056 * @classdesc Represents an EncryptionKeyInput.
3057 * @implements IEncryptionKeyInput
3058 * @constructor
3059 * @param {ChannelMessage.IEncryptionKeyInput=} [properties] Properties to set
3060 */
3061 function EncryptionKeyInput(properties) {
3062 if (properties)
3063 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
3064 if (properties[keys[i]] != null)
3065 this[keys[i]] = properties[keys[i]];
3066 }
3067
3068 /**
3069 * EncryptionKeyInput channelPubKey.
3070 * @member {Uint8Array} channelPubKey
3071 * @memberof ChannelMessage.EncryptionKeyInput
3072 * @instance
3073 */
3074 EncryptionKeyInput.prototype.channelPubKey = $util.newBuffer([]);
3075
3076 /**
3077 * Creates a new EncryptionKeyInput instance using the specified properties.
3078 * @function create
3079 * @memberof ChannelMessage.EncryptionKeyInput
3080 * @static
3081 * @param {ChannelMessage.IEncryptionKeyInput=} [properties] Properties to set
3082 * @returns {ChannelMessage.EncryptionKeyInput} EncryptionKeyInput instance
3083 */
3084 EncryptionKeyInput.create = function create(properties) {
3085 return new EncryptionKeyInput(properties);
3086 };
3087
3088 /**
3089 * Encodes the specified EncryptionKeyInput message. Does not implicitly {@link ChannelMessage.EncryptionKeyInput.verify|verify} messages.
3090 * @function encode
3091 * @memberof ChannelMessage.EncryptionKeyInput
3092 * @static
3093 * @param {ChannelMessage.IEncryptionKeyInput} message EncryptionKeyInput message or plain object to encode
3094 * @param {$protobuf.Writer} [writer] Writer to encode to
3095 * @returns {$protobuf.Writer} Writer
3096 */
3097 EncryptionKeyInput.encode = function encode(message, writer) {
3098 if (!writer)
3099 writer = $Writer.create();
3100 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
3101 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelPubKey);
3102 return writer;
3103 };
3104
3105 /**
3106 * Encodes the specified EncryptionKeyInput message, length delimited. Does not implicitly {@link ChannelMessage.EncryptionKeyInput.verify|verify} messages.
3107 * @function encodeDelimited
3108 * @memberof ChannelMessage.EncryptionKeyInput
3109 * @static
3110 * @param {ChannelMessage.IEncryptionKeyInput} message EncryptionKeyInput message or plain object to encode
3111 * @param {$protobuf.Writer} [writer] Writer to encode to
3112 * @returns {$protobuf.Writer} Writer
3113 */
3114 EncryptionKeyInput.encodeDelimited = function encodeDelimited(message, writer) {
3115 return this.encode(message, writer).ldelim();
3116 };
3117
3118 /**
3119 * Decodes an EncryptionKeyInput message from the specified reader or buffer.
3120 * @function decode
3121 * @memberof ChannelMessage.EncryptionKeyInput
3122 * @static
3123 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3124 * @param {number} [length] Message length if known beforehand
3125 * @returns {ChannelMessage.EncryptionKeyInput} EncryptionKeyInput
3126 * @throws {Error} If the payload is not a reader or valid buffer
3127 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3128 */
3129 EncryptionKeyInput.decode = function decode(reader, length) {
3130 if (!(reader instanceof $Reader))
3131 reader = $Reader.create(reader);
3132 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChannelMessage.EncryptionKeyInput();
3133 while (reader.pos < end) {
3134 let tag = reader.uint32();
3135 switch (tag >>> 3) {
3136 case 1:
3137 message.channelPubKey = reader.bytes();
3138 break;
3139 default:
3140 reader.skipType(tag & 7);
3141 break;
3142 }
3143 }
3144 return message;
3145 };
3146
3147 /**
3148 * Decodes an EncryptionKeyInput message from the specified reader or buffer, length delimited.
3149 * @function decodeDelimited
3150 * @memberof ChannelMessage.EncryptionKeyInput
3151 * @static
3152 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3153 * @returns {ChannelMessage.EncryptionKeyInput} EncryptionKeyInput
3154 * @throws {Error} If the payload is not a reader or valid buffer
3155 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3156 */
3157 EncryptionKeyInput.decodeDelimited = function decodeDelimited(reader) {
3158 if (!(reader instanceof $Reader))
3159 reader = new $Reader(reader);
3160 return this.decode(reader, reader.uint32());
3161 };
3162
3163 /**
3164 * Verifies an EncryptionKeyInput message.
3165 * @function verify
3166 * @memberof ChannelMessage.EncryptionKeyInput
3167 * @static
3168 * @param {Object.<string,*>} message Plain object to verify
3169 * @returns {string|null} `null` if valid, otherwise the reason why it is not
3170 */
3171 EncryptionKeyInput.verify = function verify(message) {
3172 if (typeof message !== "object" || message === null)
3173 return "object expected";
3174 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
3175 if (!(message.channelPubKey && typeof message.channelPubKey.length === "number" || $util.isString(message.channelPubKey)))
3176 return "channelPubKey: buffer expected";
3177 return null;
3178 };
3179
3180 /**
3181 * Creates an EncryptionKeyInput message from a plain object. Also converts values to their respective internal types.
3182 * @function fromObject
3183 * @memberof ChannelMessage.EncryptionKeyInput
3184 * @static
3185 * @param {Object.<string,*>} object Plain object
3186 * @returns {ChannelMessage.EncryptionKeyInput} EncryptionKeyInput
3187 */
3188 EncryptionKeyInput.fromObject = function fromObject(object) {
3189 if (object instanceof $root.ChannelMessage.EncryptionKeyInput)
3190 return object;
3191 let message = new $root.ChannelMessage.EncryptionKeyInput();
3192 if (object.channelPubKey != null)
3193 if (typeof object.channelPubKey === "string")
3194 $util.base64.decode(object.channelPubKey, message.channelPubKey = $util.newBuffer($util.base64.length(object.channelPubKey)), 0);
3195 else if (object.channelPubKey.length)
3196 message.channelPubKey = object.channelPubKey;
3197 return message;
3198 };
3199
3200 /**
3201 * Creates a plain object from an EncryptionKeyInput message. Also converts values to other types if specified.
3202 * @function toObject
3203 * @memberof ChannelMessage.EncryptionKeyInput
3204 * @static
3205 * @param {ChannelMessage.EncryptionKeyInput} message EncryptionKeyInput
3206 * @param {$protobuf.IConversionOptions} [options] Conversion options
3207 * @returns {Object.<string,*>} Plain object
3208 */
3209 EncryptionKeyInput.toObject = function toObject(message, options) {
3210 if (!options)
3211 options = {};
3212 let object = {};
3213 if (options.defaults)
3214 if (options.bytes === String)
3215 object.channelPubKey = "";
3216 else {
3217 object.channelPubKey = [];
3218 if (options.bytes !== Array)
3219 object.channelPubKey = $util.newBuffer(object.channelPubKey);
3220 }
3221 if (message.channelPubKey != null && message.hasOwnProperty("channelPubKey"))
3222 object.channelPubKey = options.bytes === String ? $util.base64.encode(message.channelPubKey, 0, message.channelPubKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelPubKey) : message.channelPubKey;
3223 return object;
3224 };
3225
3226 /**
3227 * Converts this EncryptionKeyInput to JSON.
3228 * @function toJSON
3229 * @memberof ChannelMessage.EncryptionKeyInput
3230 * @instance
3231 * @returns {Object.<string,*>} JSON object
3232 */
3233 EncryptionKeyInput.prototype.toJSON = function toJSON() {
3234 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
3235 };
3236
3237 return EncryptionKeyInput;
3238 })();
3239
3240 return ChannelMessage;
3241})();
3242
3243export const Query = $root.Query = (() => {
3244
3245 /**
3246 * Properties of a Query.
3247 * @exports IQuery
3248 * @interface IQuery
3249 * @property {Uint8Array|null} [channelId] Query channelId
3250 * @property {number|null} [seq] Query seq
3251 * @property {number|Long|null} [height] Query height
3252 * @property {Uint8Array|null} [hash] Query hash
3253 * @property {boolean|null} [isBackward] Query isBackward
3254 * @property {number|null} [limit] Query limit
3255 */
3256
3257 /**
3258 * Constructs a new Query.
3259 * @exports Query
3260 * @classdesc Represents a Query.
3261 * @implements IQuery
3262 * @constructor
3263 * @param {IQuery=} [properties] Properties to set
3264 */
3265 function Query(properties) {
3266 if (properties)
3267 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
3268 if (properties[keys[i]] != null)
3269 this[keys[i]] = properties[keys[i]];
3270 }
3271
3272 /**
3273 * Query channelId.
3274 * @member {Uint8Array} channelId
3275 * @memberof Query
3276 * @instance
3277 */
3278 Query.prototype.channelId = $util.newBuffer([]);
3279
3280 /**
3281 * Query seq.
3282 * @member {number} seq
3283 * @memberof Query
3284 * @instance
3285 */
3286 Query.prototype.seq = 0;
3287
3288 /**
3289 * Query height.
3290 * @member {number|Long} height
3291 * @memberof Query
3292 * @instance
3293 */
3294 Query.prototype.height = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
3295
3296 /**
3297 * Query hash.
3298 * @member {Uint8Array} hash
3299 * @memberof Query
3300 * @instance
3301 */
3302 Query.prototype.hash = $util.newBuffer([]);
3303
3304 /**
3305 * Query isBackward.
3306 * @member {boolean} isBackward
3307 * @memberof Query
3308 * @instance
3309 */
3310 Query.prototype.isBackward = false;
3311
3312 /**
3313 * Query limit.
3314 * @member {number} limit
3315 * @memberof Query
3316 * @instance
3317 */
3318 Query.prototype.limit = 0;
3319
3320 // OneOf field names bound to virtual getters and setters
3321 let $oneOfFields;
3322
3323 /**
3324 * Query cursor.
3325 * @member {"height"|"hash"|undefined} cursor
3326 * @memberof Query
3327 * @instance
3328 */
3329 Object.defineProperty(Query.prototype, "cursor", {
3330 get: $util.oneOfGetter($oneOfFields = ["height", "hash"]),
3331 set: $util.oneOfSetter($oneOfFields)
3332 });
3333
3334 /**
3335 * Creates a new Query instance using the specified properties.
3336 * @function create
3337 * @memberof Query
3338 * @static
3339 * @param {IQuery=} [properties] Properties to set
3340 * @returns {Query} Query instance
3341 */
3342 Query.create = function create(properties) {
3343 return new Query(properties);
3344 };
3345
3346 /**
3347 * Encodes the specified Query message. Does not implicitly {@link Query.verify|verify} messages.
3348 * @function encode
3349 * @memberof Query
3350 * @static
3351 * @param {IQuery} message Query message or plain object to encode
3352 * @param {$protobuf.Writer} [writer] Writer to encode to
3353 * @returns {$protobuf.Writer} Writer
3354 */
3355 Query.encode = function encode(message, writer) {
3356 if (!writer)
3357 writer = $Writer.create();
3358 if (message.channelId != null && message.hasOwnProperty("channelId"))
3359 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
3360 if (message.seq != null && message.hasOwnProperty("seq"))
3361 writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.seq);
3362 if (message.height != null && message.hasOwnProperty("height"))
3363 writer.uint32(/* id 3, wireType 0 =*/24).int64(message.height);
3364 if (message.hash != null && message.hasOwnProperty("hash"))
3365 writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.hash);
3366 if (message.isBackward != null && message.hasOwnProperty("isBackward"))
3367 writer.uint32(/* id 5, wireType 0 =*/40).bool(message.isBackward);
3368 if (message.limit != null && message.hasOwnProperty("limit"))
3369 writer.uint32(/* id 6, wireType 0 =*/48).uint32(message.limit);
3370 return writer;
3371 };
3372
3373 /**
3374 * Encodes the specified Query message, length delimited. Does not implicitly {@link Query.verify|verify} messages.
3375 * @function encodeDelimited
3376 * @memberof Query
3377 * @static
3378 * @param {IQuery} message Query message or plain object to encode
3379 * @param {$protobuf.Writer} [writer] Writer to encode to
3380 * @returns {$protobuf.Writer} Writer
3381 */
3382 Query.encodeDelimited = function encodeDelimited(message, writer) {
3383 return this.encode(message, writer).ldelim();
3384 };
3385
3386 /**
3387 * Decodes a Query message from the specified reader or buffer.
3388 * @function decode
3389 * @memberof Query
3390 * @static
3391 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3392 * @param {number} [length] Message length if known beforehand
3393 * @returns {Query} Query
3394 * @throws {Error} If the payload is not a reader or valid buffer
3395 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3396 */
3397 Query.decode = function decode(reader, length) {
3398 if (!(reader instanceof $Reader))
3399 reader = $Reader.create(reader);
3400 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Query();
3401 while (reader.pos < end) {
3402 let tag = reader.uint32();
3403 switch (tag >>> 3) {
3404 case 1:
3405 message.channelId = reader.bytes();
3406 break;
3407 case 2:
3408 message.seq = reader.uint32();
3409 break;
3410 case 3:
3411 message.height = reader.int64();
3412 break;
3413 case 4:
3414 message.hash = reader.bytes();
3415 break;
3416 case 5:
3417 message.isBackward = reader.bool();
3418 break;
3419 case 6:
3420 message.limit = reader.uint32();
3421 break;
3422 default:
3423 reader.skipType(tag & 7);
3424 break;
3425 }
3426 }
3427 return message;
3428 };
3429
3430 /**
3431 * Decodes a Query message from the specified reader or buffer, length delimited.
3432 * @function decodeDelimited
3433 * @memberof Query
3434 * @static
3435 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3436 * @returns {Query} Query
3437 * @throws {Error} If the payload is not a reader or valid buffer
3438 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3439 */
3440 Query.decodeDelimited = function decodeDelimited(reader) {
3441 if (!(reader instanceof $Reader))
3442 reader = new $Reader(reader);
3443 return this.decode(reader, reader.uint32());
3444 };
3445
3446 /**
3447 * Verifies a Query message.
3448 * @function verify
3449 * @memberof Query
3450 * @static
3451 * @param {Object.<string,*>} message Plain object to verify
3452 * @returns {string|null} `null` if valid, otherwise the reason why it is not
3453 */
3454 Query.verify = function verify(message) {
3455 if (typeof message !== "object" || message === null)
3456 return "object expected";
3457 let properties = {};
3458 if (message.channelId != null && message.hasOwnProperty("channelId"))
3459 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
3460 return "channelId: buffer expected";
3461 if (message.seq != null && message.hasOwnProperty("seq"))
3462 if (!$util.isInteger(message.seq))
3463 return "seq: integer expected";
3464 if (message.height != null && message.hasOwnProperty("height")) {
3465 properties.cursor = 1;
3466 if (!$util.isInteger(message.height) && !(message.height && $util.isInteger(message.height.low) && $util.isInteger(message.height.high)))
3467 return "height: integer|Long expected";
3468 }
3469 if (message.hash != null && message.hasOwnProperty("hash")) {
3470 if (properties.cursor === 1)
3471 return "cursor: multiple values";
3472 properties.cursor = 1;
3473 if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash)))
3474 return "hash: buffer expected";
3475 }
3476 if (message.isBackward != null && message.hasOwnProperty("isBackward"))
3477 if (typeof message.isBackward !== "boolean")
3478 return "isBackward: boolean expected";
3479 if (message.limit != null && message.hasOwnProperty("limit"))
3480 if (!$util.isInteger(message.limit))
3481 return "limit: integer expected";
3482 return null;
3483 };
3484
3485 /**
3486 * Creates a Query message from a plain object. Also converts values to their respective internal types.
3487 * @function fromObject
3488 * @memberof Query
3489 * @static
3490 * @param {Object.<string,*>} object Plain object
3491 * @returns {Query} Query
3492 */
3493 Query.fromObject = function fromObject(object) {
3494 if (object instanceof $root.Query)
3495 return object;
3496 let message = new $root.Query();
3497 if (object.channelId != null)
3498 if (typeof object.channelId === "string")
3499 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
3500 else if (object.channelId.length)
3501 message.channelId = object.channelId;
3502 if (object.seq != null)
3503 message.seq = object.seq >>> 0;
3504 if (object.height != null)
3505 if ($util.Long)
3506 (message.height = $util.Long.fromValue(object.height)).unsigned = false;
3507 else if (typeof object.height === "string")
3508 message.height = parseInt(object.height, 10);
3509 else if (typeof object.height === "number")
3510 message.height = object.height;
3511 else if (typeof object.height === "object")
3512 message.height = new $util.LongBits(object.height.low >>> 0, object.height.high >>> 0).toNumber();
3513 if (object.hash != null)
3514 if (typeof object.hash === "string")
3515 $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0);
3516 else if (object.hash.length)
3517 message.hash = object.hash;
3518 if (object.isBackward != null)
3519 message.isBackward = Boolean(object.isBackward);
3520 if (object.limit != null)
3521 message.limit = object.limit >>> 0;
3522 return message;
3523 };
3524
3525 /**
3526 * Creates a plain object from a Query message. Also converts values to other types if specified.
3527 * @function toObject
3528 * @memberof Query
3529 * @static
3530 * @param {Query} message Query
3531 * @param {$protobuf.IConversionOptions} [options] Conversion options
3532 * @returns {Object.<string,*>} Plain object
3533 */
3534 Query.toObject = function toObject(message, options) {
3535 if (!options)
3536 options = {};
3537 let object = {};
3538 if (options.defaults) {
3539 if (options.bytes === String)
3540 object.channelId = "";
3541 else {
3542 object.channelId = [];
3543 if (options.bytes !== Array)
3544 object.channelId = $util.newBuffer(object.channelId);
3545 }
3546 object.seq = 0;
3547 object.isBackward = false;
3548 object.limit = 0;
3549 }
3550 if (message.channelId != null && message.hasOwnProperty("channelId"))
3551 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
3552 if (message.seq != null && message.hasOwnProperty("seq"))
3553 object.seq = message.seq;
3554 if (message.height != null && message.hasOwnProperty("height")) {
3555 if (typeof message.height === "number")
3556 object.height = options.longs === String ? String(message.height) : message.height;
3557 else
3558 object.height = options.longs === String ? $util.Long.prototype.toString.call(message.height) : options.longs === Number ? new $util.LongBits(message.height.low >>> 0, message.height.high >>> 0).toNumber() : message.height;
3559 if (options.oneofs)
3560 object.cursor = "height";
3561 }
3562 if (message.hash != null && message.hasOwnProperty("hash")) {
3563 object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash;
3564 if (options.oneofs)
3565 object.cursor = "hash";
3566 }
3567 if (message.isBackward != null && message.hasOwnProperty("isBackward"))
3568 object.isBackward = message.isBackward;
3569 if (message.limit != null && message.hasOwnProperty("limit"))
3570 object.limit = message.limit;
3571 return object;
3572 };
3573
3574 /**
3575 * Converts this Query to JSON.
3576 * @function toJSON
3577 * @memberof Query
3578 * @instance
3579 * @returns {Object.<string,*>} JSON object
3580 */
3581 Query.prototype.toJSON = function toJSON() {
3582 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
3583 };
3584
3585 return Query;
3586})();
3587
3588export const QueryResponse = $root.QueryResponse = (() => {
3589
3590 /**
3591 * Properties of a QueryResponse.
3592 * @exports IQueryResponse
3593 * @interface IQueryResponse
3594 * @property {Uint8Array|null} [channelId] QueryResponse channelId
3595 * @property {number|null} [seq] QueryResponse seq
3596 * @property {Array.<QueryResponse.IAbbreviated>|null} [abbreviatedMessages] QueryResponse abbreviatedMessages
3597 * @property {Uint8Array|null} [forwardHash] QueryResponse forwardHash
3598 * @property {Uint8Array|null} [backwardHash] QueryResponse backwardHash
3599 */
3600
3601 /**
3602 * Constructs a new QueryResponse.
3603 * @exports QueryResponse
3604 * @classdesc Represents a QueryResponse.
3605 * @implements IQueryResponse
3606 * @constructor
3607 * @param {IQueryResponse=} [properties] Properties to set
3608 */
3609 function QueryResponse(properties) {
3610 this.abbreviatedMessages = [];
3611 if (properties)
3612 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
3613 if (properties[keys[i]] != null)
3614 this[keys[i]] = properties[keys[i]];
3615 }
3616
3617 /**
3618 * QueryResponse channelId.
3619 * @member {Uint8Array} channelId
3620 * @memberof QueryResponse
3621 * @instance
3622 */
3623 QueryResponse.prototype.channelId = $util.newBuffer([]);
3624
3625 /**
3626 * QueryResponse seq.
3627 * @member {number} seq
3628 * @memberof QueryResponse
3629 * @instance
3630 */
3631 QueryResponse.prototype.seq = 0;
3632
3633 /**
3634 * QueryResponse abbreviatedMessages.
3635 * @member {Array.<QueryResponse.IAbbreviated>} abbreviatedMessages
3636 * @memberof QueryResponse
3637 * @instance
3638 */
3639 QueryResponse.prototype.abbreviatedMessages = $util.emptyArray;
3640
3641 /**
3642 * QueryResponse forwardHash.
3643 * @member {Uint8Array} forwardHash
3644 * @memberof QueryResponse
3645 * @instance
3646 */
3647 QueryResponse.prototype.forwardHash = $util.newBuffer([]);
3648
3649 /**
3650 * QueryResponse backwardHash.
3651 * @member {Uint8Array} backwardHash
3652 * @memberof QueryResponse
3653 * @instance
3654 */
3655 QueryResponse.prototype.backwardHash = $util.newBuffer([]);
3656
3657 /**
3658 * Creates a new QueryResponse instance using the specified properties.
3659 * @function create
3660 * @memberof QueryResponse
3661 * @static
3662 * @param {IQueryResponse=} [properties] Properties to set
3663 * @returns {QueryResponse} QueryResponse instance
3664 */
3665 QueryResponse.create = function create(properties) {
3666 return new QueryResponse(properties);
3667 };
3668
3669 /**
3670 * Encodes the specified QueryResponse message. Does not implicitly {@link QueryResponse.verify|verify} messages.
3671 * @function encode
3672 * @memberof QueryResponse
3673 * @static
3674 * @param {IQueryResponse} message QueryResponse message or plain object to encode
3675 * @param {$protobuf.Writer} [writer] Writer to encode to
3676 * @returns {$protobuf.Writer} Writer
3677 */
3678 QueryResponse.encode = function encode(message, writer) {
3679 if (!writer)
3680 writer = $Writer.create();
3681 if (message.channelId != null && message.hasOwnProperty("channelId"))
3682 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
3683 if (message.seq != null && message.hasOwnProperty("seq"))
3684 writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.seq);
3685 if (message.abbreviatedMessages != null && message.abbreviatedMessages.length)
3686 for (let i = 0; i < message.abbreviatedMessages.length; ++i)
3687 $root.QueryResponse.Abbreviated.encode(message.abbreviatedMessages[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
3688 if (message.forwardHash != null && message.hasOwnProperty("forwardHash"))
3689 writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.forwardHash);
3690 if (message.backwardHash != null && message.hasOwnProperty("backwardHash"))
3691 writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.backwardHash);
3692 return writer;
3693 };
3694
3695 /**
3696 * Encodes the specified QueryResponse message, length delimited. Does not implicitly {@link QueryResponse.verify|verify} messages.
3697 * @function encodeDelimited
3698 * @memberof QueryResponse
3699 * @static
3700 * @param {IQueryResponse} message QueryResponse message or plain object to encode
3701 * @param {$protobuf.Writer} [writer] Writer to encode to
3702 * @returns {$protobuf.Writer} Writer
3703 */
3704 QueryResponse.encodeDelimited = function encodeDelimited(message, writer) {
3705 return this.encode(message, writer).ldelim();
3706 };
3707
3708 /**
3709 * Decodes a QueryResponse message from the specified reader or buffer.
3710 * @function decode
3711 * @memberof QueryResponse
3712 * @static
3713 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3714 * @param {number} [length] Message length if known beforehand
3715 * @returns {QueryResponse} QueryResponse
3716 * @throws {Error} If the payload is not a reader or valid buffer
3717 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3718 */
3719 QueryResponse.decode = function decode(reader, length) {
3720 if (!(reader instanceof $Reader))
3721 reader = $Reader.create(reader);
3722 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.QueryResponse();
3723 while (reader.pos < end) {
3724 let tag = reader.uint32();
3725 switch (tag >>> 3) {
3726 case 1:
3727 message.channelId = reader.bytes();
3728 break;
3729 case 2:
3730 message.seq = reader.uint32();
3731 break;
3732 case 3:
3733 if (!(message.abbreviatedMessages && message.abbreviatedMessages.length))
3734 message.abbreviatedMessages = [];
3735 message.abbreviatedMessages.push($root.QueryResponse.Abbreviated.decode(reader, reader.uint32()));
3736 break;
3737 case 4:
3738 message.forwardHash = reader.bytes();
3739 break;
3740 case 5:
3741 message.backwardHash = reader.bytes();
3742 break;
3743 default:
3744 reader.skipType(tag & 7);
3745 break;
3746 }
3747 }
3748 return message;
3749 };
3750
3751 /**
3752 * Decodes a QueryResponse message from the specified reader or buffer, length delimited.
3753 * @function decodeDelimited
3754 * @memberof QueryResponse
3755 * @static
3756 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
3757 * @returns {QueryResponse} QueryResponse
3758 * @throws {Error} If the payload is not a reader or valid buffer
3759 * @throws {$protobuf.util.ProtocolError} If required fields are missing
3760 */
3761 QueryResponse.decodeDelimited = function decodeDelimited(reader) {
3762 if (!(reader instanceof $Reader))
3763 reader = new $Reader(reader);
3764 return this.decode(reader, reader.uint32());
3765 };
3766
3767 /**
3768 * Verifies a QueryResponse message.
3769 * @function verify
3770 * @memberof QueryResponse
3771 * @static
3772 * @param {Object.<string,*>} message Plain object to verify
3773 * @returns {string|null} `null` if valid, otherwise the reason why it is not
3774 */
3775 QueryResponse.verify = function verify(message) {
3776 if (typeof message !== "object" || message === null)
3777 return "object expected";
3778 if (message.channelId != null && message.hasOwnProperty("channelId"))
3779 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
3780 return "channelId: buffer expected";
3781 if (message.seq != null && message.hasOwnProperty("seq"))
3782 if (!$util.isInteger(message.seq))
3783 return "seq: integer expected";
3784 if (message.abbreviatedMessages != null && message.hasOwnProperty("abbreviatedMessages")) {
3785 if (!Array.isArray(message.abbreviatedMessages))
3786 return "abbreviatedMessages: array expected";
3787 for (let i = 0; i < message.abbreviatedMessages.length; ++i) {
3788 let error = $root.QueryResponse.Abbreviated.verify(message.abbreviatedMessages[i]);
3789 if (error)
3790 return "abbreviatedMessages." + error;
3791 }
3792 }
3793 if (message.forwardHash != null && message.hasOwnProperty("forwardHash"))
3794 if (!(message.forwardHash && typeof message.forwardHash.length === "number" || $util.isString(message.forwardHash)))
3795 return "forwardHash: buffer expected";
3796 if (message.backwardHash != null && message.hasOwnProperty("backwardHash"))
3797 if (!(message.backwardHash && typeof message.backwardHash.length === "number" || $util.isString(message.backwardHash)))
3798 return "backwardHash: buffer expected";
3799 return null;
3800 };
3801
3802 /**
3803 * Creates a QueryResponse message from a plain object. Also converts values to their respective internal types.
3804 * @function fromObject
3805 * @memberof QueryResponse
3806 * @static
3807 * @param {Object.<string,*>} object Plain object
3808 * @returns {QueryResponse} QueryResponse
3809 */
3810 QueryResponse.fromObject = function fromObject(object) {
3811 if (object instanceof $root.QueryResponse)
3812 return object;
3813 let message = new $root.QueryResponse();
3814 if (object.channelId != null)
3815 if (typeof object.channelId === "string")
3816 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
3817 else if (object.channelId.length)
3818 message.channelId = object.channelId;
3819 if (object.seq != null)
3820 message.seq = object.seq >>> 0;
3821 if (object.abbreviatedMessages) {
3822 if (!Array.isArray(object.abbreviatedMessages))
3823 throw TypeError(".QueryResponse.abbreviatedMessages: array expected");
3824 message.abbreviatedMessages = [];
3825 for (let i = 0; i < object.abbreviatedMessages.length; ++i) {
3826 if (typeof object.abbreviatedMessages[i] !== "object")
3827 throw TypeError(".QueryResponse.abbreviatedMessages: object expected");
3828 message.abbreviatedMessages[i] = $root.QueryResponse.Abbreviated.fromObject(object.abbreviatedMessages[i]);
3829 }
3830 }
3831 if (object.forwardHash != null)
3832 if (typeof object.forwardHash === "string")
3833 $util.base64.decode(object.forwardHash, message.forwardHash = $util.newBuffer($util.base64.length(object.forwardHash)), 0);
3834 else if (object.forwardHash.length)
3835 message.forwardHash = object.forwardHash;
3836 if (object.backwardHash != null)
3837 if (typeof object.backwardHash === "string")
3838 $util.base64.decode(object.backwardHash, message.backwardHash = $util.newBuffer($util.base64.length(object.backwardHash)), 0);
3839 else if (object.backwardHash.length)
3840 message.backwardHash = object.backwardHash;
3841 return message;
3842 };
3843
3844 /**
3845 * Creates a plain object from a QueryResponse message. Also converts values to other types if specified.
3846 * @function toObject
3847 * @memberof QueryResponse
3848 * @static
3849 * @param {QueryResponse} message QueryResponse
3850 * @param {$protobuf.IConversionOptions} [options] Conversion options
3851 * @returns {Object.<string,*>} Plain object
3852 */
3853 QueryResponse.toObject = function toObject(message, options) {
3854 if (!options)
3855 options = {};
3856 let object = {};
3857 if (options.arrays || options.defaults)
3858 object.abbreviatedMessages = [];
3859 if (options.defaults) {
3860 if (options.bytes === String)
3861 object.channelId = "";
3862 else {
3863 object.channelId = [];
3864 if (options.bytes !== Array)
3865 object.channelId = $util.newBuffer(object.channelId);
3866 }
3867 object.seq = 0;
3868 if (options.bytes === String)
3869 object.forwardHash = "";
3870 else {
3871 object.forwardHash = [];
3872 if (options.bytes !== Array)
3873 object.forwardHash = $util.newBuffer(object.forwardHash);
3874 }
3875 if (options.bytes === String)
3876 object.backwardHash = "";
3877 else {
3878 object.backwardHash = [];
3879 if (options.bytes !== Array)
3880 object.backwardHash = $util.newBuffer(object.backwardHash);
3881 }
3882 }
3883 if (message.channelId != null && message.hasOwnProperty("channelId"))
3884 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
3885 if (message.seq != null && message.hasOwnProperty("seq"))
3886 object.seq = message.seq;
3887 if (message.abbreviatedMessages && message.abbreviatedMessages.length) {
3888 object.abbreviatedMessages = [];
3889 for (let j = 0; j < message.abbreviatedMessages.length; ++j)
3890 object.abbreviatedMessages[j] = $root.QueryResponse.Abbreviated.toObject(message.abbreviatedMessages[j], options);
3891 }
3892 if (message.forwardHash != null && message.hasOwnProperty("forwardHash"))
3893 object.forwardHash = options.bytes === String ? $util.base64.encode(message.forwardHash, 0, message.forwardHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.forwardHash) : message.forwardHash;
3894 if (message.backwardHash != null && message.hasOwnProperty("backwardHash"))
3895 object.backwardHash = options.bytes === String ? $util.base64.encode(message.backwardHash, 0, message.backwardHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.backwardHash) : message.backwardHash;
3896 return object;
3897 };
3898
3899 /**
3900 * Converts this QueryResponse to JSON.
3901 * @function toJSON
3902 * @memberof QueryResponse
3903 * @instance
3904 * @returns {Object.<string,*>} JSON object
3905 */
3906 QueryResponse.prototype.toJSON = function toJSON() {
3907 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
3908 };
3909
3910 QueryResponse.Abbreviated = (function() {
3911
3912 /**
3913 * Properties of an Abbreviated.
3914 * @memberof QueryResponse
3915 * @interface IAbbreviated
3916 * @property {Array.<Uint8Array>|null} [parents] Abbreviated parents
3917 * @property {Uint8Array|null} [hash] Abbreviated hash
3918 */
3919
3920 /**
3921 * Constructs a new Abbreviated.
3922 * @memberof QueryResponse
3923 * @classdesc Represents an Abbreviated.
3924 * @implements IAbbreviated
3925 * @constructor
3926 * @param {QueryResponse.IAbbreviated=} [properties] Properties to set
3927 */
3928 function Abbreviated(properties) {
3929 this.parents = [];
3930 if (properties)
3931 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
3932 if (properties[keys[i]] != null)
3933 this[keys[i]] = properties[keys[i]];
3934 }
3935
3936 /**
3937 * Abbreviated parents.
3938 * @member {Array.<Uint8Array>} parents
3939 * @memberof QueryResponse.Abbreviated
3940 * @instance
3941 */
3942 Abbreviated.prototype.parents = $util.emptyArray;
3943
3944 /**
3945 * Abbreviated hash.
3946 * @member {Uint8Array} hash
3947 * @memberof QueryResponse.Abbreviated
3948 * @instance
3949 */
3950 Abbreviated.prototype.hash = $util.newBuffer([]);
3951
3952 /**
3953 * Creates a new Abbreviated instance using the specified properties.
3954 * @function create
3955 * @memberof QueryResponse.Abbreviated
3956 * @static
3957 * @param {QueryResponse.IAbbreviated=} [properties] Properties to set
3958 * @returns {QueryResponse.Abbreviated} Abbreviated instance
3959 */
3960 Abbreviated.create = function create(properties) {
3961 return new Abbreviated(properties);
3962 };
3963
3964 /**
3965 * Encodes the specified Abbreviated message. Does not implicitly {@link QueryResponse.Abbreviated.verify|verify} messages.
3966 * @function encode
3967 * @memberof QueryResponse.Abbreviated
3968 * @static
3969 * @param {QueryResponse.IAbbreviated} message Abbreviated message or plain object to encode
3970 * @param {$protobuf.Writer} [writer] Writer to encode to
3971 * @returns {$protobuf.Writer} Writer
3972 */
3973 Abbreviated.encode = function encode(message, writer) {
3974 if (!writer)
3975 writer = $Writer.create();
3976 if (message.parents != null && message.parents.length)
3977 for (let i = 0; i < message.parents.length; ++i)
3978 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.parents[i]);
3979 if (message.hash != null && message.hasOwnProperty("hash"))
3980 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.hash);
3981 return writer;
3982 };
3983
3984 /**
3985 * Encodes the specified Abbreviated message, length delimited. Does not implicitly {@link QueryResponse.Abbreviated.verify|verify} messages.
3986 * @function encodeDelimited
3987 * @memberof QueryResponse.Abbreviated
3988 * @static
3989 * @param {QueryResponse.IAbbreviated} message Abbreviated message or plain object to encode
3990 * @param {$protobuf.Writer} [writer] Writer to encode to
3991 * @returns {$protobuf.Writer} Writer
3992 */
3993 Abbreviated.encodeDelimited = function encodeDelimited(message, writer) {
3994 return this.encode(message, writer).ldelim();
3995 };
3996
3997 /**
3998 * Decodes an Abbreviated message from the specified reader or buffer.
3999 * @function decode
4000 * @memberof QueryResponse.Abbreviated
4001 * @static
4002 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4003 * @param {number} [length] Message length if known beforehand
4004 * @returns {QueryResponse.Abbreviated} Abbreviated
4005 * @throws {Error} If the payload is not a reader or valid buffer
4006 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4007 */
4008 Abbreviated.decode = function decode(reader, length) {
4009 if (!(reader instanceof $Reader))
4010 reader = $Reader.create(reader);
4011 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.QueryResponse.Abbreviated();
4012 while (reader.pos < end) {
4013 let tag = reader.uint32();
4014 switch (tag >>> 3) {
4015 case 1:
4016 if (!(message.parents && message.parents.length))
4017 message.parents = [];
4018 message.parents.push(reader.bytes());
4019 break;
4020 case 2:
4021 message.hash = reader.bytes();
4022 break;
4023 default:
4024 reader.skipType(tag & 7);
4025 break;
4026 }
4027 }
4028 return message;
4029 };
4030
4031 /**
4032 * Decodes an Abbreviated message from the specified reader or buffer, length delimited.
4033 * @function decodeDelimited
4034 * @memberof QueryResponse.Abbreviated
4035 * @static
4036 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4037 * @returns {QueryResponse.Abbreviated} Abbreviated
4038 * @throws {Error} If the payload is not a reader or valid buffer
4039 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4040 */
4041 Abbreviated.decodeDelimited = function decodeDelimited(reader) {
4042 if (!(reader instanceof $Reader))
4043 reader = new $Reader(reader);
4044 return this.decode(reader, reader.uint32());
4045 };
4046
4047 /**
4048 * Verifies an Abbreviated message.
4049 * @function verify
4050 * @memberof QueryResponse.Abbreviated
4051 * @static
4052 * @param {Object.<string,*>} message Plain object to verify
4053 * @returns {string|null} `null` if valid, otherwise the reason why it is not
4054 */
4055 Abbreviated.verify = function verify(message) {
4056 if (typeof message !== "object" || message === null)
4057 return "object expected";
4058 if (message.parents != null && message.hasOwnProperty("parents")) {
4059 if (!Array.isArray(message.parents))
4060 return "parents: array expected";
4061 for (let i = 0; i < message.parents.length; ++i)
4062 if (!(message.parents[i] && typeof message.parents[i].length === "number" || $util.isString(message.parents[i])))
4063 return "parents: buffer[] expected";
4064 }
4065 if (message.hash != null && message.hasOwnProperty("hash"))
4066 if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash)))
4067 return "hash: buffer expected";
4068 return null;
4069 };
4070
4071 /**
4072 * Creates an Abbreviated message from a plain object. Also converts values to their respective internal types.
4073 * @function fromObject
4074 * @memberof QueryResponse.Abbreviated
4075 * @static
4076 * @param {Object.<string,*>} object Plain object
4077 * @returns {QueryResponse.Abbreviated} Abbreviated
4078 */
4079 Abbreviated.fromObject = function fromObject(object) {
4080 if (object instanceof $root.QueryResponse.Abbreviated)
4081 return object;
4082 let message = new $root.QueryResponse.Abbreviated();
4083 if (object.parents) {
4084 if (!Array.isArray(object.parents))
4085 throw TypeError(".QueryResponse.Abbreviated.parents: array expected");
4086 message.parents = [];
4087 for (let i = 0; i < object.parents.length; ++i)
4088 if (typeof object.parents[i] === "string")
4089 $util.base64.decode(object.parents[i], message.parents[i] = $util.newBuffer($util.base64.length(object.parents[i])), 0);
4090 else if (object.parents[i].length)
4091 message.parents[i] = object.parents[i];
4092 }
4093 if (object.hash != null)
4094 if (typeof object.hash === "string")
4095 $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0);
4096 else if (object.hash.length)
4097 message.hash = object.hash;
4098 return message;
4099 };
4100
4101 /**
4102 * Creates a plain object from an Abbreviated message. Also converts values to other types if specified.
4103 * @function toObject
4104 * @memberof QueryResponse.Abbreviated
4105 * @static
4106 * @param {QueryResponse.Abbreviated} message Abbreviated
4107 * @param {$protobuf.IConversionOptions} [options] Conversion options
4108 * @returns {Object.<string,*>} Plain object
4109 */
4110 Abbreviated.toObject = function toObject(message, options) {
4111 if (!options)
4112 options = {};
4113 let object = {};
4114 if (options.arrays || options.defaults)
4115 object.parents = [];
4116 if (options.defaults)
4117 if (options.bytes === String)
4118 object.hash = "";
4119 else {
4120 object.hash = [];
4121 if (options.bytes !== Array)
4122 object.hash = $util.newBuffer(object.hash);
4123 }
4124 if (message.parents && message.parents.length) {
4125 object.parents = [];
4126 for (let j = 0; j < message.parents.length; ++j)
4127 object.parents[j] = options.bytes === String ? $util.base64.encode(message.parents[j], 0, message.parents[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.parents[j]) : message.parents[j];
4128 }
4129 if (message.hash != null && message.hasOwnProperty("hash"))
4130 object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash;
4131 return object;
4132 };
4133
4134 /**
4135 * Converts this Abbreviated to JSON.
4136 * @function toJSON
4137 * @memberof QueryResponse.Abbreviated
4138 * @instance
4139 * @returns {Object.<string,*>} JSON object
4140 */
4141 Abbreviated.prototype.toJSON = function toJSON() {
4142 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
4143 };
4144
4145 return Abbreviated;
4146 })();
4147
4148 return QueryResponse;
4149})();
4150
4151export const Bulk = $root.Bulk = (() => {
4152
4153 /**
4154 * Properties of a Bulk.
4155 * @exports IBulk
4156 * @interface IBulk
4157 * @property {Uint8Array|null} [channelId] Bulk channelId
4158 * @property {number|null} [seq] Bulk seq
4159 * @property {Array.<Uint8Array>|null} [hashes] Bulk hashes
4160 */
4161
4162 /**
4163 * Constructs a new Bulk.
4164 * @exports Bulk
4165 * @classdesc Represents a Bulk.
4166 * @implements IBulk
4167 * @constructor
4168 * @param {IBulk=} [properties] Properties to set
4169 */
4170 function Bulk(properties) {
4171 this.hashes = [];
4172 if (properties)
4173 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
4174 if (properties[keys[i]] != null)
4175 this[keys[i]] = properties[keys[i]];
4176 }
4177
4178 /**
4179 * Bulk channelId.
4180 * @member {Uint8Array} channelId
4181 * @memberof Bulk
4182 * @instance
4183 */
4184 Bulk.prototype.channelId = $util.newBuffer([]);
4185
4186 /**
4187 * Bulk seq.
4188 * @member {number} seq
4189 * @memberof Bulk
4190 * @instance
4191 */
4192 Bulk.prototype.seq = 0;
4193
4194 /**
4195 * Bulk hashes.
4196 * @member {Array.<Uint8Array>} hashes
4197 * @memberof Bulk
4198 * @instance
4199 */
4200 Bulk.prototype.hashes = $util.emptyArray;
4201
4202 /**
4203 * Creates a new Bulk instance using the specified properties.
4204 * @function create
4205 * @memberof Bulk
4206 * @static
4207 * @param {IBulk=} [properties] Properties to set
4208 * @returns {Bulk} Bulk instance
4209 */
4210 Bulk.create = function create(properties) {
4211 return new Bulk(properties);
4212 };
4213
4214 /**
4215 * Encodes the specified Bulk message. Does not implicitly {@link Bulk.verify|verify} messages.
4216 * @function encode
4217 * @memberof Bulk
4218 * @static
4219 * @param {IBulk} message Bulk message or plain object to encode
4220 * @param {$protobuf.Writer} [writer] Writer to encode to
4221 * @returns {$protobuf.Writer} Writer
4222 */
4223 Bulk.encode = function encode(message, writer) {
4224 if (!writer)
4225 writer = $Writer.create();
4226 if (message.channelId != null && message.hasOwnProperty("channelId"))
4227 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
4228 if (message.seq != null && message.hasOwnProperty("seq"))
4229 writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.seq);
4230 if (message.hashes != null && message.hashes.length)
4231 for (let i = 0; i < message.hashes.length; ++i)
4232 writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.hashes[i]);
4233 return writer;
4234 };
4235
4236 /**
4237 * Encodes the specified Bulk message, length delimited. Does not implicitly {@link Bulk.verify|verify} messages.
4238 * @function encodeDelimited
4239 * @memberof Bulk
4240 * @static
4241 * @param {IBulk} message Bulk message or plain object to encode
4242 * @param {$protobuf.Writer} [writer] Writer to encode to
4243 * @returns {$protobuf.Writer} Writer
4244 */
4245 Bulk.encodeDelimited = function encodeDelimited(message, writer) {
4246 return this.encode(message, writer).ldelim();
4247 };
4248
4249 /**
4250 * Decodes a Bulk message from the specified reader or buffer.
4251 * @function decode
4252 * @memberof Bulk
4253 * @static
4254 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4255 * @param {number} [length] Message length if known beforehand
4256 * @returns {Bulk} Bulk
4257 * @throws {Error} If the payload is not a reader or valid buffer
4258 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4259 */
4260 Bulk.decode = function decode(reader, length) {
4261 if (!(reader instanceof $Reader))
4262 reader = $Reader.create(reader);
4263 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Bulk();
4264 while (reader.pos < end) {
4265 let tag = reader.uint32();
4266 switch (tag >>> 3) {
4267 case 1:
4268 message.channelId = reader.bytes();
4269 break;
4270 case 2:
4271 message.seq = reader.uint32();
4272 break;
4273 case 3:
4274 if (!(message.hashes && message.hashes.length))
4275 message.hashes = [];
4276 message.hashes.push(reader.bytes());
4277 break;
4278 default:
4279 reader.skipType(tag & 7);
4280 break;
4281 }
4282 }
4283 return message;
4284 };
4285
4286 /**
4287 * Decodes a Bulk message from the specified reader or buffer, length delimited.
4288 * @function decodeDelimited
4289 * @memberof Bulk
4290 * @static
4291 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4292 * @returns {Bulk} Bulk
4293 * @throws {Error} If the payload is not a reader or valid buffer
4294 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4295 */
4296 Bulk.decodeDelimited = function decodeDelimited(reader) {
4297 if (!(reader instanceof $Reader))
4298 reader = new $Reader(reader);
4299 return this.decode(reader, reader.uint32());
4300 };
4301
4302 /**
4303 * Verifies a Bulk message.
4304 * @function verify
4305 * @memberof Bulk
4306 * @static
4307 * @param {Object.<string,*>} message Plain object to verify
4308 * @returns {string|null} `null` if valid, otherwise the reason why it is not
4309 */
4310 Bulk.verify = function verify(message) {
4311 if (typeof message !== "object" || message === null)
4312 return "object expected";
4313 if (message.channelId != null && message.hasOwnProperty("channelId"))
4314 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
4315 return "channelId: buffer expected";
4316 if (message.seq != null && message.hasOwnProperty("seq"))
4317 if (!$util.isInteger(message.seq))
4318 return "seq: integer expected";
4319 if (message.hashes != null && message.hasOwnProperty("hashes")) {
4320 if (!Array.isArray(message.hashes))
4321 return "hashes: array expected";
4322 for (let i = 0; i < message.hashes.length; ++i)
4323 if (!(message.hashes[i] && typeof message.hashes[i].length === "number" || $util.isString(message.hashes[i])))
4324 return "hashes: buffer[] expected";
4325 }
4326 return null;
4327 };
4328
4329 /**
4330 * Creates a Bulk message from a plain object. Also converts values to their respective internal types.
4331 * @function fromObject
4332 * @memberof Bulk
4333 * @static
4334 * @param {Object.<string,*>} object Plain object
4335 * @returns {Bulk} Bulk
4336 */
4337 Bulk.fromObject = function fromObject(object) {
4338 if (object instanceof $root.Bulk)
4339 return object;
4340 let message = new $root.Bulk();
4341 if (object.channelId != null)
4342 if (typeof object.channelId === "string")
4343 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
4344 else if (object.channelId.length)
4345 message.channelId = object.channelId;
4346 if (object.seq != null)
4347 message.seq = object.seq >>> 0;
4348 if (object.hashes) {
4349 if (!Array.isArray(object.hashes))
4350 throw TypeError(".Bulk.hashes: array expected");
4351 message.hashes = [];
4352 for (let i = 0; i < object.hashes.length; ++i)
4353 if (typeof object.hashes[i] === "string")
4354 $util.base64.decode(object.hashes[i], message.hashes[i] = $util.newBuffer($util.base64.length(object.hashes[i])), 0);
4355 else if (object.hashes[i].length)
4356 message.hashes[i] = object.hashes[i];
4357 }
4358 return message;
4359 };
4360
4361 /**
4362 * Creates a plain object from a Bulk message. Also converts values to other types if specified.
4363 * @function toObject
4364 * @memberof Bulk
4365 * @static
4366 * @param {Bulk} message Bulk
4367 * @param {$protobuf.IConversionOptions} [options] Conversion options
4368 * @returns {Object.<string,*>} Plain object
4369 */
4370 Bulk.toObject = function toObject(message, options) {
4371 if (!options)
4372 options = {};
4373 let object = {};
4374 if (options.arrays || options.defaults)
4375 object.hashes = [];
4376 if (options.defaults) {
4377 if (options.bytes === String)
4378 object.channelId = "";
4379 else {
4380 object.channelId = [];
4381 if (options.bytes !== Array)
4382 object.channelId = $util.newBuffer(object.channelId);
4383 }
4384 object.seq = 0;
4385 }
4386 if (message.channelId != null && message.hasOwnProperty("channelId"))
4387 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
4388 if (message.seq != null && message.hasOwnProperty("seq"))
4389 object.seq = message.seq;
4390 if (message.hashes && message.hashes.length) {
4391 object.hashes = [];
4392 for (let j = 0; j < message.hashes.length; ++j)
4393 object.hashes[j] = options.bytes === String ? $util.base64.encode(message.hashes[j], 0, message.hashes[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.hashes[j]) : message.hashes[j];
4394 }
4395 return object;
4396 };
4397
4398 /**
4399 * Converts this Bulk to JSON.
4400 * @function toJSON
4401 * @memberof Bulk
4402 * @instance
4403 * @returns {Object.<string,*>} JSON object
4404 */
4405 Bulk.prototype.toJSON = function toJSON() {
4406 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
4407 };
4408
4409 return Bulk;
4410})();
4411
4412export const BulkResponse = $root.BulkResponse = (() => {
4413
4414 /**
4415 * Properties of a BulkResponse.
4416 * @exports IBulkResponse
4417 * @interface IBulkResponse
4418 * @property {Uint8Array|null} [channelId] BulkResponse channelId
4419 * @property {number|null} [seq] BulkResponse seq
4420 * @property {Array.<IChannelMessage>|null} [messages] BulkResponse messages
4421 * @property {number|null} [forwardIndex] BulkResponse forwardIndex
4422 */
4423
4424 /**
4425 * Constructs a new BulkResponse.
4426 * @exports BulkResponse
4427 * @classdesc Represents a BulkResponse.
4428 * @implements IBulkResponse
4429 * @constructor
4430 * @param {IBulkResponse=} [properties] Properties to set
4431 */
4432 function BulkResponse(properties) {
4433 this.messages = [];
4434 if (properties)
4435 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
4436 if (properties[keys[i]] != null)
4437 this[keys[i]] = properties[keys[i]];
4438 }
4439
4440 /**
4441 * BulkResponse channelId.
4442 * @member {Uint8Array} channelId
4443 * @memberof BulkResponse
4444 * @instance
4445 */
4446 BulkResponse.prototype.channelId = $util.newBuffer([]);
4447
4448 /**
4449 * BulkResponse seq.
4450 * @member {number} seq
4451 * @memberof BulkResponse
4452 * @instance
4453 */
4454 BulkResponse.prototype.seq = 0;
4455
4456 /**
4457 * BulkResponse messages.
4458 * @member {Array.<IChannelMessage>} messages
4459 * @memberof BulkResponse
4460 * @instance
4461 */
4462 BulkResponse.prototype.messages = $util.emptyArray;
4463
4464 /**
4465 * BulkResponse forwardIndex.
4466 * @member {number} forwardIndex
4467 * @memberof BulkResponse
4468 * @instance
4469 */
4470 BulkResponse.prototype.forwardIndex = 0;
4471
4472 /**
4473 * Creates a new BulkResponse instance using the specified properties.
4474 * @function create
4475 * @memberof BulkResponse
4476 * @static
4477 * @param {IBulkResponse=} [properties] Properties to set
4478 * @returns {BulkResponse} BulkResponse instance
4479 */
4480 BulkResponse.create = function create(properties) {
4481 return new BulkResponse(properties);
4482 };
4483
4484 /**
4485 * Encodes the specified BulkResponse message. Does not implicitly {@link BulkResponse.verify|verify} messages.
4486 * @function encode
4487 * @memberof BulkResponse
4488 * @static
4489 * @param {IBulkResponse} message BulkResponse message or plain object to encode
4490 * @param {$protobuf.Writer} [writer] Writer to encode to
4491 * @returns {$protobuf.Writer} Writer
4492 */
4493 BulkResponse.encode = function encode(message, writer) {
4494 if (!writer)
4495 writer = $Writer.create();
4496 if (message.channelId != null && message.hasOwnProperty("channelId"))
4497 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
4498 if (message.seq != null && message.hasOwnProperty("seq"))
4499 writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.seq);
4500 if (message.messages != null && message.messages.length)
4501 for (let i = 0; i < message.messages.length; ++i)
4502 $root.ChannelMessage.encode(message.messages[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
4503 if (message.forwardIndex != null && message.hasOwnProperty("forwardIndex"))
4504 writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.forwardIndex);
4505 return writer;
4506 };
4507
4508 /**
4509 * Encodes the specified BulkResponse message, length delimited. Does not implicitly {@link BulkResponse.verify|verify} messages.
4510 * @function encodeDelimited
4511 * @memberof BulkResponse
4512 * @static
4513 * @param {IBulkResponse} message BulkResponse message or plain object to encode
4514 * @param {$protobuf.Writer} [writer] Writer to encode to
4515 * @returns {$protobuf.Writer} Writer
4516 */
4517 BulkResponse.encodeDelimited = function encodeDelimited(message, writer) {
4518 return this.encode(message, writer).ldelim();
4519 };
4520
4521 /**
4522 * Decodes a BulkResponse message from the specified reader or buffer.
4523 * @function decode
4524 * @memberof BulkResponse
4525 * @static
4526 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4527 * @param {number} [length] Message length if known beforehand
4528 * @returns {BulkResponse} BulkResponse
4529 * @throws {Error} If the payload is not a reader or valid buffer
4530 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4531 */
4532 BulkResponse.decode = function decode(reader, length) {
4533 if (!(reader instanceof $Reader))
4534 reader = $Reader.create(reader);
4535 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.BulkResponse();
4536 while (reader.pos < end) {
4537 let tag = reader.uint32();
4538 switch (tag >>> 3) {
4539 case 1:
4540 message.channelId = reader.bytes();
4541 break;
4542 case 2:
4543 message.seq = reader.uint32();
4544 break;
4545 case 3:
4546 if (!(message.messages && message.messages.length))
4547 message.messages = [];
4548 message.messages.push($root.ChannelMessage.decode(reader, reader.uint32()));
4549 break;
4550 case 4:
4551 message.forwardIndex = reader.uint32();
4552 break;
4553 default:
4554 reader.skipType(tag & 7);
4555 break;
4556 }
4557 }
4558 return message;
4559 };
4560
4561 /**
4562 * Decodes a BulkResponse message from the specified reader or buffer, length delimited.
4563 * @function decodeDelimited
4564 * @memberof BulkResponse
4565 * @static
4566 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4567 * @returns {BulkResponse} BulkResponse
4568 * @throws {Error} If the payload is not a reader or valid buffer
4569 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4570 */
4571 BulkResponse.decodeDelimited = function decodeDelimited(reader) {
4572 if (!(reader instanceof $Reader))
4573 reader = new $Reader(reader);
4574 return this.decode(reader, reader.uint32());
4575 };
4576
4577 /**
4578 * Verifies a BulkResponse message.
4579 * @function verify
4580 * @memberof BulkResponse
4581 * @static
4582 * @param {Object.<string,*>} message Plain object to verify
4583 * @returns {string|null} `null` if valid, otherwise the reason why it is not
4584 */
4585 BulkResponse.verify = function verify(message) {
4586 if (typeof message !== "object" || message === null)
4587 return "object expected";
4588 if (message.channelId != null && message.hasOwnProperty("channelId"))
4589 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
4590 return "channelId: buffer expected";
4591 if (message.seq != null && message.hasOwnProperty("seq"))
4592 if (!$util.isInteger(message.seq))
4593 return "seq: integer expected";
4594 if (message.messages != null && message.hasOwnProperty("messages")) {
4595 if (!Array.isArray(message.messages))
4596 return "messages: array expected";
4597 for (let i = 0; i < message.messages.length; ++i) {
4598 let error = $root.ChannelMessage.verify(message.messages[i]);
4599 if (error)
4600 return "messages." + error;
4601 }
4602 }
4603 if (message.forwardIndex != null && message.hasOwnProperty("forwardIndex"))
4604 if (!$util.isInteger(message.forwardIndex))
4605 return "forwardIndex: integer expected";
4606 return null;
4607 };
4608
4609 /**
4610 * Creates a BulkResponse message from a plain object. Also converts values to their respective internal types.
4611 * @function fromObject
4612 * @memberof BulkResponse
4613 * @static
4614 * @param {Object.<string,*>} object Plain object
4615 * @returns {BulkResponse} BulkResponse
4616 */
4617 BulkResponse.fromObject = function fromObject(object) {
4618 if (object instanceof $root.BulkResponse)
4619 return object;
4620 let message = new $root.BulkResponse();
4621 if (object.channelId != null)
4622 if (typeof object.channelId === "string")
4623 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
4624 else if (object.channelId.length)
4625 message.channelId = object.channelId;
4626 if (object.seq != null)
4627 message.seq = object.seq >>> 0;
4628 if (object.messages) {
4629 if (!Array.isArray(object.messages))
4630 throw TypeError(".BulkResponse.messages: array expected");
4631 message.messages = [];
4632 for (let i = 0; i < object.messages.length; ++i) {
4633 if (typeof object.messages[i] !== "object")
4634 throw TypeError(".BulkResponse.messages: object expected");
4635 message.messages[i] = $root.ChannelMessage.fromObject(object.messages[i]);
4636 }
4637 }
4638 if (object.forwardIndex != null)
4639 message.forwardIndex = object.forwardIndex >>> 0;
4640 return message;
4641 };
4642
4643 /**
4644 * Creates a plain object from a BulkResponse message. Also converts values to other types if specified.
4645 * @function toObject
4646 * @memberof BulkResponse
4647 * @static
4648 * @param {BulkResponse} message BulkResponse
4649 * @param {$protobuf.IConversionOptions} [options] Conversion options
4650 * @returns {Object.<string,*>} Plain object
4651 */
4652 BulkResponse.toObject = function toObject(message, options) {
4653 if (!options)
4654 options = {};
4655 let object = {};
4656 if (options.arrays || options.defaults)
4657 object.messages = [];
4658 if (options.defaults) {
4659 if (options.bytes === String)
4660 object.channelId = "";
4661 else {
4662 object.channelId = [];
4663 if (options.bytes !== Array)
4664 object.channelId = $util.newBuffer(object.channelId);
4665 }
4666 object.seq = 0;
4667 object.forwardIndex = 0;
4668 }
4669 if (message.channelId != null && message.hasOwnProperty("channelId"))
4670 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
4671 if (message.seq != null && message.hasOwnProperty("seq"))
4672 object.seq = message.seq;
4673 if (message.messages && message.messages.length) {
4674 object.messages = [];
4675 for (let j = 0; j < message.messages.length; ++j)
4676 object.messages[j] = $root.ChannelMessage.toObject(message.messages[j], options);
4677 }
4678 if (message.forwardIndex != null && message.hasOwnProperty("forwardIndex"))
4679 object.forwardIndex = message.forwardIndex;
4680 return object;
4681 };
4682
4683 /**
4684 * Converts this BulkResponse to JSON.
4685 * @function toJSON
4686 * @memberof BulkResponse
4687 * @instance
4688 * @returns {Object.<string,*>} JSON object
4689 */
4690 BulkResponse.prototype.toJSON = function toJSON() {
4691 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
4692 };
4693
4694 return BulkResponse;
4695})();
4696
4697export const Error = $root.Error = (() => {
4698
4699 /**
4700 * Properties of an Error.
4701 * @exports IError
4702 * @interface IError
4703 * @property {string|null} [reason] Error reason
4704 */
4705
4706 /**
4707 * Constructs a new Error.
4708 * @exports Error
4709 * @classdesc Represents an Error.
4710 * @implements IError
4711 * @constructor
4712 * @param {IError=} [properties] Properties to set
4713 */
4714 function Error(properties) {
4715 if (properties)
4716 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
4717 if (properties[keys[i]] != null)
4718 this[keys[i]] = properties[keys[i]];
4719 }
4720
4721 /**
4722 * Error reason.
4723 * @member {string} reason
4724 * @memberof Error
4725 * @instance
4726 */
4727 Error.prototype.reason = "";
4728
4729 /**
4730 * Creates a new Error instance using the specified properties.
4731 * @function create
4732 * @memberof Error
4733 * @static
4734 * @param {IError=} [properties] Properties to set
4735 * @returns {Error} Error instance
4736 */
4737 Error.create = function create(properties) {
4738 return new Error(properties);
4739 };
4740
4741 /**
4742 * Encodes the specified Error message. Does not implicitly {@link Error.verify|verify} messages.
4743 * @function encode
4744 * @memberof Error
4745 * @static
4746 * @param {IError} message Error message or plain object to encode
4747 * @param {$protobuf.Writer} [writer] Writer to encode to
4748 * @returns {$protobuf.Writer} Writer
4749 */
4750 Error.encode = function encode(message, writer) {
4751 if (!writer)
4752 writer = $Writer.create();
4753 if (message.reason != null && message.hasOwnProperty("reason"))
4754 writer.uint32(/* id 1, wireType 2 =*/10).string(message.reason);
4755 return writer;
4756 };
4757
4758 /**
4759 * Encodes the specified Error message, length delimited. Does not implicitly {@link Error.verify|verify} messages.
4760 * @function encodeDelimited
4761 * @memberof Error
4762 * @static
4763 * @param {IError} message Error message or plain object to encode
4764 * @param {$protobuf.Writer} [writer] Writer to encode to
4765 * @returns {$protobuf.Writer} Writer
4766 */
4767 Error.encodeDelimited = function encodeDelimited(message, writer) {
4768 return this.encode(message, writer).ldelim();
4769 };
4770
4771 /**
4772 * Decodes an Error message from the specified reader or buffer.
4773 * @function decode
4774 * @memberof Error
4775 * @static
4776 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4777 * @param {number} [length] Message length if known beforehand
4778 * @returns {Error} Error
4779 * @throws {Error} If the payload is not a reader or valid buffer
4780 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4781 */
4782 Error.decode = function decode(reader, length) {
4783 if (!(reader instanceof $Reader))
4784 reader = $Reader.create(reader);
4785 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Error();
4786 while (reader.pos < end) {
4787 let tag = reader.uint32();
4788 switch (tag >>> 3) {
4789 case 1:
4790 message.reason = reader.string();
4791 break;
4792 default:
4793 reader.skipType(tag & 7);
4794 break;
4795 }
4796 }
4797 return message;
4798 };
4799
4800 /**
4801 * Decodes an Error message from the specified reader or buffer, length delimited.
4802 * @function decodeDelimited
4803 * @memberof Error
4804 * @static
4805 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4806 * @returns {Error} Error
4807 * @throws {Error} If the payload is not a reader or valid buffer
4808 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4809 */
4810 Error.decodeDelimited = function decodeDelimited(reader) {
4811 if (!(reader instanceof $Reader))
4812 reader = new $Reader(reader);
4813 return this.decode(reader, reader.uint32());
4814 };
4815
4816 /**
4817 * Verifies an Error message.
4818 * @function verify
4819 * @memberof Error
4820 * @static
4821 * @param {Object.<string,*>} message Plain object to verify
4822 * @returns {string|null} `null` if valid, otherwise the reason why it is not
4823 */
4824 Error.verify = function verify(message) {
4825 if (typeof message !== "object" || message === null)
4826 return "object expected";
4827 if (message.reason != null && message.hasOwnProperty("reason"))
4828 if (!$util.isString(message.reason))
4829 return "reason: string expected";
4830 return null;
4831 };
4832
4833 /**
4834 * Creates an Error message from a plain object. Also converts values to their respective internal types.
4835 * @function fromObject
4836 * @memberof Error
4837 * @static
4838 * @param {Object.<string,*>} object Plain object
4839 * @returns {Error} Error
4840 */
4841 Error.fromObject = function fromObject(object) {
4842 if (object instanceof $root.Error)
4843 return object;
4844 let message = new $root.Error();
4845 if (object.reason != null)
4846 message.reason = String(object.reason);
4847 return message;
4848 };
4849
4850 /**
4851 * Creates a plain object from an Error message. Also converts values to other types if specified.
4852 * @function toObject
4853 * @memberof Error
4854 * @static
4855 * @param {Error} message Error
4856 * @param {$protobuf.IConversionOptions} [options] Conversion options
4857 * @returns {Object.<string,*>} Plain object
4858 */
4859 Error.toObject = function toObject(message, options) {
4860 if (!options)
4861 options = {};
4862 let object = {};
4863 if (options.defaults)
4864 object.reason = "";
4865 if (message.reason != null && message.hasOwnProperty("reason"))
4866 object.reason = message.reason;
4867 return object;
4868 };
4869
4870 /**
4871 * Converts this Error to JSON.
4872 * @function toJSON
4873 * @memberof Error
4874 * @instance
4875 * @returns {Object.<string,*>} JSON object
4876 */
4877 Error.prototype.toJSON = function toJSON() {
4878 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
4879 };
4880
4881 return Error;
4882})();
4883
4884export const Notification = $root.Notification = (() => {
4885
4886 /**
4887 * Properties of a Notification.
4888 * @exports INotification
4889 * @interface INotification
4890 * @property {Uint8Array|null} [channelId] Notification channelId
4891 */
4892
4893 /**
4894 * Constructs a new Notification.
4895 * @exports Notification
4896 * @classdesc Represents a Notification.
4897 * @implements INotification
4898 * @constructor
4899 * @param {INotification=} [properties] Properties to set
4900 */
4901 function Notification(properties) {
4902 if (properties)
4903 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
4904 if (properties[keys[i]] != null)
4905 this[keys[i]] = properties[keys[i]];
4906 }
4907
4908 /**
4909 * Notification channelId.
4910 * @member {Uint8Array} channelId
4911 * @memberof Notification
4912 * @instance
4913 */
4914 Notification.prototype.channelId = $util.newBuffer([]);
4915
4916 /**
4917 * Creates a new Notification instance using the specified properties.
4918 * @function create
4919 * @memberof Notification
4920 * @static
4921 * @param {INotification=} [properties] Properties to set
4922 * @returns {Notification} Notification instance
4923 */
4924 Notification.create = function create(properties) {
4925 return new Notification(properties);
4926 };
4927
4928 /**
4929 * Encodes the specified Notification message. Does not implicitly {@link Notification.verify|verify} messages.
4930 * @function encode
4931 * @memberof Notification
4932 * @static
4933 * @param {INotification} message Notification message or plain object to encode
4934 * @param {$protobuf.Writer} [writer] Writer to encode to
4935 * @returns {$protobuf.Writer} Writer
4936 */
4937 Notification.encode = function encode(message, writer) {
4938 if (!writer)
4939 writer = $Writer.create();
4940 if (message.channelId != null && message.hasOwnProperty("channelId"))
4941 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
4942 return writer;
4943 };
4944
4945 /**
4946 * Encodes the specified Notification message, length delimited. Does not implicitly {@link Notification.verify|verify} messages.
4947 * @function encodeDelimited
4948 * @memberof Notification
4949 * @static
4950 * @param {INotification} message Notification message or plain object to encode
4951 * @param {$protobuf.Writer} [writer] Writer to encode to
4952 * @returns {$protobuf.Writer} Writer
4953 */
4954 Notification.encodeDelimited = function encodeDelimited(message, writer) {
4955 return this.encode(message, writer).ldelim();
4956 };
4957
4958 /**
4959 * Decodes a Notification message from the specified reader or buffer.
4960 * @function decode
4961 * @memberof Notification
4962 * @static
4963 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4964 * @param {number} [length] Message length if known beforehand
4965 * @returns {Notification} Notification
4966 * @throws {Error} If the payload is not a reader or valid buffer
4967 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4968 */
4969 Notification.decode = function decode(reader, length) {
4970 if (!(reader instanceof $Reader))
4971 reader = $Reader.create(reader);
4972 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Notification();
4973 while (reader.pos < end) {
4974 let tag = reader.uint32();
4975 switch (tag >>> 3) {
4976 case 1:
4977 message.channelId = reader.bytes();
4978 break;
4979 default:
4980 reader.skipType(tag & 7);
4981 break;
4982 }
4983 }
4984 return message;
4985 };
4986
4987 /**
4988 * Decodes a Notification message from the specified reader or buffer, length delimited.
4989 * @function decodeDelimited
4990 * @memberof Notification
4991 * @static
4992 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
4993 * @returns {Notification} Notification
4994 * @throws {Error} If the payload is not a reader or valid buffer
4995 * @throws {$protobuf.util.ProtocolError} If required fields are missing
4996 */
4997 Notification.decodeDelimited = function decodeDelimited(reader) {
4998 if (!(reader instanceof $Reader))
4999 reader = new $Reader(reader);
5000 return this.decode(reader, reader.uint32());
5001 };
5002
5003 /**
5004 * Verifies a Notification message.
5005 * @function verify
5006 * @memberof Notification
5007 * @static
5008 * @param {Object.<string,*>} message Plain object to verify
5009 * @returns {string|null} `null` if valid, otherwise the reason why it is not
5010 */
5011 Notification.verify = function verify(message) {
5012 if (typeof message !== "object" || message === null)
5013 return "object expected";
5014 if (message.channelId != null && message.hasOwnProperty("channelId"))
5015 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
5016 return "channelId: buffer expected";
5017 return null;
5018 };
5019
5020 /**
5021 * Creates a Notification message from a plain object. Also converts values to their respective internal types.
5022 * @function fromObject
5023 * @memberof Notification
5024 * @static
5025 * @param {Object.<string,*>} object Plain object
5026 * @returns {Notification} Notification
5027 */
5028 Notification.fromObject = function fromObject(object) {
5029 if (object instanceof $root.Notification)
5030 return object;
5031 let message = new $root.Notification();
5032 if (object.channelId != null)
5033 if (typeof object.channelId === "string")
5034 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
5035 else if (object.channelId.length)
5036 message.channelId = object.channelId;
5037 return message;
5038 };
5039
5040 /**
5041 * Creates a plain object from a Notification message. Also converts values to other types if specified.
5042 * @function toObject
5043 * @memberof Notification
5044 * @static
5045 * @param {Notification} message Notification
5046 * @param {$protobuf.IConversionOptions} [options] Conversion options
5047 * @returns {Object.<string,*>} Plain object
5048 */
5049 Notification.toObject = function toObject(message, options) {
5050 if (!options)
5051 options = {};
5052 let object = {};
5053 if (options.defaults)
5054 if (options.bytes === String)
5055 object.channelId = "";
5056 else {
5057 object.channelId = [];
5058 if (options.bytes !== Array)
5059 object.channelId = $util.newBuffer(object.channelId);
5060 }
5061 if (message.channelId != null && message.hasOwnProperty("channelId"))
5062 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
5063 return object;
5064 };
5065
5066 /**
5067 * Converts this Notification to JSON.
5068 * @function toJSON
5069 * @memberof Notification
5070 * @instance
5071 * @returns {Object.<string,*>} JSON object
5072 */
5073 Notification.prototype.toJSON = function toJSON() {
5074 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
5075 };
5076
5077 return Notification;
5078})();
5079
5080export const Packet = $root.Packet = (() => {
5081
5082 /**
5083 * Properties of a Packet.
5084 * @exports IPacket
5085 * @interface IPacket
5086 * @property {IError|null} [error] Packet error
5087 * @property {IEncryptedInvite|null} [invite] Packet invite
5088 * @property {IQuery|null} [query] Packet query
5089 * @property {IQueryResponse|null} [queryResponse] Packet queryResponse
5090 * @property {IBulk|null} [bulk] Packet bulk
5091 * @property {IBulkResponse|null} [bulkResponse] Packet bulkResponse
5092 * @property {INotification|null} [notification] Packet notification
5093 */
5094
5095 /**
5096 * Constructs a new Packet.
5097 * @exports Packet
5098 * @classdesc Represents a Packet.
5099 * @implements IPacket
5100 * @constructor
5101 * @param {IPacket=} [properties] Properties to set
5102 */
5103 function Packet(properties) {
5104 if (properties)
5105 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
5106 if (properties[keys[i]] != null)
5107 this[keys[i]] = properties[keys[i]];
5108 }
5109
5110 /**
5111 * Packet error.
5112 * @member {IError|null|undefined} error
5113 * @memberof Packet
5114 * @instance
5115 */
5116 Packet.prototype.error = null;
5117
5118 /**
5119 * Packet invite.
5120 * @member {IEncryptedInvite|null|undefined} invite
5121 * @memberof Packet
5122 * @instance
5123 */
5124 Packet.prototype.invite = null;
5125
5126 /**
5127 * Packet query.
5128 * @member {IQuery|null|undefined} query
5129 * @memberof Packet
5130 * @instance
5131 */
5132 Packet.prototype.query = null;
5133
5134 /**
5135 * Packet queryResponse.
5136 * @member {IQueryResponse|null|undefined} queryResponse
5137 * @memberof Packet
5138 * @instance
5139 */
5140 Packet.prototype.queryResponse = null;
5141
5142 /**
5143 * Packet bulk.
5144 * @member {IBulk|null|undefined} bulk
5145 * @memberof Packet
5146 * @instance
5147 */
5148 Packet.prototype.bulk = null;
5149
5150 /**
5151 * Packet bulkResponse.
5152 * @member {IBulkResponse|null|undefined} bulkResponse
5153 * @memberof Packet
5154 * @instance
5155 */
5156 Packet.prototype.bulkResponse = null;
5157
5158 /**
5159 * Packet notification.
5160 * @member {INotification|null|undefined} notification
5161 * @memberof Packet
5162 * @instance
5163 */
5164 Packet.prototype.notification = null;
5165
5166 // OneOf field names bound to virtual getters and setters
5167 let $oneOfFields;
5168
5169 /**
5170 * Packet content.
5171 * @member {"error"|"invite"|"query"|"queryResponse"|"bulk"|"bulkResponse"|"notification"|undefined} content
5172 * @memberof Packet
5173 * @instance
5174 */
5175 Object.defineProperty(Packet.prototype, "content", {
5176 get: $util.oneOfGetter($oneOfFields = ["error", "invite", "query", "queryResponse", "bulk", "bulkResponse", "notification"]),
5177 set: $util.oneOfSetter($oneOfFields)
5178 });
5179
5180 /**
5181 * Creates a new Packet instance using the specified properties.
5182 * @function create
5183 * @memberof Packet
5184 * @static
5185 * @param {IPacket=} [properties] Properties to set
5186 * @returns {Packet} Packet instance
5187 */
5188 Packet.create = function create(properties) {
5189 return new Packet(properties);
5190 };
5191
5192 /**
5193 * Encodes the specified Packet message. Does not implicitly {@link Packet.verify|verify} messages.
5194 * @function encode
5195 * @memberof Packet
5196 * @static
5197 * @param {IPacket} message Packet message or plain object to encode
5198 * @param {$protobuf.Writer} [writer] Writer to encode to
5199 * @returns {$protobuf.Writer} Writer
5200 */
5201 Packet.encode = function encode(message, writer) {
5202 if (!writer)
5203 writer = $Writer.create();
5204 if (message.error != null && message.hasOwnProperty("error"))
5205 $root.Error.encode(message.error, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
5206 if (message.invite != null && message.hasOwnProperty("invite"))
5207 $root.EncryptedInvite.encode(message.invite, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
5208 if (message.query != null && message.hasOwnProperty("query"))
5209 $root.Query.encode(message.query, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
5210 if (message.queryResponse != null && message.hasOwnProperty("queryResponse"))
5211 $root.QueryResponse.encode(message.queryResponse, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
5212 if (message.bulk != null && message.hasOwnProperty("bulk"))
5213 $root.Bulk.encode(message.bulk, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim();
5214 if (message.bulkResponse != null && message.hasOwnProperty("bulkResponse"))
5215 $root.BulkResponse.encode(message.bulkResponse, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim();
5216 if (message.notification != null && message.hasOwnProperty("notification"))
5217 $root.Notification.encode(message.notification, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
5218 return writer;
5219 };
5220
5221 /**
5222 * Encodes the specified Packet message, length delimited. Does not implicitly {@link Packet.verify|verify} messages.
5223 * @function encodeDelimited
5224 * @memberof Packet
5225 * @static
5226 * @param {IPacket} message Packet message or plain object to encode
5227 * @param {$protobuf.Writer} [writer] Writer to encode to
5228 * @returns {$protobuf.Writer} Writer
5229 */
5230 Packet.encodeDelimited = function encodeDelimited(message, writer) {
5231 return this.encode(message, writer).ldelim();
5232 };
5233
5234 /**
5235 * Decodes a Packet message from the specified reader or buffer.
5236 * @function decode
5237 * @memberof Packet
5238 * @static
5239 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5240 * @param {number} [length] Message length if known beforehand
5241 * @returns {Packet} Packet
5242 * @throws {Error} If the payload is not a reader or valid buffer
5243 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5244 */
5245 Packet.decode = function decode(reader, length) {
5246 if (!(reader instanceof $Reader))
5247 reader = $Reader.create(reader);
5248 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Packet();
5249 while (reader.pos < end) {
5250 let tag = reader.uint32();
5251 switch (tag >>> 3) {
5252 case 1:
5253 message.error = $root.Error.decode(reader, reader.uint32());
5254 break;
5255 case 2:
5256 message.invite = $root.EncryptedInvite.decode(reader, reader.uint32());
5257 break;
5258 case 3:
5259 message.query = $root.Query.decode(reader, reader.uint32());
5260 break;
5261 case 4:
5262 message.queryResponse = $root.QueryResponse.decode(reader, reader.uint32());
5263 break;
5264 case 5:
5265 message.bulk = $root.Bulk.decode(reader, reader.uint32());
5266 break;
5267 case 6:
5268 message.bulkResponse = $root.BulkResponse.decode(reader, reader.uint32());
5269 break;
5270 case 7:
5271 message.notification = $root.Notification.decode(reader, reader.uint32());
5272 break;
5273 default:
5274 reader.skipType(tag & 7);
5275 break;
5276 }
5277 }
5278 return message;
5279 };
5280
5281 /**
5282 * Decodes a Packet message from the specified reader or buffer, length delimited.
5283 * @function decodeDelimited
5284 * @memberof Packet
5285 * @static
5286 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5287 * @returns {Packet} Packet
5288 * @throws {Error} If the payload is not a reader or valid buffer
5289 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5290 */
5291 Packet.decodeDelimited = function decodeDelimited(reader) {
5292 if (!(reader instanceof $Reader))
5293 reader = new $Reader(reader);
5294 return this.decode(reader, reader.uint32());
5295 };
5296
5297 /**
5298 * Verifies a Packet message.
5299 * @function verify
5300 * @memberof Packet
5301 * @static
5302 * @param {Object.<string,*>} message Plain object to verify
5303 * @returns {string|null} `null` if valid, otherwise the reason why it is not
5304 */
5305 Packet.verify = function verify(message) {
5306 if (typeof message !== "object" || message === null)
5307 return "object expected";
5308 let properties = {};
5309 if (message.error != null && message.hasOwnProperty("error")) {
5310 properties.content = 1;
5311 {
5312 let error = $root.Error.verify(message.error);
5313 if (error)
5314 return "error." + error;
5315 }
5316 }
5317 if (message.invite != null && message.hasOwnProperty("invite")) {
5318 if (properties.content === 1)
5319 return "content: multiple values";
5320 properties.content = 1;
5321 {
5322 let error = $root.EncryptedInvite.verify(message.invite);
5323 if (error)
5324 return "invite." + error;
5325 }
5326 }
5327 if (message.query != null && message.hasOwnProperty("query")) {
5328 if (properties.content === 1)
5329 return "content: multiple values";
5330 properties.content = 1;
5331 {
5332 let error = $root.Query.verify(message.query);
5333 if (error)
5334 return "query." + error;
5335 }
5336 }
5337 if (message.queryResponse != null && message.hasOwnProperty("queryResponse")) {
5338 if (properties.content === 1)
5339 return "content: multiple values";
5340 properties.content = 1;
5341 {
5342 let error = $root.QueryResponse.verify(message.queryResponse);
5343 if (error)
5344 return "queryResponse." + error;
5345 }
5346 }
5347 if (message.bulk != null && message.hasOwnProperty("bulk")) {
5348 if (properties.content === 1)
5349 return "content: multiple values";
5350 properties.content = 1;
5351 {
5352 let error = $root.Bulk.verify(message.bulk);
5353 if (error)
5354 return "bulk." + error;
5355 }
5356 }
5357 if (message.bulkResponse != null && message.hasOwnProperty("bulkResponse")) {
5358 if (properties.content === 1)
5359 return "content: multiple values";
5360 properties.content = 1;
5361 {
5362 let error = $root.BulkResponse.verify(message.bulkResponse);
5363 if (error)
5364 return "bulkResponse." + error;
5365 }
5366 }
5367 if (message.notification != null && message.hasOwnProperty("notification")) {
5368 if (properties.content === 1)
5369 return "content: multiple values";
5370 properties.content = 1;
5371 {
5372 let error = $root.Notification.verify(message.notification);
5373 if (error)
5374 return "notification." + error;
5375 }
5376 }
5377 return null;
5378 };
5379
5380 /**
5381 * Creates a Packet message from a plain object. Also converts values to their respective internal types.
5382 * @function fromObject
5383 * @memberof Packet
5384 * @static
5385 * @param {Object.<string,*>} object Plain object
5386 * @returns {Packet} Packet
5387 */
5388 Packet.fromObject = function fromObject(object) {
5389 if (object instanceof $root.Packet)
5390 return object;
5391 let message = new $root.Packet();
5392 if (object.error != null) {
5393 if (typeof object.error !== "object")
5394 throw TypeError(".Packet.error: object expected");
5395 message.error = $root.Error.fromObject(object.error);
5396 }
5397 if (object.invite != null) {
5398 if (typeof object.invite !== "object")
5399 throw TypeError(".Packet.invite: object expected");
5400 message.invite = $root.EncryptedInvite.fromObject(object.invite);
5401 }
5402 if (object.query != null) {
5403 if (typeof object.query !== "object")
5404 throw TypeError(".Packet.query: object expected");
5405 message.query = $root.Query.fromObject(object.query);
5406 }
5407 if (object.queryResponse != null) {
5408 if (typeof object.queryResponse !== "object")
5409 throw TypeError(".Packet.queryResponse: object expected");
5410 message.queryResponse = $root.QueryResponse.fromObject(object.queryResponse);
5411 }
5412 if (object.bulk != null) {
5413 if (typeof object.bulk !== "object")
5414 throw TypeError(".Packet.bulk: object expected");
5415 message.bulk = $root.Bulk.fromObject(object.bulk);
5416 }
5417 if (object.bulkResponse != null) {
5418 if (typeof object.bulkResponse !== "object")
5419 throw TypeError(".Packet.bulkResponse: object expected");
5420 message.bulkResponse = $root.BulkResponse.fromObject(object.bulkResponse);
5421 }
5422 if (object.notification != null) {
5423 if (typeof object.notification !== "object")
5424 throw TypeError(".Packet.notification: object expected");
5425 message.notification = $root.Notification.fromObject(object.notification);
5426 }
5427 return message;
5428 };
5429
5430 /**
5431 * Creates a plain object from a Packet message. Also converts values to other types if specified.
5432 * @function toObject
5433 * @memberof Packet
5434 * @static
5435 * @param {Packet} message Packet
5436 * @param {$protobuf.IConversionOptions} [options] Conversion options
5437 * @returns {Object.<string,*>} Plain object
5438 */
5439 Packet.toObject = function toObject(message, options) {
5440 if (!options)
5441 options = {};
5442 let object = {};
5443 if (message.error != null && message.hasOwnProperty("error")) {
5444 object.error = $root.Error.toObject(message.error, options);
5445 if (options.oneofs)
5446 object.content = "error";
5447 }
5448 if (message.invite != null && message.hasOwnProperty("invite")) {
5449 object.invite = $root.EncryptedInvite.toObject(message.invite, options);
5450 if (options.oneofs)
5451 object.content = "invite";
5452 }
5453 if (message.query != null && message.hasOwnProperty("query")) {
5454 object.query = $root.Query.toObject(message.query, options);
5455 if (options.oneofs)
5456 object.content = "query";
5457 }
5458 if (message.queryResponse != null && message.hasOwnProperty("queryResponse")) {
5459 object.queryResponse = $root.QueryResponse.toObject(message.queryResponse, options);
5460 if (options.oneofs)
5461 object.content = "queryResponse";
5462 }
5463 if (message.bulk != null && message.hasOwnProperty("bulk")) {
5464 object.bulk = $root.Bulk.toObject(message.bulk, options);
5465 if (options.oneofs)
5466 object.content = "bulk";
5467 }
5468 if (message.bulkResponse != null && message.hasOwnProperty("bulkResponse")) {
5469 object.bulkResponse = $root.BulkResponse.toObject(message.bulkResponse, options);
5470 if (options.oneofs)
5471 object.content = "bulkResponse";
5472 }
5473 if (message.notification != null && message.hasOwnProperty("notification")) {
5474 object.notification = $root.Notification.toObject(message.notification, options);
5475 if (options.oneofs)
5476 object.content = "notification";
5477 }
5478 return object;
5479 };
5480
5481 /**
5482 * Converts this Packet to JSON.
5483 * @function toJSON
5484 * @memberof Packet
5485 * @instance
5486 * @returns {Object.<string,*>} JSON object
5487 */
5488 Packet.prototype.toJSON = function toJSON() {
5489 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
5490 };
5491
5492 return Packet;
5493})();
5494
5495export const Identity = $root.Identity = (() => {
5496
5497 /**
5498 * Properties of an Identity.
5499 * @exports IIdentity
5500 * @interface IIdentity
5501 * @property {string|null} [name] Identity name
5502 * @property {Uint8Array|null} [publicKey] Identity publicKey
5503 * @property {Uint8Array|null} [secretKey] Identity secretKey
5504 * @property {Array.<Identity.IChannelChain>|null} [channelChains] Identity channelChains
5505 * @property {string|null} [metadata] Identity metadata
5506 */
5507
5508 /**
5509 * Constructs a new Identity.
5510 * @exports Identity
5511 * @classdesc Represents an Identity.
5512 * @implements IIdentity
5513 * @constructor
5514 * @param {IIdentity=} [properties] Properties to set
5515 */
5516 function Identity(properties) {
5517 this.channelChains = [];
5518 if (properties)
5519 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
5520 if (properties[keys[i]] != null)
5521 this[keys[i]] = properties[keys[i]];
5522 }
5523
5524 /**
5525 * Identity name.
5526 * @member {string} name
5527 * @memberof Identity
5528 * @instance
5529 */
5530 Identity.prototype.name = "";
5531
5532 /**
5533 * Identity publicKey.
5534 * @member {Uint8Array} publicKey
5535 * @memberof Identity
5536 * @instance
5537 */
5538 Identity.prototype.publicKey = $util.newBuffer([]);
5539
5540 /**
5541 * Identity secretKey.
5542 * @member {Uint8Array} secretKey
5543 * @memberof Identity
5544 * @instance
5545 */
5546 Identity.prototype.secretKey = $util.newBuffer([]);
5547
5548 /**
5549 * Identity channelChains.
5550 * @member {Array.<Identity.IChannelChain>} channelChains
5551 * @memberof Identity
5552 * @instance
5553 */
5554 Identity.prototype.channelChains = $util.emptyArray;
5555
5556 /**
5557 * Identity metadata.
5558 * @member {string} metadata
5559 * @memberof Identity
5560 * @instance
5561 */
5562 Identity.prototype.metadata = "";
5563
5564 /**
5565 * Creates a new Identity instance using the specified properties.
5566 * @function create
5567 * @memberof Identity
5568 * @static
5569 * @param {IIdentity=} [properties] Properties to set
5570 * @returns {Identity} Identity instance
5571 */
5572 Identity.create = function create(properties) {
5573 return new Identity(properties);
5574 };
5575
5576 /**
5577 * Encodes the specified Identity message. Does not implicitly {@link Identity.verify|verify} messages.
5578 * @function encode
5579 * @memberof Identity
5580 * @static
5581 * @param {IIdentity} message Identity message or plain object to encode
5582 * @param {$protobuf.Writer} [writer] Writer to encode to
5583 * @returns {$protobuf.Writer} Writer
5584 */
5585 Identity.encode = function encode(message, writer) {
5586 if (!writer)
5587 writer = $Writer.create();
5588 if (message.name != null && message.hasOwnProperty("name"))
5589 writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
5590 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
5591 writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.publicKey);
5592 if (message.secretKey != null && message.hasOwnProperty("secretKey"))
5593 writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.secretKey);
5594 if (message.channelChains != null && message.channelChains.length)
5595 for (let i = 0; i < message.channelChains.length; ++i)
5596 $root.Identity.ChannelChain.encode(message.channelChains[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
5597 if (message.metadata != null && message.hasOwnProperty("metadata"))
5598 writer.uint32(/* id 5, wireType 2 =*/42).string(message.metadata);
5599 return writer;
5600 };
5601
5602 /**
5603 * Encodes the specified Identity message, length delimited. Does not implicitly {@link Identity.verify|verify} messages.
5604 * @function encodeDelimited
5605 * @memberof Identity
5606 * @static
5607 * @param {IIdentity} message Identity message or plain object to encode
5608 * @param {$protobuf.Writer} [writer] Writer to encode to
5609 * @returns {$protobuf.Writer} Writer
5610 */
5611 Identity.encodeDelimited = function encodeDelimited(message, writer) {
5612 return this.encode(message, writer).ldelim();
5613 };
5614
5615 /**
5616 * Decodes an Identity message from the specified reader or buffer.
5617 * @function decode
5618 * @memberof Identity
5619 * @static
5620 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5621 * @param {number} [length] Message length if known beforehand
5622 * @returns {Identity} Identity
5623 * @throws {Error} If the payload is not a reader or valid buffer
5624 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5625 */
5626 Identity.decode = function decode(reader, length) {
5627 if (!(reader instanceof $Reader))
5628 reader = $Reader.create(reader);
5629 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Identity();
5630 while (reader.pos < end) {
5631 let tag = reader.uint32();
5632 switch (tag >>> 3) {
5633 case 1:
5634 message.name = reader.string();
5635 break;
5636 case 2:
5637 message.publicKey = reader.bytes();
5638 break;
5639 case 3:
5640 message.secretKey = reader.bytes();
5641 break;
5642 case 4:
5643 if (!(message.channelChains && message.channelChains.length))
5644 message.channelChains = [];
5645 message.channelChains.push($root.Identity.ChannelChain.decode(reader, reader.uint32()));
5646 break;
5647 case 5:
5648 message.metadata = reader.string();
5649 break;
5650 default:
5651 reader.skipType(tag & 7);
5652 break;
5653 }
5654 }
5655 return message;
5656 };
5657
5658 /**
5659 * Decodes an Identity message from the specified reader or buffer, length delimited.
5660 * @function decodeDelimited
5661 * @memberof Identity
5662 * @static
5663 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5664 * @returns {Identity} Identity
5665 * @throws {Error} If the payload is not a reader or valid buffer
5666 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5667 */
5668 Identity.decodeDelimited = function decodeDelimited(reader) {
5669 if (!(reader instanceof $Reader))
5670 reader = new $Reader(reader);
5671 return this.decode(reader, reader.uint32());
5672 };
5673
5674 /**
5675 * Verifies an Identity message.
5676 * @function verify
5677 * @memberof Identity
5678 * @static
5679 * @param {Object.<string,*>} message Plain object to verify
5680 * @returns {string|null} `null` if valid, otherwise the reason why it is not
5681 */
5682 Identity.verify = function verify(message) {
5683 if (typeof message !== "object" || message === null)
5684 return "object expected";
5685 if (message.name != null && message.hasOwnProperty("name"))
5686 if (!$util.isString(message.name))
5687 return "name: string expected";
5688 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
5689 if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey)))
5690 return "publicKey: buffer expected";
5691 if (message.secretKey != null && message.hasOwnProperty("secretKey"))
5692 if (!(message.secretKey && typeof message.secretKey.length === "number" || $util.isString(message.secretKey)))
5693 return "secretKey: buffer expected";
5694 if (message.channelChains != null && message.hasOwnProperty("channelChains")) {
5695 if (!Array.isArray(message.channelChains))
5696 return "channelChains: array expected";
5697 for (let i = 0; i < message.channelChains.length; ++i) {
5698 let error = $root.Identity.ChannelChain.verify(message.channelChains[i]);
5699 if (error)
5700 return "channelChains." + error;
5701 }
5702 }
5703 if (message.metadata != null && message.hasOwnProperty("metadata"))
5704 if (!$util.isString(message.metadata))
5705 return "metadata: string expected";
5706 return null;
5707 };
5708
5709 /**
5710 * Creates an Identity message from a plain object. Also converts values to their respective internal types.
5711 * @function fromObject
5712 * @memberof Identity
5713 * @static
5714 * @param {Object.<string,*>} object Plain object
5715 * @returns {Identity} Identity
5716 */
5717 Identity.fromObject = function fromObject(object) {
5718 if (object instanceof $root.Identity)
5719 return object;
5720 let message = new $root.Identity();
5721 if (object.name != null)
5722 message.name = String(object.name);
5723 if (object.publicKey != null)
5724 if (typeof object.publicKey === "string")
5725 $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0);
5726 else if (object.publicKey.length)
5727 message.publicKey = object.publicKey;
5728 if (object.secretKey != null)
5729 if (typeof object.secretKey === "string")
5730 $util.base64.decode(object.secretKey, message.secretKey = $util.newBuffer($util.base64.length(object.secretKey)), 0);
5731 else if (object.secretKey.length)
5732 message.secretKey = object.secretKey;
5733 if (object.channelChains) {
5734 if (!Array.isArray(object.channelChains))
5735 throw TypeError(".Identity.channelChains: array expected");
5736 message.channelChains = [];
5737 for (let i = 0; i < object.channelChains.length; ++i) {
5738 if (typeof object.channelChains[i] !== "object")
5739 throw TypeError(".Identity.channelChains: object expected");
5740 message.channelChains[i] = $root.Identity.ChannelChain.fromObject(object.channelChains[i]);
5741 }
5742 }
5743 if (object.metadata != null)
5744 message.metadata = String(object.metadata);
5745 return message;
5746 };
5747
5748 /**
5749 * Creates a plain object from an Identity message. Also converts values to other types if specified.
5750 * @function toObject
5751 * @memberof Identity
5752 * @static
5753 * @param {Identity} message Identity
5754 * @param {$protobuf.IConversionOptions} [options] Conversion options
5755 * @returns {Object.<string,*>} Plain object
5756 */
5757 Identity.toObject = function toObject(message, options) {
5758 if (!options)
5759 options = {};
5760 let object = {};
5761 if (options.arrays || options.defaults)
5762 object.channelChains = [];
5763 if (options.defaults) {
5764 object.name = "";
5765 if (options.bytes === String)
5766 object.publicKey = "";
5767 else {
5768 object.publicKey = [];
5769 if (options.bytes !== Array)
5770 object.publicKey = $util.newBuffer(object.publicKey);
5771 }
5772 if (options.bytes === String)
5773 object.secretKey = "";
5774 else {
5775 object.secretKey = [];
5776 if (options.bytes !== Array)
5777 object.secretKey = $util.newBuffer(object.secretKey);
5778 }
5779 object.metadata = "";
5780 }
5781 if (message.name != null && message.hasOwnProperty("name"))
5782 object.name = message.name;
5783 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
5784 object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey;
5785 if (message.secretKey != null && message.hasOwnProperty("secretKey"))
5786 object.secretKey = options.bytes === String ? $util.base64.encode(message.secretKey, 0, message.secretKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.secretKey) : message.secretKey;
5787 if (message.channelChains && message.channelChains.length) {
5788 object.channelChains = [];
5789 for (let j = 0; j < message.channelChains.length; ++j)
5790 object.channelChains[j] = $root.Identity.ChannelChain.toObject(message.channelChains[j], options);
5791 }
5792 if (message.metadata != null && message.hasOwnProperty("metadata"))
5793 object.metadata = message.metadata;
5794 return object;
5795 };
5796
5797 /**
5798 * Converts this Identity to JSON.
5799 * @function toJSON
5800 * @memberof Identity
5801 * @instance
5802 * @returns {Object.<string,*>} JSON object
5803 */
5804 Identity.prototype.toJSON = function toJSON() {
5805 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
5806 };
5807
5808 Identity.ChannelChain = (function() {
5809
5810 /**
5811 * Properties of a ChannelChain.
5812 * @memberof Identity
5813 * @interface IChannelChain
5814 * @property {Uint8Array|null} [channelId] ChannelChain channelId
5815 * @property {Array.<ILink>|null} [links] ChannelChain links
5816 */
5817
5818 /**
5819 * Constructs a new ChannelChain.
5820 * @memberof Identity
5821 * @classdesc Represents a ChannelChain.
5822 * @implements IChannelChain
5823 * @constructor
5824 * @param {Identity.IChannelChain=} [properties] Properties to set
5825 */
5826 function ChannelChain(properties) {
5827 this.links = [];
5828 if (properties)
5829 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
5830 if (properties[keys[i]] != null)
5831 this[keys[i]] = properties[keys[i]];
5832 }
5833
5834 /**
5835 * ChannelChain channelId.
5836 * @member {Uint8Array} channelId
5837 * @memberof Identity.ChannelChain
5838 * @instance
5839 */
5840 ChannelChain.prototype.channelId = $util.newBuffer([]);
5841
5842 /**
5843 * ChannelChain links.
5844 * @member {Array.<ILink>} links
5845 * @memberof Identity.ChannelChain
5846 * @instance
5847 */
5848 ChannelChain.prototype.links = $util.emptyArray;
5849
5850 /**
5851 * Creates a new ChannelChain instance using the specified properties.
5852 * @function create
5853 * @memberof Identity.ChannelChain
5854 * @static
5855 * @param {Identity.IChannelChain=} [properties] Properties to set
5856 * @returns {Identity.ChannelChain} ChannelChain instance
5857 */
5858 ChannelChain.create = function create(properties) {
5859 return new ChannelChain(properties);
5860 };
5861
5862 /**
5863 * Encodes the specified ChannelChain message. Does not implicitly {@link Identity.ChannelChain.verify|verify} messages.
5864 * @function encode
5865 * @memberof Identity.ChannelChain
5866 * @static
5867 * @param {Identity.IChannelChain} message ChannelChain message or plain object to encode
5868 * @param {$protobuf.Writer} [writer] Writer to encode to
5869 * @returns {$protobuf.Writer} Writer
5870 */
5871 ChannelChain.encode = function encode(message, writer) {
5872 if (!writer)
5873 writer = $Writer.create();
5874 if (message.channelId != null && message.hasOwnProperty("channelId"))
5875 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelId);
5876 if (message.links != null && message.links.length)
5877 for (let i = 0; i < message.links.length; ++i)
5878 $root.Link.encode(message.links[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
5879 return writer;
5880 };
5881
5882 /**
5883 * Encodes the specified ChannelChain message, length delimited. Does not implicitly {@link Identity.ChannelChain.verify|verify} messages.
5884 * @function encodeDelimited
5885 * @memberof Identity.ChannelChain
5886 * @static
5887 * @param {Identity.IChannelChain} message ChannelChain message or plain object to encode
5888 * @param {$protobuf.Writer} [writer] Writer to encode to
5889 * @returns {$protobuf.Writer} Writer
5890 */
5891 ChannelChain.encodeDelimited = function encodeDelimited(message, writer) {
5892 return this.encode(message, writer).ldelim();
5893 };
5894
5895 /**
5896 * Decodes a ChannelChain message from the specified reader or buffer.
5897 * @function decode
5898 * @memberof Identity.ChannelChain
5899 * @static
5900 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5901 * @param {number} [length] Message length if known beforehand
5902 * @returns {Identity.ChannelChain} ChannelChain
5903 * @throws {Error} If the payload is not a reader or valid buffer
5904 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5905 */
5906 ChannelChain.decode = function decode(reader, length) {
5907 if (!(reader instanceof $Reader))
5908 reader = $Reader.create(reader);
5909 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Identity.ChannelChain();
5910 while (reader.pos < end) {
5911 let tag = reader.uint32();
5912 switch (tag >>> 3) {
5913 case 1:
5914 message.channelId = reader.bytes();
5915 break;
5916 case 2:
5917 if (!(message.links && message.links.length))
5918 message.links = [];
5919 message.links.push($root.Link.decode(reader, reader.uint32()));
5920 break;
5921 default:
5922 reader.skipType(tag & 7);
5923 break;
5924 }
5925 }
5926 return message;
5927 };
5928
5929 /**
5930 * Decodes a ChannelChain message from the specified reader or buffer, length delimited.
5931 * @function decodeDelimited
5932 * @memberof Identity.ChannelChain
5933 * @static
5934 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
5935 * @returns {Identity.ChannelChain} ChannelChain
5936 * @throws {Error} If the payload is not a reader or valid buffer
5937 * @throws {$protobuf.util.ProtocolError} If required fields are missing
5938 */
5939 ChannelChain.decodeDelimited = function decodeDelimited(reader) {
5940 if (!(reader instanceof $Reader))
5941 reader = new $Reader(reader);
5942 return this.decode(reader, reader.uint32());
5943 };
5944
5945 /**
5946 * Verifies a ChannelChain message.
5947 * @function verify
5948 * @memberof Identity.ChannelChain
5949 * @static
5950 * @param {Object.<string,*>} message Plain object to verify
5951 * @returns {string|null} `null` if valid, otherwise the reason why it is not
5952 */
5953 ChannelChain.verify = function verify(message) {
5954 if (typeof message !== "object" || message === null)
5955 return "object expected";
5956 if (message.channelId != null && message.hasOwnProperty("channelId"))
5957 if (!(message.channelId && typeof message.channelId.length === "number" || $util.isString(message.channelId)))
5958 return "channelId: buffer expected";
5959 if (message.links != null && message.hasOwnProperty("links")) {
5960 if (!Array.isArray(message.links))
5961 return "links: array expected";
5962 for (let i = 0; i < message.links.length; ++i) {
5963 let error = $root.Link.verify(message.links[i]);
5964 if (error)
5965 return "links." + error;
5966 }
5967 }
5968 return null;
5969 };
5970
5971 /**
5972 * Creates a ChannelChain message from a plain object. Also converts values to their respective internal types.
5973 * @function fromObject
5974 * @memberof Identity.ChannelChain
5975 * @static
5976 * @param {Object.<string,*>} object Plain object
5977 * @returns {Identity.ChannelChain} ChannelChain
5978 */
5979 ChannelChain.fromObject = function fromObject(object) {
5980 if (object instanceof $root.Identity.ChannelChain)
5981 return object;
5982 let message = new $root.Identity.ChannelChain();
5983 if (object.channelId != null)
5984 if (typeof object.channelId === "string")
5985 $util.base64.decode(object.channelId, message.channelId = $util.newBuffer($util.base64.length(object.channelId)), 0);
5986 else if (object.channelId.length)
5987 message.channelId = object.channelId;
5988 if (object.links) {
5989 if (!Array.isArray(object.links))
5990 throw TypeError(".Identity.ChannelChain.links: array expected");
5991 message.links = [];
5992 for (let i = 0; i < object.links.length; ++i) {
5993 if (typeof object.links[i] !== "object")
5994 throw TypeError(".Identity.ChannelChain.links: object expected");
5995 message.links[i] = $root.Link.fromObject(object.links[i]);
5996 }
5997 }
5998 return message;
5999 };
6000
6001 /**
6002 * Creates a plain object from a ChannelChain message. Also converts values to other types if specified.
6003 * @function toObject
6004 * @memberof Identity.ChannelChain
6005 * @static
6006 * @param {Identity.ChannelChain} message ChannelChain
6007 * @param {$protobuf.IConversionOptions} [options] Conversion options
6008 * @returns {Object.<string,*>} Plain object
6009 */
6010 ChannelChain.toObject = function toObject(message, options) {
6011 if (!options)
6012 options = {};
6013 let object = {};
6014 if (options.arrays || options.defaults)
6015 object.links = [];
6016 if (options.defaults)
6017 if (options.bytes === String)
6018 object.channelId = "";
6019 else {
6020 object.channelId = [];
6021 if (options.bytes !== Array)
6022 object.channelId = $util.newBuffer(object.channelId);
6023 }
6024 if (message.channelId != null && message.hasOwnProperty("channelId"))
6025 object.channelId = options.bytes === String ? $util.base64.encode(message.channelId, 0, message.channelId.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelId) : message.channelId;
6026 if (message.links && message.links.length) {
6027 object.links = [];
6028 for (let j = 0; j < message.links.length; ++j)
6029 object.links[j] = $root.Link.toObject(message.links[j], options);
6030 }
6031 return object;
6032 };
6033
6034 /**
6035 * Converts this ChannelChain to JSON.
6036 * @function toJSON
6037 * @memberof Identity.ChannelChain
6038 * @instance
6039 * @returns {Object.<string,*>} JSON object
6040 */
6041 ChannelChain.prototype.toJSON = function toJSON() {
6042 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
6043 };
6044
6045 return ChannelChain;
6046 })();
6047
6048 return Identity;
6049})();
6050
6051export const Channel = $root.Channel = (() => {
6052
6053 /**
6054 * Properties of a Channel.
6055 * @exports IChannel
6056 * @interface IChannel
6057 * @property {Uint8Array|null} [publicKey] Channel publicKey
6058 * @property {string|null} [name] Channel name
6059 * @property {string|null} [metadata] Channel metadata
6060 */
6061
6062 /**
6063 * Constructs a new Channel.
6064 * @exports Channel
6065 * @classdesc Represents a Channel.
6066 * @implements IChannel
6067 * @constructor
6068 * @param {IChannel=} [properties] Properties to set
6069 */
6070 function Channel(properties) {
6071 if (properties)
6072 for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
6073 if (properties[keys[i]] != null)
6074 this[keys[i]] = properties[keys[i]];
6075 }
6076
6077 /**
6078 * Channel publicKey.
6079 * @member {Uint8Array} publicKey
6080 * @memberof Channel
6081 * @instance
6082 */
6083 Channel.prototype.publicKey = $util.newBuffer([]);
6084
6085 /**
6086 * Channel name.
6087 * @member {string} name
6088 * @memberof Channel
6089 * @instance
6090 */
6091 Channel.prototype.name = "";
6092
6093 /**
6094 * Channel metadata.
6095 * @member {string} metadata
6096 * @memberof Channel
6097 * @instance
6098 */
6099 Channel.prototype.metadata = "";
6100
6101 /**
6102 * Creates a new Channel instance using the specified properties.
6103 * @function create
6104 * @memberof Channel
6105 * @static
6106 * @param {IChannel=} [properties] Properties to set
6107 * @returns {Channel} Channel instance
6108 */
6109 Channel.create = function create(properties) {
6110 return new Channel(properties);
6111 };
6112
6113 /**
6114 * Encodes the specified Channel message. Does not implicitly {@link Channel.verify|verify} messages.
6115 * @function encode
6116 * @memberof Channel
6117 * @static
6118 * @param {IChannel} message Channel message or plain object to encode
6119 * @param {$protobuf.Writer} [writer] Writer to encode to
6120 * @returns {$protobuf.Writer} Writer
6121 */
6122 Channel.encode = function encode(message, writer) {
6123 if (!writer)
6124 writer = $Writer.create();
6125 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
6126 writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.publicKey);
6127 if (message.name != null && message.hasOwnProperty("name"))
6128 writer.uint32(/* id 2, wireType 2 =*/18).string(message.name);
6129 if (message.metadata != null && message.hasOwnProperty("metadata"))
6130 writer.uint32(/* id 4, wireType 2 =*/34).string(message.metadata);
6131 return writer;
6132 };
6133
6134 /**
6135 * Encodes the specified Channel message, length delimited. Does not implicitly {@link Channel.verify|verify} messages.
6136 * @function encodeDelimited
6137 * @memberof Channel
6138 * @static
6139 * @param {IChannel} message Channel message or plain object to encode
6140 * @param {$protobuf.Writer} [writer] Writer to encode to
6141 * @returns {$protobuf.Writer} Writer
6142 */
6143 Channel.encodeDelimited = function encodeDelimited(message, writer) {
6144 return this.encode(message, writer).ldelim();
6145 };
6146
6147 /**
6148 * Decodes a Channel message from the specified reader or buffer.
6149 * @function decode
6150 * @memberof Channel
6151 * @static
6152 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
6153 * @param {number} [length] Message length if known beforehand
6154 * @returns {Channel} Channel
6155 * @throws {Error} If the payload is not a reader or valid buffer
6156 * @throws {$protobuf.util.ProtocolError} If required fields are missing
6157 */
6158 Channel.decode = function decode(reader, length) {
6159 if (!(reader instanceof $Reader))
6160 reader = $Reader.create(reader);
6161 let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Channel();
6162 while (reader.pos < end) {
6163 let tag = reader.uint32();
6164 switch (tag >>> 3) {
6165 case 1:
6166 message.publicKey = reader.bytes();
6167 break;
6168 case 2:
6169 message.name = reader.string();
6170 break;
6171 case 4:
6172 message.metadata = reader.string();
6173 break;
6174 default:
6175 reader.skipType(tag & 7);
6176 break;
6177 }
6178 }
6179 return message;
6180 };
6181
6182 /**
6183 * Decodes a Channel message from the specified reader or buffer, length delimited.
6184 * @function decodeDelimited
6185 * @memberof Channel
6186 * @static
6187 * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
6188 * @returns {Channel} Channel
6189 * @throws {Error} If the payload is not a reader or valid buffer
6190 * @throws {$protobuf.util.ProtocolError} If required fields are missing
6191 */
6192 Channel.decodeDelimited = function decodeDelimited(reader) {
6193 if (!(reader instanceof $Reader))
6194 reader = new $Reader(reader);
6195 return this.decode(reader, reader.uint32());
6196 };
6197
6198 /**
6199 * Verifies a Channel message.
6200 * @function verify
6201 * @memberof Channel
6202 * @static
6203 * @param {Object.<string,*>} message Plain object to verify
6204 * @returns {string|null} `null` if valid, otherwise the reason why it is not
6205 */
6206 Channel.verify = function verify(message) {
6207 if (typeof message !== "object" || message === null)
6208 return "object expected";
6209 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
6210 if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey)))
6211 return "publicKey: buffer expected";
6212 if (message.name != null && message.hasOwnProperty("name"))
6213 if (!$util.isString(message.name))
6214 return "name: string expected";
6215 if (message.metadata != null && message.hasOwnProperty("metadata"))
6216 if (!$util.isString(message.metadata))
6217 return "metadata: string expected";
6218 return null;
6219 };
6220
6221 /**
6222 * Creates a Channel message from a plain object. Also converts values to their respective internal types.
6223 * @function fromObject
6224 * @memberof Channel
6225 * @static
6226 * @param {Object.<string,*>} object Plain object
6227 * @returns {Channel} Channel
6228 */
6229 Channel.fromObject = function fromObject(object) {
6230 if (object instanceof $root.Channel)
6231 return object;
6232 let message = new $root.Channel();
6233 if (object.publicKey != null)
6234 if (typeof object.publicKey === "string")
6235 $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0);
6236 else if (object.publicKey.length)
6237 message.publicKey = object.publicKey;
6238 if (object.name != null)
6239 message.name = String(object.name);
6240 if (object.metadata != null)
6241 message.metadata = String(object.metadata);
6242 return message;
6243 };
6244
6245 /**
6246 * Creates a plain object from a Channel message. Also converts values to other types if specified.
6247 * @function toObject
6248 * @memberof Channel
6249 * @static
6250 * @param {Channel} message Channel
6251 * @param {$protobuf.IConversionOptions} [options] Conversion options
6252 * @returns {Object.<string,*>} Plain object
6253 */
6254 Channel.toObject = function toObject(message, options) {
6255 if (!options)
6256 options = {};
6257 let object = {};
6258 if (options.defaults) {
6259 if (options.bytes === String)
6260 object.publicKey = "";
6261 else {
6262 object.publicKey = [];
6263 if (options.bytes !== Array)
6264 object.publicKey = $util.newBuffer(object.publicKey);
6265 }
6266 object.name = "";
6267 object.metadata = "";
6268 }
6269 if (message.publicKey != null && message.hasOwnProperty("publicKey"))
6270 object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey;
6271 if (message.name != null && message.hasOwnProperty("name"))
6272 object.name = message.name;
6273 if (message.metadata != null && message.hasOwnProperty("metadata"))
6274 object.metadata = message.metadata;
6275 return object;
6276 };
6277
6278 /**
6279 * Converts this Channel to JSON.
6280 * @function toJSON
6281 * @memberof Channel
6282 * @instance
6283 * @returns {Object.<string,*>} JSON object
6284 */
6285 Channel.prototype.toJSON = function toJSON() {
6286 return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
6287 };
6288
6289 return Channel;
6290})();
6291
6292export { $root as default };