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
|
@@ -1,369 +1,24 @@
|
|
|
1
|
-
/*eslint-disable*/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @property {string|null} [protocolVersion] Identify protocolVersion
|
|
17
|
-
* @property {string|null} [agentVersion] Identify agentVersion
|
|
18
|
-
* @property {Uint8Array|null} [publicKey] Identify publicKey
|
|
19
|
-
* @property {Array.<Uint8Array>|null} [listenAddrs] Identify listenAddrs
|
|
20
|
-
* @property {Uint8Array|null} [observedAddr] Identify observedAddr
|
|
21
|
-
* @property {Array.<string>|null} [protocols] Identify protocols
|
|
22
|
-
* @property {Uint8Array|null} [signedPeerRecord] Identify signedPeerRecord
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Constructs a new Identify.
|
|
27
|
-
* @exports Identify
|
|
28
|
-
* @classdesc Represents an Identify.
|
|
29
|
-
* @implements IIdentify
|
|
30
|
-
* @constructor
|
|
31
|
-
* @param {IIdentify=} [p] Properties to set
|
|
32
|
-
*/
|
|
33
|
-
function Identify(p) {
|
|
34
|
-
this.listenAddrs = [];
|
|
35
|
-
this.protocols = [];
|
|
36
|
-
if (p)
|
|
37
|
-
for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
|
|
38
|
-
if (p[ks[i]] != null)
|
|
39
|
-
this[ks[i]] = p[ks[i]];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Identify protocolVersion.
|
|
44
|
-
* @member {string|null|undefined} protocolVersion
|
|
45
|
-
* @memberof Identify
|
|
46
|
-
* @instance
|
|
47
|
-
*/
|
|
48
|
-
Identify.prototype.protocolVersion = null;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Identify agentVersion.
|
|
52
|
-
* @member {string|null|undefined} agentVersion
|
|
53
|
-
* @memberof Identify
|
|
54
|
-
* @instance
|
|
55
|
-
*/
|
|
56
|
-
Identify.prototype.agentVersion = null;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Identify publicKey.
|
|
60
|
-
* @member {Uint8Array|null|undefined} publicKey
|
|
61
|
-
* @memberof Identify
|
|
62
|
-
* @instance
|
|
63
|
-
*/
|
|
64
|
-
Identify.prototype.publicKey = null;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Identify listenAddrs.
|
|
68
|
-
* @member {Array.<Uint8Array>} listenAddrs
|
|
69
|
-
* @memberof Identify
|
|
70
|
-
* @instance
|
|
71
|
-
*/
|
|
72
|
-
Identify.prototype.listenAddrs = $util.emptyArray;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Identify observedAddr.
|
|
76
|
-
* @member {Uint8Array|null|undefined} observedAddr
|
|
77
|
-
* @memberof Identify
|
|
78
|
-
* @instance
|
|
79
|
-
*/
|
|
80
|
-
Identify.prototype.observedAddr = null;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Identify protocols.
|
|
84
|
-
* @member {Array.<string>} protocols
|
|
85
|
-
* @memberof Identify
|
|
86
|
-
* @instance
|
|
87
|
-
*/
|
|
88
|
-
Identify.prototype.protocols = $util.emptyArray;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Identify signedPeerRecord.
|
|
92
|
-
* @member {Uint8Array|null|undefined} signedPeerRecord
|
|
93
|
-
* @memberof Identify
|
|
94
|
-
* @instance
|
|
95
|
-
*/
|
|
96
|
-
Identify.prototype.signedPeerRecord = null;
|
|
97
|
-
|
|
98
|
-
// OneOf field names bound to virtual getters and setters
|
|
99
|
-
let $oneOfFields;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Identify _protocolVersion.
|
|
103
|
-
* @member {"protocolVersion"|undefined} _protocolVersion
|
|
104
|
-
* @memberof Identify
|
|
105
|
-
* @instance
|
|
106
|
-
*/
|
|
107
|
-
Object.defineProperty(Identify.prototype, "_protocolVersion", {
|
|
108
|
-
get: $util.oneOfGetter($oneOfFields = ["protocolVersion"]),
|
|
109
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Identify _agentVersion.
|
|
114
|
-
* @member {"agentVersion"|undefined} _agentVersion
|
|
115
|
-
* @memberof Identify
|
|
116
|
-
* @instance
|
|
117
|
-
*/
|
|
118
|
-
Object.defineProperty(Identify.prototype, "_agentVersion", {
|
|
119
|
-
get: $util.oneOfGetter($oneOfFields = ["agentVersion"]),
|
|
120
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Identify _publicKey.
|
|
125
|
-
* @member {"publicKey"|undefined} _publicKey
|
|
126
|
-
* @memberof Identify
|
|
127
|
-
* @instance
|
|
128
|
-
*/
|
|
129
|
-
Object.defineProperty(Identify.prototype, "_publicKey", {
|
|
130
|
-
get: $util.oneOfGetter($oneOfFields = ["publicKey"]),
|
|
131
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Identify _observedAddr.
|
|
136
|
-
* @member {"observedAddr"|undefined} _observedAddr
|
|
137
|
-
* @memberof Identify
|
|
138
|
-
* @instance
|
|
139
|
-
*/
|
|
140
|
-
Object.defineProperty(Identify.prototype, "_observedAddr", {
|
|
141
|
-
get: $util.oneOfGetter($oneOfFields = ["observedAddr"]),
|
|
142
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Identify _signedPeerRecord.
|
|
147
|
-
* @member {"signedPeerRecord"|undefined} _signedPeerRecord
|
|
148
|
-
* @memberof Identify
|
|
149
|
-
* @instance
|
|
150
|
-
*/
|
|
151
|
-
Object.defineProperty(Identify.prototype, "_signedPeerRecord", {
|
|
152
|
-
get: $util.oneOfGetter($oneOfFields = ["signedPeerRecord"]),
|
|
153
|
-
set: $util.oneOfSetter($oneOfFields)
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Encodes the specified Identify message. Does not implicitly {@link Identify.verify|verify} messages.
|
|
158
|
-
* @function encode
|
|
159
|
-
* @memberof Identify
|
|
160
|
-
* @static
|
|
161
|
-
* @param {IIdentify} m Identify message or plain object to encode
|
|
162
|
-
* @param {$protobuf.Writer} [w] Writer to encode to
|
|
163
|
-
* @returns {$protobuf.Writer} Writer
|
|
164
|
-
*/
|
|
165
|
-
Identify.encode = function encode(m, w) {
|
|
166
|
-
if (!w)
|
|
167
|
-
w = $Writer.create();
|
|
168
|
-
if (m.publicKey != null && Object.hasOwnProperty.call(m, "publicKey"))
|
|
169
|
-
w.uint32(10).bytes(m.publicKey);
|
|
170
|
-
if (m.listenAddrs != null && m.listenAddrs.length) {
|
|
171
|
-
for (var i = 0; i < m.listenAddrs.length; ++i)
|
|
172
|
-
w.uint32(18).bytes(m.listenAddrs[i]);
|
|
173
|
-
}
|
|
174
|
-
if (m.protocols != null && m.protocols.length) {
|
|
175
|
-
for (var i = 0; i < m.protocols.length; ++i)
|
|
176
|
-
w.uint32(26).string(m.protocols[i]);
|
|
177
|
-
}
|
|
178
|
-
if (m.observedAddr != null && Object.hasOwnProperty.call(m, "observedAddr"))
|
|
179
|
-
w.uint32(34).bytes(m.observedAddr);
|
|
180
|
-
if (m.protocolVersion != null && Object.hasOwnProperty.call(m, "protocolVersion"))
|
|
181
|
-
w.uint32(42).string(m.protocolVersion);
|
|
182
|
-
if (m.agentVersion != null && Object.hasOwnProperty.call(m, "agentVersion"))
|
|
183
|
-
w.uint32(50).string(m.agentVersion);
|
|
184
|
-
if (m.signedPeerRecord != null && Object.hasOwnProperty.call(m, "signedPeerRecord"))
|
|
185
|
-
w.uint32(66).bytes(m.signedPeerRecord);
|
|
186
|
-
return w;
|
|
1
|
+
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { encodeMessage, decodeMessage, message, string, bytes } from 'protons-runtime';
|
|
4
|
+
export var Identify;
|
|
5
|
+
(function (Identify) {
|
|
6
|
+
Identify.codec = () => {
|
|
7
|
+
return message({
|
|
8
|
+
5: { name: 'protocolVersion', codec: string, optional: true },
|
|
9
|
+
6: { name: 'agentVersion', codec: string, optional: true },
|
|
10
|
+
1: { name: 'publicKey', codec: bytes, optional: true },
|
|
11
|
+
2: { name: 'listenAddrs', codec: bytes, repeats: true },
|
|
12
|
+
4: { name: 'observedAddr', codec: bytes, optional: true },
|
|
13
|
+
3: { name: 'protocols', codec: string, repeats: true },
|
|
14
|
+
8: { name: 'signedPeerRecord', codec: bytes, optional: true }
|
|
15
|
+
});
|
|
187
16
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
* Decodes an Identify message from the specified reader or buffer.
|
|
191
|
-
* @function decode
|
|
192
|
-
* @memberof Identify
|
|
193
|
-
* @static
|
|
194
|
-
* @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
|
|
195
|
-
* @param {number} [l] Message length if known beforehand
|
|
196
|
-
* @returns {Identify} Identify
|
|
197
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
198
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
199
|
-
*/
|
|
200
|
-
Identify.decode = function decode(r, l) {
|
|
201
|
-
if (!(r instanceof $Reader))
|
|
202
|
-
r = $Reader.create(r);
|
|
203
|
-
var c = l === undefined ? r.len : r.pos + l, m = new $root.Identify();
|
|
204
|
-
while (r.pos < c) {
|
|
205
|
-
var t = r.uint32();
|
|
206
|
-
switch (t >>> 3) {
|
|
207
|
-
case 5:
|
|
208
|
-
m.protocolVersion = r.string();
|
|
209
|
-
break;
|
|
210
|
-
case 6:
|
|
211
|
-
m.agentVersion = r.string();
|
|
212
|
-
break;
|
|
213
|
-
case 1:
|
|
214
|
-
m.publicKey = r.bytes();
|
|
215
|
-
break;
|
|
216
|
-
case 2:
|
|
217
|
-
if (!(m.listenAddrs && m.listenAddrs.length))
|
|
218
|
-
m.listenAddrs = [];
|
|
219
|
-
m.listenAddrs.push(r.bytes());
|
|
220
|
-
break;
|
|
221
|
-
case 4:
|
|
222
|
-
m.observedAddr = r.bytes();
|
|
223
|
-
break;
|
|
224
|
-
case 3:
|
|
225
|
-
if (!(m.protocols && m.protocols.length))
|
|
226
|
-
m.protocols = [];
|
|
227
|
-
m.protocols.push(r.string());
|
|
228
|
-
break;
|
|
229
|
-
case 8:
|
|
230
|
-
m.signedPeerRecord = r.bytes();
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
r.skipType(t & 7);
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return m;
|
|
17
|
+
Identify.encode = (obj) => {
|
|
18
|
+
return encodeMessage(obj, Identify.codec());
|
|
238
19
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
* Creates an Identify message from a plain object. Also converts values to their respective internal types.
|
|
242
|
-
* @function fromObject
|
|
243
|
-
* @memberof Identify
|
|
244
|
-
* @static
|
|
245
|
-
* @param {Object.<string,*>} d Plain object
|
|
246
|
-
* @returns {Identify} Identify
|
|
247
|
-
*/
|
|
248
|
-
Identify.fromObject = function fromObject(d) {
|
|
249
|
-
if (d instanceof $root.Identify)
|
|
250
|
-
return d;
|
|
251
|
-
var m = new $root.Identify();
|
|
252
|
-
if (d.protocolVersion != null) {
|
|
253
|
-
m.protocolVersion = String(d.protocolVersion);
|
|
254
|
-
}
|
|
255
|
-
if (d.agentVersion != null) {
|
|
256
|
-
m.agentVersion = String(d.agentVersion);
|
|
257
|
-
}
|
|
258
|
-
if (d.publicKey != null) {
|
|
259
|
-
if (typeof d.publicKey === "string")
|
|
260
|
-
$util.base64.decode(d.publicKey, m.publicKey = $util.newBuffer($util.base64.length(d.publicKey)), 0);
|
|
261
|
-
else if (d.publicKey.length)
|
|
262
|
-
m.publicKey = d.publicKey;
|
|
263
|
-
}
|
|
264
|
-
if (d.listenAddrs) {
|
|
265
|
-
if (!Array.isArray(d.listenAddrs))
|
|
266
|
-
throw TypeError(".Identify.listenAddrs: array expected");
|
|
267
|
-
m.listenAddrs = [];
|
|
268
|
-
for (var i = 0; i < d.listenAddrs.length; ++i) {
|
|
269
|
-
if (typeof d.listenAddrs[i] === "string")
|
|
270
|
-
$util.base64.decode(d.listenAddrs[i], m.listenAddrs[i] = $util.newBuffer($util.base64.length(d.listenAddrs[i])), 0);
|
|
271
|
-
else if (d.listenAddrs[i].length)
|
|
272
|
-
m.listenAddrs[i] = d.listenAddrs[i];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (d.observedAddr != null) {
|
|
276
|
-
if (typeof d.observedAddr === "string")
|
|
277
|
-
$util.base64.decode(d.observedAddr, m.observedAddr = $util.newBuffer($util.base64.length(d.observedAddr)), 0);
|
|
278
|
-
else if (d.observedAddr.length)
|
|
279
|
-
m.observedAddr = d.observedAddr;
|
|
280
|
-
}
|
|
281
|
-
if (d.protocols) {
|
|
282
|
-
if (!Array.isArray(d.protocols))
|
|
283
|
-
throw TypeError(".Identify.protocols: array expected");
|
|
284
|
-
m.protocols = [];
|
|
285
|
-
for (var i = 0; i < d.protocols.length; ++i) {
|
|
286
|
-
m.protocols[i] = String(d.protocols[i]);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (d.signedPeerRecord != null) {
|
|
290
|
-
if (typeof d.signedPeerRecord === "string")
|
|
291
|
-
$util.base64.decode(d.signedPeerRecord, m.signedPeerRecord = $util.newBuffer($util.base64.length(d.signedPeerRecord)), 0);
|
|
292
|
-
else if (d.signedPeerRecord.length)
|
|
293
|
-
m.signedPeerRecord = d.signedPeerRecord;
|
|
294
|
-
}
|
|
295
|
-
return m;
|
|
20
|
+
Identify.decode = (buf) => {
|
|
21
|
+
return decodeMessage(buf, Identify.codec());
|
|
296
22
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
* Creates a plain object from an Identify message. Also converts values to other types if specified.
|
|
300
|
-
* @function toObject
|
|
301
|
-
* @memberof Identify
|
|
302
|
-
* @static
|
|
303
|
-
* @param {Identify} m Identify
|
|
304
|
-
* @param {$protobuf.IConversionOptions} [o] Conversion options
|
|
305
|
-
* @returns {Object.<string,*>} Plain object
|
|
306
|
-
*/
|
|
307
|
-
Identify.toObject = function toObject(m, o) {
|
|
308
|
-
if (!o)
|
|
309
|
-
o = {};
|
|
310
|
-
var d = {};
|
|
311
|
-
if (o.arrays || o.defaults) {
|
|
312
|
-
d.listenAddrs = [];
|
|
313
|
-
d.protocols = [];
|
|
314
|
-
}
|
|
315
|
-
if (m.publicKey != null && m.hasOwnProperty("publicKey")) {
|
|
316
|
-
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;
|
|
317
|
-
if (o.oneofs)
|
|
318
|
-
d._publicKey = "publicKey";
|
|
319
|
-
}
|
|
320
|
-
if (m.listenAddrs && m.listenAddrs.length) {
|
|
321
|
-
d.listenAddrs = [];
|
|
322
|
-
for (var j = 0; j < m.listenAddrs.length; ++j) {
|
|
323
|
-
d.listenAddrs[j] = o.bytes === String ? $util.base64.encode(m.listenAddrs[j], 0, m.listenAddrs[j].length) : o.bytes === Array ? Array.prototype.slice.call(m.listenAddrs[j]) : m.listenAddrs[j];
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (m.protocols && m.protocols.length) {
|
|
327
|
-
d.protocols = [];
|
|
328
|
-
for (var j = 0; j < m.protocols.length; ++j) {
|
|
329
|
-
d.protocols[j] = m.protocols[j];
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if (m.observedAddr != null && m.hasOwnProperty("observedAddr")) {
|
|
333
|
-
d.observedAddr = o.bytes === String ? $util.base64.encode(m.observedAddr, 0, m.observedAddr.length) : o.bytes === Array ? Array.prototype.slice.call(m.observedAddr) : m.observedAddr;
|
|
334
|
-
if (o.oneofs)
|
|
335
|
-
d._observedAddr = "observedAddr";
|
|
336
|
-
}
|
|
337
|
-
if (m.protocolVersion != null && m.hasOwnProperty("protocolVersion")) {
|
|
338
|
-
d.protocolVersion = m.protocolVersion;
|
|
339
|
-
if (o.oneofs)
|
|
340
|
-
d._protocolVersion = "protocolVersion";
|
|
341
|
-
}
|
|
342
|
-
if (m.agentVersion != null && m.hasOwnProperty("agentVersion")) {
|
|
343
|
-
d.agentVersion = m.agentVersion;
|
|
344
|
-
if (o.oneofs)
|
|
345
|
-
d._agentVersion = "agentVersion";
|
|
346
|
-
}
|
|
347
|
-
if (m.signedPeerRecord != null && m.hasOwnProperty("signedPeerRecord")) {
|
|
348
|
-
d.signedPeerRecord = o.bytes === String ? $util.base64.encode(m.signedPeerRecord, 0, m.signedPeerRecord.length) : o.bytes === Array ? Array.prototype.slice.call(m.signedPeerRecord) : m.signedPeerRecord;
|
|
349
|
-
if (o.oneofs)
|
|
350
|
-
d._signedPeerRecord = "signedPeerRecord";
|
|
351
|
-
}
|
|
352
|
-
return d;
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Converts this Identify to JSON.
|
|
357
|
-
* @function toJSON
|
|
358
|
-
* @memberof Identify
|
|
359
|
-
* @instance
|
|
360
|
-
* @returns {Object.<string,*>} JSON object
|
|
361
|
-
*/
|
|
362
|
-
Identify.prototype.toJSON = function toJSON() {
|
|
363
|
-
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
return Identify;
|
|
367
|
-
})();
|
|
368
|
-
|
|
369
|
-
export { $root as default };
|
|
23
|
+
})(Identify || (Identify = {}));
|
|
24
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/identify/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oDAAoD;AAEpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAYtF,MAAM,KAAW,QAAQ,CAoBxB;AApBD,WAAiB,QAAQ;IACV,cAAK,GAAG,GAAG,EAAE;QACxB,OAAO,OAAO,CAAW;YACvB,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC7D,CAAC,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1D,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;YACtD,CAAC,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE;YACvD,CAAC,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;YACzD,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;YACtD,CAAC,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC9D,CAAC,CAAA;IACJ,CAAC,CAAA;IAEY,eAAM,GAAG,CAAC,GAAa,EAAc,EAAE;QAClD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;IAEY,eAAM,GAAG,CAAC,GAAe,EAAY,EAAE;QAClD,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC,CAAA;AACH,CAAC,EApBgB,QAAQ,KAAR,QAAQ,QAoBxB"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ import type { ConnectionEncrypter } from '@libp2p/interfaces/connection-encrypte
|
|
|
15
15
|
import type { PeerRouting } from '@libp2p/interfaces/peer-routing';
|
|
16
16
|
import type { ContentRouting } from '@libp2p/interfaces/content-routing';
|
|
17
17
|
import type { PubSub } from '@libp2p/interfaces/pubsub';
|
|
18
|
-
import type { ConnectionManager, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
19
|
-
import type { MetricsInit } from '@libp2p/interfaces/metrics';
|
|
18
|
+
import type { ConnectionManager, Registrar, StreamHandler } from '@libp2p/interfaces/registrar';
|
|
19
|
+
import type { Metrics, MetricsInit } from '@libp2p/interfaces/metrics';
|
|
20
20
|
import type { PeerInfo } from '@libp2p/interfaces/peer-info';
|
|
21
21
|
import type { DialerInit } from '@libp2p/interfaces/dialer';
|
|
22
22
|
import type { KeyChain } from './keychain/index.js';
|
|
@@ -131,8 +131,10 @@ export interface Libp2p extends Startable, EventEmitter<Libp2pEvents> {
|
|
|
131
131
|
contentRouting: ContentRouting;
|
|
132
132
|
keychain: KeyChain;
|
|
133
133
|
connectionManager: ConnectionManager;
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
registrar: Registrar;
|
|
135
|
+
metrics?: Metrics;
|
|
136
|
+
pubsub: PubSub;
|
|
137
|
+
dht: DualDHT;
|
|
136
138
|
/**
|
|
137
139
|
* Load keychain keys from the datastore.
|
|
138
140
|
* Imports the private key as 'self', if needed.
|
|
@@ -188,6 +190,11 @@ export interface Libp2p extends Startable, EventEmitter<Libp2pEvents> {
|
|
|
188
190
|
* Sends a request to fetch the value associated with the given key from the given peer.
|
|
189
191
|
*/
|
|
190
192
|
fetch: (peer: PeerId | Multiaddr | string, key: string) => Promise<Uint8Array | null>;
|
|
193
|
+
/**
|
|
194
|
+
* Returns the public key for the passed PeerId. If the PeerId is of the 'RSA' type
|
|
195
|
+
* this may mean searching the DHT if the key is not present in the KeyStore.
|
|
196
|
+
*/
|
|
197
|
+
getPublicKey: (peer: PeerId, options?: AbortOptions) => Promise<Uint8Array>;
|
|
191
198
|
}
|
|
192
199
|
export declare type Libp2pOptions = RecursivePartial<Libp2pInit>;
|
|
193
200
|
/**
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EA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AE9E;;;OAGG;IACH,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzD;;OAEG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,GAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAElD;;OAEG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAA;IAErF;;;OAGG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CAC5E;AAED,oBAAY,aAAa,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAA;AAExD;;;GAGG;AACH,wBAAsB,YAAY,CAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3E"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AA0O9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,OAAsB;IACxD,OAAO,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/insecure/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AACrG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/insecure/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AACrG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAkF7C,qBAAa,SAAU,YAAW,mBAAmB;IAC5C,QAAQ,EAAE,MAAM,CAAW;IAE5B,aAAa,CAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxG,cAAc,CAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG/G"}
|
|
@@ -7,7 +7,7 @@ import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id';
|
|
|
7
7
|
const log = logger('libp2p:plaintext');
|
|
8
8
|
const PROTOCOL = '/plaintext/2.0.0';
|
|
9
9
|
function lpEncodeExchange(exchange) {
|
|
10
|
-
const pb = Exchange.encode(exchange)
|
|
10
|
+
const pb = Exchange.encode(exchange);
|
|
11
11
|
return lp.encode.single(pb);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -27,7 +27,7 @@ async function encrypt(localId, conn, remoteId) {
|
|
|
27
27
|
id: localId.toBytes(),
|
|
28
28
|
pubkey: {
|
|
29
29
|
Type: type,
|
|
30
|
-
Data: localId.publicKey
|
|
30
|
+
Data: localId.publicKey ?? new Uint8Array(0)
|
|
31
31
|
}
|
|
32
32
|
}).slice());
|
|
33
33
|
log('write pubkey exchange to peer %p', remoteId);
|
|
@@ -38,6 +38,9 @@ async function encrypt(localId, conn, remoteId) {
|
|
|
38
38
|
log('read pubkey exchange from peer %p', remoteId);
|
|
39
39
|
let peerId;
|
|
40
40
|
try {
|
|
41
|
+
if (id.pubkey == null) {
|
|
42
|
+
throw new Error('Public key missing');
|
|
43
|
+
}
|
|
41
44
|
if (id.pubkey.Data.length === 0) {
|
|
42
45
|
throw new Error('Public key data too short');
|
|
43
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/insecure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAChH,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/insecure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAChH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAIjE,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AACtC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAEnC,SAAS,gBAAgB,CAAE,QAAkB;IAC3C,MAAM,EAA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EAAE,IAAwB,EAAE,QAAgB;QAC/E,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;CACF"}
|
|
@@ -1,134 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Exchange id */
|
|
6
|
-
id?: (Uint8Array|null);
|
|
7
|
-
|
|
8
|
-
/** Exchange pubkey */
|
|
9
|
-
pubkey?: (IPublicKey|null);
|
|
1
|
+
export interface Exchange {
|
|
2
|
+
id?: Uint8Array;
|
|
3
|
+
pubkey?: PublicKey;
|
|
10
4
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Constructs a new Exchange.
|
|
17
|
-
* @param [p] Properties to set
|
|
18
|
-
*/
|
|
19
|
-
constructor(p?: IExchange);
|
|
20
|
-
|
|
21
|
-
/** Exchange id. */
|
|
22
|
-
public id?: (Uint8Array|null);
|
|
23
|
-
|
|
24
|
-
/** Exchange pubkey. */
|
|
25
|
-
public pubkey?: (IPublicKey|null);
|
|
26
|
-
|
|
27
|
-
/** Exchange _id. */
|
|
28
|
-
public _id?: "id";
|
|
29
|
-
|
|
30
|
-
/** Exchange _pubkey. */
|
|
31
|
-
public _pubkey?: "pubkey";
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Encodes the specified Exchange message. Does not implicitly {@link Exchange.verify|verify} messages.
|
|
35
|
-
* @param m Exchange message or plain object to encode
|
|
36
|
-
* @param [w] Writer to encode to
|
|
37
|
-
* @returns Writer
|
|
38
|
-
*/
|
|
39
|
-
public static encode(m: IExchange, w?: $protobuf.Writer): $protobuf.Writer;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Decodes an Exchange 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 Exchange
|
|
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): Exchange;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates an Exchange message from a plain object. Also converts values to their respective internal types.
|
|
53
|
-
* @param d Plain object
|
|
54
|
-
* @returns Exchange
|
|
55
|
-
*/
|
|
56
|
-
public static fromObject(d: { [k: string]: any }): Exchange;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Creates a plain object from an Exchange message. Also converts values to other types if specified.
|
|
60
|
-
* @param m Exchange
|
|
61
|
-
* @param [o] Conversion options
|
|
62
|
-
* @returns Plain object
|
|
63
|
-
*/
|
|
64
|
-
public static toObject(m: Exchange, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Converts this Exchange to JSON.
|
|
68
|
-
* @returns JSON object
|
|
69
|
-
*/
|
|
70
|
-
public toJSON(): { [k: string]: any };
|
|
5
|
+
export declare namespace Exchange {
|
|
6
|
+
const codec: () => import("protons-runtime").Codec<Exchange>;
|
|
7
|
+
const encode: (obj: Exchange) => Uint8Array;
|
|
8
|
+
const decode: (buf: Uint8Array) => Exchange;
|
|
71
9
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Secp256k1 = 2,
|
|
78
|
-
ECDSA = 3
|
|
10
|
+
export declare enum KeyType {
|
|
11
|
+
RSA = "RSA",
|
|
12
|
+
Ed25519 = "Ed25519",
|
|
13
|
+
Secp256k1 = "Secp256k1",
|
|
14
|
+
ECDSA = "ECDSA"
|
|
79
15
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export class PublicKey implements IPublicKey {
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Constructs a new PublicKey.
|
|
86
|
-
* @param [p] Properties to set
|
|
87
|
-
*/
|
|
88
|
-
constructor(p?: IPublicKey);
|
|
89
|
-
|
|
90
|
-
/** PublicKey Type. */
|
|
91
|
-
public Type: KeyType;
|
|
92
|
-
|
|
93
|
-
/** PublicKey Data. */
|
|
94
|
-
public Data: Uint8Array;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Encodes the specified PublicKey message. Does not implicitly {@link PublicKey.verify|verify} messages.
|
|
98
|
-
* @param m PublicKey message or plain object to encode
|
|
99
|
-
* @param [w] Writer to encode to
|
|
100
|
-
* @returns Writer
|
|
101
|
-
*/
|
|
102
|
-
public static encode(m: IPublicKey, w?: $protobuf.Writer): $protobuf.Writer;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Decodes a PublicKey message from the specified reader or buffer.
|
|
106
|
-
* @param r Reader or buffer to decode from
|
|
107
|
-
* @param [l] Message length if known beforehand
|
|
108
|
-
* @returns PublicKey
|
|
109
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
110
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
111
|
-
*/
|
|
112
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): PublicKey;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Creates a PublicKey message from a plain object. Also converts values to their respective internal types.
|
|
116
|
-
* @param d Plain object
|
|
117
|
-
* @returns PublicKey
|
|
118
|
-
*/
|
|
119
|
-
public static fromObject(d: { [k: string]: any }): PublicKey;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Creates a plain object from a PublicKey message. Also converts values to other types if specified.
|
|
123
|
-
* @param m PublicKey
|
|
124
|
-
* @param [o] Conversion options
|
|
125
|
-
* @returns Plain object
|
|
126
|
-
*/
|
|
127
|
-
public static toObject(m: PublicKey, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Converts this PublicKey to JSON.
|
|
131
|
-
* @returns JSON object
|
|
132
|
-
*/
|
|
133
|
-
public toJSON(): { [k: string]: any };
|
|
16
|
+
export declare namespace KeyType {
|
|
17
|
+
const codec: () => import("protons-runtime").Codec<typeof KeyType>;
|
|
134
18
|
}
|
|
19
|
+
export interface PublicKey {
|
|
20
|
+
Type: KeyType;
|
|
21
|
+
Data: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace PublicKey {
|
|
24
|
+
const codec: () => import("protons-runtime").Codec<PublicKey>;
|
|
25
|
+
const encode: (obj: PublicKey) => Uint8Array;
|
|
26
|
+
const decode: (buf: Uint8Array) => PublicKey;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=proto.d.ts.map
|