diff --git a/packages/gateway-conformance/package.json b/packages/gateway-conformance/package.json index c3482138..0892075b 100644 --- a/packages/gateway-conformance/package.json +++ b/packages/gateway-conformance/package.json @@ -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", @@ -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" }, diff --git a/packages/gateway-conformance/src/conformance.spec.ts b/packages/gateway-conformance/src/conformance.spec.ts index 62039853..c9508e5c 100644 --- a/packages/gateway-conformance/src/conformance.spec.ts +++ b/packages/gateway-conformance/src/conformance.spec.ts @@ -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 diff --git a/packages/gateway-conformance/src/fixtures/kubo-mgmt.ts b/packages/gateway-conformance/src/fixtures/kubo-mgmt.ts index d1dd81aa..a0b343f3 100644 --- a/packages/gateway-conformance/src/fixtures/kubo-mgmt.ts +++ b/packages/gateway-conformance/src/fixtures/kubo-mgmt.ts @@ -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)) @@ -92,13 +104,23 @@ export async function loadFixtures (kuboRepoDir: string): Promise { } 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)) diff --git a/packages/interop/package.json b/packages/interop/package.json index 98158221..4dfb8680 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -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", diff --git a/packages/interop/src/fixtures/create-kubo.ts b/packages/interop/src/fixtures/create-kubo.ts index b167d765..cca0e7bb 100644 --- a/packages/interop/src/fixtures/create-kubo.ts +++ b/packages/interop/src/fixtures/create-kubo.ts @@ -14,7 +14,11 @@ export async function createKuboNode (repoPath = undefined): Promise { 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' }, diff --git a/packages/interop/src/fixtures/load-fixtures.ts b/packages/interop/src/fixtures/load-fixtures.ts index 9fa5c296..f95eb218 100644 --- a/packages/interop/src/fixtures/load-fixtures.ts +++ b/packages/interop/src/fixtures/load-fixtures.ts @@ -1,5 +1,5 @@ import { $ } from 'execa' -import fg from 'fast-glob' +import { glob } from 'glob' import { path as kuboPath } from 'kubo' /** @@ -9,7 +9,9 @@ import { path as kuboPath } from 'kubo' export async function loadFixtures (IPFS_PATH = undefined): Promise { 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}` - } + })) } diff --git a/packages/verified-fetch/package.json b/packages/verified-fetch/package.json index 5d4d8014..2a0253e0 100644 --- a/packages/verified-fetch/package.json +++ b/packages/verified-fetch/package.json @@ -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", @@ -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", @@ -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 } diff --git a/packages/verified-fetch/src/utils/get-peer-id-from-string.ts b/packages/verified-fetch/src/utils/get-peer-id-from-string.ts new file mode 100644 index 00000000..abe7724e --- /dev/null +++ b/packages/verified-fetch/src/utils/get-peer-id-from-string.ts @@ -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)) +} diff --git a/packages/verified-fetch/src/utils/parse-url-string.ts b/packages/verified-fetch/src/utils/parse-url-string.ts index 337fe7b6..145d82a0 100644 --- a/packages/verified-fetch/src/utils/parse-url-string.ts +++ b/packages/verified-fetch/src/utils/parse-url-string.ts @@ -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' @@ -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') } diff --git a/packages/verified-fetch/src/verified-fetch.ts b/packages/verified-fetch/src/verified-fetch.ts index 7476edcf..81311580 100644 --- a/packages/verified-fetch/src/verified-fetch.ts +++ b/packages/verified-fetch/src/verified-fetch.ts @@ -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' @@ -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' @@ -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) diff --git a/packages/verified-fetch/test/custom-dns-resolvers.spec.ts b/packages/verified-fetch/test/custom-dns-resolvers.spec.ts index f8ff6414..c3991a9e 100644 --- a/packages/verified-fetch/test/custom-dns-resolvers.spec.ts +++ b/packages/verified-fetch/test/custom-dns-resolvers.spec.ts @@ -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: [{ @@ -40,6 +29,7 @@ describe('custom dns-resolvers', () => { RecordType.TXT ] }]) + await stop(fetch) }) it('is used when passed to VerifiedFetch', async () => { @@ -49,8 +39,7 @@ describe('custom dns-resolvers', () => { }] }) - await stop(helia) - helia = await createHelia({ + const helia = await createHelia({ dns: dns({ resolvers: { '.': customDnsResolver @@ -73,5 +62,6 @@ describe('custom dns-resolvers', () => { RecordType.TXT ] }]) + await stop(helia, verifiedFetch) }) }) diff --git a/packages/verified-fetch/test/fixtures/create-offline-helia.ts b/packages/verified-fetch/test/fixtures/create-offline-helia.ts index 8b7e3d1d..9698d607 100644 --- a/packages/verified-fetch/test/fixtures/create-offline-helia.ts +++ b/packages/verified-fetch/test/fixtures/create-offline-helia.ts @@ -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 = {}): Promise { +export async function createHelia (init: Partial = {}): Promise> { const datastore = new MemoryDatastore() const blockstore = new IdentityBlockstore(new MemoryBlockstore()) - const helia = new HeliaClass({ + const helia = await createHeliaHTTP({ datastore, blockstore, blockBrokers: [], diff --git a/packages/verified-fetch/test/utils/parse-url-string.spec.ts b/packages/verified-fetch/test/utils/parse-url-string.spec.ts index 5e7d588b..97f3347e 100644 --- a/packages/verified-fetch/test/utils/parse-url-string.spec.ts +++ b/packages/verified-fetch/test/utils/parse-url-string.spec.ts @@ -1,12 +1,10 @@ import { generateKeyPair } from '@libp2p/crypto/keys' -import { matchPeerId } from '@libp2p/interface-compliance-tests/matchers' import { defaultLogger } from '@libp2p/logger' import { peerIdFromPrivateKey } from '@libp2p/peer-id' import { type Answer } from '@multiformats/dns' import { expect } from 'aegir/chai' import { base36 } from 'multiformats/bases/base36' import { CID } from 'multiformats/cid' -import { match } from 'sinon' import { stubInterface } from 'sinon-ts' import { parseUrlString } from '../../src/utils/parse-url-string.js' import { ipnsRecordStub } from '../fixtures/ipns-stubs.js' @@ -283,7 +281,7 @@ describe('parseUrlString', () => { const key = await generateKeyPair('Ed25519') const testPeerId = peerIdFromPrivateKey(key) - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(key.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId, ttl: oneHourInNanoseconds }) @@ -492,7 +490,7 @@ describe('parseUrlString', () => { }) it('can parse a URL with PeerId only', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -509,7 +507,7 @@ describe('parseUrlString', () => { }) it('can parse a base36 PeerId CID', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -526,7 +524,7 @@ describe('parseUrlString', () => { }) it('can parse a URL with PeerId+path', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -543,7 +541,7 @@ describe('parseUrlString', () => { }) it('can parse a URL with PeerId+path with a trailing slash', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -560,7 +558,7 @@ describe('parseUrlString', () => { }) it('can parse a URL with PeerId+queryString', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -579,7 +577,7 @@ describe('parseUrlString', () => { }) it('can parse a URL with PeerId+path+queryString', async () => { - ipns.resolve.withArgs(matchPeerId(testPeerId)).resolves({ + ipns.resolve.withArgs(testPeerId.publicKey).resolves({ cid: CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'), path: '', record: ipnsRecordStub({ peerId: testPeerId }) @@ -604,7 +602,7 @@ describe('parseUrlString', () => { const recordPath = 'foo' const requestPath = 'bar/baz.txt' - ipns.resolve.withArgs(matchPeerId(peerId)).resolves({ + ipns.resolve.withArgs(peerId.publicKey).resolves({ cid, path: recordPath, record: ipnsRecordStub({ peerId: testPeerId }) @@ -627,7 +625,7 @@ describe('parseUrlString', () => { const recordPath = 'foo/' const requestPath = 'bar/baz.txt' - ipns.resolve.withArgs(matchPeerId(peerId)).resolves({ + ipns.resolve.withArgs(peerId.publicKey).resolves({ cid, path: recordPath, record: ipnsRecordStub({ peerId: testPeerId }) @@ -650,7 +648,7 @@ describe('parseUrlString', () => { const recordPath = '/foo/////bar//' const requestPath = '///baz///qux.txt' - ipns.resolve.withArgs(matchPeerId(peerId)).resolves({ + ipns.resolve.withArgs(peerId.publicKey).resolves({ cid, path: recordPath, record: ipnsRecordStub({ peerId: testPeerId }) @@ -675,7 +673,7 @@ describe('parseUrlString', () => { const key = await generateKeyPair('Ed25519') peerId = peerIdFromPrivateKey(key) cid = CID.parse('QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm') - ipns.resolve.withArgs(matchPeerId(peerId)).resolves({ + ipns.resolve.withArgs(peerId.publicKey).resolves({ cid, path: '', record: ipnsRecordStub({ peerId }) @@ -764,7 +762,7 @@ describe('parseUrlString', () => { const key = await generateKeyPair('Ed25519') peerId = peerIdFromPrivateKey(key) cid = CID.parse('QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm') - ipns.resolve.withArgs(matchPeerId(peerId)).resolves({ + ipns.resolve.withArgs(peerId.publicKey).resolves({ cid, path: '', record: ipnsRecordStub({ peerId }) @@ -869,20 +867,19 @@ describe('parseUrlString', () => { value = await getVal(i++) cid = CID.parse('QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm') if (type === 'peerid') { - ipns.resolve.withArgs(matchPeerId(value as PeerId)).resolves({ + ipns.resolve.withArgs((value as PeerId).publicKey).resolves({ cid, path: '', record: ipnsRecordStub({ peerId: value as PeerId }) }) } else if (type === 'dnslink-encoded') { - const matchValue = (value as string).replace(/-/g, '.') - ipns.resolveDNSLink.withArgs(match(matchValue)).resolves({ + ipns.resolveDNSLink.withArgs(value.toString().replace(/-/g, '.')).resolves({ cid, path: '', answer: stubInterface() }) } else { - ipns.resolveDNSLink.withArgs(match(value as string)).resolves({ + ipns.resolveDNSLink.withArgs(value.toString()).resolves({ cid, path: '', answer: stubInterface()