RangerMauve / js-ipfs-fetch

Use the same `fetch()` API browsers provide for HTTP, but for IPFS
https://youtu.be/kI9Issf3MNc?t=1606
MIT License
64 stars 7 forks source link

Adding path to IPNS fails #10

Closed dirkcuys closed 2 years ago

dirkcuys commented 2 years ago

When I try to publish to a name in Agregore Mobile, I get the following error:

Error: To parse non base32 or base58btc encoded CID multibase decoder must be provided at parseCIDtoBytes (/tmp/.mount_agregoj9a9pB/resources/app.asar/node_modules/js-ipfs-fetch/node_modules/multiformats/cjs/src/cid.js:235:15) at Function.parse (/tmp/.mount_agregoj9a9pB/resources/app.asar/node_modules/js-ipfs-fetch/node_modules/multiformats/cjs/src/cid.js:204:29) at updateIPNS (/tmp/.mount_agregoj9a9pB/resources/app.asar/node_modules/js-ipfs-fetch/index.js:180:24) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async fetch (/tmp/.mount_agregoj9a9pB/resources/app.asar/node_modules/make-fetch/index.js:35:9) at async AsyncFunction.protocolHandler (/tmp/.mount_agregoj9a9pB/resources/app.asar/app/protocols/fetch-to-handler.js:45:24)

I might be misssing something, but the CID.parse step seems unnecessary when updating a ipns name:

const publish = await ipfs.name.publish(value, { allowOffline: true, key: finalName, signal })
const { name: cid } = publish
const hash = CID.parse(cid).toV1().toString(base32)

ipfs.name.publish gives back {name: 'keyvaluehere', value: '/ipfs/cid'}:

> await ipfs.name.publish('bafybeicjitceezjtkh26dveohzvvsfowrdmpo32c74455sb6p7bkrt4pyy', {key: 'bob'})
{
  name: 'k2k4r8nd95al2cdxrj0r0m40xqlq2ce1ffxv9ml4tgk3blydgzbqhgyc',
  value: '/ipfs/bafybeicjitceezjtkh26dveohzvvsfowrdmpo32c74455sb6p7bkrt4pyy'
}

So the IPNS address should just be '/ipns/' + name?

RangerMauve commented 2 years ago

I think this is an issue coming from switching to go-ipfs's latest version.

They changed the default encoding of the CID they return after doing a publish. Related to this: https://github.com/multiformats/js-multiformats/issues/173

I've got fixes for this on my local machine already, so I'll try to release soon.

RangerMauve commented 2 years ago

Fixed in 3.5.0, still needs to be added to Agregore Desktop