@libp2p/identify 4.0.13 → 4.0.14-2a3e54738

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.
@@ -11,7 +11,38 @@ export interface Identify {
11
11
  }
12
12
  export declare namespace Identify {
13
13
  const codec: () => Codec<Identify>;
14
- const encode: (obj: Partial<Identify>) => Uint8Array;
15
- const decode: (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>) => Identify;
14
+ interface IdentifyProtocolVersionFieldEvent {
15
+ field: '$.protocolVersion';
16
+ value: string;
17
+ }
18
+ interface IdentifyAgentVersionFieldEvent {
19
+ field: '$.agentVersion';
20
+ value: string;
21
+ }
22
+ interface IdentifyPublicKeyFieldEvent {
23
+ field: '$.publicKey';
24
+ value: Uint8Array;
25
+ }
26
+ interface IdentifyListenAddrsFieldEvent {
27
+ field: '$.listenAddrs[]';
28
+ index: number;
29
+ value: Uint8Array;
30
+ }
31
+ interface IdentifyObservedAddrFieldEvent {
32
+ field: '$.observedAddr';
33
+ value: Uint8Array;
34
+ }
35
+ interface IdentifyProtocolsFieldEvent {
36
+ field: '$.protocols[]';
37
+ index: number;
38
+ value: string;
39
+ }
40
+ interface IdentifySignedPeerRecordFieldEvent {
41
+ field: '$.signedPeerRecord';
42
+ value: Uint8Array;
43
+ }
44
+ function encode(obj: Partial<Identify>): Uint8Array;
45
+ function decode(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>): Identify;
46
+ function stream(buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>): Generator<IdentifyProtocolVersionFieldEvent | IdentifyAgentVersionFieldEvent | IdentifyPublicKeyFieldEvent | IdentifyListenAddrsFieldEvent | IdentifyObservedAddrFieldEvent | IdentifyProtocolsFieldEvent | IdentifySignedPeerRecordFieldEvent>;
16
47
  }
17
48
  //# sourceMappingURL=message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/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time';
1
+ import { decodeMessage, encodeMessage, MaxLengthError, message, streamMessage } from 'protons-runtime';
2
2
  export var Identify;
