Skip to content

Commit 4cae71c

Browse files
committed
ipip: ipns signed records response format
1 parent 331d472 commit 4cae71c

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

src/http-gateways/path-gateway.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >
44
The most versatile form of IPFS Gateway is a Path Gateway. It exposes namespaces, such
55
as /ipfs/ and /ipns/ under an HTTP server root and provides basic primitives for integrating
66
IPFS resources within the existing HTTP stack.
7-
date: 2023-02-27
7+
date: 2023-03-30
88
maturity: reliable
99
editors:
1010
- name: Marcin Rataj
@@ -138,6 +138,7 @@ For example:
138138
- [application/vnd.ipld.dag-cbor](https://www.iana.org/assignments/media-types/application/vnd.ipld.dag-cbor) – requests [IPLD Data Model](https://ipld.io/docs/data-model/) representation serialized into [DAG-CBOR format](https://ipld.io/docs/codecs/known/dag-cbor/). If the requested CID already has `dag-cbor` (0x71) codec, data is validated as DAG-CBOR before being returned as-is. Invalid DAG-CBON produces HTTP Error 500.
139139
- [application/json](https://www.iana.org/assignments/media-types/application/json) – same as `application/vnd.ipld.dag-json`, unless the CID's codec already is `json` (0x0200). Then, the raw JSON block can be returned as-is without any conversion.
140140
- [application/cbor](https://www.iana.org/assignments/media-types/application/cbor) – same as `application/vnd.ipld.dag-cbor`, unless the CID's codec already is `cbor` (0x51). Then, the raw CBOR block can be returned as-is without any conversion.
141+
- [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) – requests a verifiable [IPNS Record](../ipns/IPNS.md#ipns-record) to be returned. Produces 400 Bad Request if the content is not under the IPNS namespace, or contains a path.
141142

142143
### `Range` (request header)
143144

@@ -202,14 +203,16 @@ parameter, if present)
202203

203204
Optional, `format=<format>` can be used to request specific response format.
204205

205-
This is a URL-friendly alternative to sending an [`Accept`](#accept-request-header) header. These are the equivalents:
206+
This is a URL-friendly alternative to sending an [`Accept`](#accept-request-header) header.
207+
These are the equivalents:
206208
- `format=raw``Accept: application/vnd.ipld.raw`
207209
- `format=car``Accept: application/vnd.ipld.car`
208210
- `format=tar``Accept: application/x-tar`
209211
- `format=dag-json``Accept: application/vnd.ipld.dag-json`
210212
- `format=dag-cbor``Accept: application/vnd.ipld.dag-cbor`
211213
- `format=json``Accept: application/json`
212214
- `format=cbor``Accept: application/cbor`
215+
- `format=ipns-record``Accept: application/vnd.ipfs.ipns-record`
213216

214217
<!-- TODO Planned: https://github.com/ipfs/go-ipfs/issues/8769
215218
- `selector=<cid>` can be used for passing a CID with [IPLD selector](https://ipld.io/specs/selectors)
@@ -576,6 +579,8 @@ The following response types require an explicit opt-in, can only be requested w
576579
- Arbitrary DAG as a verifiable CAR file or a stream, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car).
577580
- TAR (`?format=tar`)
578581
- Deserialized UnixFS files and directories as a TAR file or a stream, see [IPIP-288](https://github.com/ipfs/specs/pull/288)
582+
- IPNS Record
583+
- Protobuf bytes representing a verifiable [IPNS Record](../ipns/IPNS.md#record-serialization-format) (multicodec `0x0300`)
579584

580585
# Appendix: notes for implementers
581586

src/http-gateways/trustless-gateway.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ description: >
44
Trustless Gateways are a minimal subset of Path Gateways that allow light IPFS
55
clients to retrieve data behind a CID and verify its integrity without delegating any
66
trust to the gateway itself.
7-
date: 2022-11-09
7+
date: 2023-03-30
88
maturity: reliable
99
editors:
1010
- name: Marcin Rataj
1111
github: lidel
1212
url: https://lidel.org/
13+
- name: Henrique Dias
14+
github: hacdias
15+
url: https://hacdias.com/
1316
tags: ['httpGateways', 'lowLevelHttpGateways']
1417
order: 1
1518
---
@@ -36,6 +39,14 @@ Downloads data at specified CID.
3639

3740
Same as GET, but does not return any payload.
3841

42+
## `GET /ipns/{key}[?{params}]`
43+
44+
Downloads data at specified IPNS Key. Verifiable :cite[ipns-record] can be requested via `?format=ipns-record`
45+
46+
## `HEAD /ipns/{key}[?{params}]`
47+
48+
same as GET, but does not return any payload.
49+
3950
# HTTP Request
4051

4152
Same as in :cite[path-gateway], but with limited number of supported response types.
@@ -53,6 +64,7 @@ Below response types MUST to be supported:
5364

5465
- [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) – requests a single, verifiable raw block to be returned
5566
- [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) – disables IPLD/IPFS deserialization, requests a verifiable CAR stream to be returned
67+
- [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) – requests a verifiable :cite[ipns-record] (multicodec `0x0300`).
5668

5769
# HTTP Response
5870

src/ipips/ipip-0351.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: "IPIP 0351: IPNS Signed Records Response Format on HTTP Gateways"
3+
date: 2022-11-29
4+
ipip: ratified
5+
editors:
6+
- name: Henrique Dias
7+
github: hacdias
8+
url: https://hacdias.com/
9+
relatedIssues:
10+
- https://github.com/ipfs/specs/issues/320
11+
- https://github.com/ipfs/specs/pull/351
12+
- https://github.com/ipfs/kubo/pull/9399
13+
order: 351
14+
tags: ['ipips']
15+
---
16+
17+
## Summary
18+
19+
Add IPNS Signed Records response format to the [HTTP Gateway](/http-gateways/).
20+
21+
## Motivation
22+
23+
Currently, the gateway allows for trustless retrieval of data under the `/ipfs`
24+
namespace, but fetching the data as a CAR, or Block, and then verifying it locally.
25+
This is especially important for light IPFS clients, so that they can retrieve
26+
data from other gateways without delegating any of the trust to them. Unfortunately,
27+
this is not possible under the `/ipns` namespace.
28+
29+
In contrary to DNSLink, IPNS provides cryptographically-verifiable records that
30+
can be verified by the client. This means that, if a gateway is able to provide
31+
the IPNS signed record to an HTTP client, trustless retrieval would also be available
32+
under the `/ipns` namespace.
33+
34+
In this IPIP, we propose adding :cite[ipns-record] as a response
35+
format to the gateway under the `/ipns` namespace, allowing for trustless
36+
retrieval of IPNS records.
37+
38+
## Detailed design
39+
40+
The solution is to allow the Gateway to provide an IPNS signed record by
41+
requesting it using either the `Accept` HTTP header or the `format` URL query.
42+
43+
## Test fixtures
44+
45+
IPNS records for testing can be generated in Kubo by creating an IPNS record:
46+
47+
```bash
48+
$ ipfs key gen <key-name>
49+
k51Key
50+
51+
$ ipfs name publish /ipfs/bafyHash --key=<key-name> --ttl=<record-ttl>
52+
Published to k51Key: /ipfs/bafyHash
53+
54+
$ ipfs routing get /ipns/k51Key > key.pb
55+
```
56+
57+
## Design rationale
58+
59+
The current gateway already supports different response formats via the
60+
`Accept` HTTP header and the `format` URL query. This IPIP proposes adding
61+
one more supported format to that list.
62+
63+
### User benefit
64+
65+
By providing IPNS records through the gateway, IPFS light clients are able
66+
to race multiple gateways in search for an IPNS record for a certain IPNS key.
67+
This way, IPFS light clients do not necessarily need to implement the required
68+
machinery to fetch IPNS records from other IPFS nodes through the DHT or PubSub.
69+
70+
In addition, the retrieval of IPNS records is trustless in the sense that they can
71+
be verified by the client since the IPNS record includes a cryptographic signature
72+
provided by its creator.
73+
74+
### Compatibility
75+
76+
This IPIP proposes a new format to be added to the gateway, but does not change
77+
any prior format. Therefore, this IPIP is backwards compatible. Please note
78+
that IPNS records are also added to the :cite[trustless-gateway] specification.
79+
80+
### Copyright
81+
82+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)