libp2p 0.36.2-64bfcee → 0.36.2-c64a586

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.
Files changed (66) hide show
  1. package/dist/src/circuit/circuit/hop.d.ts +3 -3
  2. package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
  3. package/dist/src/circuit/circuit/hop.js +1 -1
  4. package/dist/src/circuit/circuit/hop.js.map +1 -1
  5. package/dist/src/circuit/circuit/stop.d.ts +3 -3
  6. package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
  7. package/dist/src/circuit/circuit/stop.js.map +1 -1
  8. package/dist/src/circuit/circuit/stream-handler.d.ts +4 -4
  9. package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
  10. package/dist/src/circuit/circuit/stream-handler.js +2 -3
  11. package/dist/src/circuit/circuit/stream-handler.js.map +1 -1
  12. package/dist/src/circuit/circuit/utils.d.ts +2 -2
  13. package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
  14. package/dist/src/circuit/circuit/utils.js.map +1 -1
  15. package/dist/src/circuit/pb/index.d.ts +42 -164
  16. package/dist/src/circuit/pb/index.d.ts.map +1 -0
  17. package/dist/src/circuit/pb/index.js +67 -523
  18. package/dist/src/circuit/pb/index.js.map +1 -0
  19. package/dist/src/fetch/index.d.ts.map +1 -1
  20. package/dist/src/fetch/index.js +5 -6
  21. package/dist/src/fetch/index.js.map +1 -1
  22. package/dist/src/fetch/pb/proto.d.ts +20 -128
  23. package/dist/src/fetch/pb/proto.d.ts.map +1 -0
  24. package/dist/src/fetch/pb/proto.js +44 -331
  25. package/dist/src/fetch/pb/proto.js.map +1 -0
  26. package/dist/src/identify/index.d.ts +4 -2
  27. package/dist/src/identify/index.d.ts.map +1 -1
  28. package/dist/src/identify/index.js +8 -8
  29. package/dist/src/identify/index.js.map +1 -1
  30. package/dist/src/identify/pb/message.d.ts +13 -108
  31. package/dist/src/identify/pb/message.d.ts.map +1 -0
  32. package/dist/src/identify/pb/message.js +21 -366
  33. package/dist/src/identify/pb/message.js.map +1 -0
  34. package/dist/src/insecure/index.d.ts.map +1 -1
  35. package/dist/src/insecure/index.js +5 -2
  36. package/dist/src/insecure/index.js.map +1 -1
  37. package/dist/src/insecure/pb/proto.d.ts +24 -130
  38. package/dist/src/insecure/pb/proto.d.ts.map +1 -0
  39. package/dist/src/insecure/pb/proto.js +46 -388
  40. package/dist/src/insecure/pb/proto.js.map +1 -0
  41. package/dist/src/keychain/index.d.ts +2 -2
  42. package/dist/src/keychain/index.js +2 -2
  43. package/dist/src/keychain/util.d.ts +1 -1
  44. package/dist/src/keychain/util.d.ts.map +1 -1
  45. package/package.json +24 -22
  46. package/src/circuit/circuit/hop.ts +4 -4
  47. package/src/circuit/circuit/stop.ts +3 -3
  48. package/src/circuit/circuit/stream-handler.ts +5 -6
  49. package/src/circuit/circuit/utils.ts +2 -2
  50. package/src/circuit/pb/index.proto +1 -1
  51. package/src/circuit/pb/index.ts +88 -0
  52. package/src/fetch/index.ts +6 -7
  53. package/src/fetch/pb/proto.ts +58 -0
  54. package/src/identify/index.ts +10 -10
  55. package/src/identify/pb/message.ts +36 -0
  56. package/src/insecure/index.ts +8 -4
  57. package/src/insecure/pb/proto.ts +61 -0
  58. package/src/keychain/index.ts +2 -2
  59. package/src/circuit/pb/index.d.ts +0 -173
  60. package/src/circuit/pb/index.js +0 -528
  61. package/src/fetch/pb/proto.d.ts +0 -134
  62. package/src/fetch/pb/proto.js +0 -331
  63. package/src/identify/pb/message.d.ts +0 -110
  64. package/src/identify/pb/message.js +0 -369
  65. package/src/insecure/pb/proto.d.ts +0 -134
  66. package/src/insecure/pb/proto.js +0 -388
