@libp2p/peer-record 9.0.5 → 9.0.6
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/README.md +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/envelope/envelope.d.ts +19 -2
- package/dist/src/envelope/envelope.d.ts.map +1 -1
- package/dist/src/envelope/envelope.js +50 -5
- package/dist/src/envelope/envelope.js.map +1 -1
- package/dist/src/peer-record/peer-record.d.ts +23 -4
- package/dist/src/peer-record/peer-record.d.ts.map +1 -1
- package/dist/src/peer-record/peer-record.js +84 -11
- package/dist/src/peer-record/peer-record.js.map +1 -1
- package/package.json +6 -6
- package/src/envelope/envelope.ts +68 -3
- package/src/peer-record/peer-record.ts +105 -7
|
@@ -8,7 +8,24 @@ export interface Envelope {
|
|
|
8
8
|
}
|
|
9
9
|
export declare namespace Envelope {
|
|
10
10
|
const codec: () => Codec<Envelope>;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
interface EnvelopePublicKeyFieldEvent {
|
|
12
|
+
field: '$.publicKey';
|
|
13
|
+
value: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
interface EnvelopePayloadTypeFieldEvent {
|
|
16
|
+
field: '$.payloadType';
|
|
17
|
+
value: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
interface EnvelopePayloadFieldEvent {
|
|
20
|
+
field: '$.payload';
|
|
21
|
+
value: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
interface EnvelopeSignatureFieldEvent {
|
|
24
|
+
field: '$.signature';
|
|
25
|
+
value: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
function encode(obj: Partial<Envelope>): Uint8Array;
|
|
28
|
+
function decode(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Envelope;
|
|
29
|
+
function stream(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Generator<EnvelopePublicKeyFieldEvent | EnvelopePayloadTypeFieldEvent | EnvelopePayloadFieldEvent | EnvelopeSignatureFieldEvent>;
|
|
13
30
|
}
|
|
14
31
|
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/envelope/envelope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,UAAU,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;CACtB;AAED,yBAAiB,QAAQ,CAAC;IAGjB,MAAM,KAAK,QAAO,KAAK,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/envelope/envelope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,UAAU,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;CACtB;AAED,yBAAiB,QAAQ,CAAC;IAGjB,MAAM,KAAK,QAAO,KAAK,CAAC,QAAQ,CAiHtC,CAAA;IAED,UAAiB,2BAA2B;QAC1C,KAAK,EAAE,aAAa,CAAA;QACpB,KAAK,EAAE,UAAU,CAAA;KAClB;IAED,UAAiB,6BAA6B;QAC5C,KAAK,EAAE,eAAe,CAAA;QACtB,KAAK,EAAE,UAAU,CAAA;KAClB;IAED,UAAiB,yBAAyB;QACxC,KAAK,EAAE,WAAW,CAAA;QAClB,KAAK,EAAE,UAAU,CAAA;KAClB;IAED,UAAiB,2BAA2B;QAC1C,KAAK,EAAE,aAAa,CAAA;QACpB,KAAK,EAAE,UAAU,CAAA;KAClB;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU,CAE1D;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAElG;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,2BAA2B,GAAG,6BAA6B,GAAG,yBAAyB,GAAG,2BAA2B,CAAC,CAE1N;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeMessage, encodeMessage, message } from 'protons-runtime';
|
|
1
|
+
import { decodeMessage, encodeMessage, message, streamMessage } from 'protons-runtime';
|
|
2
2
|
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc';
|
|
3
3
|
export var Envelope;
|
|
4
4
|
(function (Envelope) {
|
|
@@ -62,15 +62,60 @@ export var Envelope;
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
return obj;
|
|
65
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
66
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
67
|
+
while (reader.pos < end) {
|
|
68
|
+
const tag = reader.uint32();
|
|
69
|
+
switch (tag >>> 3) {
|
|
70
|
+
case 1: {
|
|
71
|
+
yield {
|
|
72
|
+
field: `${prefix}.publicKey`,
|
|
73
|
+
value: reader.bytes()
|
|
74
|
+
};
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 2: {
|
|
78
|
+
yield {
|
|
79
|
+
field: `${prefix}.payloadType`,
|
|
80
|
+
value: reader.bytes()
|
|
81
|
+
};
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case 3: {
|
|
85
|
+
yield {
|
|
86
|
+
field: `${prefix}.payload`,
|
|
87
|
+
value: reader.bytes()
|
|
88
|
+
};
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 5: {
|
|
92
|
+
yield {
|
|
93
|
+
field: `${prefix}.signature`,
|
|
94
|
+
value: reader.bytes()
|
|
95
|
+
};
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
default: {
|
|
99
|
+
reader.skipType(tag & 7);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
65
104
|
});
|
|
66
105
|
}
|
|
67
106
|
return _codec;
|
|
68
107
|
};
|
|
69
|
-
|
|
108
|
+
function encode(obj) {
|
|
70
109
|
return encodeMessage(obj, Envelope.codec());
|
|
71
|
-
}
|
|
72
|
-
Envelope.
|
|
110
|
+
}
|
|
111
|
+
Envelope.encode = encode;
|
|
112
|
+
function decode(buf, opts) {
|
|
73
113
|
return decodeMessage(buf, Envelope.codec(), opts);
|
|
74
|
-
}
|
|
114
|
+
}
|
|
115
|
+
Envelope.decode = decode;
|
|
116
|
+
function stream(buf, opts) {
|
|
117
|
+
return streamMessage(buf, Envelope.codec(), opts);
|
|
118
|
+
}
|
|
119
|
+
Envelope.stream = stream;
|
|
75
120
|
})(Envelope || (Envelope = {}));
|
|
76
121
|
//# sourceMappingURL=envelope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/envelope/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/envelope/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,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AG,MAAM,YAAY;gCAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;6BACtB,CAAA;4BACD,MAAK;wBACP,CAAC;wBACD,OAAO,CAAC,CAAC,CAAC;4BACR,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;4BACxB,MAAK;wBACP,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAsBD,SAAgB,MAAM,CAAE,GAAsB;QAC5C,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IAC7C,CAAC;IAFe,eAAM,SAErB,CAAA;IAED,SAAgB,MAAM,CAAE,GAAgC,EAAE,IAA8B;QACtF,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAFe,eAAM,SAErB,CAAA;IAED,SAAgB,MAAM,CAAE,GAAgC,EAAE,IAA8B;QACtF,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAFe,eAAM,SAErB,CAAA;AACH,CAAC,EArJgB,QAAQ,KAAR,QAAQ,QAqJxB"}
|
|
@@ -11,11 +11,30 @@ export declare namespace PeerRecord {
|
|
|
11
11
|
}
|
|
12
12
|
namespace AddressInfo {
|
|
13
13
|
const codec: () => Codec<AddressInfo>;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
interface AddressInfoMultiaddrFieldEvent {
|
|
15
|
+
field: '$.multiaddr';
|
|
16
|
+
value: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
function encode(obj: Partial<AddressInfo>): Uint8Array;
|
|
19
|
+
function decode(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<AddressInfo>): AddressInfo;
|
|
20
|
+
function stream(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<AddressInfo>): Generator<AddressInfoMultiaddrFieldEvent>;
|
|
16
21
|
}
|
|
17
22
|
const codec: () => Codec<PeerRecord>;
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
interface PeerRecordPeerIdFieldEvent {
|
|
24
|
+
field: '$.peerId';
|
|
25
|
+
value: Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
interface PeerRecordSeqFieldEvent {
|
|
28
|
+
field: '$.seq';
|
|
29
|
+
value: bigint;
|
|
30
|
+
}
|
|
31
|
+
interface PeerRecordAddressesMultiaddrFieldEvent {
|
|
32
|
+
field: '$.addresses[].multiaddr';
|
|
33
|
+
value: Uint8Array;
|
|
34
|
+
index: number;
|
|
35
|
+
}
|
|
36
|
+
function encode(obj: Partial<PeerRecord>): Uint8Array;
|
|
37
|
+
function decode(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerRecord>): PeerRecord;
|
|
38
|
+
function stream(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerRecord>): Generator<PeerRecordPeerIdFieldEvent | PeerRecordSeqFieldEvent | PeerRecordAddressesMultiaddrFieldEvent>;
|
|
20
39
|
}
|
|
21
40
|
//# sourceMappingURL=peer-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-record.d.ts","sourceRoot":"","sources":["../../../src/peer-record/peer-record.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,UAAU,CAAC,WAAW,EAAE,CAAA;CACpC;AAED,yBAAiB,UAAU,CAAC;IAC1B,UAAiB,WAAW;QAC1B,SAAS,EAAE,UAAU,CAAA;K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AE,MAAM,CAAA;KACd;IAED,UAAiB,sCAAsC;QACrD,KAAK,EAAE,yBAAyB,CAAA;QAChC,KAAK,EAAE,UAAU,CAAA;QACjB,KAAK,EAAE,MAAM,CAAA;KACd;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAE5D;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,UAAU,CAEtG;IAED,SAAgB,MAAM,CAAE,GAAG,EAAE,UAAU,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,0BAA0B,GAAG,uBAAuB,GAAG,sCAAsC,CAAC,CAEpM;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeMessage, encodeMessage, MaxLengthError, message } from 'protons-runtime';
|
|
1
|
+
import { decodeMessage, encodeMessage, MaxLengthError, message, streamMessage } from 'protons-runtime';
|
|
2
2
|
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc';
|
|
3
3
|
export var PeerRecord;
|
|
4
4
|
(function (PeerRecord) {
|
|
@@ -37,16 +37,40 @@ export var PeerRecord;
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
return obj;
|
|
40
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
41
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
42
|
+
while (reader.pos < end) {
|
|
43
|
+
const tag = reader.uint32();
|
|
44
|
+
switch (tag >>> 3) {
|
|
45
|
+
case 1: {
|
|
46
|
+
yield {
|
|
47
|
+
field: `${prefix}.multiaddr`,
|
|
48
|
+
value: reader.bytes()
|
|
49
|
+
};
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
default: {
|
|
53
|
+
reader.skipType(tag & 7);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
40
58
|
});
|
|
41
59
|
}
|
|
42
60
|
return _codec;
|
|
43
61
|
};
|
|
44
|
-
|
|
62
|
+
function encode(obj) {
|
|
45
63
|
return encodeMessage(obj, AddressInfo.codec());
|
|
46
|
-
}
|
|
47
|
-
AddressInfo.
|
|
64
|
+
}
|
|
65
|
+
AddressInfo.encode = encode;
|
|
66
|
+
function decode(buf, opts) {
|
|
48
67
|
return decodeMessage(buf, AddressInfo.codec(), opts);
|
|
49
|
-
}
|
|
68
|
+
}
|
|
69
|
+
AddressInfo.decode = decode;
|
|
70
|
+
function stream(buf, opts) {
|
|
71
|
+
return streamMessage(buf, AddressInfo.codec(), opts);
|
|
72
|
+
}
|
|
73
|
+
AddressInfo.stream = stream;
|
|
50
74
|
})(AddressInfo = PeerRecord.AddressInfo || (PeerRecord.AddressInfo = {}));
|
|
51
75
|
let _codec;
|
|
52
76
|
PeerRecord.codec = () => {
|
|
@@ -63,7 +87,7 @@ export var PeerRecord;
|
|
|
63
87
|
w.uint32(16);
|
|
64
88
|
w.uint64(obj.seq);
|
|
65
89
|
}
|
|
66
|
-
if (obj.addresses != null) {
|
|
90
|
+
if (obj.addresses != null && obj.addresses.length > 0) {
|
|
67
91
|
for (const value of obj.addresses) {
|
|
68
92
|
w.uint32(26);
|
|
69
93
|
PeerRecord.AddressInfo.codec().encode(value, w);
|
|
@@ -92,7 +116,7 @@ export var PeerRecord;
|
|
|
92
116
|
}
|
|
93
117
|
case 3: {
|
|
94
118
|
if (opts.limits?.addresses != null && obj.addresses.length === opts.limits.addresses) {
|
|
95
|
-
throw new MaxLengthError('Decode error -
|
|
119
|
+
throw new MaxLengthError('Decode error - repeated field "addresses" had too many elements');
|
|
96
120
|
}
|
|
97
121
|
obj.addresses.push(PeerRecord.AddressInfo.codec().decode(reader, reader.uint32(), {
|
|
98
122
|
limits: opts.limits?.addresses$
|
|
@@ -106,15 +130,64 @@ export var PeerRecord;
|
|
|
106
130
|
}
|
|
107
131
|
}
|
|
108
132
|
return obj;
|
|
133
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
134
|
+
const obj = {
|
|
135
|
+
addresses: 0
|
|
136
|
+
};
|
|
137
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
138
|
+
while (reader.pos < end) {
|
|
139
|
+
const tag = reader.uint32();
|
|
140
|
+
switch (tag >>> 3) {
|
|
141
|
+
case 1: {
|
|
142
|
+
yield {
|
|
143
|
+
field: `${prefix}.peerId`,
|
|
144
|
+
value: reader.bytes()
|
|
145
|
+
};
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 2: {
|
|
149
|
+
yield {
|
|
150
|
+
field: `${prefix}.seq`,
|
|
151
|
+
value: reader.uint64()
|
|
152
|
+
};
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 3: {
|
|
156
|
+
if (opts.limits?.addresses != null && obj.addresses === opts.limits.addresses) {
|
|
157
|
+
throw new MaxLengthError('Streaming decode error - repeated field "addresses" had too many elements');
|
|
158
|
+
}
|
|
159
|
+
for (const evt of PeerRecord.AddressInfo.codec().stream(reader, reader.uint32(), `${prefix}.addresses[]`, {
|
|
160
|
+
limits: opts.limits?.addresses$
|
|
161
|
+
})) {
|
|
162
|
+
yield {
|
|
163
|
+
...evt,
|
|
164
|
+
index: obj.addresses
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
obj.addresses++;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
default: {
|
|
171
|
+
reader.skipType(tag & 7);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
109
176
|
});
|
|
110
177
|
}
|
|
111
178
|
return _codec;
|
|
112
179
|
};
|
|
113
|
-
|
|
180
|
+
function encode(obj) {
|
|
114
181
|
return encodeMessage(obj, PeerRecord.codec());
|
|
115
|
-
}
|
|
116
|
-
PeerRecord.
|
|
182
|
+
}
|
|
183
|
+
PeerRecord.encode = encode;
|
|
184
|
+
function decode(buf, opts) {
|
|
117
185
|
return decodeMessage(buf, PeerRecord.codec(), opts);
|
|
118
|
-
}
|
|
186
|
+
}
|
|
187
|
+
PeerRecord.decode = decode;
|
|
188
|
+
function stream(buf, opts) {
|
|
189
|
+
return streamMessage(buf, PeerRecord.codec(), opts);
|
|
190
|
+
}
|
|
191
|
+
PeerRecord.stream = stream;
|
|
119
192
|
})(PeerRecord || (PeerRecord = {}));
|
|
120
193
|
//# sourceMappingURL=peer-record.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-record.js","sourceRoot":"","sources":["../../../src/peer-record/peer-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"peer-record.js","sourceRoot":"","sources":["../../../src/peer-record/peer-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACtG,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAU5D,MAAM,KAAW,UAAU,CAgP1B;AAhPD,WAAiB,UAAU;IAKzB,IAAiB,WAAW,CAmF3B;IAnFD,WAAiB,WAAW;QAC1B,IAAI,MAA0B,CAAA;QAEjB,iBAAK,GAAG,GAAuB,EAAE;YAC5C,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,MAAM,GAAG,OAAO,CAAc,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;oBAClD,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;wBACnC,CAAC,CAAC,IAAI,EAAE,CAAA;oBACV,CAAC;oBAED,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC,UAAU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,EAAE,GAAG,CAAC,SAAS;iCACrB,CAAA;4BACH,CAAC;4BAED,GAAG,CAAC,SAAS,EAAE,CAAA;4BAEf,MAAK;wBACP,CAAC;wBACD,OAAO,CAAC,CAAC,CAAC;4BACR,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;4BACxB,MAAK;wBACP,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAkBD,SAAgB,MAAM,CAAE,GAAwB;QAC9C,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAA;IAC/C,CAAC;IAFe,iBAAM,SAErB,CAAA;IAED,SAAgB,MAAM,CAAE,GAAgC,EAAE,IAAgC;QACxF,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;IAFe,iBAAM,SAErB,CAAA;IAED,SAAgB,MAAM,CAAE,GAAgC,EAAE,IAAgC;QACxF,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;IAFe,iBAAM,SAErB,CAAA;AACH,CAAC,EAhPgB,UAAU,KAAV,UAAU,QAgP1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/peer-record",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"description": "Used to transfer signed peer data across the network",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-record#readme",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"test:electron-main": "aegir test -t electron-main"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@libp2p/crypto": "^5.1.
|
|
52
|
-
"@libp2p/interface": "^3.1.
|
|
53
|
-
"@libp2p/peer-id": "^6.0.
|
|
51
|
+
"@libp2p/crypto": "^5.1.14",
|
|
52
|
+
"@libp2p/interface": "^3.1.1",
|
|
53
|
+
"@libp2p/peer-id": "^6.0.5",
|
|
54
54
|
"@multiformats/multiaddr": "^13.0.1",
|
|
55
55
|
"multiformats": "^13.4.0",
|
|
56
|
-
"protons-runtime": "^
|
|
56
|
+
"protons-runtime": "^6.0.1",
|
|
57
57
|
"uint8-varint": "^2.0.4",
|
|
58
58
|
"uint8arraylist": "^2.4.8",
|
|
59
59
|
"uint8arrays": "^5.1.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"aegir": "^47.0.22",
|
|
63
|
-
"protons": "^
|
|
63
|
+
"protons": "^8.1.1"
|
|
64
64
|
},
|
|
65
65
|
"sideEffects": false
|
|
66
66
|
}
|
package/src/envelope/envelope.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeMessage, encodeMessage, message } from 'protons-runtime'
|
|
1
|
+
import { decodeMessage, encodeMessage, message, streamMessage } from 'protons-runtime'
|
|
2
2
|
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
|
|
3
3
|
import type { Codec, DecodeOptions } from 'protons-runtime'
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
@@ -81,17 +81,82 @@ export namespace Envelope {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
return obj
|
|
84
|
+
}, function * (reader, length, prefix, opts = {}) {
|
|
85
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
86
|
+
|
|
87
|
+
while (reader.pos < end) {
|
|
88
|
+
const tag = reader.uint32()
|
|
89
|
+
|
|
90
|
+
switch (tag >>> 3) {
|
|
91
|
+
case 1: {
|
|
92
|
+
yield {
|
|
93
|
+
field: `${prefix}.publicKey`,
|
|
94
|
+
value: reader.bytes()
|
|
95
|
+
}
|
|
96
|
+
break
|
|
97
|
+
}
|
|
98
|
+
case 2: {
|
|
99
|
+
yield {
|
|
100
|
+
field: `${prefix}.payloadType`,
|
|
101
|
+
value: reader.bytes()
|
|
102
|
+
}
|
|
103
|
+
break
|
|
104
|
+
}
|
|
105
|
+
case 3: {
|
|
106
|
+
yield {
|
|
107
|
+
field: `${prefix}.payload`,
|
|
108
|
+
value: reader.bytes()
|
|
109
|
+
}
|
|
110
|
+
break
|
|
111
|
+
}
|
|
112
|
+
case 5: {
|
|
113
|
+
yield {
|
|
114
|
+
field: `${prefix}.signature`,
|
|
115
|
+
value: reader.bytes()
|
|
116
|
+
}
|
|
117
|
+
break
|
|
118
|
+
}
|
|
119
|
+
default: {
|
|
120
|
+
reader.skipType(tag & 7)
|
|
121
|
+
break
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
84
125
|
})
|
|
85
126
|
}
|
|
86
127
|
|
|
87
128
|
return _codec
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
export
|
|
131
|
+
export interface EnvelopePublicKeyFieldEvent {
|
|
132
|
+
field: '$.publicKey'
|
|
133
|
+
value: Uint8Array
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface EnvelopePayloadTypeFieldEvent {
|
|
137
|
+
field: '$.payloadType'
|
|
138
|
+
value: Uint8Array
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface EnvelopePayloadFieldEvent {
|
|
142
|
+
field: '$.payload'
|
|
143
|
+
value: Uint8Array
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface EnvelopeSignatureFieldEvent {
|
|
147
|
+
field: '$.signature'
|
|
148
|
+
value: Uint8Array
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function encode (obj: Partial<Envelope>): Uint8Array {
|
|
91
152
|
return encodeMessage(obj, Envelope.codec())
|
|
92
153
|
}
|
|
93
154
|
|
|
94
|
-
export
|
|
155
|
+
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Envelope {
|
|
95
156
|
return decodeMessage(buf, Envelope.codec(), opts)
|
|
96
157
|
}
|
|
158
|
+
|
|
159
|
+
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Envelope>): Generator<EnvelopePublicKeyFieldEvent | EnvelopePayloadTypeFieldEvent | EnvelopePayloadFieldEvent | EnvelopeSignatureFieldEvent> {
|
|
160
|
+
return streamMessage(buf, Envelope.codec(), opts)
|
|
161
|
+
}
|
|
97
162
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decodeMessage, encodeMessage, MaxLengthError, message } from 'protons-runtime'
|
|
1
|
+
import { decodeMessage, encodeMessage, MaxLengthError, message, streamMessage } from 'protons-runtime'
|
|
2
2
|
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
|
|
3
3
|
import type { Codec, DecodeOptions } from 'protons-runtime'
|
|
4
4
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
@@ -55,19 +55,48 @@ export namespace PeerRecord {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return obj
|
|
58
|
+
}, function * (reader, length, prefix, opts = {}) {
|
|
59
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
60
|
+
|
|
61
|
+
while (reader.pos < end) {
|
|
62
|
+
const tag = reader.uint32()
|
|
63
|
+
|
|
64
|
+
switch (tag >>> 3) {
|
|
65
|
+
case 1: {
|
|
66
|
+
yield {
|
|
67
|
+
field: `${prefix}.multiaddr`,
|
|
68
|
+
value: reader.bytes()
|
|
69
|
+
}
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
default: {
|
|
73
|
+
reader.skipType(tag & 7)
|
|
74
|
+
break
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
58
78
|
})
|
|
59
79
|
}
|
|
60
80
|
|
|
61
81
|
return _codec
|
|
62
82
|
}
|
|
63
83
|
|
|
64
|
-
export
|
|
84
|
+
export interface AddressInfoMultiaddrFieldEvent {
|
|
85
|
+
field: '$.multiaddr'
|
|
86
|
+
value: Uint8Array
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function encode (obj: Partial<AddressInfo>): Uint8Array {
|
|
65
90
|
return encodeMessage(obj, AddressInfo.codec())
|
|
66
91
|
}
|
|
67
92
|
|
|
68
|
-
export
|
|
93
|
+
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<AddressInfo>): AddressInfo {
|
|
69
94
|
return decodeMessage(buf, AddressInfo.codec(), opts)
|
|
70
95
|
}
|
|
96
|
+
|
|
97
|
+
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<AddressInfo>): Generator<AddressInfoMultiaddrFieldEvent> {
|
|
98
|
+
return streamMessage(buf, AddressInfo.codec(), opts)
|
|
99
|
+
}
|
|
71
100
|
}
|
|
72
101
|
|
|
73
102
|
let _codec: Codec<PeerRecord>
|
|
@@ -89,7 +118,7 @@ export namespace PeerRecord {
|
|
|
89
118
|
w.uint64(obj.seq)
|
|
90
119
|
}
|
|
91
120
|
|
|
92
|
-
if (obj.addresses != null) {
|
|
121
|
+
if (obj.addresses != null && obj.addresses.length > 0) {
|
|
93
122
|
for (const value of obj.addresses) {
|
|
94
123
|
w.uint32(26)
|
|
95
124
|
PeerRecord.AddressInfo.codec().encode(value, w)
|
|
@@ -122,7 +151,7 @@ export namespace PeerRecord {
|
|
|
122
151
|
}
|
|
123
152
|
case 3: {
|
|
124
153
|
if (opts.limits?.addresses != null && obj.addresses.length === opts.limits.addresses) {
|
|
125
|
-
throw new MaxLengthError('Decode error -
|
|
154
|
+
throw new MaxLengthError('Decode error - repeated field "addresses" had too many elements')
|
|
126
155
|
}
|
|
127
156
|
|
|
128
157
|
obj.addresses.push(PeerRecord.AddressInfo.codec().decode(reader, reader.uint32(), {
|
|
@@ -138,17 +167,86 @@ export namespace PeerRecord {
|
|
|
138
167
|
}
|
|
139
168
|
|
|
140
169
|
return obj
|
|
170
|
+
}, function * (reader, length, prefix, opts = {}) {
|
|
171
|
+
const obj = {
|
|
172
|
+
addresses: 0
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
176
|
+
|
|
177
|
+
while (reader.pos < end) {
|
|
178
|
+
const tag = reader.uint32()
|
|
179
|
+
|
|
180
|
+
switch (tag >>> 3) {
|
|
181
|
+
case 1: {
|
|
182
|
+
yield {
|
|
183
|
+
field: `${prefix}.peerId`,
|
|
184
|
+
value: reader.bytes()
|
|
185
|
+
}
|
|
186
|
+
break
|
|
187
|
+
}
|
|
188
|
+
case 2: {
|
|
189
|
+
yield {
|
|
190
|
+
field: `${prefix}.seq`,
|
|
191
|
+
value: reader.uint64()
|
|
192
|
+
}
|
|
193
|
+
break
|
|
194
|
+
}
|
|
195
|
+
case 3: {
|
|
196
|
+
if (opts.limits?.addresses != null && obj.addresses === opts.limits.addresses) {
|
|
197
|
+
throw new MaxLengthError('Streaming decode error - repeated field "addresses" had too many elements')
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
for (const evt of PeerRecord.AddressInfo.codec().stream(reader, reader.uint32(), `${prefix}.addresses[]`, {
|
|
201
|
+
limits: opts.limits?.addresses$
|
|
202
|
+
})) {
|
|
203
|
+
yield {
|
|
204
|
+
...evt,
|
|
205
|
+
index: obj.addresses
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
obj.addresses++
|
|
210
|
+
|
|
211
|
+
break
|
|
212
|
+
}
|
|
213
|
+
default: {
|
|
214
|
+
reader.skipType(tag & 7)
|
|
215
|
+
break
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
141
219
|
})
|
|
142
220
|
}
|
|
143
221
|
|
|
144
222
|
return _codec
|
|
145
223
|
}
|
|
146
224
|
|
|
147
|
-
export
|
|
225
|
+
export interface PeerRecordPeerIdFieldEvent {
|
|
226
|
+
field: '$.peerId'
|
|
227
|
+
value: Uint8Array
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface PeerRecordSeqFieldEvent {
|
|
231
|
+
field: '$.seq'
|
|
232
|
+
value: bigint
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface PeerRecordAddressesMultiaddrFieldEvent {
|
|
236
|
+
field: '$.addresses[].multiaddr'
|
|
237
|
+
value: Uint8Array
|
|
238
|
+
index: number
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function encode (obj: Partial<PeerRecord>): Uint8Array {
|
|
148
242
|
return encodeMessage(obj, PeerRecord.codec())
|
|
149
243
|
}
|
|
150
244
|
|
|
151
|
-
export
|
|
245
|
+
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerRecord>): PeerRecord {
|
|
152
246
|
return decodeMessage(buf, PeerRecord.codec(), opts)
|
|
153
247
|
}
|
|
248
|
+
|
|
249
|
+
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerRecord>): Generator<PeerRecordPeerIdFieldEvent | PeerRecordSeqFieldEvent | PeerRecordAddressesMultiaddrFieldEvent> {
|
|
250
|
+
return streamMessage(buf, PeerRecord.codec(), opts)
|
|
251
|
+
}
|
|
154
252
|
}
|