quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

IPFS.md (5927B)


      1 <!--
      2 Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 
      4 SPDX-License-Identifier: curl
      5 -->
      6 
      7 # IPFS
      8 For an overview about IPFS, visit the [IPFS project site](https://ipfs.tech/).
      9 
     10 In IPFS there are two protocols. IPFS and IPNS (their workings are explained in detail [here](https://docs.ipfs.tech/concepts/)). The ideal way to access data on the IPFS network is through those protocols. For example to access the Big Buck Bunny video the ideal way to access it is like: `ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi`
     11 
     12 ## IPFS Gateways
     13 
     14 IPFS Gateway acts as a bridge between traditional HTTP clients and IPFS.
     15 IPFS Gateway specifications of HTTP semantics can be found [here](https://specs.ipfs.tech/http-gateways/).
     16 
     17 ### Deserialized responses
     18 
     19 By default, a gateway acts as a bridge between traditional HTTP clients and IPFS and performs necessary hash verification and deserialization. Through such gateway, users can download files, directories, and other content-addressed data stored with IPFS or IPNS as if they were stored in a traditional web server.
     20 
     21 ### Verifiable responses
     22 
     23 By explicitly requesting [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) or [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) responses, by means defined in [Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/), the user is able to fetch raw content-addressed data and [perform hash verification themselves](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval).
     24 
     25 This enables users to use untrusted, public gateways without worrying they might return invalid/malicious bytes.
     26 
     27 ## IPFS and IPNS protocol handling
     28 
     29 There are various ways to access data from the IPFS network. One such way is
     30 through the concept of public
     31 "[gateways](https://docs.ipfs.tech/concepts/ipfs-gateway/#overview)". The
     32 short version is that entities can offer gateway services. An example here
     33 that is hosted by Protocol Labs (who also makes IPFS) is `dweb.link` and
     34 `ipfs.io`. Both sites expose gateway functionality. Getting a file through
     35 `ipfs.io` looks like this:
     36 `https://ipfs.io/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi`
     37 
     38 If you were to be [running your own IPFS
     39 node](https://docs.ipfs.tech/how-to/command-line-quick-start/) then you, by
     40 default, also have a [local gateway](https://specs.ipfs.tech/http-gateways/)
     41 running. In its default configuration the earlier example would then also work
     42 in this link:
     43 
     44 `http://127.0.0.1:8080/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi`
     45 
     46 ## cURL handling of the IPFS protocols
     47 
     48 The IPFS integration in cURL hides this gateway logic for you. Instead of
     49 providing a full URL to a file on IPFS like this:
     50 
     51 ```
     52 curl http://127.0.0.1:8080/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi
     53 ```
     54 
     55 You can provide it with the IPFS protocol instead:
     56 ```
     57 curl ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi
     58 ```
     59 
     60 With the IPFS protocol way of asking a file, cURL still needs to know the
     61 gateway. curl essentially just rewrites the IPFS based URL to a gateway URL.
     62 
     63 ### IPFS_GATEWAY environment variable
     64 
     65 If the `IPFS_GATEWAY` environment variable is found, its value is used as
     66 gateway.
     67 
     68 ### Automatic gateway detection
     69 
     70 When you provide no additional details to cURL then it:
     71 
     72 1. First looks for the `IPFS_GATEWAY` environment variable and use that if it
     73    is set.
     74 2. Looks for the file: `~/.ipfs/gateway`. If it can find that file then it
     75    means that you have a local gateway running and that file contains the URL
     76    to your local gateway.
     77 
     78 If cURL fails, you are presented with an error message and a link to this page
     79 to the option most applicable to solving the issue.
     80 
     81 ### `--ipfs-gateway` argument
     82 
     83 You can also provide a `--ipfs-gateway` argument to cURL. This overrules any
     84 other gateway setting. curl does not fallback to the other options if the
     85 provided gateway did not work.
     86 
     87 ## Gateway redirects
     88 
     89 A gateway could redirect to another place. For example, `dweb.link` redirects
     90 [path based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#path-gateway)
     91 requests to [subdomain
     92 based](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#subdomain-gateway)
     93 ones. A request using:
     94 
     95     curl ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi --ipfs-gateway https://dweb.link
     96 
     97 Which would be translated to:
     98 
     99     https://dweb.link/ipfs/bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi
    100 
    101 redirects to:
    102 
    103     https://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi.ipfs.dweb.link
    104 
    105 If you trust this behavior from your gateway of choice then passing the `-L`
    106 option follows the redirect.
    107 
    108 ## Error messages and hints
    109 
    110 Depending on the arguments, cURL could present the user with an error.
    111 
    112 ### Gateway file and environment variable
    113 
    114 cURL tried to look for the file: `~/.ipfs/gateway` but could not find it. It
    115 also tried to look for the `IPFS_GATEWAY` environment variable but could not
    116 find that either. This happens when no extra arguments are passed to cURL and
    117 letting it try to figure it out [automatically](#automatic-gateway-detection).
    118 
    119 Any IPFS implementation that has gateway support should expose its URL in
    120 `~/.ipfs/gateway`. If you are already running a gateway, make sure it exposes
    121 the file where cURL expects to find it.
    122 
    123 Alternatively you could set the `IPFS_GATEWAY` environment variable or pass
    124 the `--ipfs-gateway` flag to the cURL command.
    125 
    126 ### Malformed gateway URL
    127 
    128 The command executed evaluates in an invalid URL. This could be anywhere in
    129 the URL, but a likely point is a wrong gateway URL.
    130 
    131 Inspect the URL set via the `IPFS_GATEWAY` environment variable or passed with
    132 the `--ipfs-gateway` flag. Alternatively opt to go for the
    133 [automatic](#automatic-gateway-detection) gateway detection.