@libp2p/utils 1.0.1 → 1.0.5
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/LICENSE +3 -1
- package/dist/src/multiaddr/is-loopback.d.ts +1 -1
- package/dist/src/multiaddr/is-loopback.d.ts.map +1 -1
- package/dist/src/multiaddr/is-loopback.js +1 -2
- package/dist/src/multiaddr/is-loopback.js.map +1 -1
- package/dist/src/stream-to-ma-conn.d.ts +2 -2
- package/dist/src/stream-to-ma-conn.d.ts.map +1 -1
- package/dist/src/stream-to-ma-conn.js +3 -3
- package/dist/src/stream-to-ma-conn.js.map +1 -1
- package/package.json +136 -41
- package/src/multiaddr/is-loopback.ts +1 -2
- package/src/stream-to-ma-conn.ts +4 -4
package/LICENSE
CHANGED
|
@@ -2,5 +2,5 @@ import type { Multiaddr } from '@multiformats/multiaddr';
|
|
|
2
2
|
/**
|
|
3
3
|
* Check if a given multiaddr is a loopback address.
|
|
4
4
|
*/
|
|
5
|
-
export declare function isLoopback(ma: Multiaddr):
|
|
5
|
+
export declare function isLoopback(ma: Multiaddr): boolean;
|
|
6
6
|
//# sourceMappingURL=is-loopback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-loopback.d.ts","sourceRoot":"","sources":["../../../src/multiaddr/is-loopback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-loopback.d.ts","sourceRoot":"","sources":["../../../src/multiaddr/is-loopback.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD;;GAEG;AACH,wBAAgB,UAAU,CAAE,EAAE,EAAE,SAAS,WAIxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-loopback.js","sourceRoot":"","sources":["../../../src/multiaddr/is-loopback.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"is-loopback.js","sourceRoot":"","sources":["../../../src/multiaddr/is-loopback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD;;GAEG;AACH,MAAM,UAAU,UAAU,CAAE,EAAa;IACvC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;IAEpC,OAAO,cAAc,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -25,7 +25,7 @@ interface StreamOptions {
|
|
|
25
25
|
signal?: AbortSignal;
|
|
26
26
|
}
|
|
27
27
|
interface StreamProperties {
|
|
28
|
-
stream: MuxedStream
|
|
28
|
+
stream: MuxedStream;
|
|
29
29
|
remoteAddr: Multiaddr;
|
|
30
30
|
localAddr: Multiaddr;
|
|
31
31
|
}
|
|
@@ -33,6 +33,6 @@ interface StreamProperties {
|
|
|
33
33
|
* Convert a duplex iterable into a MultiaddrConnection.
|
|
34
34
|
* https://github.com/libp2p/interface-transport#multiaddrconnection
|
|
35
35
|
*/
|
|
36
|
-
export declare function streamToMaConnection(props: StreamProperties, options?: StreamOptions): MultiaddrConnection
|
|
36
|
+
export declare function streamToMaConnection(props: StreamProperties, options?: StreamOptions): MultiaddrConnection;
|
|
37
37
|
export {};
|
|
38
38
|
//# sourceMappingURL=stream-to-ma-conn.d.ts.map
|
|
@@ -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,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAIvE;;;;;GAKG;AAEH,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,WAAW,
|
|
1
|
+
{"version":3,"file":"stream-to-ma-conn.d.ts","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAIvE;;;;;GAKG;AAEH,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,WAAW,CAAA;IACnB,UAAU,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAkB,uBA4CzF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { abortableSource } from 'abortable-iterator';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
const log = debug('libp2p:stream:converter');
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ export function streamToMaConnection(props, options = {}) {
|
|
|
11
11
|
const maConn = {
|
|
12
12
|
async sink(source) {
|
|
13
13
|
if (options.signal != null) {
|
|
14
|
-
source =
|
|
14
|
+
source = abortableSource(source, options.signal);
|
|
15
15
|
}
|
|
16
16
|
try {
|
|
17
17
|
await sink(source);
|
|
@@ -27,7 +27,7 @@ export function streamToMaConnection(props, options = {}) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
source: (options.signal != null) ?
|
|
30
|
+
source: (options.signal != null) ? abortableSource(source, options.signal) : source,
|
|
31
31
|
conn: stream,
|
|
32
32
|
localAddr,
|
|
33
33
|
remoteAddr,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-to-ma-conn.js","sourceRoot":"","sources":["../../src/stream-to-ma-conn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,GAAG,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAA;AAqC5C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,KAAuB,EAAE,UAAyB,EAAE;IACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IAC/C,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,IAAI,EAAE,MAAM;QACZ,SAAS;QACT,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,10 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
|
|
5
|
-
"
|
|
5
|
+
"license": "Apache-2.0 OR MIT",
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p-utils#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/libp2p/js-libp2p-utils.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/libp2p/js-libp2p-utils/issues"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=16.0.0",
|
|
16
|
+
"npm": ">=7.0.0"
|
|
17
|
+
},
|
|
6
18
|
"type": "module",
|
|
19
|
+
"types": "./dist/src/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
"*": [
|
|
23
|
+
"*",
|
|
24
|
+
"dist/*",
|
|
25
|
+
"dist/src/*",
|
|
26
|
+
"dist/src/*/index"
|
|
27
|
+
],
|
|
28
|
+
"src/*": [
|
|
29
|
+
"*",
|
|
30
|
+
"dist/*",
|
|
31
|
+
"dist/src/*",
|
|
32
|
+
"dist/src/*/index"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"src",
|
|
38
|
+
"dist/src",
|
|
39
|
+
"!dist/test",
|
|
40
|
+
"!**/*.tsbuildinfo"
|
|
41
|
+
],
|
|
7
42
|
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"import": "./dist/src/index.js"
|
|
45
|
+
},
|
|
8
46
|
"./multiaddr/is-loopback": {
|
|
9
47
|
"import": "./dist/src/multiaddr/is-loopback.js",
|
|
10
48
|
"types": "./dist/src/multiaddr/is-loopback.d.ts"
|
|
@@ -30,22 +68,93 @@
|
|
|
30
68
|
"types": "./dist/src/stream-to-ma-connr.d.ts"
|
|
31
69
|
}
|
|
32
70
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"dist/src/*/index"
|
|
38
|
-
],
|
|
39
|
-
"src/*": [
|
|
40
|
-
"dist/src/*",
|
|
41
|
-
"dist/src/*/index"
|
|
42
|
-
]
|
|
71
|
+
"eslintConfig": {
|
|
72
|
+
"extends": "ipfs",
|
|
73
|
+
"parserOptions": {
|
|
74
|
+
"sourceType": "module"
|
|
43
75
|
}
|
|
44
76
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
77
|
+
"release": {
|
|
78
|
+
"branches": [
|
|
79
|
+
"master"
|
|
80
|
+
],
|
|
81
|
+
"plugins": [
|
|
82
|
+
[
|
|
83
|
+
"@semantic-release/commit-analyzer",
|
|
84
|
+
{
|
|
85
|
+
"preset": "conventionalcommits",
|
|
86
|
+
"releaseRules": [
|
|
87
|
+
{
|
|
88
|
+
"breaking": true,
|
|
89
|
+
"release": "major"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"revert": true,
|
|
93
|
+
"release": "patch"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "feat",
|
|
97
|
+
"release": "minor"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"type": "fix",
|
|
101
|
+
"release": "patch"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "chore",
|
|
105
|
+
"release": "patch"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": "docs",
|
|
109
|
+
"release": "patch"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "test",
|
|
113
|
+
"release": "patch"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"scope": "no-release",
|
|
117
|
+
"release": false
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
"@semantic-release/release-notes-generator",
|
|
124
|
+
{
|
|
125
|
+
"preset": "conventionalcommits",
|
|
126
|
+
"presetConfig": {
|
|
127
|
+
"types": [
|
|
128
|
+
{
|
|
129
|
+
"type": "feat",
|
|
130
|
+
"section": "Features"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "fix",
|
|
134
|
+
"section": "Bug Fixes"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"type": "chore",
|
|
138
|
+
"section": "Trivial Changes"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "docs",
|
|
142
|
+
"section": "Trivial Changes"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"type": "test",
|
|
146
|
+
"section": "Tests"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"@semantic-release/changelog",
|
|
153
|
+
"@semantic-release/npm",
|
|
154
|
+
"@semantic-release/github",
|
|
155
|
+
"@semantic-release/git"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
49
158
|
"scripts": {
|
|
50
159
|
"lint": "aegir lint",
|
|
51
160
|
"dep-check": "aegir dep-check dist/src/**/*.js dist/test/**/*.js",
|
|
@@ -60,36 +169,22 @@
|
|
|
60
169
|
"test:electron-main": "npm run test -- -t electron-main",
|
|
61
170
|
"release": "semantic-release"
|
|
62
171
|
},
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "git",
|
|
65
|
-
"url": "git+https://github.com/libp2p/js-libp2p-utils.git"
|
|
66
|
-
},
|
|
67
|
-
"license": "(Apache-2.0 OR MIT)",
|
|
68
|
-
"bugs": {
|
|
69
|
-
"url": "https://github.com/libp2p/js-libp2p-utils/issues"
|
|
70
|
-
},
|
|
71
|
-
"homepage": "https://github.com/libp2p/js-libp2p-utils#readme",
|
|
72
|
-
"devDependencies": {
|
|
73
|
-
"@libp2p/interfaces": "^0.2.0",
|
|
74
|
-
"@types/debug": "^4.1.5",
|
|
75
|
-
"aegir": "^36.1.2",
|
|
76
|
-
"it-pair": "^1.0.0",
|
|
77
|
-
"it-pipe": "^1.1.0",
|
|
78
|
-
"streaming-iterables": "^6.0.0",
|
|
79
|
-
"util": "^0.12.3"
|
|
80
|
-
},
|
|
81
172
|
"dependencies": {
|
|
82
173
|
"@achingbrain/ip-address": "^8.1.0",
|
|
83
174
|
"@multiformats/multiaddr": "^10.1.1",
|
|
84
|
-
"abortable-iterator": "^
|
|
175
|
+
"abortable-iterator": "^4.0.2",
|
|
85
176
|
"debug": "^4.3.0",
|
|
86
177
|
"err-code": "^3.0.1",
|
|
87
|
-
"is-loopback-addr": "^
|
|
178
|
+
"is-loopback-addr": "^2.0.1",
|
|
88
179
|
"private-ip": "^2.1.1"
|
|
89
180
|
},
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
|
|
181
|
+
"devDependencies": {
|
|
182
|
+
"@libp2p/interfaces": "^1.0.3",
|
|
183
|
+
"@types/debug": "^4.1.5",
|
|
184
|
+
"aegir": "^36.1.2",
|
|
185
|
+
"it-pair": "^2.0.2",
|
|
186
|
+
"it-pipe": "^2.0.2",
|
|
187
|
+
"streaming-iterables": "^6.0.0",
|
|
188
|
+
"util": "^0.12.3"
|
|
189
|
+
}
|
|
95
190
|
}
|
package/src/stream-to-ma-conn.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { abortableSource } from 'abortable-iterator'
|
|
2
2
|
import debug from 'debug'
|
|
3
3
|
import type { MuxedStream } from '@libp2p/interfaces/stream-muxer'
|
|
4
4
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
@@ -36,7 +36,7 @@ interface StreamOptions {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
interface StreamProperties {
|
|
39
|
-
stream: MuxedStream
|
|
39
|
+
stream: MuxedStream
|
|
40
40
|
remoteAddr: Multiaddr
|
|
41
41
|
localAddr: Multiaddr
|
|
42
42
|
}
|
|
@@ -51,7 +51,7 @@ export function streamToMaConnection (props: StreamProperties, options: StreamOp
|
|
|
51
51
|
const maConn: MultiaddrConnection = {
|
|
52
52
|
async sink (source) {
|
|
53
53
|
if (options.signal != null) {
|
|
54
|
-
source =
|
|
54
|
+
source = abortableSource(source, options.signal)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
try {
|
|
@@ -67,7 +67,7 @@ export function streamToMaConnection (props: StreamProperties, options: StreamOp
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
source: (options.signal != null) ?
|
|
70
|
+
source: (options.signal != null) ? abortableSource(source, options.signal) : source,
|
|
71
71
|
conn: stream,
|
|
72
72
|
localAddr,
|
|
73
73
|
remoteAddr,
|