3
3
  (function (Identify) {
4
4
  let _codec;
@@ -20,7 +20,7 @@ export var Identify;
20
20
  w.uint32(10);
21
21
  w.bytes(obj.publicKey);
22
22
  }
23
- if (obj.listenAddrs != null) {
23
+ if (obj.listenAddrs != null && obj.listenAddrs.length > 0) {
24
24
  for (const value of obj.listenAddrs) {
25
25
  w.uint32(18);
26
26
  w.bytes(value);
@@ -30,7 +30,7 @@ export var Identify;
30
30
  w.uint32(34);
31
31
  w.bytes(obj.observedAddr);
32
32
  }
33
- if (obj.protocols != null) {
33
+ if (obj.protocols != null && obj.protocols.length > 0) {
34
34
  for (const value of obj.protocols) {
35
35
  w.uint32(26);
36
36
  w.string(value);
@@ -66,7 +66,7 @@ export var Identify;
66
66
  }
67
67
  case 2: {
68
68
  if (opts.limits?.listenAddrs != null && obj.listenAddrs.length === opts.limits.listenAddrs) {
69
- throw new MaxLengthError('Decode error - map field "listenAddrs" had too many elements');
69
+ throw new MaxLengthError('Decode error - repeated field "listenAddrs" had too many elements');
70
70
  }
71
71
  obj.listenAddrs.push(reader.bytes());
72
72
  break;
@@ -77,7 +77,7 @@ export var Identify;
77
77
  }
78
78
  case 3: {
79
79
  if (opts.limits?.protocols != null && obj.protocols.length === opts.limits.protocols) {
80
- throw new MaxLengthError('Decode error - map field "protocols" had too many elements');
80
+ throw new MaxLengthError('Decode error - repeated field "protocols" had too many elements');
81
81
  }
82
82
  obj.protocols.push(reader.string());
83
83
  break;
@@ -93,15 +93,95 @@ export var Identify;
93
93
  }
94
94
  }
95
95
  return obj;
96
+ }, function* (reader, length, prefix, opts = {}) {
97
+ const obj = {
98
+ listenAddrs: 0,
99
+ protocols: 0
100
+ };
101
+ const end = length == null ? reader.len : reader.pos + length;
102
+ while (reader.pos < end) {
103
+ const tag = reader.uint32();
104
+ switch (tag >>> 3) {
105
+ case 5: {
106
+ yield {
107
+ field: `${prefix}.protocolVersion`,
108
+ value: reader.string()
109
+ };
110
+ break;
111
+ }
112
+ case 6: {
113
+ yield {
114
+ field: `${prefix}.agentVersion`,
115
+ value: reader.string()
116
+ };
117
+ break;
118
+ }
119
+ case 1: {
120
+ yield {
121
+ field: `${prefix}.publicKey`,
122
+ value: reader.bytes()
123
+ };
124
+ break;
125
+ }
126
+ case 2: {
127
+ if (opts.limits?.listenAddrs != null && obj.listenAddrs === opts.limits.listenAddrs) {
128
+ throw new MaxLengthError('Streaming decode error - repeated field "listenAddrs" had too many elements');
129
+ }
130
+ yield {
131
+ field: `${prefix}.listenAddrs[]`,
132
+ index: obj.listenAddrs,
133
+ value: reader.bytes()
134
+ };
135
+ obj.listenAddrs++;
136
+ break;
137
+ }
138
+ case 4: {
139
+ yield {
140
+ field: `${prefix}.observedAddr`,
141
+ value: reader.bytes()
142
+ };
143
+ break;
144
+ }
145
+ case 3: {
146
+ if (opts.limits?.protocols != null && obj.protocols === opts.limits.protocols) {
147
+ throw new MaxLengthError('Streaming decode error - repeated field "protocols" had too many elements');
148
+ }
149
+ yield {
150
+ field: `${prefix}.protocols[]`,
151
+ index: obj.protocols,
152
+ value: reader.string()
153
+ };
154
+ obj.protocols++;
155
+ break;
156
+ }
157
+ case 8: {
158
+ yield {
159
+ field: `${prefix}.signedPeerRecord`,
160
+ value: reader.bytes()
161
+ };
162
+ break;
163
+ }
164
+ default: {
165
+ reader.skipType(tag & 7);
166
+ break;
167
+ }
168
+ }
169
+ }
96
170
  });
97
171
  }
98
172
  return _codec;
99
173
  };
100
- Identify.encode = (obj) => {
174
+ function encode(obj) {
101
175
  return encodeMessage(obj, Identify.codec());
102
- };
103
- Identify.decode = (buf, opts) => {
176
+ }
177
+ Identify.encode = encode;
178
+ function decode(buf, opts) {
104
179
  return decodeMessage(buf, Identify.codec(), opts);
105
- };
180
+ }
181
+ Identify.decode = decode;
182
+ function stream(buf, opts) {
183
+ return streamMessage(buf, Identify.codec(), opts);
184
+ }
185
+ Identify.stream = stream;
106
186
  })(Identify || (Identify = {}));
107
187
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAcvF,MAAM,KAAW,QAAQ,CAyHxB;AAzHD,WAAiB,QAAQ;IACvB,IAAI,MAAuB,CAAA;IAEd,cAAK,GAAG,GAAoB,EAAE;QACzC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,GAAG,OAAO,CAAW,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;gBAC/C,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;oBACnC,CAAC,CAAC,IAAI,EAAE,CAAA;gBACV,CAAC;gBAED,IAAI,GAAG,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;oBAChC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACZ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;gBAC/B,CAAC;gBAED,IAAI,GAAG,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;oBAC7B,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACZ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;gBAC5B,CAAC;gBAED,IAAI,GAAG,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;oBAC1B,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACZ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;gBACxB,CAAC;gBAED,IAAI,GAAG,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;oBAC5B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;wBAC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AAA;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,EArPgB,QAAQ,KAAR,QAAQ,QAqPxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/identify",
3
- "version": "4.0.13",
3
+ "version": "4.0.14-2a3e54738",
4
4
  "description": "Implementation of the Identify Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme",
@@ -45,27 +45,27 @@
45
45
  "doc-check": "aegir doc-check"
46
46
  },
