Skip to content

Commit 7c2652c

Browse files
authoredJun 11, 2019
Add examples to ADDRESSING.md (#148)
Add examples to ADDRESSING.md
2 parents 7812711 + c4723df commit 7c2652c

File tree

1 file changed

+68
-16
lines changed

1 file changed

+68
-16
lines changed
 

‎ADDRESSING.md

+68-16
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44

55
> ### Status of This Memo
6-
>
6+
>
77
> This living document specifies current set of conventions for the IPFS community,
88
> and requests discussion and suggestions for improvements via PR.
99
1010
## Table of Contents
1111

12-
- [Summary](#tldr)
12+
- [**TL;DR**](#tldr)
13+
- [With HTTP](#addressing-with-http)
14+
- [With New URIs](#addressing-with-native-url)
1315
- [References](#references)
1416
- [Appendices](#appendices)
1517
- Notes on addressing with [http://](#notes-on-addressing-with-http)
@@ -18,34 +20,87 @@
1820

1921
## TL;DR
2022

21-
### Addressing with HTTP
23+
If no native protocol handler is available, redirect to a gateway:
2224

25+
```bash
26+
ipfs://{cid} → https://{gateway}/ipfs/{cid}
27+
ipns://{libp2p-key} → https://{gateway}/ipns/{libp2p-key}
28+
ipns://{fqdn-with-dnslink} → https://{gateway}/ipns/{fqdn-with-dnslink}
29+
```
30+
31+
With native protocol handlers, follow below:
32+
33+
```bash
34+
ipfs://{cidv1base32}
35+
ipfs://{cidv0} → redirect → ipfs://{cidv1base32} # CIDv0 is case-sensitive Base58, does not work as Origin authority
36+
37+
ipns://{libp2p-key-in-cidv1base32}
38+
ipns://{libp2p-key-in-base58} → redirect → ipns://{libp2p-key-in-cidv1} # Base58, does not work as Origin authority
39+
40+
ipns://{fqdn-with-dnslink}
41+
ipfs://{fqdn-with-dnslink} → redirect → ipns://{fqdn-with-dnslink} # just to improve UX :-)
42+
43+
dweb:/ipfs/{root}/{resource} → redirect → ipfs://{root}/{resource} # ensures {root} is the authority component
44+
dweb:/ipns/{root}/{resource} → redirect → ipns://{root}/{resource} # ensures {root} is the authority component
45+
```
46+
47+
## Addressing with HTTP
48+
49+
### Paths
2350

2451
When site isolation does not matter gateway can expose IPFS namespaces as regular URL paths:
2552

2653
https://<gateway-host>.tld/ipfs/<cid>/path/to/resource
2754
https://<gateway-host>.tld/ipns/<keyid_or_fqdn>/path/to/resource
2855

29-
When origin-based security perimeter is needed, [CIDv1](https://github.com/ipld/cid#cidv1) in Base32 ([RFC4648](https://tools.ietf.org/html/rfc4648#section-6), no padding) should be used in subdomain:
56+
Examples:
57+
58+
https://gateway.ipfs.io/ipfs/bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html
59+
https://gateway.ipfs.io/ipfs/QmT5NvUtoM5nWFfrQdVrFtvGfKFmG7AHE8P34isapyhCxX/wiki/Mars.html
60+
https://gateway.ipfs.io/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html
61+
62+
### Subdomains
63+
64+
When [origin-based security](https://en.wikipedia.org/wiki/Same-origin_policy) perimeter is needed, [CIDv1](https://github.com/ipld/cid#cidv1) in Base32 ([RFC4648](https://tools.ietf.org/html/rfc4648#section-6), no padding) should be used in subdomain:
3065

3166
https://<cidv1-base32>.ipfs.<gateway-host>.tld/path/to/resource
3267

68+
Example:
69+
70+
https://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq.ipfs.dweb.link/wiki/
71+
3372
Read more: [notes on addressing with HTTP](#notes-on-addressing-with-http).
3473

35-
### Addressing with Native URL
74+
## Addressing with Native URL
3675

3776
In future, subdomain convention will be replaced with native handler that provides the same origin-based guarantees:
3877

3978
ipfs://{cidv1b32}/path/to/resource
4079

80+
Example:
81+
82+
ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html
83+
4184
Read more: [notes on addressing with ipfs://](#notes-on-addressing-with-ipfs).
4285

43-
### Addressing with URI
86+
## Addressing with URI
87+
88+
> **Implementation Warning:**
89+
> web browsers often implement custom URIs in a way that enforces Origin to be either equal `null` or based on the first label after `:`.
90+
> This makes proper security isolation of content loaded via `dweb:/ipfs/{root}/` difficult to get right, and it may be easier to redirect to `ipfs://{root}`.
4491
4592
In contexts that do not require origin-based security a simple URI can be used for addressing both IPFS and IPNS resources.
93+
4694
We argue that paths are the better canonical address and that all kinds of things with different semantics can live in a shared universal namespace. To provide a first step towards that goal, the dweb: URI is proposed:
4795

4896
dweb:/ipfs/{cidv1b32}/path/to/resource
97+
dweb:/ipns/{libp2p-key-in-cidv1base32}/path/to/resource
98+
dweb:/ipns/{fqdn-with-dnslink}/path/to/resource
99+
100+
Example:
101+
102+
dweb:/ipfs/bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html
103+
dweb:/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html
49104

50105
Read more: [notes on addressing with dweb:](#notes-on-addressing-with-dweb).
51106

@@ -55,9 +110,9 @@ Read more: [notes on addressing with dweb:](#notes-on-addressing-with-dweb).
55110
- [IPFS: Migration to CIDv1 (default base32)](https://github.com/ipfs/ipfs/issues/337)
56111
- [Support Custom Protocols in WebExtension](https://github.com/lidel/ipfs-firefox-addon/issues/164)
57112
- [mozilla/libdweb experiment: ipfs:// protocol handler](https://github.com/ipfs-shipyard/ipfs-companion/pull/533)
58-
113+
59114
## Appendices
60-
115+
61116
### Notes on addressing with `http://`
62117

63118
The first stage on the upgrade path are HTTP gateways.
@@ -125,7 +180,7 @@ According to [RFC 1035](http://tools.ietf.org/html/rfc1035) subdomains (aka
125180
of content addressing identifier types that can be used without need for an
126181
additional conversion step.
127182

128-
Due to this IPFS community [decided](https://github.com/ipfs/ipfs/issues/337) to use lowercased base32
183+
Due to this IPFS community [decided](https://github.com/ipfs/ipfs/issues/337) to use lowercased base32
129184
([RFC4648](https://tools.ietf.org/html/rfc4648#section-6) - no padding - highest letter)
130185
as the default base encoding of [CIDv1](https://github.com/ipld/cid#cidv1) (our binary identifiers).
131186

@@ -137,9 +192,9 @@ Suborigins are a
137192
provide a new mechanism for allowing sites to separate their content by
138193
creating synthetic origins while serving content from a single physical origin.
139194

140-
A [`suborigin` header](https://w3c.github.io/webappsec-suborigins/#the-suborigin-header)
195+
A [`suborigin` header](https://w3c.github.io/webappsec-suborigins/#the-suborigin-header)
141196
SHOULD be returned by HTTP gateway and contain a value
142-
unique to the current content addressing root.
197+
unique to the current content addressing root.
143198

144199
Unfortunately due to limited adoption suborigin have no practical use.
145200

@@ -157,14 +212,11 @@ calculation, which provides necessary isolation between security contexts of dif
157212

158213
### Notes on addressing with `dweb:`
159214

160-
We're not trying to bring in all the possible sources of data, or interfaces into this namespace.
161-
We only work on content-addressed stuff here.
215+
We're not trying to bring in all the possible sources of data, or interfaces into this namespace.
216+
We only work on content-addressed stuff here.
162217

163218
Why not just only `ipfs://` and `ipns://`?
164219

165220
- These URLs satisfy the content-addressing requirement
166221
- They don't satisfy the universal-data-namespace requirement
167222
- [We want to leave room for others in this new addressing scheme](https://github.com/arewedistributedyet/arewedistributedyet/issues/28)
168-
169-
170-

0 commit comments

Comments
 (0)
Please sign in to comment.