You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/http-gateways/path-gateway.md
+1-5
Original file line number
Diff line number
Diff line change
@@ -595,11 +595,7 @@ The following response types require an explicit opt-in, can only be requested w
595
595
- Raw Block (`?format=raw`)
596
596
- Opaque bytes, see [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw).
597
597
- CAR (`?format=car`)
598
-
- A CAR file or a stream that contains all blocks required to trustlessly verify the requested content path query, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) and :cite[trustless-gateway].
599
-
-**Note:** by default, block order in CAR response is not deterministic,
600
-
blocks can be returned in different order, depending on implementation
601
-
choices (traversal, speed at which blocks arrive from the network, etc).
602
-
An opt-in ordered CAR responses MAY be introduced in a future IPIP.
598
+
- A CAR file or a stream that contains all blocks required to trustlessly verify the requested content path query, see [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) and Section 5 (CAR Responses) at :cite[trustless-gateway].
603
599
- TAR (`?format=tar`)
604
600
- Deserialized UnixFS files and directories as a TAR file or a stream, see :cite[ipip-0288].
Copy file name to clipboardExpand all lines: src/http-gateways/trustless-gateway.md
+153-24
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,10 @@ editors:
13
13
- name: Henrique Dias
14
14
github: hacdias
15
15
url: https://hacdias.com/
16
+
xref:
17
+
- url
18
+
- path-gateway
19
+
- ipip-0412
16
20
tags: ['httpGateways', 'lowLevelHttpGateways']
17
21
order: 1
18
22
---
@@ -25,11 +29,12 @@ The minimal implementation means:
25
29
26
30
- response type is always fully verifiable: client can decide between a raw block or a CAR stream
27
31
- no UnixFS/IPLD deserialization
28
-
- for CAR files:
29
-
- the behavior is identical to :cite[path-gateway]
30
32
- for raw blocks:
31
33
- data is requested by CID, only supported path is `/ipfs/{cid}`
32
34
- no path traversal or recursive resolution
35
+
- for CAR files:
36
+
- the pathing behavior is identical to :cite[path-gateway]
37
+
33
38
34
39
# HTTP API
35
40
@@ -63,13 +68,14 @@ Same as in :cite[path-gateway], but with limited number of supported response ty
63
68
64
69
### `Accept` (request header)
65
70
66
-
This HTTP header is required when running in a strict, trustless mode.
71
+
A Client SHOULD sent this HTTP header to leverage content type negotiation
72
+
based on section 12.5.1 of :cite[rfc9110].
67
73
68
74
Below response types MUST to be supported:
69
75
-[application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) – requests a single, verifiable raw block to be returned
70
76
71
77
Below response types SHOULD to be supported:
72
-
-[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, implementations MAY support optional parameters (:cite[ipip-0412])
78
+
-[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, implementations MAY support optional CAR content type parameters (:cite[ipip-0412])
73
79
-[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`).
74
80
75
81
Gateway SHOULD return HTTP 400 Bad Request when running in strict trustless
@@ -168,35 +174,37 @@ Below MUST be implemented **in addition** to "HTTP Response" of :cite[path-gatew
168
174
169
175
MUST be returned and include additional format-specific parameters when possible.
170
176
171
-
If a CAR stream was requested, the response MUST include the parameter specifying CAR version.
172
-
For example: `Content-Type: application/vnd.ipld.car; version=1`
177
+
If a CAR stream was requested:
178
+
- the response MUST include the parameter specifying CAR version. For example:
order, enables streaming responses with minimal memory usage.
228
+
-`unk` (or missing): Unknown order, which serves as the implicit default when the `order`
229
+
parameter is unspecified. In this case, the client cannot make any assumptions
230
+
about the block order: blocks may arrive in a random order or be a result of
231
+
a custom DAG traversal algorithm.
232
+
233
+
A Gateway SHOULD always return explicit `order` in CAR's `Content-Type` response header.
234
+
235
+
A Gateway MAY skip `order` in CAR response if no order was explicitly requested
236
+
by the client and the default order is unknown.
237
+
238
+
A Client MUST assume implicit `order=unk` when `order` is missing, unknown, or empty.
239
+
240
+
## CAR `dups` (content type parameter)
241
+
242
+
The `dups` parameter specifies whether duplicate blocks (the same block
243
+
occurring multiple times in the requested DAG) will be present in the CAR
244
+
response. Useful when a deterministic block order is used.
245
+
246
+
It accepts two values:
247
+
-`y`: Duplicate blocks MUST be sent every time they occur during the DAG walk.
248
+
-`n`: Duplicate blocks MUST be sent only once.
249
+
250
+
When set to `y`, light clients are able to discard blocks after
251
+
reading them, removing the need for caching in-memory or on-disk.
252
+
253
+
Setting to `n` allows for more efficient data transfer of certain types of
254
+
data, but introduces additional resource cost on the receiving end, as each
255
+
block needs to be kept around in case its CID appears again.
256
+
257
+
A Client MUST not assume any implicit behavior when `dups` is missing.
258
+
259
+
If the `dups` parameter is not present in the `Content-Type` header, the
260
+
behavior is unspecified, and the CAR response includes an arbitrary list of
261
+
blocks. In this unknown state, the client MUST assume duplicates are not sent,
262
+
but also MUST ignore duplicates if they are present.
263
+
264
+
A Gateway MUST return always return `dups` in `Content-Type` response header
265
+
when the duplicate status is known at the time of response.
266
+
267
+
A Gateway MAY skip `dups` if it was not present in `Accept` header sent by the
268
+
client or if it is not possible to tell the duplicate status.
269
+
270
+
:::warning
271
+
272
+
The specified parameter does not apply to virtual blocks identified by identity
273
+
CIDs. CAR responses MUST never include these virtual blocks. The parameter in
274
+
question is meant to control the behavior of non-virtual blocks in the
275
+
response. Therefore, it does not have any effect on virtual blocks, and they
276
+
should never be included in the CAR response, no matter if present, or what
277
+
value is set.
278
+
279
+
:::
280
+
214
281
215
-
The default CAR header and block order in a CAR response is not specified and is non-deterministic.
282
+
## CAR parameters and determinism
283
+
284
+
The default header and block order in a CAR format is not specified by IPLD specifications.
216
285
217
286
Clients MUST NOT assume that CAR responses are deterministic (byte-for-byte identical) across different gateways.
218
287
219
288
Clients MUST NOT assume that CAR includes CIDs and their blocks in the same order across different gateways.
220
289
290
+
Clients MUST assume block order and duplicate status only if `Content-Type` returned with CAR responses includes optional `order` or `dups` parameters, as specified by :cite[ipip-0412].
291
+
292
+
A Gateway SHOULD support some aspects of determinism by implementing content type negotiation and signaling via `Accept` and `Content-Type` headers.
293
+
221
294
:::issue
222
295
223
-
In controlled environments, clients MAY choose to rely on undocumented CAR determinism,
224
-
subject to the agreement of the following conditions between the client and the
225
-
gateway:
296
+
In controlled environments, clients MAY choose to rely on implicit and
297
+
undocumented CAR determinism, subject to the agreement of the following
298
+
conditions between the client and the gateway:
226
299
- CAR version
227
300
- content of [`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
228
-
- order of blocks
229
-
- status of duplicate blocks
301
+
- order of blocks (`order` from :cite[ipip-0412])
302
+
- status of duplicate blocks (`dups` from :cite[ipip-0412])
230
303
231
-
In the future, there may be an introduction of a convention to indicate aspects
232
-
of determinism in CAR responses. Please refer to
233
-
[IPIP-412](https://github.com/ipfs/specs/pull/412) for potential developments
234
-
in this area.
304
+
Mind this is undocumented behavior, and MUST NOT be used on public networks.
235
305
236
306
:::
307
+
308
+
### CAR format signaling in Request
309
+
310
+
Content type negotiation is based on section 12.5.1 of :cite[rfc9110].
311
+
312
+
Clients MAY indicate their preferred block order by sending an `Accept` header in
313
+
the HTTP request. The `Accept` header format is as follows:
Gateway implementations SHOULD decide on the implicit default ordering or
344
+
other parameters, and use it in responses when client did not explicitly
345
+
specify any matching preference.
346
+
347
+
A Gateway MAY choose to implement only some of the parameters and return HTTP
348
+
400 Bad Request or 406 Not Acceptable when client requested a response with
349
+
unsupported content type variant.
350
+
351
+
A Client MUST verify `Content-Type` returned with CAR response before
352
+
processing the payload, as the legacy gateway may not support optional content
353
+
type parameters like `order` an `dups` and return plain
354
+
`application/vnd.ipld.car`.
355
+
356
+
357
+
# IPNS Record Responses (application/vnd.ipfs.ipns-record)
358
+
359
+
An opaque bytes matching the [Signed IPNS Record](https://specs.ipfs.tech/ipns/ipns-record/#ipns-record)
360
+
for the requested [IPNS Name](https://specs.ipfs.tech/ipns/ipns-record/#ipns-name)
361
+
returned as [application/vnd.ipfs.ipns-record](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record).
362
+
363
+
A Client MUST confirm the record signature match `libp2p-key` from the requested IPNS Name.
364
+
365
+
A Client MUST [perform additional record verification according to the IPNS specification](https://specs.ipfs.tech/ipns/ipns-record/#record-verification).
0 commit comments