Skip to content

Commit b3ab660

Browse files
authored
Merge pull request #351 from ipfs/ipns-records-gateway
2 parents 331d472 + 6785981 commit b3ab660

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

src/http-gateways/path-gateway.md

+8-3
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)
@@ -575,7 +578,9 @@ The following response types require an explicit opt-in, can only be requested w
575578
- CAR (`?format=car`)
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`)
578-
- Deserialized UnixFS files and directories as a TAR file or a stream, see [IPIP-288](https://github.com/ipfs/specs/pull/288)
581+
- Deserialized UnixFS files and directories as a TAR file or a stream, see :cite[ipip-0288].
582+
- IPNS Record
583+
- Protobuf bytes representing a verifiable :cite[ipns-record] (multicodec `0x0300`)
579584

580585
# Appendix: notes for implementers
581586

src/http-gateways/trustless-gateway.md

+13-1
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

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
- name: Marcin Rataj
10+
github: lidel
11+
url: https://lidel.org/
12+
relatedIssues:
13+
- https://github.com/ipfs/specs/issues/320
14+
- https://github.com/ipfs/specs/pull/351
15+
- https://github.com/ipfs/kubo/pull/9399
16+
order: 351
17+
tags: ['ipips']
18+
---
19+
20+
## Summary
21+
22+
Add IPNS Signed Records response format to the [HTTP Gateway](/http-gateways/).
23+
24+
## Motivation
25+
26+
Currently, the gateway allows for trustless retrieval of data under the `/ipfs`
27+
namespace, but fetching the data as a CAR, or Block, and then verifying it locally.
28+
This is especially important for light IPFS clients, so that they can retrieve
29+
data from other gateways without delegating any of the trust to them. Unfortunately,
30+
this is not possible under the `/ipns` namespace.
31+
32+
In contrary to DNSLink, IPNS provides cryptographically-verifiable records that
33+
can be verified by the client. This means that, if a gateway is able to provide
34+
the IPNS signed record to an HTTP client, trustless retrieval would also be available
35+
under the `/ipns` namespace.
36+
37+
In this IPIP, we propose adding :cite[ipns-record] as a response
38+
format to the gateway under the `/ipns` namespace, allowing for trustless
39+
retrieval of IPNS records over HTTP as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record) content type (multicodec `0x0300`).
40+
41+
## Detailed design
42+
43+
- :cite[trustless-gateway] can now provide a signed IPNS record upon request for `/ipns/{ipns-name}` path.
44+
- To request the IPNS record, use one of the following methods:
45+
- Include the `Accept: application/vnd.ipfs.ipns-record` HTTP header in the request.
46+
- Include the `format=ipns-record` query parameter in the request URL.
47+
- The HTTP response containing the verifiable IPNS record will have the following format:
48+
- Header: `Content-Type: application/vnd.ipfs.ipns-record`
49+
- Body: :cite[ipns-record] serialized as the `IpnsEntry` protobuf.
50+
51+
## Test fixtures
52+
53+
This IPIP got ratified before
54+
[gateway-conformance](https://github.com/ipfs/gateway-conformance) existed.
55+
56+
57+
The [reference implementation in Kubo 0.19](https://github.com/ipfs/kubo/blob/master/docs/changelogs/v0.19.md#signed-ipns-record-response-format)
58+
provides reusable [assertions](https://github.com/ipfs/kubo/blob/v0.19.2/test/sharness/t0124-gateway-ipns-record.sh).
59+
60+
:::issue
61+
Until vendor-agnostic fixtures are added to the conformance test suite ([tracking issue](https://github.com/ipfs/gateway-conformance/issues/3)),
62+
IPNS records for testing can be generated in Kubo by creating an IPNS record:
63+
64+
```bash
65+
$ ipfs key gen <key-name>
66+
k51Key
67+
68+
$ ipfs name publish /ipfs/bafyHash --key=<key-name> --ttl=<record-ttl>
69+
Published to k51Key: /ipfs/bafyHash
70+
71+
$ ipfs routing get /ipns/k51Key > key.pb
72+
```
73+
:::
74+
75+
## Design rationale
76+
77+
The current gateway already supports different response formats via the
78+
`Accept` HTTP header and the `format` URL query. This IPIP proposes adding
79+
one more supported format to that list.
80+
81+
### User benefit
82+
83+
By providing IPNS records through the gateway, IPFS light clients are able
84+
to race multiple gateways in search for an IPNS record for a certain IPNS key.
85+
This way, IPFS light clients do not necessarily need to implement the required
86+
machinery to fetch IPNS records from other IPFS nodes through the DHT or PubSub.
87+
88+
In addition, the retrieval of IPNS records is trustless in the sense that they can
89+
be verified by the client since the IPNS record includes a cryptographic signature
90+
provided by its creator.
91+
92+
### Compatibility
93+
94+
This IPIP proposes a new format to be added to the gateway, but does not change
95+
any prior format. Therefore, this IPIP is backwards compatible. Please note
96+
that IPNS records are also added to the :cite[trustless-gateway] specification.
97+
98+
### Copyright
99+
100+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)