@helia/interop 8.1.2 → 8.2.0-5a911c69
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.map +1 -1
- package/dist/src/dag-cbor.spec.js.map +1 -1
- package/dist/src/dag-json.spec.js.map +1 -1
- package/dist/src/fixtures/connect.d.ts +2 -2
- package/dist/src/fixtures/connect.d.ts.map +1 -1
- package/dist/src/fixtures/connect.js.map +1 -1
- package/dist/src/fixtures/create-helia.browser.d.ts +3 -3
- package/dist/src/fixtures/create-helia.browser.d.ts.map +1 -1
- package/dist/src/fixtures/create-helia.d.ts +3 -3
- package/dist/src/fixtures/create-helia.d.ts.map +1 -1
- package/dist/src/helia-blockstore-sessions.spec.js.map +1 -1
- package/dist/src/helia-blockstore.spec.js.map +1 -1
- package/dist/src/helia-hashes.spec.js.map +1 -1
- package/dist/src/helia-pins.spec.js.map +1 -1
- package/dist/src/ipns-dnslink.spec.js.map +1 -1
- package/dist/src/ipns-http.spec.js +1 -1
- package/dist/src/ipns-http.spec.js.map +1 -1
- package/dist/src/ipns-pubsub.spec.js.map +1 -1
- package/dist/src/ipns.spec.js.map +1 -1
- package/dist/src/json.spec.js.map +1 -1
- package/dist/src/mfs.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 +192 -0
- package/dist/src/providers.spec.js.map +1 -0
- package/dist/src/strings.spec.js.map +1 -1
- package/dist/src/unixfs-bitswap.spec.js.map +1 -1
- package/dist/src/unixfs-files.spec.js.map +1 -1
- package/package.json +17 -16
- package/src/car.spec.ts +2 -2
- package/src/dag-cbor.spec.ts +2 -2
- package/src/dag-json.spec.ts +2 -2
- package/src/fixtures/connect.ts +2 -2
- package/src/fixtures/create-helia.browser.ts +4 -4
- package/src/fixtures/create-helia.ts +4 -4
- package/src/helia-blockstore-sessions.spec.ts +2 -2
- package/src/helia-blockstore.spec.ts +2 -2
- package/src/helia-hashes.spec.ts +2 -2
- package/src/helia-pins.spec.ts +2 -2
- package/src/ipns-dnslink.spec.ts +3 -2
- package/src/ipns-http.spec.ts +3 -2
- package/src/ipns-pubsub.spec.ts +2 -2
- package/src/ipns.spec.ts +3 -3
- package/src/json.spec.ts +2 -2
- package/src/mfs.spec.ts +2 -2
- package/src/providers.spec.ts +230 -0
- package/src/strings.spec.ts +2 -2
- package/src/unixfs-bitswap.spec.ts +2 -2
- package/src/unixfs-files.spec.ts +2 -2
- package/dist/src/fixtures/create-helia-http.d.ts +0 -4
- package/dist/src/fixtures/create-helia-http.d.ts.map +0 -1
- package/dist/src/fixtures/create-helia-http.js +0 -7
- package/dist/src/fixtures/create-helia-http.js.map +0 -1
- package/src/fixtures/create-helia-http.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interop",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0-5a911c69",
|
|
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",
|
|
@@ -59,18 +59,18 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@chainsafe/libp2p-gossipsub": "^14.1.0",
|
|
62
|
-
"@helia/block-brokers": "
|
|
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": "
|
|
62
|
+
"@helia/block-brokers": "4.2.3-5a911c69",
|
|
63
|
+
"@helia/car": "4.1.3-5a911c69",
|
|
64
|
+
"@helia/dag-cbor": "4.0.7-5a911c69",
|
|
65
|
+
"@helia/dag-json": "4.0.7-5a911c69",
|
|
66
|
+
"@helia/http": "2.2.0-5a911c69",
|
|
67
|
+
"@helia/interface": "5.4.0-5a911c69",
|
|
68
|
+
"@helia/ipns": "8.2.4-5a911c69",
|
|
69
|
+
"@helia/json": "4.0.7-5a911c69",
|
|
70
|
+
"@helia/mfs": "5.0.4-5a911c69",
|
|
71
|
+
"@helia/routers": "3.1.3-5a911c69",
|
|
72
|
+
"@helia/strings": "4.0.7-5a911c69",
|
|
73
|
+
"@helia/unixfs": "5.0.4-5a911c69",
|
|
74
74
|
"@ipld/car": "^5.3.3",
|
|
75
75
|
"@ipld/dag-cbor": "^9.2.2",
|
|
76
76
|
"@ipld/dag-pb": "^4.1.3",
|
|
@@ -79,11 +79,12 @@
|
|
|
79
79
|
"@libp2p/kad-dht": "^15.0.2",
|
|
80
80
|
"@libp2p/keychain": "^5.0.10",
|
|
81
81
|
"@libp2p/peer-id": "^5.0.8",
|
|
82
|
+
"@libp2p/utils": "^6.7.1",
|
|
82
83
|
"@libp2p/websockets": "^9.0.13",
|
|
83
84
|
"@multiformats/multiaddr": "^12.4.0",
|
|
84
85
|
"@multiformats/sha3": "^3.0.2",
|
|
85
86
|
"aegir": "^47.0.7",
|
|
86
|
-
"helia": "
|
|
87
|
+
"helia": "5.5.0-5a911c69",
|
|
87
88
|
"ipfs-unixfs-importer": "^15.3.1",
|
|
88
89
|
"ipfsd-ctl": "^15.0.2",
|
|
89
90
|
"ipns": "^10.0.0",
|
|
@@ -92,9 +93,9 @@
|
|
|
92
93
|
"it-last": "^3.0.6",
|
|
93
94
|
"it-map": "^3.1.1",
|
|
94
95
|
"it-to-buffer": "^4.0.7",
|
|
95
|
-
"kubo": "^0.
|
|
96
|
+
"kubo": "^0.35.0",
|
|
96
97
|
"kubo-rpc-client": "^5.0.2",
|
|
97
|
-
"libp2p": "^2.
|
|
98
|
+
"libp2p": "^2.9.0",
|
|
98
99
|
"multiformats": "^13.3.1",
|
|
99
100
|
"p-defer": "^4.0.1",
|
|
100
101
|
"uint8arrays": "^5.1.0",
|
package/src/car.spec.ts
CHANGED
|
@@ -12,12 +12,12 @@ import { createKuboNode } from './fixtures/create-kubo.js'
|
|
|
12
12
|
import { memoryCarWriter } from './fixtures/memory-car.js'
|
|
13
13
|
import type { Car } from '@helia/car'
|
|
14
14
|
import type { UnixFS } from '@helia/unixfs'
|
|
15
|
-
import type {
|
|
15
|
+
import type { Helia } from 'helia'
|
|
16
16
|
import type { ByteStream, FileCandidate } from 'ipfs-unixfs-importer'
|
|
17
17
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
18
18
|
|
|
19
19
|
describe('@helia/car', () => {
|
|
20
|
-
let helia:
|
|
20
|
+
let helia: Helia
|
|
21
21
|
let c: Car
|
|
22
22
|
let u: UnixFS
|
|
23
23
|
let kubo: KuboNode
|
package/src/dag-cbor.spec.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { CID } from 'multiformats/cid'
|
|
|
7
7
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
8
8
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
9
9
|
import type { DAGCBOR, AddOptions } from '@helia/dag-cbor'
|
|
10
|
-
import type {
|
|
10
|
+
import type { Helia } from 'helia'
|
|
11
11
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
12
12
|
import type { AddOptions as KuboAddOptions } from 'kubo-rpc-client'
|
|
13
13
|
|
|
14
14
|
describe('@helia/dag-cbor', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let d: DAGCBOR
|
|
17
17
|
let kubo: KuboNode
|
|
18
18
|
|
package/src/dag-json.spec.ts
CHANGED
|
@@ -7,12 +7,12 @@ import * as codec from 'multiformats/codecs/json'
|
|
|
7
7
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
8
8
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
9
9
|
import type { DAGJSON, AddOptions } from '@helia/dag-json'
|
|
10
|
-
import type {
|
|
10
|
+
import type { Helia } from 'helia'
|
|
11
11
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
12
12
|
import type { BlockPutOptions as KuboAddOptions } from 'kubo-rpc-client'
|
|
13
13
|
|
|
14
14
|
describe('@helia/dag-json', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let d: DAGJSON
|
|
17
17
|
let kubo: KuboNode
|
|
18
18
|
|
package/src/fixtures/connect.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { expect } from 'aegir/chai'
|
|
2
|
-
import type {
|
|
2
|
+
import type { Helia } from 'helia'
|
|
3
3
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Connect the two nodes by dialing a protocol stream
|
|
7
7
|
*/
|
|
8
|
-
export async function connect (helia:
|
|
8
|
+
export async function connect (helia: Helia<any>, kubo: KuboNode, protocol: string): Promise<void> {
|
|
9
9
|
let connected = false
|
|
10
10
|
const id = await kubo.api.id()
|
|
11
11
|
|
|
@@ -6,12 +6,12 @@ import { all } from '@libp2p/websockets/filters'
|
|
|
6
6
|
import { sha3512 } from '@multiformats/sha3'
|
|
7
7
|
import { createHelia, libp2pDefaults } from 'helia'
|
|
8
8
|
import type { Libp2p } from '@libp2p/interface'
|
|
9
|
-
import type { DefaultLibp2pServices,
|
|
9
|
+
import type { DefaultLibp2pServices, Helia } from 'helia'
|
|
10
10
|
import type { Libp2pOptions } from 'libp2p'
|
|
11
11
|
|
|
12
|
-
export async function createHeliaNode (): Promise<
|
|
13
|
-
export async function createHeliaNode <Services extends Record<string, unknown>> (libp2pOptions: Libp2pOptions<Services>): Promise<
|
|
14
|
-
export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<
|
|
12
|
+
export async function createHeliaNode (): Promise<Helia<Libp2p<DefaultLibp2pServices>>>
|
|
13
|
+
export async function createHeliaNode <Services extends Record<string, unknown>> (libp2pOptions: Libp2pOptions<Services>): Promise<Helia<Libp2p<Services & DefaultLibp2pServices>>>
|
|
14
|
+
export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<Helia<Libp2p<DefaultLibp2pServices>>> {
|
|
15
15
|
const defaults = libp2pDefaults()
|
|
16
16
|
|
|
17
17
|
// allow dialing insecure WebSockets
|
|
@@ -4,12 +4,12 @@ import { kadDHT, removePublicAddressesMapper } from '@libp2p/kad-dht'
|
|
|
4
4
|
import { sha3512 } from '@multiformats/sha3'
|
|
5
5
|
import { createHelia, libp2pDefaults } from 'helia'
|
|
6
6
|
import type { Libp2p } from '@libp2p/interface'
|
|
7
|
-
import type { DefaultLibp2pServices,
|
|
7
|
+
import type { DefaultLibp2pServices, Helia } from 'helia'
|
|
8
8
|
import type { Libp2pOptions } from 'libp2p'
|
|
9
9
|
|
|
10
|
-
export async function createHeliaNode (): Promise<
|
|
11
|
-
export async function createHeliaNode <Services extends Record<string, unknown>> (libp2pOptions: Libp2pOptions<Services>): Promise<
|
|
12
|
-
export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<
|
|
10
|
+
export async function createHeliaNode (): Promise<Helia<Libp2p<DefaultLibp2pServices>>>
|
|
11
|
+
export async function createHeliaNode <Services extends Record<string, unknown>> (libp2pOptions: Libp2pOptions<Services>): Promise<Helia<Libp2p<Services & DefaultLibp2pServices>>>
|
|
12
|
+
export async function createHeliaNode (libp2pOptions?: Libp2pOptions): Promise<Helia<Libp2p<DefaultLibp2pServices>>> {
|
|
13
13
|
const defaults = libp2pDefaults()
|
|
14
14
|
defaults.addresses = {
|
|
15
15
|
listen: [
|
|
@@ -5,11 +5,11 @@ import { expect } from 'aegir/chai'
|
|
|
5
5
|
import { CID } from 'multiformats/cid'
|
|
6
6
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
7
7
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
8
|
-
import type {
|
|
8
|
+
import type { Helia } from 'helia'
|
|
9
9
|
import type { KuboInfo, KuboNode } from 'ipfsd-ctl'
|
|
10
10
|
|
|
11
11
|
describe('helia - blockstore sessions', () => {
|
|
12
|
-
let helia:
|
|
12
|
+
let helia: Helia
|
|
13
13
|
let kubo: KuboNode
|
|
14
14
|
let kuboInfo: KuboInfo
|
|
15
15
|
|
|
@@ -8,11 +8,11 @@ import * as raw from 'multiformats/codecs/raw'
|
|
|
8
8
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
9
9
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
10
10
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
11
|
-
import type {
|
|
11
|
+
import type { Helia } from 'helia'
|
|
12
12
|
import type { KuboInfo, KuboNode } from 'ipfsd-ctl'
|
|
13
13
|
|
|
14
14
|
describe('helia - blockstore', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let kubo: KuboNode
|
|
17
17
|
let kuboInfo: KuboInfo
|
|
18
18
|
|
package/src/helia-hashes.spec.ts
CHANGED
|
@@ -7,11 +7,11 @@ import { CID } from 'multiformats/cid'
|
|
|
7
7
|
import * as raw from 'multiformats/codecs/raw'
|
|
8
8
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
9
9
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
10
|
-
import type {
|
|
10
|
+
import type { Helia } from 'helia'
|
|
11
11
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
12
12
|
|
|
13
13
|
describe('helia - hashes', () => {
|
|
14
|
-
let helia:
|
|
14
|
+
let helia: Helia
|
|
15
15
|
let kubo: KuboNode
|
|
16
16
|
|
|
17
17
|
beforeEach(async () => {
|
package/src/helia-pins.spec.ts
CHANGED
|
@@ -8,11 +8,11 @@ import * as raw from 'multiformats/codecs/raw'
|
|
|
8
8
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
9
9
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
10
10
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
11
|
-
import type {
|
|
11
|
+
import type { Helia } from 'helia'
|
|
12
12
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
13
13
|
|
|
14
14
|
describe('helia - pins', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let kubo: KuboNode
|
|
17
17
|
|
|
18
18
|
beforeEach(async () => {
|
package/src/ipns-dnslink.spec.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ipns } from '@helia/ipns'
|
|
|
4
4
|
import { expect } from 'aegir/chai'
|
|
5
5
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
6
6
|
import type { IPNS } from '@helia/ipns'
|
|
7
|
-
import type {
|
|
7
|
+
import type { DefaultLibp2pServices, Helia } from 'helia'
|
|
8
|
+
import type { Libp2p } from 'libp2p'
|
|
8
9
|
|
|
9
10
|
const TEST_DOMAINS: string[] = [
|
|
10
11
|
'ipfs.tech',
|
|
@@ -13,7 +14,7 @@ const TEST_DOMAINS: string[] = [
|
|
|
13
14
|
]
|
|
14
15
|
|
|
15
16
|
describe('@helia/ipns - dnslink', () => {
|
|
16
|
-
let helia:
|
|
17
|
+
let helia: Helia<Libp2p<DefaultLibp2pServices>>
|
|
17
18
|
let name: IPNS
|
|
18
19
|
|
|
19
20
|
beforeEach(async () => {
|
package/src/ipns-http.spec.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/* eslint-env mocha */
|
|
2
2
|
|
|
3
|
+
import { createHeliaHTTP } from '@helia/http'
|
|
3
4
|
import { ipns } from '@helia/ipns'
|
|
4
5
|
import { delegatedHTTPRouting } from '@helia/routers'
|
|
5
6
|
import { peerIdFromCID } from '@libp2p/peer-id'
|
|
6
7
|
import { expect } from 'aegir/chai'
|
|
7
8
|
import { CID } from 'multiformats/cid'
|
|
8
9
|
import { isNode } from 'wherearewe'
|
|
9
|
-
import { createHeliaHTTP } from './fixtures/create-helia-http.js'
|
|
10
10
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
11
11
|
import type { Helia } from '@helia/interface'
|
|
12
12
|
import type { IPNS } from '@helia/ipns'
|
|
13
13
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
14
|
+
import type { Libp2p } from 'libp2p'
|
|
14
15
|
|
|
15
16
|
describe('@helia/ipns - http', () => {
|
|
16
|
-
let helia: Helia
|
|
17
|
+
let helia: Helia<Libp2p<any>>
|
|
17
18
|
let kubo: KuboNode
|
|
18
19
|
let name: IPNS
|
|
19
20
|
|
package/src/ipns-pubsub.spec.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { waitFor } from './fixtures/wait-for.js'
|
|
|
25
25
|
import type { IPNS, ResolveResult } from '@helia/ipns'
|
|
26
26
|
import type { Libp2p, PubSub } from '@libp2p/interface'
|
|
27
27
|
import type { Keychain } from '@libp2p/keychain'
|
|
28
|
-
import type {
|
|
28
|
+
import type { Helia } from 'helia'
|
|
29
29
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
30
30
|
|
|
31
31
|
// skip RSA tests because we need the DHT enabled to find the public key
|
|
@@ -33,7 +33,7 @@ import type { KuboNode } from 'ipfsd-ctl'
|
|
|
33
33
|
// resolution because Kubo will use the DHT as well
|
|
34
34
|
keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => {
|
|
35
35
|
describe(`@helia/ipns - pubsub routing with ${keyType} keys`, () => {
|
|
36
|
-
let helia:
|
|
36
|
+
let helia: Helia<Libp2p<{ pubsub: PubSub, keychain: Keychain }>>
|
|
37
37
|
let kubo: KuboNode
|
|
38
38
|
let name: IPNS
|
|
39
39
|
|
package/src/ipns.spec.ts
CHANGED
|
@@ -17,13 +17,13 @@ import { sortClosestPeers } from './fixtures/create-peer-ids.js'
|
|
|
17
17
|
import { keyTypes } from './fixtures/key-types.js'
|
|
18
18
|
import { waitFor } from './fixtures/wait-for.js'
|
|
19
19
|
import type { IPNS } from '@helia/ipns'
|
|
20
|
-
import type { PrivateKey } from '@libp2p/interface'
|
|
21
|
-
import type {
|
|
20
|
+
import type { Libp2p, PrivateKey } from '@libp2p/interface'
|
|
21
|
+
import type { DefaultLibp2pServices, Helia } from 'helia'
|
|
22
22
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
23
23
|
|
|
24
24
|
keyTypes.forEach(type => {
|
|
25
25
|
describe(`@helia/ipns - default routing with ${type} keys`, () => {
|
|
26
|
-
let helia:
|
|
26
|
+
let helia: Helia<Libp2p<DefaultLibp2pServices>>
|
|
27
27
|
let kubo: KuboNode
|
|
28
28
|
let name: IPNS
|
|
29
29
|
|
package/src/json.spec.ts
CHANGED
|
@@ -7,12 +7,12 @@ import * as jsonCodec from 'multiformats/codecs/json'
|
|
|
7
7
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
8
8
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
9
9
|
import type { JSON, AddOptions } from '@helia/json'
|
|
10
|
-
import type {
|
|
10
|
+
import type { Helia } from 'helia'
|
|
11
11
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
12
12
|
import type { BlockPutOptions as KuboAddOptions } from 'kubo-rpc-client'
|
|
13
13
|
|
|
14
14
|
describe('@helia/json', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let j: JSON
|
|
17
17
|
let kubo: KuboNode
|
|
18
18
|
|
package/src/mfs.spec.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { expect } from 'aegir/chai'
|
|
|
5
5
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
6
6
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
7
7
|
import type { MFS } from '@helia/mfs'
|
|
8
|
-
import type {
|
|
8
|
+
import type { Helia } from 'helia'
|
|
9
9
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
10
10
|
|
|
11
11
|
describe('@helia/mfs', () => {
|
|
12
|
-
let helia:
|
|
12
|
+
let helia: Helia
|
|
13
13
|
let fs: MFS
|
|
14
14
|
let kubo: KuboNode
|
|
15
15
|
|
|
@@ -0,0 +1,230 @@
|
|
|
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/filters'
|
|
11
|
+
import { expect } from 'aegir/chai'
|
|
12
|
+
import toBuffer from 'it-to-buffer'
|
|
13
|
+
import { multiaddr } from 'kubo-rpc-client'
|
|
14
|
+
import { CID } from 'multiformats/cid'
|
|
15
|
+
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
16
|
+
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
17
|
+
import type { PeerId } from '@libp2p/interface'
|
|
18
|
+
import type { Helia } from 'helia'
|
|
19
|
+
import type { FileCandidate } from 'ipfs-unixfs-importer'
|
|
20
|
+
import type { KuboInfo, KuboNode } from 'ipfsd-ctl'
|
|
21
|
+
|
|
22
|
+
describe('providers', () => {
|
|
23
|
+
let helia: Helia
|
|
24
|
+
let kubo: KuboNode
|
|
25
|
+
let cid: CID
|
|
26
|
+
let kuboInfo: KuboInfo
|
|
27
|
+
let input: Uint8Array[]
|
|
28
|
+
|
|
29
|
+
beforeEach(async () => {
|
|
30
|
+
// helia and kubo are not connected together before the test
|
|
31
|
+
helia = await createHeliaNode()
|
|
32
|
+
kubo = await createKuboNode()
|
|
33
|
+
|
|
34
|
+
const chunkSize = 1024 * 1024
|
|
35
|
+
const size = chunkSize * 10
|
|
36
|
+
input = []
|
|
37
|
+
|
|
38
|
+
const candidate: FileCandidate = {
|
|
39
|
+
content: (async function * () {
|
|
40
|
+
for (let i = 0; i < size; i += chunkSize) {
|
|
41
|
+
const buf = new Uint8Array(chunkSize)
|
|
42
|
+
input.push(buf)
|
|
43
|
+
|
|
44
|
+
yield buf
|
|
45
|
+
}
|
|
46
|
+
}())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const importResult = await kubo.api.add(candidate.content)
|
|
50
|
+
cid = CID.parse(importResult.cid.toString())
|
|
51
|
+
kuboInfo = await kubo.info()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
afterEach(async () => {
|
|
55
|
+
if (helia != null) {
|
|
56
|
+
await helia.stop()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (kubo != null) {
|
|
60
|
+
await kubo.stop()
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should fail to fetch without using a provider', async () => {
|
|
65
|
+
await expect(helia.blockstore.get(cid, {
|
|
66
|
+
signal: AbortSignal.timeout(100)
|
|
67
|
+
})).to.eventually.be.rejected()
|
|
68
|
+
.with.nested.property('errors[0].name', 'AbortError')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should fetch raw using a provider', async () => {
|
|
72
|
+
let sender: PeerId | undefined
|
|
73
|
+
|
|
74
|
+
const buf = await helia.blockstore.get(cid, {
|
|
75
|
+
providers: [
|
|
76
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
77
|
+
],
|
|
78
|
+
onProgress (evt) {
|
|
79
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
80
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
81
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
82
|
+
sender = evt.detail.sender
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
expect(buf).to.have.lengthOf(1930)
|
|
88
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should fetch dag-cbor using a provider', async () => {
|
|
92
|
+
let sender: PeerId | undefined
|
|
93
|
+
const obj = { hello: 'world' }
|
|
94
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
95
|
+
storeCodec: 'dag-cbor'
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const d = dagCbor(helia)
|
|
99
|
+
|
|
100
|
+
await expect(d.get(cid, {
|
|
101
|
+
providers: [
|
|
102
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
103
|
+
],
|
|
104
|
+
onProgress (evt) {
|
|
105
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
106
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
107
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
108
|
+
sender = evt.detail.sender
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})).to.eventually.deep.equal(obj)
|
|
112
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('should fetch dag-json using a provider', async () => {
|
|
116
|
+
let sender: PeerId | undefined
|
|
117
|
+
const obj = { hello: 'world' }
|
|
118
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
119
|
+
storeCodec: 'dag-json'
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const d = dagJson(helia)
|
|
123
|
+
|
|
124
|
+
await expect(d.get(cid, {
|
|
125
|
+
providers: [
|
|
126
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
127
|
+
],
|
|
128
|
+
onProgress (evt) {
|
|
129
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
130
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
131
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
132
|
+
sender = evt.detail.sender
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
})).to.eventually.deep.equal(obj)
|
|
136
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should fetch string using a provider', async () => {
|
|
140
|
+
let sender: PeerId | undefined
|
|
141
|
+
const obj = 'hello world'
|
|
142
|
+
const cid = await kubo.api.dag.put(obj, {
|
|
143
|
+
storeCodec: 'dag-json'
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const s = strings(helia)
|
|
147
|
+
|
|
148
|
+
await expect(s.get(cid, {
|
|
149
|
+
providers: [
|
|
150
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
151
|
+
],
|
|
152
|
+
onProgress (evt) {
|
|
153
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
154
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
155
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
156
|
+
sender = evt.detail.sender
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
})).to.eventually.equal(JSON.stringify(obj))
|
|
160
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('should fetch via unixfs using a provider', async () => {
|
|
164
|
+
let sender: PeerId | undefined
|
|
165
|
+
const fs = unixfs(helia)
|
|
166
|
+
|
|
167
|
+
const bytes = await toBuffer(fs.cat(cid, {
|
|
168
|
+
providers: [
|
|
169
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
170
|
+
],
|
|
171
|
+
onProgress (evt) {
|
|
172
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
173
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
174
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
175
|
+
sender = evt.detail.sender
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}))
|
|
179
|
+
|
|
180
|
+
expect(bytes).to.equalBytes(toBuffer(input))
|
|
181
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('should fetch via mfs using a provider', async () => {
|
|
185
|
+
let sender: PeerId | undefined
|
|
186
|
+
const fs = mfs(helia)
|
|
187
|
+
|
|
188
|
+
await fs.cp(cid, '/file.txt', {
|
|
189
|
+
providers: [
|
|
190
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
191
|
+
],
|
|
192
|
+
onProgress (evt) {
|
|
193
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
194
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
195
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
196
|
+
sender = evt.detail.sender
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
const bytes = await toBuffer(fs.cat('/file.txt'))
|
|
202
|
+
|
|
203
|
+
expect(bytes).to.equalBytes(toBuffer(input))
|
|
204
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should fetch via car using a provider', async () => {
|
|
208
|
+
let sender: PeerId | undefined
|
|
209
|
+
const c = car(helia)
|
|
210
|
+
|
|
211
|
+
expect(await toBuffer(
|
|
212
|
+
c.stream(cid, {
|
|
213
|
+
providers: [
|
|
214
|
+
kuboInfo.multiaddrs.map(ma => multiaddr(ma))
|
|
215
|
+
],
|
|
216
|
+
blockFilter: createScalableCuckooFilter(10),
|
|
217
|
+
onProgress (evt) {
|
|
218
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
219
|
+
if (evt.type === 'bitswap:want-block:received') {
|
|
220
|
+
// @ts-expect-error cannot derive config-based progress event types
|
|
221
|
+
sender = evt.detail.sender
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}))
|
|
225
|
+
).to.equalBytes(await toBuffer(
|
|
226
|
+
kubo.api.dag.export(cid)
|
|
227
|
+
))
|
|
228
|
+
expect(sender).to.deep.equal(peerIdFromString(kuboInfo.peerId?.toString() ?? ''))
|
|
229
|
+
})
|
|
230
|
+
})
|
package/src/strings.spec.ts
CHANGED
|
@@ -8,12 +8,12 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
|
8
8
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
9
9
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
10
10
|
import type { Strings, AddOptions } from '@helia/strings'
|
|
11
|
-
import type {
|
|
11
|
+
import type { Helia } from 'helia'
|
|
12
12
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
13
13
|
import type { BlockPutOptions as KuboAddOptions } from 'kubo-rpc-client'
|
|
14
14
|
|
|
15
15
|
describe('@helia/strings', () => {
|
|
16
|
-
let helia:
|
|
16
|
+
let helia: Helia
|
|
17
17
|
let str: Strings
|
|
18
18
|
let kubo: KuboNode
|
|
19
19
|
|
|
@@ -7,12 +7,12 @@ import { CID } from 'multiformats/cid'
|
|
|
7
7
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
8
8
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
9
9
|
import type { UnixFS } from '@helia/unixfs'
|
|
10
|
-
import type {
|
|
10
|
+
import type { Helia } from 'helia'
|
|
11
11
|
import type { ByteStream, FileCandidate } from 'ipfs-unixfs-importer'
|
|
12
12
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
13
13
|
|
|
14
14
|
describe('@helia/unixfs - bitswap', () => {
|
|
15
|
-
let helia:
|
|
15
|
+
let helia: Helia
|
|
16
16
|
let unixFs: UnixFS
|
|
17
17
|
let kubo: KuboNode
|
|
18
18
|
|
package/src/unixfs-files.spec.ts
CHANGED
|
@@ -13,13 +13,13 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
|
13
13
|
import { createHeliaNode } from './fixtures/create-helia.js'
|
|
14
14
|
import { createKuboNode } from './fixtures/create-kubo.js'
|
|
15
15
|
import type { AddOptions, UnixFS } from '@helia/unixfs'
|
|
16
|
-
import type {
|
|
16
|
+
import type { Helia } from 'helia'
|
|
17
17
|
import type { ByteStream, ImportCandidateStream } from 'ipfs-unixfs-importer'
|
|
18
18
|
import type { KuboNode } from 'ipfsd-ctl'
|
|
19
19
|
import type { AddOptions as KuboAddOptions } from 'kubo-rpc-client'
|
|
20
20
|
|
|
21
21
|
describe('@helia/unixfs - files', () => {
|
|
22
|
-
let helia:
|
|
22
|
+
let helia: Helia
|
|
23
23
|
let unixFs: UnixFS
|
|
24
24
|
let kubo: KuboNode
|
|
25
25
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia-http.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-helia-http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,wBAAsB,eAAe,CAAE,IAAI,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAIxF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-helia-http.js","sourceRoot":"","sources":["../../../src/fixtures/create-helia-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAI5D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAE,OAA+B,EAAE;IACtE,OAAO,WAAW,CAAC;QACjB,GAAG,IAAI;KACR,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createHeliaHTTP as createHelia } from '@helia/http'
|
|
2
|
-
import type { HeliaHTTPInit } from '@helia/http'
|
|
3
|
-
import type { Helia } from '@helia/interface'
|
|
4
|
-
|
|
5
|
-
export async function createHeliaHTTP (init: Partial<HeliaHTTPInit> = {}): Promise<Helia> {
|
|
6
|
-
return createHelia({
|
|
7
|
-
...init
|
|
8
|
-
})
|
|
9
|
-
}
|