@@ -1,134 +1,26 @@
1
- import * as $protobuf from "protobufjs";
2
- /** Properties of a FetchRequest. */
3
- export interface IFetchRequest {
4
-
5
- /** FetchRequest identifier */
6
- identifier?: (string|null);
1
+ export interface FetchRequest {
2
+ identifier: string;
7
3
  }
8
-
9
- /** Represents a FetchRequest. */
10
- export class FetchRequest implements IFetchRequest {
11
-
12
- /**
13
- * Constructs a new FetchRequest.
14
- * @param [p] Properties to set
15
- */
16
- constructor(p?: IFetchRequest);
17
-
18
- /** FetchRequest identifier. */
19
- public identifier: string;
20
-
21
- /**
22
- * Encodes the specified FetchRequest message. Does not implicitly {@link FetchRequest.verify|verify} messages.
23
- * @param m FetchRequest message or plain object to encode
24
- * @param [w] Writer to encode to
25
- * @returns Writer
26
- */
27
- public static encode(m: IFetchRequest, w?: $protobuf.Writer): $protobuf.Writer;
28
-
29
- /**
30
- * Decodes a FetchRequest message from the specified reader or buffer.
31
- * @param r Reader or buffer to decode from
32
- * @param [l] Message length if known beforehand
33
- * @returns FetchRequest
34
- * @throws {Error} If the payload is not a reader or valid buffer
35
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
36
- */
37
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): FetchRequest;
38
-
39
- /**
40
- * Creates a FetchRequest message from a plain object. Also converts values to their respective internal types.
41
- * @param d Plain object
42
- * @returns FetchRequest
43
- */
44
- public static fromObject(d: { [k: string]: any }): FetchRequest;
45
-
46
- /**
47
- * Creates a plain object from a FetchRequest message. Also converts values to other types if specified.
48
- * @param m FetchRequest
49
- * @param [o] Conversion options
50
- * @returns Plain object
51
- */
52
- public static toObject(m: FetchRequest, o?: $protobuf.IConversionOptions): { [k: string]: any };
53
-
54
- /**
55
- * Converts this FetchRequest to JSON.
56
- * @returns JSON object
57
- */
58
- public toJSON(): { [k: string]: any };
4
+ export declare namespace FetchRequest {
5
+ const codec: () => import("protons-runtime/dist/src/codecs/codec").Codec<FetchRequest>;
6
+ const encode: (obj: FetchRequest) => Uint8Array;
7
+ const decode: (buf: Uint8Array) => FetchRequest;
59
8
  }
60
-
61
- /** Properties of a FetchResponse. */
62
- export interface IFetchResponse {
63
-
64
- /** FetchResponse status */
65
- status?: (FetchResponse.StatusCode|null);
66
-
67
- /** FetchResponse data */
68
- data?: (Uint8Array|null);
9
+ export interface FetchResponse {
10
+ status: FetchResponse.StatusCode;
11
+ data: Uint8Array;
69
12
  }
70
-
71
- /** Represents a FetchResponse. */
72
- export class FetchResponse implements IFetchResponse {
73
-
74
- /**
75
- * Constructs a new FetchResponse.
76
- * @param [p] Properties to set
77
- */
78
- constructor(p?: IFetchResponse);
79
-
80
- /** FetchResponse status. */
81
- public status: FetchResponse.StatusCode;
82
-
83
- /** FetchResponse data. */
84
- public data: Uint8Array;
85
-
86
- /**
87
- * Encodes the specified FetchResponse message. Does not implicitly {@link FetchResponse.verify|verify} messages.
88
- * @param m FetchResponse message or plain object to encode
89
- * @param [w] Writer to encode to
90
- * @returns Writer
91
- */
92
- public static encode(m: IFetchResponse, w?: $protobuf.Writer): $protobuf.Writer;
93
-
94
- /**
95
- * Decodes a FetchResponse message from the specified reader or buffer.
96
- * @param r Reader or buffer to decode from
97
- * @param [l] Message length if known beforehand
98
- * @returns FetchResponse
99
- * @throws {Error} If the payload is not a reader or valid buffer
100
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
101
- */
102
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): FetchResponse;
103
-
104
- /**
105
- * Creates a FetchResponse message from a plain object. Also converts values to their respective internal types.
106
- * @param d Plain object
107
- * @returns FetchResponse
108
- */
109
- public static fromObject(d: { [k: string]: any }): FetchResponse;
110
-
111
- /**
112
- * Creates a plain object from a FetchResponse message. Also converts values to other types if specified.
113
- * @param m FetchResponse
114
- * @param [o] Conversion options
115
- * @returns Plain object
116
- */
117
- public static toObject(m: FetchResponse, o?: $protobuf.IConversionOptions): { [k: string]: any };
118
-
119
- /**
120
- * Converts this FetchResponse to JSON.
121
- * @returns JSON object
122
- */
123
- public toJSON(): { [k: string]: any };
124
- }
125
-
126
- export namespace FetchResponse {
127
-
128
- /** StatusCode enum. */
13
+ export declare namespace FetchResponse {
129
14
  enum StatusCode {
130
- OK = 0,
131
- NOT_FOUND = 1,
132
- ERROR = 2
15
+ OK = "OK",
16
+ NOT_FOUND = "NOT_FOUND",
17
+ ERROR = "ERROR"
18
+ }
19
+ namespace StatusCode {
20
+ const codec: () => import("protons-runtime/dist/src/codecs/codec").Codec<typeof StatusCode>;
133
21
  }
22
+ const codec: () => import("protons-runtime/dist/src/codecs/codec").Codec<FetchResponse>;
23
+ const encode: (obj: FetchResponse) => Uint8Array;
24
+ const decode: (buf: Uint8Array) => FetchResponse;
134
25
  }
26
+ //# sourceMappingURL=proto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../../../src/fetch/pb/proto.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,yBAAiB,YAAY,CAAC;IACrB,MAAM,KAAK,2EAIjB,CAAA;IAEM,MAAM,MAAM,QAAS,YAAY,KAAG,UAE1C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,KAAG,YAExC,CAAA;CACF;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAC,UAAU,CAAA;IAChC,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,yBAAiB,aAAa,CAAC;IAC7B,KAAY,UAAU;QACpB,EAAE,OAAO;QACT,SAAS,cAAc;QACvB,KAAK,UAAU;KAChB;IAED,UAAiB,UAAU,CAAC;QACnB,MAAM,KAAK,gFAEjB,CAAA;KACF;IAEM,MAAM,KAAK,4EAKjB,CAAA;IAEM,MAAM,MAAM,QAAS,aAAa,KAAG,UAE3C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,KAAG,aAExC,CAAA;CACF"}
@@ -1,331 +1,44 @@
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-fetch"] || ($protobuf.roots["libp2p-fetch"] = {});
9
-
10
- export const FetchRequest = $root.FetchRequest = (() => {
11
-
12
- /**
13
- * Properties of a FetchRequest.
14
- * @exports IFetchRequest
15
- * @interface IFetchRequest
16
- * @property {string|null} [identifier] FetchRequest identifier
17
- */
18
-
19
- /**
20
- * Constructs a new FetchRequest.
21
- * @exports FetchRequest
22
- * @classdesc Represents a FetchRequest.
23
- * @implements IFetchRequest
24
- * @constructor
25
- * @param {IFetchRequest=} [p] Properties to set
26
- */
27
- function FetchRequest(p) {
28
- if (p)
29
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
30
- if (p[ks[i]] != null)
31
- this[ks[i]] = p[ks[i]];
32
- }
33
-
34
- /**
35
- * FetchRequest identifier.
36
- * @member {string} identifier
37
- * @memberof FetchRequest
38
- * @instance
39
- */
40
- FetchRequest.prototype.identifier = "";
41
-
42
- /**
43
- * Encodes the specified FetchRequest message. Does not implicitly {@link FetchRequest.verify|verify} messages.
44
- * @function encode
45
- * @memberof FetchRequest
46
- * @static
47
- * @param {IFetchRequest} m FetchRequest message or plain object to encode
48
- * @param {$protobuf.Writer} [w] Writer to encode to
49
- * @returns {$protobuf.Writer} Writer
50
- */
51
- FetchRequest.encode = function encode(m, w) {
52
- if (!w)
53
- w = $Writer.create();
54
- if (m.identifier != null && Object.hasOwnProperty.call(m, "identifier"))
55
- w.uint32(10).string(m.identifier);
56
- return w;
57
- };
58
-
59
- /**
60
- * Decodes a FetchRequest message from the specified reader or buffer.
61
- * @function decode
62
- * @memberof FetchRequest
63
- * @static
64
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
65
- * @param {number} [l] Message length if known beforehand
66
- * @returns {FetchRequest} FetchRequest
67
- * @throws {Error} If the payload is not a reader or valid buffer
68
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
69
- */
70
- FetchRequest.decode = function decode(r, l) {
71
- if (!(r instanceof $Reader))
72
- r = $Reader.create(r);
73
- var c = l === undefined ? r.len : r.pos + l, m = new $root.FetchRequest();
74
- while (r.pos < c) {
75
- var t = r.uint32();
76
- switch (t >>> 3) {
77
- case 1:
78
- m.identifier = r.string();
79
- break;
80
- default:
81
- r.skipType(t & 7);
82
- break;
83
- }
84
- }
85
- return m;
86
- };
87
-
88
- /**
89
- * Creates a FetchRequest message from a plain object. Also converts values to their respective internal types.
90
- * @function fromObject
91
- * @memberof FetchRequest
92
- * @static
93
- * @param {Object.<string,*>} d Plain object
94
- * @returns {FetchRequest} FetchRequest
95
- */
96
- FetchRequest.fromObject = function fromObject(d) {
97
- if (d instanceof $root.FetchRequest)
98
- return d;
99
- var m = new $root.FetchRequest();
100
- if (d.identifier != null) {
101
- m.identifier = String(d.identifier);
102
- }
103
- return m;
104
- };
105
-
106
- /**
107
- * Creates a plain object from a FetchRequest message. Also converts values to other types if specified.
108
- * @function toObject
109
- * @memberof FetchRequest
110
- * @static
111
- * @param {FetchRequest} m FetchRequest
112
- * @param {$protobuf.IConversionOptions} [o] Conversion options
113
- * @returns {Object.<string,*>} Plain object
114
- */
115
- FetchRequest.toObject = function toObject(m, o) {
116
- if (!o)
117
- o = {};
118
- var d = {};
119
- if (o.defaults) {
120
- d.identifier = "";
121
- }
122
- if (m.identifier != null && m.hasOwnProperty("identifier")) {
123
- d.identifier = m.identifier;
124
- }
125
- return d;
126
- };
127
-
128
- /**
129
- * Converts this FetchRequest to JSON.
130
- * @function toJSON
131
- * @memberof FetchRequest
132
- * @instance
133
- * @returns {Object.<string,*>} JSON object
134
- */
135
- FetchRequest.prototype.toJSON = function toJSON() {
136
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
137
- };
138
-
139
- return FetchRequest;
140
- })();
141
-
142
- export const FetchResponse = $root.FetchResponse = (() => {
143
-
144
- /**
145
- * Properties of a FetchResponse.
146
- * @exports IFetchResponse
147
- * @interface IFetchResponse
148
- * @property {FetchResponse.StatusCode|null} [status] FetchResponse status
149
- * @property {Uint8Array|null} [data] FetchResponse data
150
- */
151
-
152
- /**
153
- * Constructs a new FetchResponse.
154
- * @exports FetchResponse
155
- * @classdesc Represents a FetchResponse.
156
- * @implements IFetchResponse
157
- * @constructor
158
- * @param {IFetchResponse=} [p] Properties to set
159
- */
160
- function FetchResponse(p) {
161
- if (p)
162
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
163
- if (p[ks[i]] != null)
164
- this[ks[i]] = p[ks[i]];
165
- }
166
-
167
- /**
168
- * FetchResponse status.
169
- * @member {FetchResponse.StatusCode} status
170
- * @memberof FetchResponse
171
- * @instance
172
- */
173
- FetchResponse.prototype.status = 0;
174
-
175
- /**
176
- * FetchResponse data.
177
- * @member {Uint8Array} data
178
- * @memberof FetchResponse
179
- * @instance
180
- */
181
- FetchResponse.prototype.data = $util.newBuffer([]);
182
-
183
- /**
184
- * Encodes the specified FetchResponse message. Does not implicitly {@link FetchResponse.verify|verify} messages.
185
- * @function encode
186
- * @memberof FetchResponse
187
- * @static
188
- * @param {IFetchResponse} m FetchResponse message or plain object to encode
189
- * @param {$protobuf.Writer} [w] Writer to encode to
190
- * @returns {$protobuf.Writer} Writer
191
- */
192
- FetchResponse.encode = function encode(m, w) {
193
- if (!w)
194
- w = $Writer.create();
195
- if (m.status != null && Object.hasOwnProperty.call(m, "status"))
196
- w.uint32(8).int32(m.status);
197
- if (m.data != null && Object.hasOwnProperty.call(m, "data"))
198
- w.uint32(18).bytes(m.data);
199
- return w;
200
- };
201
-
202
- /**
203
- * Decodes a FetchResponse message from the specified reader or buffer.
204
- * @function decode
205
- * @memberof FetchResponse
206
- * @static
207
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
208
- * @param {number} [l] Message length if known beforehand
209
- * @returns {FetchResponse} FetchResponse
210
- * @throws {Error} If the payload is not a reader or valid buffer
211
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
212
- */
213
- FetchResponse.decode = function decode(r, l) {
214
- if (!(r instanceof $Reader))
215
- r = $Reader.create(r);
216
- var c = l === undefined ? r.len : r.pos + l, m = new $root.FetchResponse();
217
- while (r.pos < c) {
218
- var t = r.uint32();
219
- switch (t >>> 3) {
220
- case 1:
221
- m.status = r.int32();
222
- break;
223
- case 2:
224
- m.data = r.bytes();
225
- break;
226
- default:
227
- r.skipType(t & 7);
228
- break;
229
- }
230
- }
231
- return m;
232
- };
233
-
234
- /**
235
- * Creates a FetchResponse message from a plain object. Also converts values to their respective internal types.
236
- * @function fromObject
237
- * @memberof FetchResponse
238
- * @static
239
- * @param {Object.<string,*>} d Plain object
240
- * @returns {FetchResponse} FetchResponse
241
- */
242
- FetchResponse.fromObject = function fromObject(d) {
243
- if (d instanceof $root.FetchResponse)
244
- return d;
245
- var m = new $root.FetchResponse();
246
- switch (d.status) {
247
- case "OK":
248
- case 0:
249
- m.status = 0;
250
- break;
251
- case "NOT_FOUND":
252
- case 1:
253
- m.status = 1;
254
- break;
255
- case "ERROR":
256
- case 2:
257
- m.status = 2;
258
- break;
259
- }
260
- if (d.data != null) {
261
- if (typeof d.data === "string")
262
- $util.base64.decode(d.data, m.data = $util.newBuffer($util.base64.length(d.data)), 0);
263
- else if (d.data.length)
264
- m.data = d.data;
265
- }
266
- return m;
267
- };
268
-
269
- /**
270
- * Creates a plain object from a FetchResponse message. Also converts values to other types if specified.
271
- * @function toObject
272
- * @memberof FetchResponse
273
- * @static
274
- * @param {FetchResponse} m FetchResponse
275
- * @param {$protobuf.IConversionOptions} [o] Conversion options
276
- * @returns {Object.<string,*>} Plain object
277
- */
278
- FetchResponse.toObject = function toObject(m, o) {
279
- if (!o)
280
- o = {};
281
- var d = {};
282
- if (o.defaults) {
283
- d.status = o.enums === String ? "OK" : 0;
284
- if (o.bytes === String)
285
- d.data = "";
286
- else {
287
- d.data = [];
288
- if (o.bytes !== Array)
289
- d.data = $util.newBuffer(d.data);
290
- }
291
- }
292
- if (m.status != null && m.hasOwnProperty("status")) {
293
- d.status = o.enums === String ? $root.FetchResponse.StatusCode[m.status] : m.status;
294
- }
295
- if (m.data != null && m.hasOwnProperty("data")) {
296
- d.data = o.bytes === String ? $util.base64.encode(m.data, 0, m.data.length) : o.bytes === Array ? Array.prototype.slice.call(m.data) : m.data;
297
- }
298
- return d;
299
- };
300
-
301
- /**
302
- * Converts this FetchResponse to JSON.
303
- * @function toJSON
304
- * @memberof FetchResponse
305
- * @instance
306
- * @returns {Object.<string,*>} JSON object
307
- */
308
- FetchResponse.prototype.toJSON = function toJSON() {
309
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
310
- };
311
-
312
- /**
313
- * StatusCode enum.
314
- * @name FetchResponse.StatusCode
315
- * @enum {number}
316
- * @property {number} OK=0 OK value
317
- * @property {number} NOT_FOUND=1 NOT_FOUND value
318
- * @property {number} ERROR=2 ERROR value
319
- */
320
- FetchResponse.StatusCode = (function() {
321
- const valuesById = {}, values = Object.create(valuesById);
322
- values[valuesById[0] = "OK"] = 0;
323
- values[valuesById[1] = "NOT_FOUND"] = 1;
324
- values[valuesById[2] = "ERROR"] = 2;
325
- return values;
326
- })();
327
-
328
- return FetchResponse;
329
- })();
330
-
331
- export { $root as default };
1
+ /* eslint-disable import/export */
2
+ /* eslint-disable @typescript-eslint/no-namespace */
3
+ import { encodeMessage, decodeMessage, message, string, enumeration, bytes } from 'protons-runtime';
4
+ export var FetchRequest;
5
+ (function (FetchRequest) {
6
+ FetchRequest.codec = () => {
7
+ return message({
8
+ 1: { name: 'identifier', codec: string }
9
+ });
10
+ };
11
+ FetchRequest.encode = (obj) => {
12
+ return encodeMessage(obj, FetchRequest.codec());
13
+ };
14
+ FetchRequest.decode = (buf) => {
15
+ return decodeMessage(buf, FetchRequest.codec());
16
+ };
17
+ })(FetchRequest || (FetchRequest = {}));
18
+ export var FetchResponse;
19
+ (function (FetchResponse) {
20
+ let StatusCode;
21
+ (function (StatusCode) {
22
+ StatusCode["OK"] = "OK";
23
+ StatusCode["NOT_FOUND"] = "NOT_FOUND";
24
+ StatusCode["ERROR"] = "ERROR";
25
+ })(StatusCode = FetchResponse.StatusCode || (FetchResponse.StatusCode = {}));
26
+ (function (StatusCode) {
27
+ StatusCode.codec = () => {
28
+ return enumeration(StatusCode);
29
+ };
30
+ })(StatusCode = FetchResponse.StatusCode || (FetchResponse.StatusCode = {}));
31
+ FetchResponse.codec = () => {
32
+ return message({
33
+ 1: { name: 'status', codec: FetchResponse.StatusCode.codec() },
34
+ 2: { name: 'data', codec: bytes }
35
+ });
36
+ };
37
+ FetchResponse.encode = (obj) => {
38
+ return encodeMessage(obj, FetchResponse.codec());
39
+ };
40
+ FetchResponse.decode = (buf) => {
41
+ return decodeMessage(buf, FetchResponse.codec());
42
+ };
43
+ })(FetchResponse || (FetchResponse = {}));
44
+ //# sourceMappingURL=proto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.js","sourceRoot":"","sources":["../../../../src/fetch/pb/proto.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oDAAoD;AAEpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAMnG,MAAM,KAAW,YAAY,CAc5B;AAdD,WAAiB,YAAY;IACd,kBAAK,GAAG,GAAG,EAAE;QACxB,OAAO,OAAO,CAAe;YAC3B,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC,CAAA;IAEY,mBAAM,GAAG,CAAC,GAAiB,EAAc,EAAE;QACtD,OAAO,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAA;IACjD,CAAC,CAAA;IAEY,mBAAM,GAAG,CAAC,GAAe,EAAgB,EAAE;QACtD,OAAO,aAAa,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAA;IACjD,CAAC,CAAA;AACH,CAAC,EAdgB,YAAY,KAAZ,YAAY,QAc5B;AAOD,MAAM,KAAW,aAAa,CA2B7B;AA3BD,WAAiB,aAAa;IAC5B,IAAY,UAIX;IAJD,WAAY,UAAU;QACpB,uBAAS,CAAA;QACT,qCAAuB,CAAA;QACvB,6BAAe,CAAA;IACjB,CAAC,EAJW,UAAU,GAAV,wBAAU,KAAV,wBAAU,QAIrB;IAED,WAAiB,UAAU;QACZ,gBAAK,GAAG,GAAG,EAAE;YACxB,OAAO,WAAW,CAAoB,UAAU,CAAC,CAAA;QACnD,CAAC,CAAA;IACH,CAAC,EAJgB,UAAU,GAAV,wBAAU,KAAV,wBAAU,QAI1B;IAEY,mBAAK,GAAG,GAAG,EAAE;QACxB,OAAO,OAAO,CAAgB;YAC5B,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE;YAC9D,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;SAClC,CAAC,CAAA;IACJ,CAAC,CAAA;IAEY,oBAAM,GAAG,CAAC,GAAkB,EAAc,EAAE;QACvD,OAAO,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,EAAE,CAAC,CAAA;IAClD,CAAC,CAAA;IAEY,oBAAM,GAAG,CAAC,GAAe,EAAiB,EAAE;QACvD,OAAO,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,EAAE,CAAC,CAAA;IAClD,CAAC,CAAA;AACH,CAAC,EA3BgB,aAAa,KAAb,aAAa,QA2B7B"}
@@ -1,5 +1,5 @@
1
1
  import { Multiaddr } from '@multiformats/multiaddr';
2
- import Message from './pb/message.js';
2
+ import { Identify } from './pb/message.js';
3
3
  import type { IncomingStreamData } from '@libp2p/interfaces/registrar';
4
4
  import type { Connection } from '@libp2p/interfaces/connection';
5
5
  import type { Startable } from '@libp2p/interfaces';
@@ -60,5 +60,7 @@ export declare const multicodecs: {
60
60
  IDENTIFY: string;
61
61
  IDENTIFY_PUSH: string;
62
62
  };
63
- export { Message };
63
+ export declare const Message: {
64
+ Identify: typeof Identify;
65
+ };
64
66
  //#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eAAe;IAsBrB;;;;OAIG;IACG,QAAQ,CAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0GtD;;OAEG;IACH,aAAa,CAAE,IAAI,EAAE,kBAAkB;IAavC;;;OAGG;IACG,eAAe,CAAE,IAAI,EAAE,kBAAkB;IAwC/C;;OAEG;IACG,WAAW,CAAE,IAAI,EAAE,kBAAkB;IAuE3C;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;CASvE;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;CAGvB,CAAA;AAED,eAAO,MAAM,OAAO;;CAAe,CAAA"}
@@ -8,7 +8,7 @@ import drain from 'it-drain';
8
8
  import first from 'it-first';
9
9
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
10
10
  import { Multiaddr, protocols } from '@multiformats/multiaddr';
11
- import Message from './pb/message.js';
11
+ import { Identify } from './pb/message.js';
12
12
  import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
13
13
  import { MULTICODEC_IDENTIFY, MULTICODEC_IDENTIFY_PUSH, IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME, MULTICODEC_IDENTIFY_PROTOCOL_VERSION, MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION } from './consts.js';
14
14
  import { codes } from '../errors.js';
@@ -80,11 +80,11 @@ export class IdentifyService {
80
80
  const pushes = connections.map(async (connection) => {
81
81
  try {
82
82
  const { stream } = await connection.newStream([this.identifyPushProtocolStr]);
83
- await pipe([Message.Identify.encode({
83
+ await pipe([Identify.encode({
84
84
  listenAddrs,
85
85
  signedPeerRecord,
86
86
  protocols
87
- }).finish()], lp.encode(), stream, drain);
87
+ })], lp.encode(), stream, drain);
88
88
  }
89
89
  catch (err) {
90
90
  // Just log errors
@@ -125,7 +125,7 @@ export class IdentifyService {
125
125
  }
126
126
  let message;
127
127
  try {
128
- message = Message.Identify.decode(data);
128
+ message = Identify.decode(data);
129
129
  }
130
130
  catch (err) {
131
131
  throw errCode(err, codes.ERR_INVALID_MESSAGE);
@@ -223,7 +223,7 @@ export class IdentifyService {
223
223
  await this.components.getPeerStore().addressBook.consumePeerRecord(envelope);
224
224
  signedPeerRecord = envelope.marshal();
225
225
  }
226
- const message = Message.Identify.encode({
226
+ const message = Identify.encode({
227
227
  protocolVersion: this.host.protocolVersion,
228
228
  agentVersion: this.host.agentVersion,
229
229
  publicKey,
@@ -231,7 +231,7 @@ export class IdentifyService {
231
231
  signedPeerRecord,
232
232
  observedAddr: connection.remoteAddr.bytes,
233
233
  protocols: peerData.protocols
234
- }).finish();
234
+ });
235
235
  await pipe([message], lp.encode(), stream, drain);
236
236
  }
237
237
  catch (err) {
@@ -247,7 +247,7 @@ export class IdentifyService {
247
247
  try {
248
248
  const data = await pipe([], stream, lp.decode(), async (source) => await first(source));
249
249
  if (data != null) {
250
- message = Message.Identify.decode(data);
250
+ message = Identify.decode(data);
251
251
  }
252
252
  }
253
253
  catch (err) {
@@ -318,5 +318,5 @@ export const multicodecs = {
318
318
  IDENTIFY: MULTICODEC_IDENTIFY,
319
319
  IDENTIFY_PUSH: MULTICODEC_IDENTIFY_PUSH
320
320
  };
321
- export { Message };
321
+ export const Message = { Identify };
322
322
  //# sourceMappingURL=index.js.map