@libp2p/peer-record 1.0.7 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,77 +0,0 @@
1
- import * as $protobuf from "protobufjs";
2
- /** Properties of an Envelope. */
3
- export interface IEnvelope {
4
-
5
- /** Envelope publicKey */
6
- publicKey?: (Uint8Array|null);
7
-
8
- /** Envelope payloadType */
9
- payloadType?: (Uint8Array|null);
10
-
11
- /** Envelope payload */
12
- payload?: (Uint8Array|null);
13
-
14
- /** Envelope signature */
15
- signature?: (Uint8Array|null);
16
- }
17
-
18
- /** Represents an Envelope. */
19
- export class Envelope implements IEnvelope {
20
-
21
- /**
22
- * Constructs a new Envelope.
23
- * @param [p] Properties to set
24
- */
25
- constructor(p?: IEnvelope);
26
-
27
- /** Envelope publicKey. */
28
- public publicKey: Uint8Array;
29
-
30
- /** Envelope payloadType. */
31
- public payloadType: Uint8Array;
32
-
33
- /** Envelope payload. */
34
- public payload: Uint8Array;
35
-
36
- /** Envelope signature. */
37
- public signature: Uint8Array;
38
-
39
- /**
40
- * Encodes the specified Envelope message. Does not implicitly {@link Envelope.verify|verify} messages.
41
- * @param m Envelope message or plain object to encode
42
- * @param [w] Writer to encode to
43
- * @returns Writer
44
- */
45
- public static encode(m: IEnvelope, w?: $protobuf.Writer): $protobuf.Writer;
46
-
47
- /**
48
- * Decodes an Envelope message from the specified reader or buffer.
49
- * @param r Reader or buffer to decode from
50
- * @param [l] Message length if known beforehand
51
- * @returns Envelope
52
- * @throws {Error} If the payload is not a reader or valid buffer
53
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
54
- */
55
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Envelope;
56
-
57
- /**
58
- * Creates an Envelope message from a plain object. Also converts values to their respective internal types.
59
- * @param d Plain object
60
- * @returns Envelope
61
- */
62
- public static fromObject(d: { [k: string]: any }): Envelope;
63
-
64
- /**
65
- * Creates a plain object from an Envelope message. Also converts values to other types if specified.
66
- * @param m Envelope
67
- * @param [o] Conversion options
68
- * @returns Plain object
69
- */
70
- public static toObject(m: Envelope, o?: $protobuf.IConversionOptions): { [k: string]: any };
71
-
72
- /**
73
- * Converts this Envelope to JSON.
74
- * @returns JSON object
75
- */
76
- public toJSON(): { [k: string]: any };
77
- }
@@ -1,241 +0,0 @@
1
- /*eslint-disable*/
2
- import $protobuf from "protobufjs/minimal.js";
3
-
4
- // Common aliases
5
- const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
6
-
7
- // Exported root namespace
8
- const $root = $protobuf.roots["libp2p-peer-record-envelope"] || ($protobuf.roots["libp2p-peer-record-envelope"] = {});
9
-
10
- export const Envelope = $root.Envelope = (() => {
11
-
12
- /**
13
- * Properties of an Envelope.
14
- * @exports IEnvelope
15
- * @interface IEnvelope
16
- * @property {Uint8Array|null} [publicKey] Envelope publicKey
17
- * @property {Uint8Array|null} [payloadType] Envelope payloadType
18
- * @property {Uint8Array|null} [payload] Envelope payload
19
- * @property {Uint8Array|null} [signature] Envelope signature
20
- */
21
-
22
- /**
23
- * Constructs a new Envelope.
24
- * @exports Envelope
25
- * @classdesc Represents an Envelope.
26
- * @implements IEnvelope
27
- * @constructor
28
- * @param {IEnvelope=} [p] Properties to set
29
- */
30
- function Envelope(p) {
31
- if (p)
32
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
33
- if (p[ks[i]] != null)
34
- this[ks[i]] = p[ks[i]];
35
- }
36
-
37
- /**
38
- * Envelope publicKey.
39
- * @member {Uint8Array} publicKey
40
- * @memberof Envelope
41
- * @instance
42
- */
43
- Envelope.prototype.publicKey = $util.newBuffer([]);
44
-
45
- /**
46
- * Envelope payloadType.
47
- * @member {Uint8Array} payloadType
48
- * @memberof Envelope
49
- * @instance
50
- */
51
- Envelope.prototype.payloadType = $util.newBuffer([]);
52
-
53
- /**
54
- * Envelope payload.
55
- * @member {Uint8Array} payload
56
- * @memberof Envelope
57
- * @instance
58
- */
59
- Envelope.prototype.payload = $util.newBuffer([]);
60
-
61
- /**
62
- * Envelope signature.
63
- * @member {Uint8Array} signature
64
- * @memberof Envelope
65
- * @instance
66
- */
67
- Envelope.prototype.signature = $util.newBuffer([]);
68
-
69
- /**
70
- * Encodes the specified Envelope message. Does not implicitly {@link Envelope.verify|verify} messages.
71
- * @function encode
72
- * @memberof Envelope
73
- * @static
74
- * @param {IEnvelope} m Envelope message or plain object to encode
75
- * @param {$protobuf.Writer} [w] Writer to encode to
76
- * @returns {$protobuf.Writer} Writer
77
- */
78
- Envelope.encode = function encode(m, w) {
79
- if (!w)
80
- w = $Writer.create();
81
- if (m.publicKey != null && Object.hasOwnProperty.call(m, "publicKey"))
82
- w.uint32(10).bytes(m.publicKey);
83
- if (m.payloadType != null && Object.hasOwnProperty.call(m, "payloadType"))
84
- w.uint32(18).bytes(m.payloadType);
85
- if (m.payload != null && Object.hasOwnProperty.call(m, "payload"))
86
- w.uint32(26).bytes(m.payload);
87
- if (m.signature != null && Object.hasOwnProperty.call(m, "signature"))
88
- w.uint32(42).bytes(m.signature);
89
- return w;
90
- };
91
-
92
- /**
93
- * Decodes an Envelope message from the specified reader or buffer.
94
- * @function decode
95
- * @memberof Envelope
96
- * @static
97
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
98
- * @param {number} [l] Message length if known beforehand
99
- * @returns {Envelope} Envelope
100
- * @throws {Error} If the payload is not a reader or valid buffer
101
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
102
- */
103
- Envelope.decode = function decode(r, l) {
104
- if (!(r instanceof $Reader))
105
- r = $Reader.create(r);
106
- var c = l === undefined ? r.len : r.pos + l, m = new $root.Envelope();
107
- while (r.pos < c) {
108
- var t = r.uint32();
109
- switch (t >>> 3) {
110
- case 1:
111
- m.publicKey = r.bytes();
112
- break;
113
- case 2:
114
- m.payloadType = r.bytes();
115
- break;
116
- case 3:
117
- m.payload = r.bytes();
118
- break;
119
- case 5:
120
- m.signature = r.bytes();
121
- break;
122
- default:
123
- r.skipType(t & 7);
124
- break;
125
- }
126
- }
127
- return m;
128
- };
129
-
130
- /**
131
- * Creates an Envelope message from a plain object. Also converts values to their respective internal types.
132
- * @function fromObject
133
- * @memberof Envelope
134
- * @static
135
- * @param {Object.<string,*>} d Plain object
136
- * @returns {Envelope} Envelope
137
- */
138
- Envelope.fromObject = function fromObject(d) {
139
- if (d instanceof $root.Envelope)
140
- return d;
141
- var m = new $root.Envelope();
142
- if (d.publicKey != null) {
143
- if (typeof d.publicKey === "string")
144
- $util.base64.decode(d.publicKey, m.publicKey = $util.newBuffer($util.base64.length(d.publicKey)), 0);
145
- else if (d.publicKey.length)
146
- m.publicKey = d.publicKey;
147
- }
148
- if (d.payloadType != null) {
149
- if (typeof d.payloadType === "string")
150
- $util.base64.decode(d.payloadType, m.payloadType = $util.newBuffer($util.base64.length(d.payloadType)), 0);
151
- else if (d.payloadType.length)
152
- m.payloadType = d.payloadType;
153
- }
154
- if (d.payload != null) {
155
- if (typeof d.payload === "string")
156
- $util.base64.decode(d.payload, m.payload = $util.newBuffer($util.base64.length(d.payload)), 0);
157
- else if (d.payload.length)
158
- m.payload = d.payload;
159
- }
160
- if (d.signature != null) {
161
- if (typeof d.signature === "string")
162
- $util.base64.decode(d.signature, m.signature = $util.newBuffer($util.base64.length(d.signature)), 0);
163
- else if (d.signature.length)
164
- m.signature = d.signature;
165
- }
166
- return m;
167
- };
168
-
169
- /**
170
- * Creates a plain object from an Envelope message. Also converts values to other types if specified.
171
- * @function toObject
172
- * @memberof Envelope
173
- * @static
174
- * @param {Envelope} m Envelope
175
- * @param {$protobuf.IConversionOptions} [o] Conversion options
176
- * @returns {Object.<string,*>} Plain object
177
- */
178
- Envelope.toObject = function toObject(m, o) {
179
- if (!o)
180
- o = {};
181
- var d = {};
182
- if (o.defaults) {
183
- if (o.bytes === String)
184
- d.publicKey = "";
185
- else {
186
- d.publicKey = [];
187
- if (o.bytes !== Array)
188
- d.publicKey = $util.newBuffer(d.publicKey);
189
- }
190
- if (o.bytes === String)
191
- d.payloadType = "";
192
- else {
193
- d.payloadType = [];
194
- if (o.bytes !== Array)
195
- d.payloadType = $util.newBuffer(d.payloadType);
196
- }
197
- if (o.bytes === String)
198
- d.payload = "";
199
- else {
200
- d.payload = [];
201
- if (o.bytes !== Array)
202
- d.payload = $util.newBuffer(d.payload);
203
- }
204
- if (o.bytes === String)
205
- d.signature = "";
206
- else {
207
- d.signature = [];
208
- if (o.bytes !== Array)
209
- d.signature = $util.newBuffer(d.signature);
210
- }
211
- }
212
- if (m.publicKey != null && m.hasOwnProperty("publicKey")) {
213
- d.publicKey = o.bytes === String ? $util.base64.encode(m.publicKey, 0, m.publicKey.length) : o.bytes === Array ? Array.prototype.slice.call(m.publicKey) : m.publicKey;
214
- }
215
- if (m.payloadType != null && m.hasOwnProperty("payloadType")) {
216
- d.payloadType = o.bytes === String ? $util.base64.encode(m.payloadType, 0, m.payloadType.length) : o.bytes === Array ? Array.prototype.slice.call(m.payloadType) : m.payloadType;
217
- }
218
- if (m.payload != null && m.hasOwnProperty("payload")) {
219
- d.payload = o.bytes === String ? $util.base64.encode(m.payload, 0, m.payload.length) : o.bytes === Array ? Array.prototype.slice.call(m.payload) : m.payload;
220
- }
221
- if (m.signature != null && m.hasOwnProperty("signature")) {
222
- d.signature = o.bytes === String ? $util.base64.encode(m.signature, 0, m.signature.length) : o.bytes === Array ? Array.prototype.slice.call(m.signature) : m.signature;
223
- }
224
- return d;
225
- };
226
-
227
- /**
228
- * Converts this Envelope to JSON.
229
- * @function toJSON
230
- * @memberof Envelope
231
- * @instance
232
- * @returns {Object.<string,*>} JSON object
233
- */
234
- Envelope.prototype.toJSON = function toJSON() {
235
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
236
- };
237
-
238
- return Envelope;
239
- })();
240
-
241
- export { $root as default };
@@ -1,133 +0,0 @@
1
- import * as $protobuf from "protobufjs";
2
- /** Properties of a PeerRecord. */
3
- export interface IPeerRecord {
4
-
5
- /** PeerRecord peerId */
6
- peerId?: (Uint8Array|null);
7
-
8
- /** PeerRecord seq */
9
- seq?: (number|null);
10
-
11
- /** PeerRecord addresses */
12
- addresses?: (PeerRecord.IAddressInfo[]|null);
13
- }
14
-
15
- /** Represents a PeerRecord. */
16
- export class PeerRecord implements IPeerRecord {
17
-
18
- /**
19
- * Constructs a new PeerRecord.
20
- * @param [p] Properties to set
21
- */
22
- constructor(p?: IPeerRecord);
23
-
24
- /** PeerRecord peerId. */
25
- public peerId: Uint8Array;
26
-
27
- /** PeerRecord seq. */
28
- public seq: number;
29
-
30
- /** PeerRecord addresses. */
31
- public addresses: PeerRecord.IAddressInfo[];
32
-
33
- /**
34
- * Encodes the specified PeerRecord message. Does not implicitly {@link PeerRecord.verify|verify} messages.
35
- * @param m PeerRecord message or plain object to encode
36
- * @param [w] Writer to encode to
37
- * @returns Writer
38
- */
39
- public static encode(m: IPeerRecord, w?: $protobuf.Writer): $protobuf.Writer;
40
-
41
- /**
42
- * Decodes a PeerRecord message from the specified reader or buffer.
43
- * @param r Reader or buffer to decode from
44
- * @param [l] Message length if known beforehand
45
- * @returns PeerRecord
46
- * @throws {Error} If the payload is not a reader or valid buffer
47
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
48
- */
49
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): PeerRecord;
50
-
51
- /**
52
- * Creates a PeerRecord message from a plain object. Also converts values to their respective internal types.
53
- * @param d Plain object
54
- * @returns PeerRecord
55
- */
56
- public static fromObject(d: { [k: string]: any }): PeerRecord;
57
-
58
- /**
59
- * Creates a plain object from a PeerRecord message. Also converts values to other types if specified.
60
- * @param m PeerRecord
61
- * @param [o] Conversion options
62
- * @returns Plain object
63
- */
64
- public static toObject(m: PeerRecord, o?: $protobuf.IConversionOptions): { [k: string]: any };
65
-
66
- /**
67
- * Converts this PeerRecord to JSON.
68
- * @returns JSON object
69
- */
70
- public toJSON(): { [k: string]: any };
71
- }
72
-
73
- export namespace PeerRecord {
74
-
75
- /** Properties of an AddressInfo. */
76
- interface IAddressInfo {
77
-
78
- /** AddressInfo multiaddr */
79
- multiaddr?: (Uint8Array|null);
80
- }
81
-
82
- /** Represents an AddressInfo. */
83
- class AddressInfo implements IAddressInfo {
84
-
85
- /**
86
- * Constructs a new AddressInfo.
87
- * @param [p] Properties to set
88
- */
89
- constructor(p?: PeerRecord.IAddressInfo);
90
-
91
- /** AddressInfo multiaddr. */
92
- public multiaddr: Uint8Array;
93
-
94
- /**
95
- * Encodes the specified AddressInfo message. Does not implicitly {@link PeerRecord.AddressInfo.verify|verify} messages.
96
- * @param m AddressInfo message or plain object to encode
97
- * @param [w] Writer to encode to
98
- * @returns Writer
99
- */
100
- public static encode(m: PeerRecord.IAddressInfo, w?: $protobuf.Writer): $protobuf.Writer;
101
-
102
- /**
103
- * Decodes an AddressInfo message from the specified reader or buffer.
104
- * @param r Reader or buffer to decode from
105
- * @param [l] Message length if known beforehand
106
- * @returns AddressInfo
107
- * @throws {Error} If the payload is not a reader or valid buffer
108
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
109
- */
110
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): PeerRecord.AddressInfo;
111
-
112
- /**
113
- * Creates an AddressInfo message from a plain object. Also converts values to their respective internal types.
114
- * @param d Plain object
115
- * @returns AddressInfo
116
- */
117
- public static fromObject(d: { [k: string]: any }): PeerRecord.AddressInfo;
118
-
119
- /**
120
- * Creates a plain object from an AddressInfo message. Also converts values to other types if specified.
121
- * @param m AddressInfo
122
- * @param [o] Conversion options
123
- * @returns Plain object
124
- */
125
- public static toObject(m: PeerRecord.AddressInfo, o?: $protobuf.IConversionOptions): { [k: string]: any };
126
-
127
- /**
128
- * Converts this AddressInfo to JSON.
129
- * @returns JSON object
130
- */
131
- public toJSON(): { [k: string]: any };
132
- }
133
- }