-
Notifications
You must be signed in to change notification settings - Fork 117
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
feat: support requesting raw IPNS records in @helia/verified-fetch #443
Conversation
Let users get raw data back from CIDs that would otherwise trigger decoding as JSON or CBOR etc by specifying an `Accept` header. ```typescript const res = await verifiedFetch(cid, { headers: { accept: 'application/octet-stream' } }) console.info(res.headers.get('accept')) // application/octet-stream ``` Make sure the content-type matches the accept header: ```typescript const res = await verifiedFetch(cid, { headers: { accept: 'application/vnd.ipld.raw' } }) console.info(res.headers.get('accept')) // application/vnd.ipld.raw ``` Support multiple values, match the first one: ```typescript const res = await verifiedFetch(cid, { headers: { accept: 'application/vnd.ipld.raw, application/octet-stream, */*' } }) console.info(res.headers.get('accept')) // application/vnd.ipld.raw ``` If they specify an Accept header we can't honor, return a [406](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406): ```typescript const res = await verifiedFetch(cid, { headers: { accept: 'application/what-even-is-this' } }) console.info(res.status) // 406 ```
…ader-for-raw-types
Adds support for the `application/vnd.ipld.car` accept header to allow downloading CAR files of DAGs.
Adds support for downloading tar archives of UnixFS directories
Adds support for the `application/vnd.ipfs.ipns-record` Accept header to return raw IPNS records.
@@ -153,17 +153,20 @@ | |||
"@ipld/dag-json": "^10.2.0", | |||
"@ipld/dag-pb": "^4.1.0", | |||
"@libp2p/interface": "^1.1.2", | |||
"@libp2p/kad-dht": "^12.0.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only here to be able to deserialize stored IPNS records that are wrapped in a libp2p record.
Longer term we may wish to split the libp2p record code out of the dht code to make the bundle size a bit smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a tracking issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉🎉
await stop(helia, verifiedFetch) | ||
}) | ||
|
||
it('should support fetching a raw IPNS record', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have this test, we can remove https://github.com/ipfs/helia/blob/main/packages/verified-fetch/test/accept-header.spec.ts#L227-L248 which is skipped anyways
Adds support for the
application/vnd.ipfs.ipns-record
Accept header to return raw IPNS records.