More info on active projects and modules at dat-ecosystem.org
resolve urls, links to a dat key using common methods
- Common dat key representations (
dat://
, etc.) - URLs with keys in them (
datproject.org/6161616161616161616161616161616161616161616161616161616161616161
) hyperdrive-key
ordat-key
headers- Url to JSON http request that returns
{key: <dat-key>}
- Dat-DNS resolution (via dat-dns)
npm install dat-link-resolve
var datResolve = require('dat-link-resolve')
datResolve(link, function (err, key) {
console.log('found key', key)
})
Link can be string or buffer.
Resolution order:
- Validate buffers or any strings with 64 character hashes in them via dat-encoding
- Check headers in http request
- Check JSON request response for
key
- Dat-DNS resolution via dat-dns
Trying to tighten up a bit dat-link-resolve (and its dependencies dat-dns and dat-decode). I am noticing a few inconsistencies as I'm writing dat-shell.
Ideally, I'd like to launch dat-shell like this:
$ dat-shell dat://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5/path4
and have it open the dat at version 5 and change directory to /path4.
Currently dat-shell google-fonts-kewitz.hashbase.io/fonts/
fails somewhere in dat-link-resolve.
Note that dat-link-resolve also supports other methods, such as detection of dat keys in paths and http headers.
- Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9
- DNS: pfrazee.hashbase.io
- Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5
- DNS: pfrazee.hashbase.io+5
- https: https://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/
- dat: dat://pfrazee.hashbase.io
- https: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/path1
- dat: pfrazee.hashbase.io/path2
- 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5/path3
- dat://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5/path4
- https://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/path5 (^1)
- https://pfrazee.hashbase.io+5/path6 (^2)
- browsers expect http and https schemes with traditional hostname, not a dat key
- browsers expect http and https schemes with traditional hostname, no +5 (version) support
Contributions welcome! Please read the contributing guidelines first.