libp2p 0.36.2-cc60cfd → 0.36.2-fab4f13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/circuit/circuit/hop.d.ts +3 -3
- package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/hop.js +1 -1
- package/dist/src/circuit/circuit/hop.js.map +1 -1
- package/dist/src/circuit/circuit/stop.d.ts +3 -3
- package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stop.js.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.d.ts +4 -4
- package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.js +2 -3
- package/dist/src/circuit/circuit/stream-handler.js.map +1 -1
- package/dist/src/circuit/circuit/utils.d.ts +2 -2
- package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/circuit/utils.js.map +1 -1
- package/dist/src/circuit/pb/index.d.ts +42 -164
- package/dist/src/circuit/pb/index.d.ts.map +1 -0
- package/dist/src/circuit/pb/index.js +67 -523
- package/dist/src/circuit/pb/index.js.map +1 -0
- package/dist/src/dht/dummy-dht.d.ts +17 -0
- package/dist/src/dht/dummy-dht.d.ts.map +1 -0
- package/dist/src/dht/dummy-dht.js +39 -0
- package/dist/src/dht/dummy-dht.js.map +1 -0
- package/dist/src/dialer/index.d.ts.map +1 -1
- package/dist/src/dialer/index.js +0 -1
- package/dist/src/dialer/index.js.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +2 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +5 -6
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/fetch/pb/proto.d.ts +20 -128
- package/dist/src/fetch/pb/proto.d.ts.map +1 -0
- package/dist/src/fetch/pb/proto.js +44 -331
- package/dist/src/fetch/pb/proto.js.map +1 -0
- package/dist/src/identify/index.d.ts +4 -2
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +8 -8
- package/dist/src/identify/index.js.map +1 -1
- package/dist/src/identify/pb/message.d.ts +13 -108
- package/dist/src/identify/pb/message.d.ts.map +1 -0
- package/dist/src/identify/pb/message.js +21 -366
- package/dist/src/identify/pb/message.js.map +1 -0
- package/dist/src/index.d.ts +11 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.d.ts.map +1 -1
- package/dist/src/insecure/index.js +5 -2
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/insecure/pb/proto.d.ts +24 -130
- package/dist/src/insecure/pb/proto.d.ts.map +1 -0
- package/dist/src/insecure/pb/proto.js +46 -388
- package/dist/src/insecure/pb/proto.js.map +1 -0
- package/dist/src/keychain/index.d.ts +3 -3
- package/dist/src/keychain/index.js +2 -2
- package/dist/src/keychain/util.d.ts +1 -1
- package/dist/src/keychain/util.d.ts.map +1 -1
- package/dist/src/libp2p.d.ts +7 -4
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +20 -5
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/metrics/stats.d.ts +1 -5
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js.map +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts +17 -0
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -0
- package/dist/src/pubsub/dummy-pubsub.js +37 -0
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -0
- package/package.json +45 -44
- package/src/circuit/circuit/hop.ts +4 -4
- package/src/circuit/circuit/stop.ts +3 -3
- package/src/circuit/circuit/stream-handler.ts +5 -6
- package/src/circuit/circuit/utils.ts +2 -2
- package/src/circuit/pb/index.proto +1 -1
- package/src/circuit/pb/index.ts +88 -0
- package/src/dht/dummy-dht.ts +51 -0
- package/src/dialer/index.ts +0 -3
- package/src/errors.ts +2 -0
- package/src/fetch/index.ts +6 -7
- package/src/fetch/pb/proto.ts +58 -0
- package/src/identify/index.ts +10 -10
- package/src/identify/pb/message.ts +36 -0
- package/src/index.ts +12 -5
- package/src/insecure/index.ts +8 -4
- package/src/insecure/pb/proto.ts +61 -0
- package/src/keychain/index.ts +2 -2
- package/src/libp2p.ts +27 -9
- package/src/metrics/stats.ts +1 -6
- package/src/pubsub/dummy-pubsub.ts +51 -0
- package/src/circuit/pb/index.d.ts +0 -173
- package/src/circuit/pb/index.js +0 -528
- package/src/fetch/pb/proto.d.ts +0 -134
- package/src/fetch/pb/proto.js +0 -331
- package/src/identify/pb/message.d.ts +0 -110
- package/src/identify/pb/message.js +0 -369
- package/src/insecure/pb/proto.d.ts +0 -134
- package/src/insecure/pb/proto.js +0 -388
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../../../src/insecure/pb/proto.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,UAAU,CAAA;IACf,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,yBAAiB,QAAQ,CAAC;IACjB,MAAM,KAAK,iDAKjB,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,KAAG,UAEtC,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,KAAG,QAExC,CAAA;CACF;AAED,oBAAY,OAAO;IACjB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,KAAK,UAAU;CAChB;AAED,yBAAiB,OAAO,CAAC;IAChB,MAAM,KAAK,uDAEjB,CAAA;CACF;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,yBAAiB,SAAS,CAAC;IAClB,MAAM,KAAK,kDAKjB,CAAA;IAEM,MAAM,MAAM,QAAS,SAAS,KAAG,UAEvC,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,KAAG,SAExC,CAAA;CACF"}
|
|
@@ -1,388 +1,46 @@
|
|
|
1
|
-
/*eslint-disable*/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* @instance
|
|
48
|
-
*/
|
|
49
|
-
Exchange.prototype.pubkey = null;
|
|
50
|
-
|
|
51
|
-
// OneOf field names bound to virtual getters and setters
|
|
52
|
-
let $oneOfFields;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Exchange _id.
|
|
56
|
-
* @member {"id"|undefined} _id
|
|
57
|
-
* @memberof Exchange
|
|
58
|
-
* @instance
|
|
59
|
-
*/
|
|
60
|
-
Object.defineProperty(Exchange.prototype, "_id", {
|
|
61
|
-
get: $util.oneOfGetter($oneOfFields = ["id"]),
|
|
62
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Exchange _pubkey.
|
|
67
|
-
* @member {"pubkey"|undefined} _pubkey
|
|
68
|
-
* @memberof Exchange
|
|
69
|
-
* @instance
|
|
70
|
-
*/
|
|
71
|
-
Object.defineProperty(Exchange.prototype, "_pubkey", {
|
|
72
|
-
get: $util.oneOfGetter($oneOfFields = ["pubkey"]),
|
|
73
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Encodes the specified Exchange message. Does not implicitly {@link Exchange.verify|verify} messages.
|
|
78
|
-
* @function encode
|
|
79
|
-
* @memberof Exchange
|
|
80
|
-
* @static
|
|
81
|
-
* @param {IExchange} m Exchange message or plain object to encode
|
|
82
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
83
|
-
* @returns {$protobuf.Writer} Writer
|
|
84
|
-
*/
|
|
85
|
-
Exchange.encode = function encode(m, w) {
|
|
86
|
-
if (!w)
|
|
87
|
-
w = $Writer.create();
|
|
88
|
-
if (m.id != null && Object.hasOwnProperty.call(m, "id"))
|
|
89
|
-
w.uint32(10).bytes(m.id);
|
|
90
|
-
if (m.pubkey != null && Object.hasOwnProperty.call(m, "pubkey"))
|
|
91
|
-
$root.PublicKey.encode(m.pubkey, w.uint32(18).fork()).ldelim();
|
|
92
|
-
return w;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Decodes an Exchange message from the specified reader or buffer.
|
|
97
|
-
* @function decode
|
|
98
|
-
* @memberof Exchange
|
|
99
|
-
* @static
|
|
100
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
101
|
-
* @param {number} [l] Message length if known beforehand
|
|
102
|
-
* @returns {Exchange} Exchange
|
|
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
|
-
Exchange.decode = function decode(r, l) {
|
|
107
|
-
if (!(r instanceof $Reader))
|
|
108
|
-
r = $Reader.create(r);
|
|
109
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.Exchange();
|
|
110
|
-
while (r.pos < c) {
|
|
111
|
-
var t = r.uint32();
|
|
112
|
-
switch (t >>> 3) {
|
|
113
|
-
case 1:
|
|
114
|
-
m.id = r.bytes();
|
|
115
|
-
break;
|
|
116
|
-
case 2:
|
|
117
|
-
m.pubkey = $root.PublicKey.decode(r, r.uint32());
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
r.skipType(t & 7);
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return m;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Creates an Exchange message from a plain object. Also converts values to their respective internal types.
|
|
129
|
-
* @function fromObject
|
|
130
|
-
* @memberof Exchange
|
|
131
|
-
* @static
|
|
132
|
-
* @param {Object.<string,*>} d Plain object
|
|
133
|
-
* @returns {Exchange} Exchange
|
|
134
|
-
*/
|
|
135
|
-
Exchange.fromObject = function fromObject(d) {
|
|
136
|
-
if (d instanceof $root.Exchange)
|
|
137
|
-
return d;
|
|
138
|
-
var m = new $root.Exchange();
|
|
139
|
-
if (d.id != null) {
|
|
140
|
-
if (typeof d.id === "string")
|
|
141
|
-
$util.base64.decode(d.id, m.id = $util.newBuffer($util.base64.length(d.id)), 0);
|
|
142
|
-
else if (d.id.length)
|
|
143
|
-
m.id = d.id;
|
|
144
|
-
}
|
|
145
|
-
if (d.pubkey != null) {
|
|
146
|
-
if (typeof d.pubkey !== "object")
|
|
147
|
-
throw TypeError(".Exchange.pubkey: object expected");
|
|
148
|
-
m.pubkey = $root.PublicKey.fromObject(d.pubkey);
|
|
149
|
-
}
|
|
150
|
-
return m;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Creates a plain object from an Exchange message. Also converts values to other types if specified.
|
|
155
|
-
* @function toObject
|
|
156
|
-
* @memberof Exchange
|
|
157
|
-
* @static
|
|
158
|
-
* @param {Exchange} m Exchange
|
|
159
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
160
|
-
* @returns {Object.<string,*>} Plain object
|
|
161
|
-
*/
|
|
162
|
-
Exchange.toObject = function toObject(m, o) {
|
|
163
|
-
if (!o)
|
|
164
|
-
o = {};
|
|
165
|
-
var d = {};
|
|
166
|
-
if (m.id != null && m.hasOwnProperty("id")) {
|
|
167
|
-
d.id = o.bytes === String ? $util.base64.encode(m.id, 0, m.id.length) : o.bytes === Array ? Array.prototype.slice.call(m.id) : m.id;
|
|
168
|
-
if (o.oneofs)
|
|
169
|
-
d._id = "id";
|
|
170
|
-
}
|
|
171
|
-
if (m.pubkey != null && m.hasOwnProperty("pubkey")) {
|
|
172
|
-
d.pubkey = $root.PublicKey.toObject(m.pubkey, o);
|
|
173
|
-
if (o.oneofs)
|
|
174
|
-
d._pubkey = "pubkey";
|
|
175
|
-
}
|
|
176
|
-
return d;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Converts this Exchange to JSON.
|
|
181
|
-
* @function toJSON
|
|
182
|
-
* @memberof Exchange
|
|
183
|
-
* @instance
|
|
184
|
-
* @returns {Object.<string,*>} JSON object
|
|
185
|
-
*/
|
|
186
|
-
Exchange.prototype.toJSON = function toJSON() {
|
|
187
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
return Exchange;
|
|
191
|
-
})();
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* KeyType enum.
|
|
195
|
-
* @exports KeyType
|
|
196
|
-
* @enum {number}
|
|
197
|
-
* @property {number} RSA=0 RSA value
|
|
198
|
-
* @property {number} Ed25519=1 Ed25519 value
|
|
199
|
-
* @property {number} Secp256k1=2 Secp256k1 value
|
|
200
|
-
* @property {number} ECDSA=3 ECDSA value
|
|
201
|
-
*/
|
|
202
|
-
export const KeyType = $root.KeyType = (() => {
|
|
203
|
-
const valuesById = {}, values = Object.create(valuesById);
|
|
204
|
-
values[valuesById[0] = "RSA"] = 0;
|
|
205
|
-
values[valuesById[1] = "Ed25519"] = 1;
|
|
206
|
-
values[valuesById[2] = "Secp256k1"] = 2;
|
|
207
|
-
values[valuesById[3] = "ECDSA"] = 3;
|
|
208
|
-
return values;
|
|
209
|
-
})();
|
|
210
|
-
|
|
211
|
-
export const PublicKey = $root.PublicKey = (() => {
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Properties of a PublicKey.
|
|
215
|
-
* @exports IPublicKey
|
|
216
|
-
* @interface IPublicKey
|
|
217
|
-
* @property {KeyType|null} [Type] PublicKey Type
|
|
218
|
-
* @property {Uint8Array|null} [Data] PublicKey Data
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Constructs a new PublicKey.
|
|
223
|
-
* @exports PublicKey
|
|
224
|
-
* @classdesc Represents a PublicKey.
|
|
225
|
-
* @implements IPublicKey
|
|
226
|
-
* @constructor
|
|
227
|
-
* @param {IPublicKey=} [p] Properties to set
|
|
228
|
-
*/
|
|
229
|
-
function PublicKey(p) {
|
|
230
|
-
if (p)
|
|
231
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
232
|
-
if (p[ks[i]] != null)
|
|
233
|
-
this[ks[i]] = p[ks[i]];
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* PublicKey Type.
|
|
238
|
-
* @member {KeyType} Type
|
|
239
|
-
* @memberof PublicKey
|
|
240
|
-
* @instance
|
|
241
|
-
*/
|
|
242
|
-
PublicKey.prototype.Type = 0;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* PublicKey Data.
|
|
246
|
-
* @member {Uint8Array} Data
|
|
247
|
-
* @memberof PublicKey
|
|
248
|
-
* @instance
|
|
249
|
-
*/
|
|
250
|
-
PublicKey.prototype.Data = $util.newBuffer([]);
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Encodes the specified PublicKey message. Does not implicitly {@link PublicKey.verify|verify} messages.
|
|
254
|
-
* @function encode
|
|
255
|
-
* @memberof PublicKey
|
|
256
|
-
* @static
|
|
257
|
-
* @param {IPublicKey} m PublicKey message or plain object to encode
|
|
258
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
259
|
-
* @returns {$protobuf.Writer} Writer
|
|
260
|
-
*/
|
|
261
|
-
PublicKey.encode = function encode(m, w) {
|
|
262
|
-
if (!w)
|
|
263
|
-
w = $Writer.create();
|
|
264
|
-
if (m.Type != null && Object.hasOwnProperty.call(m, "Type"))
|
|
265
|
-
w.uint32(8).int32(m.Type);
|
|
266
|
-
if (m.Data != null && Object.hasOwnProperty.call(m, "Data"))
|
|
267
|
-
w.uint32(18).bytes(m.Data);
|
|
268
|
-
return w;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Decodes a PublicKey message from the specified reader or buffer.
|
|
273
|
-
* @function decode
|
|
274
|
-
* @memberof PublicKey
|
|
275
|
-
* @static
|
|
276
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
277
|
-
* @param {number} [l] Message length if known beforehand
|
|
278
|
-
* @returns {PublicKey} PublicKey
|
|
279
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
280
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
281
|
-
*/
|
|
282
|
-
PublicKey.decode = function decode(r, l) {
|
|
283
|
-
if (!(r instanceof $Reader))
|
|
284
|
-
r = $Reader.create(r);
|
|
285
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.PublicKey();
|
|
286
|
-
while (r.pos < c) {
|
|
287
|
-
var t = r.uint32();
|
|
288
|
-
switch (t >>> 3) {
|
|
289
|
-
case 1:
|
|
290
|
-
m.Type = r.int32();
|
|
291
|
-
break;
|
|
292
|
-
case 2:
|
|
293
|
-
m.Data = r.bytes();
|
|
294
|
-
break;
|
|
295
|
-
default:
|
|
296
|
-
r.skipType(t & 7);
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return m;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Creates a PublicKey message from a plain object. Also converts values to their respective internal types.
|
|
305
|
-
* @function fromObject
|
|
306
|
-
* @memberof PublicKey
|
|
307
|
-
* @static
|
|
308
|
-
* @param {Object.<string,*>} d Plain object
|
|
309
|
-
* @returns {PublicKey} PublicKey
|
|
310
|
-
*/
|
|
311
|
-
PublicKey.fromObject = function fromObject(d) {
|
|
312
|
-
if (d instanceof $root.PublicKey)
|
|
313
|
-
return d;
|
|
314
|
-
var m = new $root.PublicKey();
|
|
315
|
-
switch (d.Type) {
|
|
316
|
-
case "RSA":
|
|
317
|
-
case 0:
|
|
318
|
-
m.Type = 0;
|
|
319
|
-
break;
|
|
320
|
-
case "Ed25519":
|
|
321
|
-
case 1:
|
|
322
|
-
m.Type = 1;
|
|
323
|
-
break;
|
|
324
|
-
case "Secp256k1":
|
|
325
|
-
case 2:
|
|
326
|
-
m.Type = 2;
|
|
327
|
-
break;
|
|
328
|
-
case "ECDSA":
|
|
329
|
-
case 3:
|
|
330
|
-
m.Type = 3;
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
if (d.Data != null) {
|
|
334
|
-
if (typeof d.Data === "string")
|
|
335
|
-
$util.base64.decode(d.Data, m.Data = $util.newBuffer($util.base64.length(d.Data)), 0);
|
|
336
|
-
else if (d.Data.length)
|
|
337
|
-
m.Data = d.Data;
|
|
338
|
-
}
|
|
339
|
-
return m;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Creates a plain object from a PublicKey message. Also converts values to other types if specified.
|
|
344
|
-
* @function toObject
|
|
345
|
-
* @memberof PublicKey
|
|
346
|
-
* @static
|
|
347
|
-
* @param {PublicKey} m PublicKey
|
|
348
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
349
|
-
* @returns {Object.<string,*>} Plain object
|
|
350
|
-
*/
|
|
351
|
-
PublicKey.toObject = function toObject(m, o) {
|
|
352
|
-
if (!o)
|
|
353
|
-
o = {};
|
|
354
|
-
var d = {};
|
|
355
|
-
if (o.defaults) {
|
|
356
|
-
d.Type = o.enums === String ? "RSA" : 0;
|
|
357
|
-
if (o.bytes === String)
|
|
358
|
-
d.Data = "";
|
|
359
|
-
else {
|
|
360
|
-
d.Data = [];
|
|
361
|
-
if (o.bytes !== Array)
|
|
362
|
-
d.Data = $util.newBuffer(d.Data);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (m.Type != null && m.hasOwnProperty("Type")) {
|
|
366
|
-
d.Type = o.enums === String ? $root.KeyType[m.Type] : m.Type;
|
|
367
|
-
}
|
|
368
|
-
if (m.Data != null && m.hasOwnProperty("Data")) {
|
|
369
|
-
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;
|
|
370
|
-
}
|
|
371
|
-
return d;
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Converts this PublicKey to JSON.
|
|
376
|
-
* @function toJSON
|
|
377
|
-
* @memberof PublicKey
|
|
378
|
-
* @instance
|
|
379
|
-
* @returns {Object.<string,*>} JSON object
|
|
380
|
-
*/
|
|
381
|
-
PublicKey.prototype.toJSON = function toJSON() {
|
|
382
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
return PublicKey;
|
|
386
|
-
})();
|
|
387
|
-
|
|
388
|
-
export { $root as default };
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { encodeMessage, decodeMessage, message, bytes, enumeration } from 'protons-runtime';
|
|
4
|
+
export var Exchange;
|
|
5
|
+
(function (Exchange) {
|
|
6
|
+
Exchange.codec = () => {
|
|
7
|
+
return message({
|
|
8
|
+
1: { name: 'id', codec: bytes, optional: true },
|
|
9
|
+
2: { name: 'pubkey', codec: PublicKey.codec(), optional: true }
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Exchange.encode = (obj) => {
|
|
13
|
+
return encodeMessage(obj, Exchange.codec());
|
|
14
|
+
};
|
|
15
|
+
Exchange.decode = (buf) => {
|
|
16
|
+
return decodeMessage(buf, Exchange.codec());
|
|
17
|
+
};
|
|
18
|
+
})(Exchange || (Exchange = {}));
|
|
19
|
+
export var KeyType;
|
|
20
|
+
(function (KeyType) {
|
|
21
|
+
KeyType["RSA"] = "RSA";
|
|
22
|
+
KeyType["Ed25519"] = "Ed25519";
|
|
23
|
+
KeyType["Secp256k1"] = "Secp256k1";
|
|
24
|
+
KeyType["ECDSA"] = "ECDSA";
|
|
25
|
+
})(KeyType || (KeyType = {}));
|
|
26
|
+
(function (KeyType) {
|
|
27
|
+
KeyType.codec = () => {
|
|
28
|
+
return enumeration(KeyType);
|
|
29
|
+
};
|
|
30
|
+
})(KeyType || (KeyType = {}));
|
|
31
|
+
export var PublicKey;
|
|
32
|
+
(function (PublicKey) {
|
|
33
|
+
PublicKey.codec = () => {
|
|
34
|
+
return message({
|
|
35
|
+
1: { name: 'Type', codec: KeyType.codec() },
|
|
36
|
+
2: { name: 'Data', codec: bytes }
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
PublicKey.encode = (obj) => {
|
|
40
|
+
return encodeMessage(obj, PublicKey.codec());
|
|
41
|
+
};
|
|
42
|
+
PublicKey.decode = (buf) => {
|
|
43
|
+
return decodeMessage(buf, PublicKey.codec());
|
|
44
|
+
};
|
|
45
|
+
})(PublicKey || (PublicKey = {}));
|
|
46
|
+
//# sourceMappingURL=proto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.js","sourceRoot":"","sources":["../../../../src/insecure/pb/proto.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oDAAoD;AAEpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAA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AE,EAAE;YAC3C,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;SAClC,CAAC,CAAA;IACJ,CAAC,CAAA;IAEY,gBAAM,GAAG,CAAC,GAAc,EAAc,EAAE;QACnD,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAA;IAEY,gBAAM,GAAG,CAAC,GAAe,EAAa,EAAE;QACnD,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IAC9C,CAAC,CAAA;AACH,CAAC,EAfgB,SAAS,KAAT,SAAS,QAezB"}
|
|
@@ -52,14 +52,14 @@ export declare class KeyChain {
|
|
|
52
52
|
/**
|
|
53
53
|
* Generates the options for a keychain. A random salt is produced.
|
|
54
54
|
*
|
|
55
|
-
* @returns {
|
|
55
|
+
* @returns {object}
|
|
56
56
|
*/
|
|
57
57
|
static generateOptions(): KeyChainInit;
|
|
58
58
|
/**
|
|
59
59
|
* Gets an object that can encrypt/decrypt protected data.
|
|
60
60
|
* The default options for a keychain.
|
|
61
61
|
*
|
|
62
|
-
* @returns {
|
|
62
|
+
* @returns {object}
|
|
63
63
|
*/
|
|
64
64
|
static get options(): {
|
|
65
65
|
dek: {
|
|
@@ -112,7 +112,7 @@ export declare class KeyChain {
|
|
|
112
112
|
/**
|
|
113
113
|
* Export an existing key as a PEM encrypted PKCS #8 string
|
|
114
114
|
*/
|
|
115
|
-
exportKey(name: string, password: string): Promise<
|
|
115
|
+
exportKey(name: string, password: string): Promise<string>;
|
|
116
116
|
/**
|
|
117
117
|
* Import a new key from a PEM encoded PKCS #8 string
|
|
118
118
|
*
|
|
@@ -115,7 +115,7 @@ export class KeyChain {
|
|
|
115
115
|
/**
|
|
116
116
|
* Generates the options for a keychain. A random salt is produced.
|
|
117
117
|
*
|
|
118
|
-
* @returns {
|
|
118
|
+
* @returns {object}
|
|
119
119
|
*/
|
|
120
120
|
static generateOptions() {
|
|
121
121
|
const options = Object.assign({}, defaultOptions);
|
|
@@ -127,7 +127,7 @@ export class KeyChain {
|
|
|
127
127
|
* Gets an object that can encrypt/decrypt protected data.
|
|
128
128
|
* The default options for a keychain.
|
|
129
129
|
*
|
|
130
|
-
* @returns {
|
|
130
|
+
* @returns {object}
|
|
131
131
|
*/
|
|
132
132
|
static get options() {
|
|
133
133
|
return defaultOptions;
|
|
@@ -6,7 +6,7 @@ import 'node-forge/lib/x509.js';
|
|
|
6
6
|
*
|
|
7
7
|
* TODO: move to libp2p-crypto package
|
|
8
8
|
*/
|
|
9
|
-
export declare const certificateForKey: (key: any, privateKey:
|
|
9
|
+
export declare const certificateForKey: (key: any, privateKey: forge.pki.rsa.PrivateKey) => any;
|
|
10
10
|
/**
|
|
11
11
|
* Finds the first item in a collection that is matched in the
|
|
12
12
|
* `asyncCompare` function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/keychain/util.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAA;AAM/B;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/keychain/util.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAA;AAM/B;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QAAS,GAAG,8CAmDzC,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAE,CAAC,EAAG,KAAK,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,cAKtF"}
|
package/dist/src/libp2p.d.ts
CHANGED
|
@@ -10,15 +10,16 @@ import type { Connection } from '@libp2p/interfaces/connection';
|
|
|
10
10
|
import type { PeerRouting } from '@libp2p/interfaces/peer-routing';
|
|
11
11
|
import type { ContentRouting } from '@libp2p/interfaces/content-routing';
|
|
12
12
|
import type { PubSub } from '@libp2p/interfaces/pubsub';
|
|
13
|
-
import type { ConnectionManager, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
13
|
+
import type { ConnectionManager, Registrar, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
14
14
|
import type { PeerInfo } from '@libp2p/interfaces/peer-info';
|
|
15
15
|
import type { Libp2p, Libp2pEvents, Libp2pInit, Libp2pOptions } from './index.js';
|
|
16
16
|
import type { PeerStore } from '@libp2p/interfaces/peer-store';
|
|
17
17
|
import type { DualDHT } from '@libp2p/interfaces/dht';
|
|
18
|
+
import type { Metrics } from '@libp2p/interfaces/metrics';
|
|
18
19
|
export declare class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
|
|
19
20
|
peerId: PeerId;
|
|
20
|
-
dht
|
|
21
|
-
pubsub
|
|
21
|
+
dht: DualDHT;
|
|
22
|
+
pubsub: PubSub;
|
|
22
23
|
identifyService?: IdentifyService;
|
|
23
24
|
fetchService: FetchService;
|
|
24
25
|
pingService: PingService;
|
|
@@ -28,6 +29,8 @@ export declare class Libp2pNode extends EventEmitter<Libp2pEvents> implements Li
|
|
|
28
29
|
peerRouting: PeerRouting;
|
|
29
30
|
keychain: KeyChain;
|
|
30
31
|
connectionManager: ConnectionManager;
|
|
32
|
+
registrar: Registrar;
|
|
33
|
+
metrics?: Metrics;
|
|
31
34
|
private started;
|
|
32
35
|
private readonly services;
|
|
33
36
|
private readonly initializables;
|
|
@@ -56,7 +59,7 @@ export declare class Libp2pNode extends EventEmitter<Libp2pEvents> implements Li
|
|
|
56
59
|
/**
|
|
57
60
|
* Get the public key for the given peer id
|
|
58
61
|
*/
|
|
59
|
-
getPublicKey(peer: PeerId, options?: AbortOptions): Promise<Uint8Array
|
|
62
|
+
getPublicKey(peer: PeerId, options?: AbortOptions): Promise<Uint8Array>;
|
|
60
63
|
fetch(peer: PeerId | Multiaddr | string, key: string): Promise<Uint8Array | null>;
|
|
61
64
|
ping(peer: PeerId | Multiaddr | string): Promise<number>;
|
|
62
65
|
handle(protocols: string | string[], handler: StreamHandler): Promise<void>;
|
package/dist/src/libp2p.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../src/libp2p.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAuC,MAAM,oBAAoB,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAYxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAK9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAO7C,OAAO,EAAiB,UAAU,EAAmB,MAAM,+BAA+B,CAAA;AAC1F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../src/libp2p.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAuC,MAAM,oBAAoB,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAYxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAK9C,OAA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AM,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E,QAAQ,CAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D;;;OAGG;IACH,eAAe,CAAE,GAAG,EAAE,WAAW,CAAC,QAAQ,CAAC;CAkB5C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAMnF"}
|
package/dist/src/libp2p.js
CHANGED
|
@@ -32,6 +32,8 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
|
|
|
32
32
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
33
33
|
import errCode from 'err-code';
|
|
34
34
|
import { unmarshalPublicKey } from '@libp2p/crypto/keys';
|
|
35
|
+
import { DummyDHT } from './dht/dummy-dht.js';
|
|
36
|
+
import { DummyPubSub } from './pubsub/dummy-pubsub.js';
|
|
35
37
|
const log = logger('libp2p');
|
|
36
38
|
export class Libp2pNode extends EventEmitter {
|
|
37
39
|
constructor(init) {
|
|
@@ -46,7 +48,7 @@ export class Libp2pNode extends EventEmitter {
|
|
|
46
48
|
});
|
|
47
49
|
// Create Metrics
|
|
48
50
|
if (init.metrics.enabled) {
|
|
49
|
-
this.components.setMetrics(this.configureComponent(new DefaultMetrics(init.metrics)));
|
|
51
|
+
this.metrics = this.components.setMetrics(this.configureComponent(new DefaultMetrics(init.metrics)));
|
|
50
52
|
}
|
|
51
53
|
this.components.setConnectionGater(this.configureComponent({
|
|
52
54
|
denyDialPeer: async () => await Promise.resolve(false),
|
|
@@ -77,7 +79,7 @@ export class Libp2pNode extends EventEmitter {
|
|
|
77
79
|
// Create the Connection Manager
|
|
78
80
|
this.connectionManager = this.components.setConnectionManager(this.configureComponent(new DefaultConnectionManager(this.components, init.connectionManager)));
|
|
79
81
|
// Create the Registrar
|
|
80
|
-
this.components.setRegistrar(this.configureComponent(new DefaultRegistrar(this.components)));
|
|
82
|
+
this.registrar = this.components.setRegistrar(this.configureComponent(new DefaultRegistrar(this.components)));
|
|
81
83
|
// Setup the transport manager
|
|
82
84
|
this.components.setTransportManager(this.configureComponent(new DefaultTransportManager(this.components, init.transportManager)));
|
|
83
85
|
// Addresses {listen, announce, noAnnounce}
|
|
@@ -116,23 +118,33 @@ export class Libp2pNode extends EventEmitter {
|
|
|
116
118
|
if (init.dht != null) {
|
|
117
119
|
this.dht = this.components.setDHT(this.configureComponent(init.dht));
|
|
118
120
|
}
|
|
121
|
+
else {
|
|
122
|
+
this.dht = new DummyDHT();
|
|
123
|
+
}
|
|
119
124
|
// Create pubsub if provided
|
|
120
125
|
if (init.pubsub != null) {
|
|
121
126
|
this.pubsub = this.components.setPubSub(this.configureComponent(init.pubsub));
|
|
122
127
|
}
|
|
128
|
+
else {
|
|
129
|
+
this.pubsub = new DummyPubSub();
|
|
130
|
+
}
|
|
123
131
|
// Attach remaining APIs
|
|
124
132
|
// peer and content routing will automatically get modules from _modules and _dht
|
|
125
133
|
const peerRouters = (init.peerRouters ?? []).map(component => this.configureComponent(component));
|
|
126
|
-
if (
|
|
134
|
+
if (init.dht != null) {
|
|
127
135
|
// add dht to routers
|
|
128
136
|
peerRouters.push(this.configureComponent(new DHTPeerRouting(this.dht)));
|
|
137
|
+
// use dht for peer discovery
|
|
138
|
+
this.dht.addEventListener('peer', (evt) => {
|
|
139
|
+
this.onDiscoveryPeer(evt);
|
|
140
|
+
});
|
|
129
141
|
}
|
|
130
142
|
this.peerRouting = this.components.setPeerRouting(this.configureComponent(new DefaultPeerRouting(this.components, {
|
|
131
143
|
...init.peerRouting,
|
|
132
144
|
routers: peerRouters
|
|
133
145
|
})));
|
|
134
146
|
const contentRouters = (init.contentRouters ?? []).map(component => this.configureComponent(component));
|
|
135
|
-
if (
|
|
147
|
+
if (init.dht != null) {
|
|
136
148
|
// add dht to routers
|
|
137
149
|
contentRouters.push(this.configureComponent(new DHTContentRouting(this.dht)));
|
|
138
150
|
}
|
|
@@ -295,6 +307,9 @@ export class Libp2pNode extends EventEmitter {
|
|
|
295
307
|
*/
|
|
296
308
|
async getPublicKey(peer, options = {}) {
|
|
297
309
|
log('getPublicKey %p', peer);
|
|
310
|
+
if (peer.publicKey != null) {
|
|
311
|
+
return peer.publicKey;
|
|
312
|
+
}
|
|
298
313
|
const peerInfo = await this.peerStore.get(peer);
|
|
299
314
|
if (peerInfo.pubKey != null) {
|
|
300
315
|
return peerInfo.pubKey;
|
|
@@ -311,7 +326,7 @@ export class Libp2pNode extends EventEmitter {
|
|
|
311
326
|
if (event.name === 'VALUE') {
|
|
312
327
|
const key = unmarshalPublicKey(event.value);
|
|
313
328
|
await this.peerStore.keyBook.set(peer, event.value);
|
|
314
|
-
return key;
|
|
329
|
+
return key.bytes;
|
|
315
330
|
}
|
|
316
331
|
}
|
|
317
332
|
throw errCode(new Error(`Node not responding with its public key: ${peer.toString()}`), codes.ERR_INVALID_RECORD);
|