47
47
  "dependencies": {
48
- "@libp2p/crypto": "^5.1.13",
49
- "@libp2p/interface": "^3.1.0",
50
- "@libp2p/interface-internal": "^3.0.13",
51
- "@libp2p/peer-id": "^6.0.4",
52
- "@libp2p/peer-record": "^9.0.5",
53
- "@libp2p/utils": "^7.0.13",
48
+ "@libp2p/crypto": "5.1.14-2a3e54738",
49
+ "@libp2p/interface": "3.1.1-2a3e54738",
50
+ "@libp2p/interface-internal": "3.0.14-2a3e54738",
51
+ "@libp2p/peer-id": "6.0.5-2a3e54738",
52
+ "@libp2p/peer-record": "9.0.6-2a3e54738",
53
+ "@libp2p/utils": "7.0.14-2a3e54738",
54
54
  "@multiformats/multiaddr": "^13.0.1",
55
55
  "@multiformats/multiaddr-matcher": "^3.0.1",
56
56
  "it-drain": "^3.0.10",
57
57
  "it-parallel": "^3.0.13",
58
58
  "main-event": "^1.0.1",
59
- "protons-runtime": "^5.6.0",
59
+ "protons-runtime": "^6.0.1",
60
60
  "uint8arraylist": "^2.4.8",
61
61
  "uint8arrays": "^5.1.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@libp2p/logger": "^6.2.2",
64
+ "@libp2p/logger": "6.2.3-2a3e54738",
65
65
  "aegir": "^47.0.22",
66
66
  "delay": "^7.0.0",
67
67
  "it-length-prefixed": "^10.0.1",
68
- "protons": "^7.7.0",
68
+ "protons": "^8.1.1",
69
69
  "sinon-ts": "^2.0.0"
70
70
  },
71
71
  "sideEffects": false
package/src/pb/message.ts CHANGED
@@ -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 type { Codec, DecodeOptions } from 'protons-runtime'
3
3
  import type { Uint8ArrayList } from 'uint8arraylist'
4
4
 
@@ -37,7 +37,7 @@ export namespace Identify {
37
37
  w.bytes(obj.publicKey)
38
38
  }
39
39
 
