storacha / w3name

IPNS client and service for generating, updating, and tracking immutable names with signed updates
Other
45 stars 12 forks source link

Name.publish rejects; Unexpected end of JSON input #17

Closed tabcat closed 2 years ago

tabcat commented 2 years ago

using the client's Name.publish with the miniflare api from packages/api i get a rejection Uncaught SyntaxError: Unexpected end of JSON input

I may be using this wrong. This is my node REPL script:

Name = await import('@w3name/client')
{ W3NameService: Service } = await import('@w3name/client/service')

const endpoint = new URL('http://127.0.0.1:8787')
service = new Service(endpoint)
name = await Name.create()
keypair = name.key

value = '/ipfs/bafkreiem4twkqzsq2aj4shbycd4yvoj2cx72vezicletlhi7dijjciqpui'
revision = await Name.v0(name, value)
await Name.publish(service, revision, name.key)

The rejection is from https://github.com/web3-storage/w3name/blob/602a20505158e558a1bfc31b6dd13e8bbb65977e/packages/client/src/index.ts#L221

By looking at res.text() instead of res.json() it looks to be a result of the response from the service being an empty string. This explains the error message

JSON.parse('') // Uncaught SyntaxError: Unexpected end of JSON input

It's also not setting a record for this key.

tabcat commented 2 years ago

I've learned web3.storage/name is probably what I want