@helia/interop 10.2.5-1361bfa5 → 10.2.5-16d805e1
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/fixtures/create-helia.browser.d.ts.map +1 -1
- package/dist/src/fixtures/create-helia.browser.js +12 -2
- package/dist/src/fixtures/create-helia.browser.js.map +1 -1
- package/dist/src/fixtures/create-helia.d.ts.map +1 -1
- package/dist/src/fixtures/create-helia.js +12 -2
- package/dist/src/fixtures/create-helia.js.map +1 -1
- package/dist/src/libp2p.spec.d.ts +2 -0
- package/dist/src/libp2p.spec.d.ts.map +1 -0
- package/dist/src/libp2p.spec.js +80 -0
- package/dist/src/libp2p.spec.js.map +1 -0
- package/package.json +17 -15
- package/src/fixtures/create-helia.browser.ts +12 -2
- package/src/fixtures/create-helia.ts +12 -2
- package/src/libp2p.spec.ts +107 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia.browser.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-helia.browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-helia.browser.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-helia.browser.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,wBAAsB,eAAe,IAAK,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAA;AACzF,wBAAsB,eAAe,CAAE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,GAAG,qBAAqB,CAAC,CAAC,CAAA"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { withBitswap } from '@helia/bitswap';
|
|
2
2
|
import { libp2pDefaults, withLibp2p } from '@helia/libp2p';
|
|
3
|
+
import * as dagCbor from '@ipld/dag-cbor';
|
|
4
|
+
import * as dagJson from '@ipld/dag-json';
|
|
3
5
|
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht';
|
|
4
6
|
import { webSockets } from '@libp2p/websockets';
|
|
5
7
|
import { sha3512 } from '@multiformats/sha3';
|
|
6
|
-
import {
|
|
8
|
+
import { createHeliaLight } from 'helia';
|
|
9
|
+
import * as json from 'multiformats/codecs/json';
|
|
10
|
+
import { sha512 } from 'multiformats/hashes/sha2';
|
|
7
11
|
export async function createHeliaNode(libp2pOptions) {
|
|
8
12
|
const defaults = libp2pDefaults();
|
|
9
13
|
// allow dialing insecure WebSockets
|
|
@@ -37,8 +41,14 @@ export async function createHeliaNode(libp2pOptions) {
|
|
|
37
41
|
delete defaults.services.delegatedContentRouting;
|
|
38
42
|
// @ts-expect-error services.delegatedPeerRouting is not optional
|
|
39
43
|
delete defaults.services.delegatedPeerRouting;
|
|
40
|
-
return withBitswap(withLibp2p(
|
|
44
|
+
return withBitswap(withLibp2p(createHeliaLight({
|
|
45
|
+
codecs: [
|
|
46
|
+
dagCbor,
|
|
47
|
+
dagJson,
|
|
48
|
+
json
|
|
49
|
+
],
|
|
41
50
|
hashers: [
|
|
51
|
+
sha512,
|
|
42
52
|
sha3512
|
|
43
53
|
]
|
|
44
54
|
}), defaults)).start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia.browser.js","sourceRoot":"","sources":["../../../src/fixtures/create-helia.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAA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;YACV,QAAQ,EAAE,qBAAqB;YAC/B,cAAc,EAAE,2BAA2B;YAC3C,UAAU,EAAE,KAAK;SAClB,CAAC;KACH,CAAA;IAED,yBAAyB;IACzB,QAAQ,CAAC,aAAa,GAAG,EAAE,CAAA;IAE3B,6CAA6C;IAC7C,oDAAoD;IACpD,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAA;IAChC,kDAAkD;IAClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC9B,oEAAoE;IACpE,OAAO,QAAQ,CAAC,QAAQ,CAAC,uBAAuB,CAAA;IAChD,iEAAiE;IACjE,OAAO,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAA;IAE7C,OAAO,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC;QAC7C,MAAM,EAAE;YACN,OAAO;YACP,OAAO;YACP,IAAI;SACL;QACD,OAAO,EAAE;YACP,MAAM;YACN,OAAO;SACR;KACF,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-helia.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-helia.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-helia.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEhG,wBAAsB,eAAe,IAAK,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAA;AACzF,wBAAsB,eAAe,CAAE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,QAAQ,GAAG,qBAAqB,CAAC,CAAC,CAAA"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { withBitswap } from '@helia/bitswap';
|
|
2
2
|
import { withLibp2p, libp2pDefaults } from '@helia/libp2p';
|
|
3
|
+
import * as dagCbor from '@ipld/dag-cbor';
|
|
4
|
+
import * as dagJson from '@ipld/dag-json';
|
|
3
5
|
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht';
|
|
4
6
|
import { sha3512 } from '@multiformats/sha3';
|
|
5
|
-
import {
|
|
7
|
+
import { createHeliaLight } from 'helia';
|
|
8
|
+
import * as json from 'multiformats/codecs/json';
|
|
9
|
+
import { sha512 } from 'multiformats/hashes/sha2';
|
|
6
10
|
export async function createHeliaNode(libp2pOptions) {
|
|
7
11
|
const defaults = libp2pDefaults();
|
|
8
12
|
defaults.addresses = {
|
|
@@ -34,8 +38,14 @@ export async function createHeliaNode(libp2pOptions) {
|
|
|
34
38
|
delete defaults.services.delegatedPeerRouting;
|
|
35
39
|
// @ts-expect-error services.autoTLS is not optional
|
|
36
40
|
delete defaults.services.autoTLS;
|
|
37
|
-
return withBitswap(withLibp2p(
|
|
41
|
+
return withBitswap(withLibp2p(createHeliaLight({
|
|
42
|
+
codecs: [
|
|
43
|
+
dagCbor,
|
|
44
|
+
dagJson,
|
|
45
|
+
json
|
|
46
|
+
],
|
|
38
47
|
hashers: [
|
|
48
|
+
sha512,
|
|
39
49
|
sha3512
|
|
40
50
|
]
|
|
41
51
|
}), defaults)).start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia.js","sourceRoot":"","sources":["../../../src/fixtures/create-helia.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,O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AClD,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC9B,oEAAoE;IACpE,OAAO,QAAQ,CAAC,QAAQ,CAAC,uBAAuB,CAAA;IAChD,iEAAiE;IACjE,OAAO,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAA;IAC7C,oDAAoD;IACpD,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAA;IAEhC,OAAO,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC;QAC7C,MAAM,EAAE;YACN,OAAO;YACP,OAAO;YACP,IAAI;SACL;QACD,OAAO,EAAE;YACP,MAAM;YACN,OAAO;SACR;KACF,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libp2p.spec.d.ts","sourceRoot":"","sources":["../../src/libp2p.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { withLibp2p } from '@helia/libp2p';
|
|
2
|
+
import { identify } from '@libp2p/identify';
|
|
3
|
+
import { webSockets } from '@libp2p/websockets';
|
|
4
|
+
import { expect } from 'aegir/chai';
|
|
5
|
+
import { createHeliaLight } from 'helia';
|
|
6
|
+
import { createLibp2p, isLibp2p } from 'libp2p';
|
|
7
|
+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
8
|
+
describe('@helia/libp2p', () => {
|
|
9
|
+
let helia;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
helia = withLibp2p(createHeliaLight());
|
|
12
|
+
});
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
if (helia != null) {
|
|
15
|
+
await helia.stop();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
it('should add a libp2p property', async () => {
|
|
19
|
+
await helia.start();
|
|
20
|
+
expect(isLibp2p(helia.libp2p)).to.be.true();
|
|
21
|
+
});
|
|
22
|
+
it('should start libp2p', async () => {
|
|
23
|
+
await helia.start();
|
|
24
|
+
await helia.stop();
|
|
25
|
+
expect(helia.libp2p.status).to.equal('stopped');
|
|
26
|
+
await helia.start();
|
|
27
|
+
expect(helia.libp2p.status).to.equal('started');
|
|
28
|
+
});
|
|
29
|
+
it('should stop libp2p', async () => {
|
|
30
|
+
await helia.start();
|
|
31
|
+
expect(helia.libp2p.status).to.equal('started');
|
|
32
|
+
await helia.stop();
|
|
33
|
+
expect(helia.libp2p.status).to.equal('stopped');
|
|
34
|
+
});
|
|
35
|
+
it('does not add helia details to the AgentVersion when it has been overridden', async () => {
|
|
36
|
+
helia = await withLibp2p(createHeliaLight(), await createLibp2p({
|
|
37
|
+
nodeInfo: {
|
|
38
|
+
userAgent: 'my custom user agent'
|
|
39
|
+
},
|
|
40
|
+
transports: [
|
|
41
|
+
webSockets()
|
|
42
|
+
],
|
|
43
|
+
services: {
|
|
44
|
+
identify: identify()
|
|
45
|
+
}
|
|
46
|
+
})).start();
|
|
47
|
+
expect(helia).to.have.nested.property('libp2p.services.identify.host.agentVersion')
|
|
48
|
+
.that.does.not.include('helia/');
|
|
49
|
+
const peer = await helia.libp2p.peerStore.get(helia.libp2p.peerId);
|
|
50
|
+
const agentVersionBuf = peer.metadata.get('AgentVersion');
|
|
51
|
+
if (agentVersionBuf == null) {
|
|
52
|
+
throw new Error('AgentVersion not stored');
|
|
53
|
+
}
|
|
54
|
+
expect(agentVersionBuf).to.be.ok();
|
|
55
|
+
expect(uint8ArrayToString(agentVersionBuf)).to.not.include('helia/');
|
|
56
|
+
});
|
|
57
|
+
it('should have the same peer id after a restart', async () => {
|
|
58
|
+
await helia.start();
|
|
59
|
+
const datastore = helia.datastore;
|
|
60
|
+
const peerId = helia.libp2p.peerId;
|
|
61
|
+
await helia.stop();
|
|
62
|
+
helia = await withLibp2p(createHeliaLight({
|
|
63
|
+
datastore
|
|
64
|
+
}), {
|
|
65
|
+
datastore
|
|
66
|
+
}).start();
|
|
67
|
+
expect(helia.libp2p.peerId.toString()).to.equal(peerId.toString());
|
|
68
|
+
});
|
|
69
|
+
it('allows passing a libp2p node', async () => {
|
|
70
|
+
const libp2p = await createLibp2p();
|
|
71
|
+
helia = await withLibp2p(createHeliaLight(), libp2p).start();
|
|
72
|
+
expect(helia.libp2p).to.equal(libp2p);
|
|
73
|
+
});
|
|
74
|
+
it('adds helia details to the AgentVersion', async () => {
|
|
75
|
+
await helia.start();
|
|
76
|
+
expect(helia).to.have.nested.property('libp2p.services.identify.host.agentVersion')
|
|
77
|
+
.that.includes('helia/');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=libp2p.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libp2p.spec.js","sourceRoot":"","sources":["../../src/libp2p.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAGtE,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,KAA2B,CAAA;IAE/B,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QACpB,CAAC;IACH,CAAC,CAAC,CAA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,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAA;QAEnC,KAAK,GAAG,MAAM,UAAU,CAAC,gBAAgB,EAAE,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAA;QAE5D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;QAEnB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,4CAA4C,CAAC;aAChF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interop",
|
|
3
|
-
"version": "10.2.5-
|
|
3
|
+
"version": "10.2.5-16d805e1",
|
|
4
4
|
"description": "Interop tests for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/interop#readme",
|
|
@@ -51,23 +51,25 @@
|
|
|
51
51
|
"test:electron-main": "aegir test -t electron-main --cov -- --exit"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@helia/bitswap": "3.2.3-
|
|
55
|
-
"@helia/car": "5.4.2-
|
|
56
|
-
"@helia/dag-cbor": "5.1.1-
|
|
57
|
-
"@helia/dag-json": "5.1.1-
|
|
58
|
-
"@helia/delegated-routing-client": "0.0.0-
|
|
59
|
-
"@helia/dnslink": "1.2.1-
|
|
60
|
-
"@helia/interface": "6.2.1-
|
|
61
|
-
"@helia/ipns": "9.2.1-
|
|
62
|
-
"@helia/json": "5.1.1-
|
|
63
|
-
"@helia/libp2p": "0.0.0-
|
|
64
|
-
"@helia/mfs": "7.1.1-
|
|
65
|
-
"@helia/strings": "5.1.1-
|
|
66
|
-
"@helia/unixfs": "7.2.1-
|
|
54
|
+
"@helia/bitswap": "3.2.3-16d805e1",
|
|
55
|
+
"@helia/car": "5.4.2-16d805e1",
|
|
56
|
+
"@helia/dag-cbor": "5.1.1-16d805e1",
|
|
57
|
+
"@helia/dag-json": "5.1.1-16d805e1",
|
|
58
|
+
"@helia/delegated-routing-client": "0.0.0-16d805e1",
|
|
59
|
+
"@helia/dnslink": "1.2.1-16d805e1",
|
|
60
|
+
"@helia/interface": "6.2.1-16d805e1",
|
|
61
|
+
"@helia/ipns": "9.2.1-16d805e1",
|
|
62
|
+
"@helia/json": "5.1.1-16d805e1",
|
|
63
|
+
"@helia/libp2p": "0.0.0-16d805e1",
|
|
64
|
+
"@helia/mfs": "7.1.1-16d805e1",
|
|
65
|
+
"@helia/strings": "5.1.1-16d805e1",
|
|
66
|
+
"@helia/unixfs": "7.2.1-16d805e1",
|
|
67
67
|
"@ipld/car": "^5.4.6",
|
|
68
68
|
"@ipld/dag-cbor": "^10.0.1",
|
|
69
|
+
"@ipld/dag-json": "^11.0.0",
|
|
69
70
|
"@ipld/dag-pb": "^4.1.7",
|
|
70
71
|
"@libp2p/floodsub": "^11.0.23",
|
|
72
|
+
"@libp2p/identify": "^4.1.8",
|
|
71
73
|
"@libp2p/interface": "^3.2.3",
|
|
72
74
|
"@libp2p/kad-dht": "^16.3.2",
|
|
73
75
|
"@libp2p/keychain": "^6.1.2",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"@multiformats/multiaddr": "^13.0.3",
|
|
78
80
|
"@multiformats/sha3": "^4.0.0",
|
|
79
81
|
"aegir": "^48.0.11",
|
|
80
|
-
"helia": "6.1.4-
|
|
82
|
+
"helia": "6.1.4-16d805e1",
|
|
81
83
|
"ipfs-unixfs-importer": "^17.0.1",
|
|
82
84
|
"ipfsd-ctl": "^17.0.0",
|
|
83
85
|
"it-all": "^3.0.11",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { withBitswap } from '@helia/bitswap'
|
|
2
2
|
import { libp2pDefaults, withLibp2p } from '@helia/libp2p'
|
|
3
|
+
import * as dagCbor from '@ipld/dag-cbor'
|
|
4
|
+
import * as dagJson from '@ipld/dag-json'
|
|
3
5
|
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
|
|
4
6
|
import { webSockets } from '@libp2p/websockets'
|
|
5
7
|
import { sha3512 } from '@multiformats/sha3'
|
|
6
|
-
import {
|
|
8
|
+
import { createHeliaLight } from 'helia'
|
|
9
|
+
import * as json from 'multiformats/codecs/json'
|
|
10
|
+
import { sha512 } from 'multiformats/hashes/sha2'
|
|
7
11
|
import type { DefaultLibp2pServices, HeliaWithLibp2p } from '@helia/libp2p'
|
|
8
12
|
import type { Libp2pOptions } from 'libp2p'
|
|
9
13
|
|
|
@@ -48,8 +52,14 @@ export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<H
|
|
|
48
52
|
// @ts-expect-error services.delegatedPeerRouting is not optional
|
|
49
53
|
delete defaults.services.delegatedPeerRouting
|
|
50
54
|
|
|
51
|
-
return withBitswap(withLibp2p(
|
|
55
|
+
return withBitswap(withLibp2p(createHeliaLight({
|
|
56
|
+
codecs: [
|
|
57
|
+
dagCbor,
|
|
58
|
+
dagJson,
|
|
59
|
+
json
|
|
60
|
+
],
|
|
52
61
|
hashers: [
|
|
62
|
+
sha512,
|
|
53
63
|
sha3512
|
|
54
64
|
]
|
|
55
65
|
}), defaults)).start()
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { withBitswap } from '@helia/bitswap'
|
|
2
2
|
import { withLibp2p, libp2pDefaults } from '@helia/libp2p'
|
|
3
|
+
import * as dagCbor from '@ipld/dag-cbor'
|
|
4
|
+
import * as dagJson from '@ipld/dag-json'
|
|
3
5
|
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
|
|
4
6
|
import { sha3512 } from '@multiformats/sha3'
|
|
5
|
-
import {
|
|
7
|
+
import { createHeliaLight } from 'helia'
|
|
8
|
+
import * as json from 'multiformats/codecs/json'
|
|
9
|
+
import { sha512 } from 'multiformats/hashes/sha2'
|
|
6
10
|
import type { HeliaWithLibp2p, DefaultLibp2pServices, CreateLibp2pOptions } from '@helia/libp2p'
|
|
7
11
|
|
|
8
12
|
export async function createHeliaNode (): Promise<HeliaWithLibp2p<DefaultLibp2pServices>>
|
|
@@ -41,8 +45,14 @@ export async function createHeliaNode (libp2pOptions?: CreateLibp2pOptions<any>)
|
|
|
41
45
|
// @ts-expect-error services.autoTLS is not optional
|
|
42
46
|
delete defaults.services.autoTLS
|
|
43
47
|
|
|
44
|
-
return withBitswap(withLibp2p(
|
|
48
|
+
return withBitswap(withLibp2p(createHeliaLight({
|
|
49
|
+
codecs: [
|
|
50
|
+
dagCbor,
|
|
51
|
+
dagJson,
|
|
52
|
+
json
|
|
53
|
+
],
|
|
45
54
|
hashers: [
|
|
55
|
+
sha512,
|
|
46
56
|
sha3512
|
|
47
57
|
]
|
|
48
58
|
}), defaults)).start()
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { withLibp2p } from '@helia/libp2p'
|
|
2
|
+
import { identify } from '@libp2p/identify'
|
|
3
|
+
import { webSockets } from '@libp2p/websockets'
|
|
4
|
+
import { expect } from 'aegir/chai'
|
|
5
|
+
import { createHeliaLight } from 'helia'
|
|
6
|
+
import { createLibp2p, isLibp2p } from 'libp2p'
|
|
7
|
+
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
8
|
+
import type { HeliaWithLibp2p } from '@helia/libp2p'
|
|
9
|
+
|
|
10
|
+
describe('@helia/libp2p', () => {
|
|
11
|
+
let helia: HeliaWithLibp2p<any>
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
helia = withLibp2p(createHeliaLight())
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
if (helia != null) {
|
|
19
|
+
await helia.stop()
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should add a libp2p property', async () => {
|
|
24
|
+
await helia.start()
|
|
25
|
+
expect(isLibp2p(helia.libp2p)).to.be.true()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should start libp2p', async () => {
|
|
29
|
+
await helia.start()
|
|
30
|
+
await helia.stop()
|
|
31
|
+
|
|
32
|
+
expect(helia.libp2p.status).to.equal('stopped')
|
|
33
|
+
|
|
34
|
+
await helia.start()
|
|
35
|
+
|
|
36
|
+
expect(helia.libp2p.status).to.equal('started')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should stop libp2p', async () => {
|
|
40
|
+
await helia.start()
|
|
41
|
+
|
|
42
|
+
expect(helia.libp2p.status).to.equal('started')
|
|
43
|
+
|
|
44
|
+
await helia.stop()
|
|
45
|
+
|
|
46
|
+
expect(helia.libp2p.status).to.equal('stopped')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('does not add helia details to the AgentVersion when it has been overridden', async () => {
|
|
50
|
+
helia = await withLibp2p(createHeliaLight(), await createLibp2p({
|
|
51
|
+
nodeInfo: {
|
|
52
|
+
userAgent: 'my custom user agent'
|
|
53
|
+
},
|
|
54
|
+
transports: [
|
|
55
|
+
webSockets()
|
|
56
|
+
],
|
|
57
|
+
services: {
|
|
58
|
+
identify: identify()
|
|
59
|
+
}
|
|
60
|
+
})).start()
|
|
61
|
+
|
|
62
|
+
expect(helia).to.have.nested.property('libp2p.services.identify.host.agentVersion')
|
|
63
|
+
.that.does.not.include('helia/')
|
|
64
|
+
|
|
65
|
+
const peer = await helia.libp2p.peerStore.get(helia.libp2p.peerId)
|
|
66
|
+
const agentVersionBuf = peer.metadata.get('AgentVersion')
|
|
67
|
+
|
|
68
|
+
if (agentVersionBuf == null) {
|
|
69
|
+
throw new Error('AgentVersion not stored')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
expect(agentVersionBuf).to.be.ok()
|
|
73
|
+
expect(uint8ArrayToString(agentVersionBuf)).to.not.include('helia/')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should have the same peer id after a restart', async () => {
|
|
77
|
+
await helia.start()
|
|
78
|
+
|
|
79
|
+
const datastore = helia.datastore
|
|
80
|
+
const peerId = helia.libp2p.peerId
|
|
81
|
+
|
|
82
|
+
await helia.stop()
|
|
83
|
+
|
|
84
|
+
helia = await withLibp2p(createHeliaLight({
|
|
85
|
+
datastore
|
|
86
|
+
}), {
|
|
87
|
+
datastore
|
|
88
|
+
}).start()
|
|
89
|
+
|
|
90
|
+
expect(helia.libp2p.peerId.toString()).to.equal(peerId.toString())
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('allows passing a libp2p node', async () => {
|
|
94
|
+
const libp2p = await createLibp2p()
|
|
95
|
+
|
|
96
|
+
helia = await withLibp2p(createHeliaLight(), libp2p).start()
|
|
97
|
+
|
|
98
|
+
expect(helia.libp2p).to.equal(libp2p)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('adds helia details to the AgentVersion', async () => {
|
|
102
|
+
await helia.start()
|
|
103
|
+
|
|
104
|
+
expect(helia).to.have.nested.property('libp2p.services.identify.host.agentVersion')
|
|
105
|
+
.that.includes('helia/')
|
|
106
|
+
})
|
|
107
|
+
})
|