Skip to content

Commit

Permalink
deps(dev): bump helia from 3.0.1 to 4.0.0 (#104)
Browse files Browse the repository at this point in the history
Bumps [helia](https://github.com/ipfs/helia) from 3.0.1 to 4.0.0.
- [Release notes](https://github.com/ipfs/helia/releases)
- [Changelog](https://github.com/ipfs/helia/blob/main/CHANGELOG.md)
- [Commits](ipfs/helia@helia-v3.0.1...helia-v4.0.0)

---
updated-dependencies:
- dependency-name: helia
  dependency-type: direct:development
  update-type: version-update:semver-major
...

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: achingbrain <alex@achingbrain.net>
  • Loading branch information
dependabot[bot] and achingbrain authored Jan 31, 2024
1 parent be52e79 commit 23cd638
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 59 deletions.
9 changes: 4 additions & 5 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@
"test:node": "aegir test -t node --cov"
},
"devDependencies": {
"@helia/delegated-routing-v1-http-api-client": "^2.0.0",
"@helia/delegated-routing-v1-http-api-server": "^2.0.0",
"@helia/interface": "^3.0.1",
"@helia/ipns": "^4.0.0",
"@helia/delegated-routing-v1-http-api-client": "^3.0.0",
"@helia/delegated-routing-v1-http-api-server": "^3.0.0",
"@helia/ipns": "^5.0.0",
"@libp2p/identify": "^1.0.10",
"@libp2p/interface": "^1.1.1",
"@libp2p/kad-dht": "^12.0.3",
"@libp2p/peer-id-factory": "^4.0.4",
"aegir": "^42.2.0",
"fastify": "^4.17.0",
"helia": "^3.0.1",
"helia": "^4.0.0",
"ipns": "^9.0.0",
"it-first": "^3.0.3",
"multiformats": "^13.0.0"
Expand Down
5 changes: 2 additions & 3 deletions packages/interop/test/fixtures/create-helia.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { identify } from '@libp2p/identify'
import { kadDHT, removePublicAddressesMapper, type KadDHT } from '@libp2p/kad-dht'
import { createHelia as createNode, type HeliaInit } from 'helia'
import { createHelia as createNode, type HeliaInit, type HeliaLibp2p } from 'helia'
import { ipnsSelector } from 'ipns/selector'
import { ipnsValidator } from 'ipns/validator'
import type { Helia } from '@helia/interface'
import type { Libp2p } from '@libp2p/interface'

export async function createHelia (init?: Partial<HeliaInit>): Promise<Helia<Libp2p<{ dht: KadDHT }>>> {
export async function createHelia (init?: Partial<HeliaInit>): Promise<HeliaLibp2p<Libp2p<{ dht: KadDHT }>>> {
const helia = await createNode({
libp2p: {
peerDiscovery: [],
Expand Down
17 changes: 4 additions & 13 deletions packages/interop/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { createDelegatedRoutingV1HttpApiServer } from '@helia/delegated-routing-v1-http-api-server'
import { ipns } from '@helia/ipns'
import { libp2p } from '@helia/ipns/routing'
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
import { expect } from 'aegir/chai'
import { create as createIpnsRecord } from 'ipns'
Expand All @@ -13,13 +12,13 @@ import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'
import { createHelia } from './fixtures/create-helia.js'
import type { DelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import type { Helia } from '@helia/interface'
import type { Libp2p } from '@libp2p/interface'
import type { KadDHT } from '@libp2p/kad-dht'
import type { FastifyInstance } from 'fastify'
import type { HeliaLibp2p } from 'helia'

describe('delegated-routing-v1-http-api interop', () => {
let network: Array<Helia<Libp2p<{ dht: KadDHT }>>>
let network: Array<HeliaLibp2p<Libp2p<{ dht: KadDHT }>>>
let server: FastifyInstance
let client: DelegatedRoutingV1HttpApiClient

Expand Down Expand Up @@ -90,11 +89,7 @@ describe('delegated-routing-v1-http-api interop', () => {

it('should get an IPNS record', async () => {
// publish a record using a remote host
const i = ipns(network[5], {
routers: [
libp2p(network[5])
]
})
const i = ipns(network[5])
const cid = CID.parse('bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354')
const peerId = await createEd25519PeerId()
await i.publish(peerId, cid)
Expand All @@ -113,11 +108,7 @@ describe('delegated-routing-v1-http-api interop', () => {
await client.putIPNS(peerId, record)

// resolve the record using a remote host
const i = ipns(network[8], {
routers: [
libp2p(network[8])
]
})
const i = ipns(network[8])
const result = await i.resolve(peerId)
expect(result.toString()).to.equal(cid.toString())
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"dependencies": {
"@fastify/cors": "^8.3.0",
"@helia/interface": "^4.0.0",
"@libp2p/interface": "^1.1.1",
"@libp2p/peer-id": "^4.0.4",
"fastify": "^4.17.0",
Expand All @@ -73,7 +74,6 @@
"raw-body": "^2.5.2"
},
"devDependencies": {
"@helia/interface": "^3.0.1",
"@libp2p/peer-id-factory": "^4.0.4",
"@multiformats/multiaddr": "^12.1.3",
"@types/sinon": "^17.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import fastify, {
type FastifyInstance
} from 'fastify'
import routes from './routes/index.js'
import type { Libp2p } from '@libp2p/interface'
import type { Helia } from '@helia/interface'

export interface ServerInit {
fastify?: FastifyInstance
Expand All @@ -67,15 +67,15 @@ export interface ServerInit {
/**
* Create and return a Routing V1 HTTP API server
*/
export async function createDelegatedRoutingV1HttpApiServer (helia: { libp2p: Libp2p }, init: ServerInit = {}): Promise<FastifyInstance> {
export async function createDelegatedRoutingV1HttpApiServer (helia: Helia, init: ServerInit = {}): Promise<FastifyInstance> {
const server = init.fastify ?? fastify()
await server.register(cors, {
origin: '*',
methods: ['GET', 'OPTIONS'],
strictPreflight: false
})

routes(server, helia.libp2p)
routes(server, helia)

await server.listen(init.listen ?? {
port: 0
Expand Down
12 changes: 6 additions & 6 deletions packages/server/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ import getIpnsV1 from './routing/v1/ipns/get.js'
import putIpnsV1 from './routing/v1/ipns/put.js'
import getPeersV1 from './routing/v1/peers/get.js'
import getProvidersV1 from './routing/v1/providers/get.js'
import type { Libp2p } from '@libp2p/interface'
import type { Helia } from '@helia/interface'
import type { FastifyInstance } from 'fastify'

export default function routes (fastify: FastifyInstance, libp2p: Libp2p): void {
getProvidersV1(fastify, libp2p)
getPeersV1(fastify, libp2p)
getIpnsV1(fastify, libp2p)
putIpnsV1(fastify, libp2p)
export default function routes (fastify: FastifyInstance, helia: Helia): void {
getProvidersV1(fastify, helia)
getPeersV1(fastify, helia)
getIpnsV1(fastify, helia)
putIpnsV1(fastify, helia)
}
7 changes: 4 additions & 3 deletions packages/server/src/routes/routing/v1/ipns/get.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { peerIdFromCID } from '@libp2p/peer-id'
import { peerIdToRoutingKey } from 'ipns'
import { CID } from 'multiformats/cid'
import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Helia } from '@helia/interface'
import type { PeerId } from '@libp2p/interface'
import type { FastifyInstance } from 'fastify'

interface Params {
name: string
}

export default function getIpnsV1 (fastify: FastifyInstance, libp2p: Libp2p): void {
export default function getIpnsV1 (fastify: FastifyInstance, helia: Helia): void {
fastify.route<{ Params: Params }>({
method: 'GET',
url: '/routing/v1/ipns/:name',
Expand Down Expand Up @@ -43,7 +44,7 @@ export default function getIpnsV1 (fastify: FastifyInstance, libp2p: Libp2p): vo
}

try {
const rawRecord = await libp2p.contentRouting.get(peerIdToRoutingKey(peerId), {
const rawRecord = await helia.routing.get(peerIdToRoutingKey(peerId), {
signal: controller.signal
})

Expand Down
7 changes: 4 additions & 3 deletions packages/server/src/routes/routing/v1/ipns/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { peerIdToRoutingKey } from 'ipns'
import { ipnsValidator } from 'ipns/validator'
import { CID } from 'multiformats/cid'
import getRawBody from 'raw-body'
import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Helia } from '@helia/interface'
import type { PeerId } from '@libp2p/interface'
import type { FastifyInstance } from 'fastify'

interface Params {
name: string
}

export default function putIpnsV1 (fastify: FastifyInstance, libp2p: Libp2p): void {
export default function putIpnsV1 (fastify: FastifyInstance, helia: Helia): void {
fastify.addContentTypeParser('application/vnd.ipfs.ipns-record', function (request, payload, done) {
getRawBody(payload)
.then(buff => { done(null, buff) })
Expand Down Expand Up @@ -54,7 +55,7 @@ export default function putIpnsV1 (fastify: FastifyInstance, libp2p: Libp2p): vo
const body: Uint8Array = request.body
await ipnsValidator(peerIdToRoutingKey(peerId), body)

await libp2p.contentRouting.put(peerIdToRoutingKey(peerId), body, {
await helia.routing.put(peerIdToRoutingKey(peerId), body, {
signal: controller.signal
})

Expand Down
7 changes: 4 additions & 3 deletions packages/server/src/routes/routing/v1/peers/get.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { PassThrough } from 'node:stream'
import { peerIdFromCID } from '@libp2p/peer-id'
import { CID } from 'multiformats/cid'
import type { Libp2p, PeerId } from '@libp2p/interface'
import type { Helia } from '@helia/interface'
import type { PeerId } from '@libp2p/interface'
import type { FastifyInstance } from 'fastify'

interface Params {
peerId: string
}

export default function getPeersV1 (fastify: FastifyInstance, libp2p: Libp2p): void {
export default function getPeersV1 (fastify: FastifyInstance, helia: Helia): void {
fastify.route<{ Params: Params }>({
method: 'GET',
url: '/routing/v1/peers/:peerId',
Expand Down Expand Up @@ -41,7 +42,7 @@ export default function getPeersV1 (fastify: FastifyInstance, libp2p: Libp2p): v
return reply.code(422).type('text/html').send('Unprocessable Entity')
}

const peerInfo = await libp2p.peerRouting.findPeer(peerId, {
const peerInfo = await helia.routing.findPeer(peerId, {
signal: controller.signal
})
const peerRecord = {
Expand Down
17 changes: 9 additions & 8 deletions packages/server/src/routes/routing/v1/providers/get.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PassThrough } from 'node:stream'
import { CID } from 'multiformats/cid'
import type { AbortOptions, Libp2p } from '@libp2p/interface'
import type { Helia } from '@helia/interface'
import type { AbortOptions } from '@libp2p/interface'
import type { FastifyInstance } from 'fastify'

interface Params {
Expand All @@ -21,7 +22,7 @@ interface Providers {

const MAX_PROVIDERS = 100

export default function getProvidersV1 (fastify: FastifyInstance, libp2p: Libp2p): void {
export default function getProvidersV1 (fastify: FastifyInstance, helia: Helia): void {
fastify.route<{ Params: Params }>({
method: 'GET',
url: '/routing/v1/providers/:cid',
Expand Down Expand Up @@ -57,7 +58,7 @@ export default function getProvidersV1 (fastify: FastifyInstance, libp2p: Libp2p
const stream = new PassThrough()

// wait until we have the first result
const iterable = streamingHandler(cid, libp2p, {
const iterable = streamingHandler(cid, helia, {
signal: controller.signal
})
const result = await iterable.next()
Expand All @@ -84,7 +85,7 @@ export default function getProvidersV1 (fastify: FastifyInstance, libp2p: Libp2p
.send(stream)
}
} else {
const result = await nonStreamingHandler(cid, libp2p, {
const result = await nonStreamingHandler(cid, helia, {
signal: controller.signal
})

Expand All @@ -98,10 +99,10 @@ export default function getProvidersV1 (fastify: FastifyInstance, libp2p: Libp2p
})
}

async function * streamingHandler (cid: CID, libp2p: Libp2p, options?: AbortOptions): AsyncGenerator<PeerRecord, void, unknown> {
async function * streamingHandler (cid: CID, helia: Helia, options?: AbortOptions): AsyncGenerator<PeerRecord, void, unknown> {
let provs = 0

for await (const prov of libp2p.contentRouting.findProviders(cid, options)) {
for await (const prov of helia.routing.findProviders(cid, options)) {
yield {
Schema: 'peer',
ID: prov.id.toString(),
Expand All @@ -116,11 +117,11 @@ async function * streamingHandler (cid: CID, libp2p: Libp2p, options?: AbortOpti
}
}

async function nonStreamingHandler (cid: CID, libp2p: Libp2p, options?: AbortOptions): Promise<Providers> {
async function nonStreamingHandler (cid: CID, helia: Helia, options?: AbortOptions): Promise<Providers> {
const providers = []

try {
for await (const prov of libp2p.contentRouting.findProviders(cid, options)) {
for await (const prov of helia.routing.findProviders(cid, options)) {
providers.push({
Schema: 'peer',
ID: prov.id.toString(),
Expand Down
20 changes: 9 additions & 11 deletions packages/server/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CID } from 'multiformats'
import { stubInterface } from 'sinon-ts'
import { createDelegatedRoutingV1HttpApiServer } from '../src/index.js'
import type { Helia } from '@helia/interface'
import type { Libp2p, PeerInfo } from '@libp2p/interface'
import type { PeerInfo } from '@libp2p/interface'
import type { FastifyInstance } from 'fastify'
import type { StubbedInstance } from 'sinon-ts'

Expand All @@ -18,9 +18,7 @@ describe('delegated-routing-v1-http-api-server', () => {
let url: URL

beforeEach(async () => {
helia = stubInterface<Helia>({
libp2p: stubInterface<Libp2p>()
})
helia = stubInterface<Helia>()
server = await createDelegatedRoutingV1HttpApiServer(helia, {
listen: {
host: '127.0.0.1',
Expand Down Expand Up @@ -68,7 +66,7 @@ describe('delegated-routing-v1-http-api-server', () => {
})

it('GET providers returns 404 if no providers are found', async () => {
helia.libp2p.contentRouting.findProviders = async function * () {}
helia.routing.findProviders = async function * () {}

const res = await fetch(`${url}routing/v1/providers/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn`, {
method: 'GET'
Expand All @@ -78,7 +76,7 @@ describe('delegated-routing-v1-http-api-server', () => {
})

it('GET providers returns 404 if no providers are found when streaming', async () => {
helia.libp2p.contentRouting.findProviders = async function * () {}
helia.routing.findProviders = async function * () {}

const res = await fetch(`${url}routing/v1/providers/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn`, {
method: 'GET',
Expand All @@ -104,7 +102,7 @@ describe('delegated-routing-v1-http-api-server', () => {
]
}

helia.libp2p.contentRouting.findProviders = async function * () {
helia.routing.findProviders = async function * () {
yield provider1
yield provider2
}
Expand Down Expand Up @@ -139,7 +137,7 @@ describe('delegated-routing-v1-http-api-server', () => {
]
}

helia.libp2p.contentRouting.findProviders = async function * () {
helia.routing.findProviders = async function * () {
yield provider1
yield provider2
}
Expand Down Expand Up @@ -190,7 +188,7 @@ describe('delegated-routing-v1-http-api-server', () => {
]
}

helia.libp2p.peerRouting.findPeer = async function () {
helia.routing.findPeer = async function () {
return peer
}

Expand Down Expand Up @@ -226,7 +224,7 @@ describe('delegated-routing-v1-http-api-server', () => {
const cid = CID.parse('bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4')
const record = await createIpnsRecord(peerId, cid, 0, 1000)

helia.libp2p.contentRouting.get = async function () {
helia.routing.get = async function () {
return marshalIpnsRecord(record)
}

Expand All @@ -251,7 +249,7 @@ describe('delegated-routing-v1-http-api-server', () => {
let putKey: Uint8Array = new Uint8Array()
let putValue: Uint8Array = new Uint8Array()

helia.libp2p.contentRouting.put = async function (key: Uint8Array, value: Uint8Array) {
helia.routing.put = async function (key: Uint8Array, value: Uint8Array) {
putKey = key
putValue = value
}
Expand Down

0 comments on commit 23cd638

Please sign in to comment.