@helia/interop 8.2.0 → 8.3.0-061f3cdb
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/car.spec.js +1 -4
- package/dist/src/car.spec.js.map +1 -1
- package/dist/src/dnslink.spec.d.ts +2 -0
- package/dist/src/dnslink.spec.d.ts.map +1 -0
- package/dist/src/{ipns-dnslink.spec.js → dnslink.spec.js} +5 -5
- package/dist/src/dnslink.spec.js.map +1 -0
- package/dist/src/fixtures/create-helia.browser.d.ts.map +1 -1
- package/dist/src/fixtures/create-helia.browser.js +1 -4
- package/dist/src/fixtures/create-helia.browser.js.map +1 -1
- package/dist/src/helia-blockstore-sessions.spec.js +3 -2
- package/dist/src/helia-blockstore-sessions.spec.js.map +1 -1
- package/dist/src/helia-blockstore.spec.js +1 -1
- package/dist/src/helia-blockstore.spec.js.map +1 -1
- package/dist/src/helia-hashes.spec.js +1 -1
- package/dist/src/helia-hashes.spec.js.map +1 -1
- package/dist/src/ipns-pubsub.spec.js +5 -3
- package/dist/src/ipns-pubsub.spec.js.map +1 -1
- package/dist/src/ipns.spec.js +3 -1
- package/dist/src/ipns.spec.js.map +1 -1
- package/dist/src/providers.spec.d.ts +2 -0
- package/dist/src/providers.spec.d.ts.map +1 -0
- package/dist/src/providers.spec.js +193 -0
- package/dist/src/providers.spec.js.map +1 -0
- package/dist/src/unixfs-files.spec.js +2 -1
- package/dist/src/unixfs-files.spec.js.map +1 -1
- package/package.json +39 -45
- package/src/car.spec.ts +1 -5
- package/src/{ipns-dnslink.spec.ts → dnslink.spec.ts} +6 -6
- package/src/fixtures/create-helia.browser.ts +1 -4
- package/src/helia-blockstore-sessions.spec.ts +3 -2
- package/src/helia-blockstore.spec.ts +1 -1
- package/src/helia-hashes.spec.ts +1 -1
- package/src/ipns-pubsub.spec.ts +7 -4
- package/src/ipns.spec.ts +3 -2
- package/src/providers.spec.ts +231 -0
- package/src/unixfs-files.spec.ts +2 -1
- package/dist/src/fixtures/memory-car.d.ts +0 -7
- package/dist/src/fixtures/memory-car.d.ts.map +0 -1
- package/dist/src/fixtures/memory-car.js +0 -26
- package/dist/src/fixtures/memory-car.js.map +0 -1
- package/dist/src/ipns-dnslink.spec.d.ts +0 -2
- package/dist/src/ipns-dnslink.spec.d.ts.map +0 -1
- package/dist/src/ipns-dnslink.spec.js.map +0 -1
- package/src/fixtures/memory-car.ts +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interop",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0-061f3cdb",
|
|
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",
|
|
@@ -36,13 +36,6 @@
|
|
|
36
36
|
"import": "./dist/src/index.js"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"eslintConfig": {
|
|
40
|
-
"extends": "ipfs",
|
|
41
|
-
"parserOptions": {
|
|
42
|
-
"project": true,
|
|
43
|
-
"sourceType": "module"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
39
|
"scripts": {
|
|
47
40
|
"clean": "aegir clean",
|
|
48
41
|
"lint": "aegir lint",
|
|
@@ -58,45 +51,46 @@
|
|
|
58
51
|
"test:electron-main": "aegir test -t electron-main"
|
|
59
52
|
},
|
|
60
53
|
"dependencies": {
|
|
61
|
-
"@
|
|
62
|
-
"@helia/
|
|
63
|
-
"@helia/car": "
|
|
64
|
-
"@helia/dag-cbor": "
|
|
65
|
-
"@helia/dag-json": "
|
|
66
|
-
"@helia/http": "
|
|
67
|
-
"@helia/interface": "
|
|
68
|
-
"@helia/ipns": "
|
|
69
|
-
"@helia/json": "
|
|
70
|
-
"@helia/mfs": "
|
|
71
|
-
"@helia/routers": "
|
|
72
|
-
"@helia/strings": "
|
|
73
|
-
"@helia/unixfs": "
|
|
74
|
-
"@ipld/car": "^5.
|
|
75
|
-
"@ipld/dag-cbor": "^9.2.
|
|
76
|
-
"@ipld/dag-pb": "^4.1.
|
|
77
|
-
"@libp2p/crypto": "^5.
|
|
78
|
-
"@libp2p/
|
|
79
|
-
"@libp2p/
|
|
80
|
-
"@libp2p/
|
|
81
|
-
"@libp2p/
|
|
82
|
-
"@libp2p/
|
|
83
|
-
"@
|
|
54
|
+
"@helia/block-brokers": "4.2.4-061f3cdb",
|
|
55
|
+
"@helia/dnslink": "0.0.0-061f3cdb",
|
|
56
|
+
"@helia/car": "4.2.0-061f3cdb",
|
|
57
|
+
"@helia/dag-cbor": "4.1.0-061f3cdb",
|
|
58
|
+
"@helia/dag-json": "4.1.0-061f3cdb",
|
|
59
|
+
"@helia/http": "2.2.1-061f3cdb",
|
|
60
|
+
"@helia/interface": "5.4.0-061f3cdb",
|
|
61
|
+
"@helia/ipns": "8.2.4-061f3cdb",
|
|
62
|
+
"@helia/json": "4.0.7-061f3cdb",
|
|
63
|
+
"@helia/mfs": "5.1.0-061f3cdb",
|
|
64
|
+
"@helia/routers": "3.1.3-061f3cdb",
|
|
65
|
+
"@helia/strings": "4.1.0-061f3cdb",
|
|
66
|
+
"@helia/unixfs": "5.1.0-061f3cdb",
|
|
67
|
+
"@ipld/car": "^5.4.2",
|
|
68
|
+
"@ipld/dag-cbor": "^9.2.5",
|
|
69
|
+
"@ipld/dag-pb": "^4.1.5",
|
|
70
|
+
"@libp2p/crypto": "^5.1.12",
|
|
71
|
+
"@libp2p/floodsub": "^11.0.6",
|
|
72
|
+
"@libp2p/interface": "^3.0.2",
|
|
73
|
+
"@libp2p/kad-dht": "^16.0.5",
|
|
74
|
+
"@libp2p/keychain": "^6.0.5",
|
|
75
|
+
"@libp2p/peer-id": "^6.0.3",
|
|
76
|
+
"@libp2p/utils": "^7.0.5",
|
|
77
|
+
"@libp2p/websockets": "^10.0.6",
|
|
78
|
+
"@multiformats/multiaddr": "^13.0.1",
|
|
84
79
|
"@multiformats/sha3": "^3.0.2",
|
|
85
|
-
"aegir": "^47.0.
|
|
86
|
-
"helia": "
|
|
87
|
-
"ipfs-unixfs-importer": "^
|
|
80
|
+
"aegir": "^47.0.22",
|
|
81
|
+
"helia": "5.5.1-061f3cdb",
|
|
82
|
+
"ipfs-unixfs-importer": "^16.0.1",
|
|
88
83
|
"ipfsd-ctl": "^15.0.2",
|
|
89
|
-
"ipns": "^10.
|
|
90
|
-
"it-all": "^3.0.
|
|
91
|
-
"it-drain": "^3.0.
|
|
92
|
-
"it-last": "^3.0.
|
|
93
|
-
"it-map": "^3.1.
|
|
94
|
-
"it-to-buffer": "^4.0.
|
|
95
|
-
"kubo": "^0.
|
|
96
|
-
"kubo-rpc-client": "^5.0
|
|
97
|
-
"libp2p": "^
|
|
98
|
-
"multiformats": "^13.
|
|
99
|
-
"p-defer": "^4.0.1",
|
|
84
|
+
"ipns": "^10.1.2",
|
|
85
|
+
"it-all": "^3.0.9",
|
|
86
|
+
"it-drain": "^3.0.10",
|
|
87
|
+
"it-last": "^3.0.9",
|
|
88
|
+
"it-map": "^3.1.4",
|
|
89
|
+
"it-to-buffer": "^4.0.10",
|
|
90
|
+
"kubo": "^0.38.0",
|
|
91
|
+
"kubo-rpc-client": "^5.4.0",
|
|
92
|
+
"libp2p": "^3.0.6",
|
|
93
|
+
"multiformats": "^13.4.1",
|
|
100
94
|
"uint8arrays": "^5.1.0",
|
|
101
95
|
"wherearewe": "^2.0.1"
|
|
102
96
|
},
|
package/src/car.spec.ts
CHANGED
|
@@ -9,7 +9,6 @@ import toBuffer from 'it-to-buffer'
|
|
|
9
9
|
import { CID } from 'multiformats/cid'
|
|
10
10
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
11
11
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
12
|
-
import { memoryCarWriter } from './fixtures/memory-car.js'
|
|
13
12
|
import type { Car } from '@helia/car'
|
|
14
13
|
import type { UnixFS } from '@helia/unixfs'
|
|
15
14
|
import type { Helia } from 'helia'
|
|
@@ -57,10 +56,7 @@ describe('@helia/car', () => {
|
|
|
57
56
|
}())
|
|
58
57
|
|
|
59
58
|
const cid = await u.addByteStream(bytes)
|
|
60
|
-
const
|
|
61
|
-
await c.export(cid, writer)
|
|
62
|
-
|
|
63
|
-
const buf = await writer.bytes()
|
|
59
|
+
const buf = await toBuffer(c.export(cid))
|
|
64
60
|
|
|
65
61
|
await drain(kubo.api.dag.import([buf]))
|
|
66
62
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-env mocha */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { dnsLink } from '@helia/dnslink'
|
|
4
4
|
import { expect } from 'aegir/chai'
|
|
5
5
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
6
|
-
import type {
|
|
6
|
+
import type { DNSLink } from '@helia/dnslink'
|
|
7
7
|
import type { DefaultLibp2pServices, Helia } from 'helia'
|
|
8
8
|
import type { Libp2p } from 'libp2p'
|
|
9
9
|
|
|
@@ -13,13 +13,13 @@ const TEST_DOMAINS: string[] = [
|
|
|
13
13
|
'en.wikipedia-on-ipfs.org'
|
|
14
14
|
]
|
|
15
15
|
|
|
16
|
-
describe('@helia/
|
|
16
|
+
describe('@helia/dnslink', () => {
|
|
17
17
|
let helia: Helia<Libp2p<DefaultLibp2pServices>>
|
|
18
|
-
let name:
|
|
18
|
+
let name: DNSLink
|
|
19
19
|
|
|
20
20
|
beforeEach(async () => {
|
|
21
21
|
helia = await createHeliaNode()
|
|
22
|
-
name =
|
|
22
|
+
name = dnsLink(helia)
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
afterEach(async () => {
|
|
@@ -30,7 +30,7 @@ describe('@helia/ipns - dnslink', () => {
|
|
|
30
30
|
|
|
31
31
|
TEST_DOMAINS.forEach(domain => {
|
|
32
32
|
it(`should resolve ${domain}`, async () => {
|
|
33
|
-
const result = await name.
|
|
33
|
+
const result = await name.resolve(domain)
|
|
34
34
|
|
|
35
35
|
expect(result).to.have.property('cid')
|
|
36
36
|
}).retries(5)
|
|
@@ -2,7 +2,6 @@ import { bitswap } from '@helia/block-brokers'
|
|
|
2
2
|
import { ipnsValidator, ipnsSelector } from '@helia/ipns'
|
|
3
3
|
import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
|
|
4
4
|
import { webSockets } from '@libp2p/websockets'
|
|
5
|
-
import { all } from '@libp2p/websockets/filters'
|
|
6
5
|
import { sha3512 } from '@multiformats/sha3'
|
|
7
6
|
import { createHelia, libp2pDefaults } from 'helia'
|
|
8
7
|
import type { Libp2p } from '@libp2p/interface'
|
|
@@ -18,9 +17,7 @@ export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<H
|
|
|
18
17
|
defaults.transports?.pop()
|
|
19
18
|
defaults.transports = [
|
|
20
19
|
...(defaults.transports ?? []),
|
|
21
|
-
webSockets(
|
|
22
|
-
filter: all
|
|
23
|
-
})
|
|
20
|
+
webSockets()
|
|
24
21
|
]
|
|
25
22
|
|
|
26
23
|
// allow dialing loopback
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
4
4
|
import { expect } from 'aegir/chai'
|
|
5
|
+
import toBuffer from 'it-to-buffer'
|
|
5
6
|
import { CID } from 'multiformats/cid'
|
|
6
7
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
7
8
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
@@ -38,7 +39,7 @@ describe('helia - blockstore sessions', () => {
|
|
|
38
39
|
|
|
39
40
|
await helia.libp2p.dial(kuboInfo.multiaddrs.map(str => multiaddr(str)))
|
|
40
41
|
|
|
41
|
-
const output = await helia.blockstore.get(CID.parse(cid.toString()))
|
|
42
|
+
const output = await toBuffer(helia.blockstore.get(CID.parse(cid.toString())))
|
|
42
43
|
|
|
43
44
|
expect(output).to.equalBytes(input)
|
|
44
45
|
})
|
|
@@ -57,7 +58,7 @@ describe('helia - blockstore sessions', () => {
|
|
|
57
58
|
]
|
|
58
59
|
})
|
|
59
60
|
|
|
60
|
-
const output = await session.get(root)
|
|
61
|
+
const output = await toBuffer(session.get(root))
|
|
61
62
|
|
|
62
63
|
expect(output).to.equalBytes(input)
|
|
63
64
|
})
|
|
@@ -51,7 +51,7 @@ describe('helia - blockstore', () => {
|
|
|
51
51
|
cidVersion: 1,
|
|
52
52
|
rawLeaves: true
|
|
53
53
|
})
|
|
54
|
-
const output = await helia.blockstore.get(CID.parse(cid.toString()))
|
|
54
|
+
const output = await toBuffer(helia.blockstore.get(CID.parse(cid.toString())))
|
|
55
55
|
|
|
56
56
|
expect(output).to.equalBytes(input)
|
|
57
57
|
})
|
package/src/helia-hashes.spec.ts
CHANGED
|
@@ -50,7 +50,7 @@ describe('helia - hashes', () => {
|
|
|
50
50
|
hashAlg: 'sha3-512'
|
|
51
51
|
})
|
|
52
52
|
expect(cid.multihash.code).to.equal(sha3512.code)
|
|
53
|
-
const output = await helia.blockstore.get(CID.parse(cid.toString()))
|
|
53
|
+
const output = await toBuffer(helia.blockstore.get(CID.parse(cid.toString())))
|
|
54
54
|
|
|
55
55
|
expect(output).to.equalBytes(input)
|
|
56
56
|
})
|
package/src/ipns-pubsub.spec.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-env mocha */
|
|
2
2
|
/* eslint max-nested-callbacks: ["error", 5] */
|
|
3
3
|
|
|
4
|
-
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
5
4
|
import { ipns } from '@helia/ipns'
|
|
6
5
|
import { pubsub } from '@helia/ipns/routing'
|
|
7
6
|
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
7
|
+
import { floodsub } from '@libp2p/floodsub'
|
|
8
8
|
import { peerIdFromCID } from '@libp2p/peer-id'
|
|
9
9
|
import { expect } from 'aegir/chai'
|
|
10
10
|
import last from 'it-last'
|
|
@@ -23,7 +23,8 @@ import { createKuboNode } from './fixtures/create-kubo.js'
|
|
|
23
23
|
import { keyTypes } from './fixtures/key-types.js'
|
|
24
24
|
import { waitFor } from './fixtures/wait-for.js'
|
|
25
25
|
import type { IPNS, ResolveResult } from '@helia/ipns'
|
|
26
|
-
import type {
|
|
26
|
+
import type { PubSub } from '@helia/ipns/routing'
|
|
27
|
+
import type { Libp2p } from '@libp2p/interface'
|
|
27
28
|
import type { Keychain } from '@libp2p/keychain'
|
|
28
29
|
import type { Helia } from 'helia'
|
|
29
30
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
@@ -40,7 +41,7 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => {
|
|
|
40
41
|
beforeEach(async () => {
|
|
41
42
|
helia = await createHeliaNode({
|
|
42
43
|
services: {
|
|
43
|
-
pubsub:
|
|
44
|
+
pubsub: floodsub()
|
|
44
45
|
}
|
|
45
46
|
})
|
|
46
47
|
kubo = await createKuboNode()
|
|
@@ -71,6 +72,8 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => {
|
|
|
71
72
|
const cid = CID.createV1(raw.code, digest)
|
|
72
73
|
|
|
73
74
|
const privateKey = await generateKeyPair('Ed25519')
|
|
75
|
+
const keyName = 'my-ipns-key'
|
|
76
|
+
await helia.libp2p.services.keychain.importKey(keyName, privateKey)
|
|
74
77
|
|
|
75
78
|
// first call to pubsub resolver will fail but we should trigger
|
|
76
79
|
// subscribing pubsub for updates
|
|
@@ -103,7 +106,7 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => {
|
|
|
103
106
|
})
|
|
104
107
|
|
|
105
108
|
// publish should now succeed
|
|
106
|
-
await name.publish(
|
|
109
|
+
await name.publish(keyName, cid)
|
|
107
110
|
|
|
108
111
|
// kubo should now be able to resolve IPNS name instantly
|
|
109
112
|
const resolved = await last(kubo.api.name.resolve(privateKey.publicKey.toString(), {
|
package/src/ipns.spec.ts
CHANGED
|
@@ -125,8 +125,9 @@ keyTypes.forEach(type => {
|
|
|
125
125
|
await createNodes('kubo')
|
|
126
126
|
|
|
127
127
|
const privateKey = await generateKeyPair('Ed25519')
|
|
128
|
-
|
|
129
|
-
await
|
|
128
|
+
const keyName = 'my-ipns-key'
|
|
129
|
+
await helia.libp2p.services.keychain.importKey(keyName, privateKey)
|
|
130
|
+
await name.publish(keyName, value)
|
|
130
131
|
|
|
131
132
|
const resolved = await last(kubo.api.name.resolve(privateKey.publicKey.toString()))
|
|
132
133
|
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import { car } from '@helia/car'
|
|
4
|
+
import { dagCbor } from '@helia/dag-cbor'
|
|
5
|
+
import { dagJson } from '@helia/dag-json'
|
|
6
|
+
import { mfs } from '@helia/mfs'
|
|
7
|
+
import { strings } from '@helia/strings'
|
|
8
|
+
import { unixfs } from '@helia/unixfs'
|
|
9
|
+
import { peerIdFromString } from '@libp2p/peer-id'
|
|
10
|
+
import { createScalableCuckooFilter } from '@libp2p/utils'
|
|
11
|
+
import { expect } from 'aegir/chai'
|
|
12
|
+
import drain from 'it-drain'
|
|
13
|
+
import toBuffer from 'it-to-buffer'
|
|
14
|
+
import { multiaddr } from 'kubo-rpc-client'
|
|
15
|
+
import { CID } from 'multiformats/cid'
|
|
16
|
+
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
17
|
+
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
18
|
+
import type { PeerId } from '@libp2p/interface'
|
|
19
|
+
import type { Helia } from 'helia'
|
|
20
|
+
import type { FileCandidate } from 'ipfs-unixfs-importer'
|
|
21
|
+
import type { KuboInfo, KuboNode } from 'ipfsd-ctl'
|
|
22
|
+
|
|
23
|
+
describe('providers', () => {
|
|
24
|
+
let helia: Helia
|
|
25
|
+
let kubo: KuboNode
|
|
26
|
+
let cid: CID
|
|
27
|
+
let kuboInfo: KuboInfo
|
|
28
|
+
let input: Uint8Array[]
|
|
29
|
+
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
// helia and kubo are not connected together before the test
|
|
32
|
+
helia = await createHeliaNode()
|
|
33
|
+
kubo = await createKuboNode()
|
|
34
|
+
|
|
35
|
+
const chunkSize = 1024 * 1024
|
|
36
|
+
const size = chunkSize * 10
|
|
37
|
+
input = []
|
|
38
|
+
|
|
39
|
+
const candidate: FileCandidate = {
|
|
40
|
+
content: (async function * () {
|
|
41
|
+
for (let i = 0; i < size; i += chunkSize) {
|
|
42
|
+
const buf = new Uint8Array(chunkSize)
|
|
43
|
+
input.push(buf)
|
|
44
|
+
|
|
45
|
+
yield buf
|
|
46
|
+
}
|
|
47
|
+
}())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const importResult = await kubo.api.add(candidate.content)
|
|
51
|
+
cid = CID.parse(importResult.cid.toString())
|
|
52
|
+
kuboInfo = await kubo.info()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
afterEach(async () => {
|
|
56
|
+
if (helia != null) {
|
|
57
|
+
await helia.stop()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (kubo != null) {
|
|
61
|
+
await kubo.stop()
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should fail to fetch without using a provider', async () => {
|
|
66
|
+
await expect(drain(helia.blockstore.get(cid, {
|
|
67
|
+
signal: AbortSignal.timeout(100)
|
|
68
|
+
}))).to.eventually.be.rejected()
|
|
69
|
+
.with.nested.property('errors[0].name', 'AbortError')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should fetch raw using a provider', async () => {
|
|
73
|
+
let sender: PeerId | undefined
|
|
74
|
+
|
|
75
|
+
const buf = await toBuffer(helia.blockstore.get(cid, {
|
|
76
|
+
providers: [
|
|
77
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
78
|
+
],
|
|
79
|
+
onProgress (evt) {
|
|
80
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
81
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
82
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
83
|
+
sender = evt.detail.sender
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}))
|
|
87
|
+
|
|
88
|
+
expect(buf).to.have.lengthOf(1930)
|
|
89
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('should fetch dag-cbor using a provider', async () => {
|
|
93
|
+
let sender: PeerId | undefined
|
|
94
|
+
const obj = { hello: 'world' }
|
|
95
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
96
|
+
storeCodec: 'dag-cbor'
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const d = dagCbor(helia)
|
|
100
|
+
|
|
101
|
+
await expect(d.get(cid, {
|
|
102
|
+
providers: [
|
|
103
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
104
|
+
],
|
|
105
|
+
onProgress (evt) {
|
|
106
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
107
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
108
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
109
|
+
sender = evt.detail.sender
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})).to.eventually.deep.equal(obj)
|
|
113
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('should fetch dag-json using a provider', async () => {
|
|
117
|
+
let sender: PeerId | undefined
|
|
118
|
+
const obj = { hello: 'world' }
|
|
119
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
120
|
+
storeCodec: 'dag-json'
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const d = dagJson(helia)
|
|
124
|
+
|
|
125
|
+
await expect(d.get(cid, {
|
|
126
|
+
providers: [
|
|
127
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
128
|
+
],
|
|
129
|
+
onProgress (evt) {
|
|
130
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
131
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
132
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
133
|
+
sender = evt.detail.sender
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})).to.eventually.deep.equal(obj)
|
|
137
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('should fetch string using a provider', async () => {
|
|
141
|
+
let sender: PeerId | undefined
|
|
142
|
+
const obj = 'hello world'
|
|
143
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
144
|
+
storeCodec: 'dag-json'
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const s = strings(helia)
|
|
148
|
+
|
|
149
|
+
await expect(s.get(cid, {
|
|
150
|
+
providers: [
|
|
151
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
152
|
+
],
|
|
153
|
+
onProgress (evt) {
|
|
154
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
155
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
156
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
157
|
+
sender = evt.detail.sender
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
})).to.eventually.equal(JSON.stringify(obj))
|
|
161
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should fetch via unixfs using a provider', async () => {
|
|
165
|
+
let sender: PeerId | undefined
|
|
166
|
+
const fs = unixfs(helia)
|
|
167
|
+
|
|
168
|
+
const bytes = await toBuffer(fs.cat(cid, {
|
|
169
|
+
providers: [
|
|
170
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
171
|
+
],
|
|
172
|
+
onProgress (evt) {
|
|
173
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
174
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
175
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
176
|
+
sender = evt.detail.sender
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}))
|
|
180
|
+
|
|
181
|
+
expect(bytes).to.equalBytes(toBuffer(input))
|
|
182
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should fetch via mfs using a provider', async () => {
|
|
186
|
+
let sender: PeerId | undefined
|
|
187
|
+
const fs = mfs(helia)
|
|
188
|
+
|
|
189
|
+
await fs.cp(cid, '/file.txt', {
|
|
190
|
+
providers: [
|
|
191
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
192
|
+
],
|
|
193
|
+
onProgress (evt) {
|
|
194
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
195
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
196
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
197
|
+
sender = evt.detail.sender
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
const bytes = await toBuffer(fs.cat('/file.txt'))
|
|
203
|
+
|
|
204
|
+
expect(bytes).to.equalBytes(toBuffer(input))
|
|
205
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('should fetch via car using a provider', async () => {
|
|
209
|
+
let sender: PeerId | undefined
|
|
210
|
+
const c = car(helia)
|
|
211
|
+
|
|
212
|
+
expect(await toBuffer(
|
|
213
|
+
c.export(cid, {
|
|
214
|
+
providers: [
|
|
215
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
216
|
+
],
|
|
217
|
+
blockFilter: createScalableCuckooFilter(10),
|
|
218
|
+
onProgress (evt) {
|
|
219
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
220
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
221
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
222
|
+
sender = evt.detail.sender
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}))
|
|
226
|
+
).to.equalBytes(await toBuffer(
|
|
227
|
+
kubo.api.dag.export(cid)
|
|
228
|
+
))
|
|
229
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
230
|
+
})
|
|
231
|
+
})
|
package/src/unixfs-files.spec.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { fixedSize } from 'ipfs-unixfs-importer/chunker'
|
|
|
8
8
|
import { balanced } from 'ipfs-unixfs-importer/layout'
|
|
9
9
|
import drain from 'it-drain'
|
|
10
10
|
import last from 'it-last'
|
|
11
|
+
import toBuffer from 'it-to-buffer'
|
|
11
12
|
import { CID } from 'multiformats/cid'
|
|
12
13
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
13
14
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
@@ -167,7 +168,7 @@ describe('@helia/unixfs - files', () => {
|
|
|
167
168
|
await drain(unixFs.cat(largeFileCid))
|
|
168
169
|
|
|
169
170
|
// check the root block
|
|
170
|
-
const block = await helia.blockstore.get(largeFileCid)
|
|
171
|
+
const block = await toBuffer(helia.blockstore.get(largeFileCid))
|
|
171
172
|
const node = dagPb.decode(block)
|
|
172
173
|
|
|
173
174
|
expect(node.Links).to.have.lengthOf(40)
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CarWriter } from '@ipld/car';
|
|
2
|
-
import type { CID } from 'multiformats/cid';
|
|
3
|
-
export interface MemoryCar extends Pick<CarWriter, 'put' | 'close'> {
|
|
4
|
-
bytes(): Promise<Uint8Array>;
|
|
5
|
-
}
|
|
6
|
-
export declare function memoryCarWriter(root: CID | CID[]): MemoryCar;
|
|
7
|
-
//# sourceMappingURL=memory-car.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-car.d.ts","sourceRoot":"","sources":["../../../src/fixtures/memory-car.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC;IACjE,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;CAC7B;AAED,wBAAgB,eAAe,CAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,SAAS,CAuB7D"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CarWriter } from '@ipld/car';
|
|
2
|
-
import toBuffer from 'it-to-buffer';
|
|
3
|
-
import defer from 'p-defer';
|
|
4
|
-
export function memoryCarWriter(root) {
|
|
5
|
-
const deferred = defer();
|
|
6
|
-
const { writer, out } = CarWriter.create(Array.isArray(root) ? root : [root]);
|
|
7
|
-
Promise.resolve()
|
|
8
|
-
.then(async () => {
|
|
9
|
-
deferred.resolve(toBuffer(out));
|
|
10
|
-
})
|
|
11
|
-
.catch(err => {
|
|
12
|
-
deferred.reject(err);
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
async put(block) {
|
|
16
|
-
await writer.put(block);
|
|
17
|
-
},
|
|
18
|
-
async close() {
|
|
19
|
-
await writer.close();
|
|
20
|
-
},
|
|
21
|
-
async bytes() {
|
|
22
|
-
return deferred.promise;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=memory-car.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-car.js","sourceRoot":"","sources":["../../../src/fixtures/memory-car.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,QAAQ,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,MAAM,SAAS,CAAA;AAO3B,MAAM,UAAU,eAAe,CAAE,IAAiB;IAChD,MAAM,QAAQ,GAAG,KAAK,EAAc,CAAA;IACpC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IAE7E,OAAO,CAAC,OAAO,EAAE;SACd,IAAI,CAAC,KAAK,IAAI,EAAE;QACf,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,CAAC,EAAE;QACX,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACtB,CAAC,CAAC,CAAA;IAEJ,OAAO;QACL,KAAK,CAAC,GAAG,CAAE,KAAsC;YAC/C,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;QACD,KAAK,CAAC,KAAK;YACT,OAAO,QAAQ,CAAC,OAAO,CAAA;QACzB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ipns-dnslink.spec.d.ts","sourceRoot":"","sources":["../../src/ipns-dnslink.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ipns-dnslink.spec.js","sourceRoot":"","sources":["../../src/ipns-dnslink.spec.ts"],"names":[],"mappings":"AAAA,sBAAsB;AAEtB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAK5D,MAAM,YAAY,GAAa;IAC7B,WAAW;IACX,gBAAgB;IAChB,0BAA0B;CAC3B,CAAA;AAED,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,KAA2C,CAAA;IAC/C,IAAI,IAAU,CAAA;IAEd,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,KAAK,GAAG,MAAM,eAAe,EAAE,CAAA;QAC/B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,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,CAAA;IAEF,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC5B,EAAE,CAAC,kBAAkB,MAAM,EAAE,EAAE,KAAK,IAAI,EAAE;YACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;YAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { CarWriter } from '@ipld/car'
|
|
2
|
-
import toBuffer from 'it-to-buffer'
|
|
3
|
-
import defer from 'p-defer'
|
|
4
|
-
import type { CID } from 'multiformats/cid'
|
|
5
|
-
|
|
6
|
-
export interface MemoryCar extends Pick<CarWriter, 'put' | 'close'> {
|
|
7
|
-
bytes(): Promise<Uint8Array>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function memoryCarWriter (root: CID | CID[]): MemoryCar {
|
|
11
|
-
const deferred = defer<Uint8Array>()
|
|
12
|
-
const { writer, out } = CarWriter.create(Array.isArray(root) ? root : [root])
|
|
13
|
-
|
|
14
|
-
Promise.resolve()
|
|
15
|
-
.then(async () => {
|
|
16
|
-
deferred.resolve(toBuffer(out))
|
|
17
|
-
})
|
|
18
|
-
.catch(err => {
|
|
19
|
-
deferred.reject(err)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
async put (block: { cid: CID, bytes: Uint8Array }): Promise<void> {
|
|
24
|
-
await writer.put(block)
|
|
25
|
-
},
|
|
26
|
-
async close (): Promise<void> {
|
|
27
|
-
await writer.close()
|
|
28
|
-
},
|
|
29
|
-
async bytes (): Promise<Uint8Array> {
|
|
30
|
-
return deferred.promise
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|