Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: bump the helia-deps group across 3 directories with 7 updates #141

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/gateway-conformance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@
"test": "aegir test -t node"
},
"dependencies": {
"@helia/block-brokers": "^3.0.1",
"@helia/http": "^1.0.8",
"@helia/interface": "^4.3.0",
"@helia/routers": "^1.1.0",
"@helia/verified-fetch": "1.5.0",
"@libp2p/kad-dht": "^12.0.17",
"@helia/block-brokers": "^4.0.2",
"@helia/http": "^2.0.2",
"@helia/interface": "^5.1.0",
"@helia/routers": "^2.2.0",
"@helia/verified-fetch": "2.1.2",
"@libp2p/interface": "^2.2.1",
"@libp2p/kad-dht": "^14.1.3",
"@libp2p/logger": "^5.1.4",
"@libp2p/peer-id": "^4.1.2",
"@libp2p/peer-id": "^5.0.8",
"@multiformats/dns": "^1.0.6",
"@sgtpooki/file-type": "^1.0.1",
"aegir": "^45.0.1",
Expand All @@ -70,9 +71,9 @@
"interface-blockstore": "^5.2.10",
"interface-datastore": "^8.2.11",
"ipfsd-ctl": "^14.1.0",
"ipns": "^9.1.0",
"kubo": "^0.32.0",
"kubo-rpc-client": "^4.1.1",
"multiformats": "^13.3.1",
"uint8arrays": "^5.1.0",
"undici": "^6.18.1"
},
Expand Down
11 changes: 9 additions & 2 deletions packages/gateway-conformance/src/conformance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,15 @@ const tests: TestConfig[] = [
// },
{
name: 'TestGatewaySubdomainAndIPNS',
run: ['TestGatewaySubdomainAndIPNS'],
successRate: 31.58
run: [
'TestGatewaySubdomainAndIPNS'
],
skip: [
'TestGatewaySubdomainAndIPNS/request_for_a_ED25519_libp2p-key_.*',
'TestGatewaySubdomainAndIPNS/.*redirects_to_CID_with_libp2p-key_multicodec',
'TestGatewaySubdomainAndIPNS/.*redirects_to_CIDv1.*'
],
successRate: 46.15
},
{
// TODO: add directory listing support to verified-fetch
Expand Down
30 changes: 26 additions & 4 deletions packages/gateway-conformance/src/fixtures/kubo-mgmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,30 @@
import { readFile } from 'node:fs/promises'
import { dirname, relative, posix, basename } from 'node:path'
import { fileURLToPath } from 'node:url'
import { type PeerId } from '@libp2p/interface'
import { Record as DhtRecord } from '@libp2p/kad-dht'
import { logger } from '@libp2p/logger'
import { peerIdFromString } from '@libp2p/peer-id'
import { peerIdFromCID, peerIdFromString } from '@libp2p/peer-id'
import { $ } from 'execa'
import fg from 'fast-glob'
import { Key } from 'interface-datastore'
import { peerIdToRoutingKey } from 'ipns'
import { path } from 'kubo'
import { CID } from 'multiformats/cid'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { GWC_IMAGE } from '../constants.js'
import { getIpnsRecordDatastore } from './ipns-record-datastore.js'

function getPeerIdFromString (peerIdString: string): PeerId {
if (peerIdString.charAt(0) === '1' || peerIdString.charAt(0) === 'Q') {
return peerIdFromString(peerIdString)
}

// try resolving as a base36 CID
return peerIdFromCID(CID.parse(peerIdString))
}

// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -92,13 +104,23 @@ export async function loadFixtures (kuboRepoDir: string): Promise<string> {
}

const datastore = getIpnsRecordDatastore()
const IPNS_PREFIX = uint8ArrayFromString('/ipns/')

for (const fsIpnsRecord of await fg.glob([`${GWC_FIXTURES_PATH}/**/*.ipns-record`])) {
const peerIdString = basename(fsIpnsRecord, '.ipns-record').split('_')[0]
const relativePath = relative(GWC_FIXTURES_PATH, fsIpnsRecord)
log('Loading *.ipns-record fixture %s', relativePath)
const key = peerIdFromString(peerIdString)
const customRoutingKey = peerIdToRoutingKey(key)
const key = getPeerIdFromString(peerIdString)
let bytes: Uint8Array
if (['Ed25519', 'RSA'].includes(key.type)) {
bytes = key.toMultihash().bytes
} else {
throw new Error('Unsupported key type')
}
const customRoutingKey = uint8ArrayConcat([
IPNS_PREFIX,
bytes
])
const dhtKey = new Key('/dht/record/' + uint8ArrayToString(customRoutingKey, 'base32'), false)

const dhtRecord = new DhtRecord(customRoutingKey, await readFile(fsIpnsRecord, null), new Date(Date.now() + 9999999))
Expand Down
4 changes: 2 additions & 2 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"test:electron-main": "aegir test -t electron-main"
},
"dependencies": {
"@helia/verified-fetch": "1.5.0",
"@helia/verified-fetch": "2.1.2",
"aegir": "^45.0.1",
"execa": "^9.1.0",
"fast-glob": "^3.3.2",
"glob": "^11.0.0",
"ipfsd-ctl": "^14.1.0",
"kubo": "^0.32.0",
"kubo-rpc-client": "^4.1.1",
Expand Down
6 changes: 5 additions & 1 deletion packages/interop/src/fixtures/create-kubo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export async function createKuboNode (repoPath = undefined): Promise<KuboNode> {
Addresses: {
Swarm: [
'/ip4/0.0.0.0/tcp/4001',
'/ip4/0.0.0.0/tcp/4002/ws'
'/ip4/0.0.0.0/tcp/4002/ws',
'/ip4/0.0.0.0/udp/4001/webrtc-direct',
'/ip4/0.0.0.0/udp/4001/quic-v1/webtransport',
'/ip6/::/udp/4001/webrtc-direct',
'/ip6/::/udp/4001/quic-v1/webtransport'
],
Gateway: '/ip4/127.0.0.1/tcp/8180'
},
Expand Down
8 changes: 5 additions & 3 deletions packages/interop/src/fixtures/load-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { $ } from 'execa'
import fg from 'fast-glob'
import { glob } from 'glob'
import { path as kuboPath } from 'kubo'

/**
Expand All @@ -9,7 +9,9 @@ import { path as kuboPath } from 'kubo'
export async function loadFixtures (IPFS_PATH = undefined): Promise<void> {
const kuboBinary = process.env.KUBO_BINARY ?? kuboPath()

for (const carFile of await fg.glob('**/fixtures/data/*.car')) {
const files = await glob('**/fixtures/data/*.car', { cwd: process.cwd() })

await Promise.allSettled(files.map(async (carFile) => {
await $({ env: { IPFS_PATH } })`${kuboBinary} dag import --pin-roots=false --offline ${carFile}`
}
}))
}
39 changes: 20 additions & 19 deletions packages/verified-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,19 @@
"release": "aegir release"
},
"dependencies": {
"@helia/block-brokers": "^4.0.0",
"@helia/car": "^4.0.0",
"@helia/http": "^2.0.0",
"@helia/interface": "^5.0.0",
"@helia/ipns": "^8.0.0",
"@helia/routers": "^2.0.0",
"@helia/unixfs": "^4.0.0",
"@helia/block-brokers": "^4.0.2",
"@helia/car": "^4.0.1",
"@helia/http": "^2.0.2",
"@helia/interface": "^5.1.0",
"@helia/ipns": "^8.0.1",
"@helia/routers": "^2.2.0",
"@helia/unixfs": "^4.0.1",
"@ipld/dag-cbor": "^9.2.1",
"@ipld/dag-json": "^10.2.2",
"@ipld/dag-pb": "^4.1.2",
"@libp2p/interface": "^2.1.3",
"@libp2p/kad-dht": "^14.0.1",
"@libp2p/peer-id": "^5.0.5",
"@libp2p/interface": "^2.2.1",
"@libp2p/kad-dht": "^14.1.3",
"@libp2p/peer-id": "^5.0.8",
"@multiformats/dns": "^1.0.6",
"cborg": "^4.2.4",
"hashlru": "^2.3.0",
Expand All @@ -166,26 +166,24 @@
"it-tar": "^6.0.5",
"it-to-browser-readablestream": "^2.0.9",
"lru-cache": "^11.0.2",
"multiformats": "^13.3.0",
"multiformats": "^13.3.1",
"progress-events": "^1.0.1",
"uint8arrays": "^5.1.0"
},
"devDependencies": {
"@helia/dag-cbor": "^4.0.0",
"@helia/dag-json": "^4.0.0",
"@helia/json": "^4.0.0",
"@helia/utils": "^1.0.0",
"@helia/dag-cbor": "^4.0.1",
"@helia/dag-json": "^4.0.1",
"@helia/json": "^4.0.1",
"@ipld/car": "^5.3.2",
"@libp2p/crypto": "^5.0.5",
"@libp2p/interface-compliance-tests": "^6.1.6",
"@libp2p/logger": "^5.1.1",
"@libp2p/crypto": "^5.0.7",
"@libp2p/logger": "^5.1.4",
"@sgtpooki/file-type": "^1.0.1",
"@types/sinon": "^17.0.3",
"aegir": "^45.0.1",
"blockstore-core": "^5.0.2",
"browser-readablestream-to-it": "^2.0.7",
"datastore-core": "^10.0.2",
"helia": "^5.0.0",
"helia": "^5.1.1",
"ipfs-unixfs-importer": "^15.3.1",
"ipns": "^10.0.0",
"it-all": "^3.0.6",
Expand All @@ -197,5 +195,8 @@
"sinon": "^18.0.0",
"sinon-ts": "^2.0.0"
},
"browser": {
"./dist/src/utils/libp2p-defaults.js": "./dist/src/utils/libp2p-defaults.browser.js"
},
"sideEffects": false
}
12 changes: 12 additions & 0 deletions packages/verified-fetch/src/utils/get-peer-id-from-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { peerIdFromCID, peerIdFromString } from '@libp2p/peer-id'
import { CID } from 'multiformats/cid'
import type { PeerId } from '@libp2p/interface'

export function getPeerIdFromString (peerIdString: string): PeerId {
if (peerIdString.charAt(0) === '1' || peerIdString.charAt(0) === 'Q') {
return peerIdFromString(peerIdString)
}

// try resolving as a base36 CID
return peerIdFromCID(CID.parse(peerIdString))
}
9 changes: 2 additions & 7 deletions packages/verified-fetch/src/utils/parse-url-string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { peerIdFromCID, peerIdFromString } from '@libp2p/peer-id'
import { CID } from 'multiformats/cid'
import { getPeerIdFromString } from './get-peer-id-from-string.js'
import { TLRU } from './tlru.js'
import type { RequestFormatShorthand } from '../types.js'
import type { DNSLinkResolveResult, IPNS, IPNSResolveResult, IPNSRoutingEvents, ResolveDNSLinkProgressEvents, ResolveProgressEvents, ResolveResult } from '@helia/ipns'
Expand Down Expand Up @@ -178,12 +178,7 @@ export async function parseUrlString ({ urlString, ipns, logger }: ParseUrlStrin
try {
// try resolving as an IPNS name

if (cidOrPeerIdOrDnsLink.charAt(0) === '1' || cidOrPeerIdOrDnsLink.charAt(0) === 'Q') {
peerId = peerIdFromString(cidOrPeerIdOrDnsLink)
} else {
// try resolving as a base36 CID
peerId = peerIdFromCID(CID.parse(cidOrPeerIdOrDnsLink))
}
peerId = getPeerIdFromString(cidOrPeerIdOrDnsLink)
if (peerId.publicKey == null) {
throw new TypeError('cidOrPeerIdOrDnsLink contains no public key')
}
Expand Down
16 changes: 4 additions & 12 deletions packages/verified-fetch/src/verified-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import * as ipldDagJson from '@ipld/dag-json'
import { code as dagPbCode } from '@ipld/dag-pb'
import { type AbortOptions, type Logger, type PeerId } from '@libp2p/interface'
import { Record as DHTRecord } from '@libp2p/kad-dht'
import { peerIdFromCID, peerIdFromString } from '@libp2p/peer-id'
import { Key } from 'interface-datastore'
import { exporter } from 'ipfs-unixfs-exporter'
import toBrowserReadableStream from 'it-to-browser-readablestream'
import { LRUCache } from 'lru-cache'
import { CID } from 'multiformats/cid'
import { type CID } from 'multiformats/cid'
import { code as jsonCode } from 'multiformats/codecs/json'
import { code as rawCode } from 'multiformats/codecs/raw'
import { identity } from 'multiformats/hashes/identity'
Expand All @@ -22,6 +21,7 @@ import { ByteRangeContext } from './utils/byte-range-context.js'
import { dagCborToSafeJSON } from './utils/dag-cbor-to-safe-json.js'
import { getContentDispositionFilename } from './utils/get-content-disposition-filename.js'
import { getETag } from './utils/get-e-tag.js'
import { getPeerIdFromString } from './utils/get-peer-id-from-string.js'
import { getResolvedAcceptHeader } from './utils/get-resolved-accept-header.js'
import { getStreamFromAsyncIterable } from './utils/get-stream-from-async-iterable.js'
import { tarStream } from './utils/get-tar-stream.js'
Expand Down Expand Up @@ -159,19 +159,11 @@ export class VerifiedFetch {
if (resource.startsWith('ipns://')) {
const peerIdString = resource.replace('ipns://', '')
this.log.trace('trying to parse peer id from "%s"', peerIdString)
peerId = peerIdFromString(peerIdString)
peerId = getPeerIdFromString(peerIdString)
} else {
const peerIdString = resource.split('.ipns.')[0].split('://')[1]
this.log.trace('trying to parse peer id from "%s"', peerIdString)
let cid: CID
try {
cid = CID.parse(peerIdString)
} catch (err: any) {
this.log.error('could not construct CID from peerId string "%s"', resource, err)
return badRequestResponse(resource, err)
}

peerId = peerIdFromCID(cid)
peerId = getPeerIdFromString(peerIdString)
}
} catch (err: any) {
this.log.error('could not parse peer id from IPNS url %s', resource, err)
Expand Down
16 changes: 3 additions & 13 deletions packages/verified-fetch/test/custom-dns-resolvers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@ import Sinon from 'sinon'
import { createVerifiedFetch } from '../src/index.js'
import { VerifiedFetch } from '../src/verified-fetch.js'
import { createHelia } from './fixtures/create-offline-helia.js'
import type { Helia } from '@helia/interface'

describe('custom dns-resolvers', () => {
let helia: Helia

beforeEach(async () => {
helia = await createHelia()
})

afterEach(async () => {
await stop(helia)
})

it('is used when passed to createVerifiedFetch', async () => {
const customDnsResolver = Sinon.stub().withArgs('_dnslink.some-non-cached-domain.com').resolves({
Answer: [{
Expand All @@ -40,6 +29,7 @@ describe('custom dns-resolvers', () => {
RecordType.TXT
]
}])
await stop(fetch)
})

it('is used when passed to VerifiedFetch', async () => {
Expand All @@ -49,8 +39,7 @@ describe('custom dns-resolvers', () => {
}]
})

await stop(helia)
helia = await createHelia({
const helia = await createHelia({
dns: dns({
resolvers: {
'.': customDnsResolver
Expand All @@ -73,5 +62,6 @@ describe('custom dns-resolvers', () => {
RecordType.TXT
]
}])
await stop(helia, verifiedFetch)
})
})
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Helia as HeliaClass } from '@helia/utils'
import { createHeliaHTTP } from '@helia/http'
import { MemoryBlockstore } from 'blockstore-core'
import { IdentityBlockstore } from 'blockstore-core/identity'
import { MemoryDatastore } from 'datastore-core'
import type { HeliaHTTPInit } from '@helia/http'
import type { Helia } from '@helia/interface'
import { type HeliaInit } from 'helia'

export async function createHelia (init: Partial<HeliaHTTPInit> = {}): Promise<Helia> {
export async function createHelia (init: Partial<HeliaInit> = {}): Promise<ReturnType<typeof createHeliaHTTP>> {
const datastore = new MemoryDatastore()
const blockstore = new IdentityBlockstore(new MemoryBlockstore())

const helia = new HeliaClass({
const helia = await createHeliaHTTP({
datastore,
blockstore,
blockBrokers: [],
Expand Down
Loading
Loading