Algorand authorised IPFS write-through cache gateway
April 13, 2023 ยท View on GitHub
This is an IPFS Gateway that has the following functionality:
- Publicly available
GETAPI at/ipfs/{cid}(where{cid}is an IPFS Content Identifier) that will:- Check if the data for that request is present in the cache (local: filesystem in
.cache, deployed: AWS S3 storage) and if so return that - Proxy the request to the Cloudflare public IPFS gateway
- Check if the data for that request is present in the cache (local: filesystem in
- Algorand account allow-listed
POSTAPI at/ipfsthat will:- Allow an authorised account to attach a HTTP header with
Authorize: Algorand {signed_transaction}where{signed_transaction}is a base 64 encodedSignedTransactionobject, which has a valid signature from one of the allow-listed accounts- Note: Rekeyed accounts are not supported, since the signature is checked offline, so the allowlist needs to be changed if you need to change the private key(s)
- Accept a file under the
fileproperty in the request body - Take the given file, save it to the cache (e.g. S3 in the deployed environment) and then send that file through to Web3.Storage via a configured API key so it will be pinned and present via the IPFS network
- Allow an authorised account to attach a HTTP header with
This component allows for easy deployment of a high performance IPFS gateway that has the advantages of IPFS (decentralised access, tamperproof immutability and, while pinned, permanence), without the usual downsides (slow, unreliable requests resulting in poor user experience).
Initial setup
- Copy
.env.templateto.env npm run installnpm run dev, or, in VS Code run theRun apiRun and Debug configuration