40
- if (obj.listenAddrs != null) {
40
+ if (obj.listenAddrs != null && obj.listenAddrs.length > 0) {
41
41
  for (const value of obj.listenAddrs) {
42
42
  w.uint32(18)
43
43
  w.bytes(value)
@@ -49,7 +49,7 @@ export namespace Identify {
49
49
  w.bytes(obj.observedAddr)
50
50
  }
51
51
 
52
- if (obj.protocols != null) {
52
+ if (obj.protocols != null && obj.protocols.length > 0) {
53
53
  for (const value of obj.protocols) {
54
54
  w.uint32(26)
55
55
  w.string(value)
@@ -90,7 +90,7 @@ export namespace Identify {
90
90
  }
91
91
  case 2: {
92
92
  if (opts.limits?.listenAddrs != null && obj.listenAddrs.length === opts.limits.listenAddrs) {
93
- throw new MaxLengthError('Decode error - map field "listenAddrs" had too many elements')
93
+ throw new MaxLengthError('Decode error - repeated field "listenAddrs" had too many elements')
94
94
  }
95
95
 
96
96
  obj.listenAddrs.push(reader.bytes())
@@ -102,7 +102,7 @@ export namespace Identify {
102
102
  }
103
103
  case 3: {
104
104
  if (opts.limits?.protocols != null && obj.protocols.length === opts.limits.protocols) {
105
- throw new MaxLengthError('Decode error - map field "protocols" had too many elements')
105
+ throw new MaxLengthError('Decode error - repeated field "protocols" had too many elements')
106
106
  }
107
107
 
108
108
  obj.protocols.push(reader.string())
@@ -120,17 +120,141 @@ export namespace Identify {
120
120
  }
121
121
 
122
122
  return obj
123
+ }, function * (reader, length, prefix, opts = {}) {
124
+ const obj = {
125
+ listenAddrs: 0,
126
+ protocols: 0
127
+ }
128
+
129
+ const end = length == null ? reader.len : reader.pos + length
130
+
131
+ while (reader.pos < end) {
132
+ const tag = reader.uint32()
133
+
134
+ switch (tag >>> 3) {
135
+ case 5: {
136
+ yield {
137
+ field: `${prefix}.protocolVersion`,
138
+ value: reader.string()
139
+ }
140
+ break
141
+ }
142
+ case 6: {
143
+ yield {
144
+ field: `${prefix}.agentVersion`,
145
+ value: reader.string()
146
+ }
147
+ break
148
+ }
149
+ case 1: {
150
+ yield {
151
+ field: `${prefix}.publicKey`,
152
+ value: reader.bytes()
153
+ }
154
+ break
155
+ }
156
+ case 2: {
157
+ if (opts.limits?.listenAddrs != null && obj.listenAddrs === opts.limits.listenAddrs) {
158
+ throw new MaxLengthError('Streaming decode error - repeated field "listenAddrs" had too many elements')
159
+ }
160
+
161
+ yield {
162
+ field: `${prefix}.listenAddrs[]`,
163
+ index: obj.listenAddrs,
164
+ value: reader.bytes()
165
+ }
166
+
167
+ obj.listenAddrs++
168
+
169
+ break
170
+ }
171
+ case 4: {
172
+ yield {
173
+ field: `${prefix}.observedAddr`,
174
+ value: reader.bytes()
175
+ }
176
+ break
177
+ }
178
+ case 3: {
179
+ if (opts.limits?.protocols != null && obj.protocols === opts.limits.protocols) {
180
+ throw new MaxLengthError('Streaming decode error - repeated field "protocols" had too many elements')
181
+ }
182
+
183
+ yield {
184
+ field: `${prefix}.protocols[]`,
185
+ index: obj.protocols,
186
+ value: reader.string()
187
+ }
188
+
189
+ obj.protocols++
190
+
191
+ break
192
+ }
193
+ case 8: {
194
+ yield {
195
+ field: `${prefix}.signedPeerRecord`,
196
+ value: reader.bytes()
197
+ }
198
+ break
199
+ }
200
+ default: {
201
+ reader.skipType(tag & 7)
202
+ break
203
+ }
204
+ }
205
+ }
123
206
  })
124
207
  }
125
208
 
126
209
  return _codec
127
210
  }
128
211
 
129
- export const encode = (obj: Partial<Identify>): Uint8Array => {
212
+ export interface IdentifyProtocolVersionFieldEvent {
213
+ field: '$.protocolVersion'
214
+ value: string
215
+ }
216
+
217
+ export interface IdentifyAgentVersionFieldEvent {
218
+ field: '$.agentVersion'
219
+ value: string
220
+ }
221
+
222
+ export interface IdentifyPublicKeyFieldEvent {
223
+ field: '$.publicKey'
224
+ value: Uint8Array
225
+ }
226
+
227
+ export interface IdentifyListenAddrsFieldEvent {
228
+ field: '$.listenAddrs[]'
229
+ index: number
230
+ value: Uint8Array
231
+ }
232
+
233
+ export interface IdentifyObservedAddrFieldEvent {
234
+ field: '$.observedAddr'
235
+ value: Uint8Array
236
+ }
237
+
238
+ export interface IdentifyProtocolsFieldEvent {
239
+ field: '$.protocols[]'
240
+ index: number
241
+ value: string
242
+ }
243
+
244
+ export interface IdentifySignedPeerRecordFieldEvent {
245
+ field: '$.signedPeerRecord'
246
+ value: Uint8Array
247
+ }
248
+
249
+ export function encode (obj: Partial<Identify>): Uint8Array {
130
250
  return encodeMessage(obj, Identify.codec())
131
251
  }
132
252
 
133
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>): Identify => {
253
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>): Identify {
134
254
  return decodeMessage(buf, Identify.codec(), opts)
135
255
  }
256
+
257
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Identify>): Generator<IdentifyProtocolVersionFieldEvent | IdentifyAgentVersionFieldEvent | IdentifyPublicKeyFieldEvent | IdentifyListenAddrsFieldEvent | IdentifyObservedAddrFieldEvent | IdentifyProtocolsFieldEvent | IdentifySignedPeerRecordFieldEvent> {
258
+ return streamMessage(buf, Identify.codec(), opts)
259
+ }
136
260
  }
@@ -1,18 +0,0 @@
1
- {
2
- "Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
3
- ".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
4
- "IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
5
- ".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
6
- "IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
7
- ".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
8
- "IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
9
- ".:IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
10
- "IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
11
- ".:IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
12
- "IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
13
- ".:IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
14
- "identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify.html",
15
- ".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify.html",
16
- "identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush.html",
17
- ".:identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush.html"
18
- }