@libp2p/utils 1.0.6 → 1.0.7
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/address-sort.d.ts.map +1 -1
- package/dist/src/address-sort.js +0 -9
- package/dist/src/address-sort.js.map +1 -1
- package/dist/src/stream-to-ma-conn.d.ts +2 -8
- package/dist/src/stream-to-ma-conn.d.ts.map +1 -1
- package/dist/src/stream-to-ma-conn.js.map +1 -1
- package/package.json +2 -1
- package/src/address-sort.ts +0 -10
- package/src/stream-to-ma-conn.ts +2 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGxD,UAAU,OAAO;IACf,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE,OAAO,CAAA;CACrB;
|
|
1
|
+
{"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGxD,UAAU,OAAO;IACf,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE,OAAO,CAAA;CACrB;AA0BD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,SAAS,EAAE,OAAO,EAAE,aAEzD"}
|
package/dist/src/address-sort.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { isPrivate } from './multiaddr/is-private.js';
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {Object} Address
|
|
4
|
-
* @property {Multiaddr} multiaddr peer multiaddr.
|
|
5
|
-
* @property {boolean} isCertified obtained from a signed peer record.
|
|
6
|
-
*/
|
|
7
2
|
/**
|
|
8
3
|
* Compare function for array.sort().
|
|
9
4
|
* This sort aims to move the private adresses to the end of the array.
|
|
10
5
|
* In case of equality, a certified address will come first.
|
|
11
|
-
*
|
|
12
|
-
* @param {Address} a
|
|
13
|
-
* @param {Address} b
|
|
14
|
-
* @returns {number}
|
|
15
6
|
*/
|
|
16
7
|
function addressesPublicFirstCompareFunction(a, b) {
|
|
17
8
|
const isAPrivate = isPrivate(a.multiaddr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAOrD;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAOrD;;;;GAIG;AACH,SAAS,mCAAmC,CAAE,CAAU,EAAE,CAAU;IAClE,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAEzC,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAC7B,OAAO,CAAC,CAAA;KACT;SAAM,IAAI,CAAC,UAAU,IAAI,UAAU,EAAE;QACpC,OAAO,CAAC,CAAC,CAAA;KACV;IACD,mBAAmB;IACnB,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE;QACnC,OAAO,CAAC,CAAC,CAAA;KACV;SAAM,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,EAAE;QAC1C,OAAO,CAAC,CAAA;KACT;IAED,OAAO,CAAC,CAAA;AACV,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,SAAoB;IACxD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAA;AACjE,CAAC"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type { Stream } from '@libp2p/interfaces/connection';
|
|
2
1
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
3
2
|
import type { MultiaddrConnection } from '@libp2p/interfaces/transport';
|
|
4
|
-
|
|
5
|
-
* @typedef {Object} Timeline
|
|
6
|
-
* @property {number} open -
|
|
7
|
-
* @property {number} [upgraded] - .
|
|
8
|
-
* @property {number} [close]
|
|
9
|
-
*/
|
|
3
|
+
import type { Duplex } from 'it-stream-types';
|
|
10
4
|
export interface Timeline {
|
|
11
5
|
/**
|
|
12
6
|
* Connection opening timestamp
|
|
@@ -25,7 +19,7 @@ interface StreamOptions {
|
|
|
25
19
|
signal?: AbortSignal;
|
|
26
20
|
}
|
|
27
21
|
interface StreamProperties {
|
|
28
|
-
stream:
|
|
22
|
+
stream: Duplex<Uint8Array>;
|
|
29
23
|
remoteAddr: Multiaddr;
|
|
30
24
|
localAddr: Multiaddr;
|
|
31
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI7C,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,WAAW,CAAA;CAErB;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC1B,UAAU,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAkB,uBA0CzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-ma-conn.js","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,MAAM,GAAG,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-to-ma-conn.js","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKvC,MAAM,GAAG,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAA;AA8B7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,KAAuB,EAAE,UAAyB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACpC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAC/B,MAAM,MAAM,GAAwB;QAClC,KAAK,CAAC,IAAI,CAAE,MAAM;YAChB,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE;gBAC1B,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;aACjD;YAED,IAAI;gBACF,MAAM,IAAI,CAAC,MAAM,CAAC,CAAA;gBAClB,MAAM,KAAK,EAAE,CAAA;aACd;YAAC,OAAO,GAAQ,EAAE;gBACjB,kCAAkC;gBAClC,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE;oBAC1B,uEAAuE;oBACvE,gEAAgE;oBAChE,uEAAuE;oBACvE,GAAG,CAAC,GAAG,CAAC,CAAA;iBACT;aACF;QACH,CAAC;QACD,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM;QACnF,UAAU;QACV,uBAAuB;QACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;QAChD,KAAK,CAAC,KAAK;YACT,MAAM,IAAI,CAAC,KAAK,SAAU,CAAC;gBACzB,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;YACzB,CAAC,EAAE,CAAC,CAAA;YACJ,MAAM,KAAK,EAAE,CAAA;QACf,CAAC;KACF,CAAA;IAED,KAAK,UAAU,KAAK;QAClB,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI,EAAE;YACjC,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;SACnC;QACD,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IAChC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-utils#readme",
|
|
@@ -176,6 +176,7 @@
|
|
|
176
176
|
"abortable-iterator": "^4.0.2",
|
|
177
177
|
"err-code": "^3.0.1",
|
|
178
178
|
"is-loopback-addr": "^2.0.1",
|
|
179
|
+
"it-stream-types": "^1.0.4",
|
|
179
180
|
"private-ip": "^2.1.1"
|
|
180
181
|
},
|
|
181
182
|
"devDependencies": {
|
package/src/address-sort.ts
CHANGED
|
@@ -6,20 +6,10 @@ interface Address {
|
|
|
6
6
|
isCertified: boolean
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} Address
|
|
11
|
-
* @property {Multiaddr} multiaddr peer multiaddr.
|
|
12
|
-
* @property {boolean} isCertified obtained from a signed peer record.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* Compare function for array.sort().
|
|
17
11
|
* This sort aims to move the private adresses to the end of the array.
|
|
18
12
|
* In case of equality, a certified address will come first.
|
|
19
|
-
*
|
|
20
|
-
* @param {Address} a
|
|
21
|
-
* @param {Address} b
|
|
22
|
-
* @returns {number}
|
|
23
13
|
*/
|
|
24
14
|
function addressesPublicFirstCompareFunction (a: Address, b: Address) {
|
|
25
15
|
const isAPrivate = isPrivate(a.multiaddr)
|
package/src/stream-to-ma-conn.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { abortableSource } from 'abortable-iterator'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
|
-
import type { Stream } from '@libp2p/interfaces/connection'
|
|
4
3
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
5
4
|
import type { MultiaddrConnection } from '@libp2p/interfaces/transport'
|
|
5
|
+
import type { Duplex } from 'it-stream-types'
|
|
6
6
|
|
|
7
7
|
const log = logger('libp2p:stream:converter')
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} Timeline
|
|
11
|
-
* @property {number} open -
|
|
12
|
-
* @property {number} [upgraded] - .
|
|
13
|
-
* @property {number} [close]
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
9
|
export interface Timeline {
|
|
17
10
|
/**
|
|
18
11
|
* Connection opening timestamp
|
|
@@ -36,7 +29,7 @@ interface StreamOptions {
|
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
interface StreamProperties {
|
|
39
|
-
stream:
|
|
32
|
+
stream: Duplex<Uint8Array>
|
|
40
33
|
remoteAddr: Multiaddr
|
|
41
34
|
localAddr: Multiaddr
|
|
42
35
|
}
|