Git Product home page Git Product logo

dat-link-resolve's Introduction

dat-link-resolve

resolve urls, links to a dat key using common methods

npm travis standard

Supports

  • Common dat key representations (dat://, etc.)
  • URLs with keys in them (datproject.org/6161616161616161616161616161616161616161616161616161616161616161)
  • hyperdrive-key or dat-key headers
  • Url to JSON http request that returns {key: <dat-key>}
  • Dat-DNS resolution (via dat-dns)

Install

npm install dat-link-resolve

Usage

var datResolve = require('dat-link-resolve')

datResolve(link, function (err, key) {
  console.log('found key', key)
})

API

datResolve(link, callback(err, key))

Link can be string or buffer.

Resolution order:

  1. Validate buffers or any strings with 64 character hashes in them via dat-encoding
  2. Check headers in http request
  3. Check JSON request response for key
  4. Dat-DNS resolution via dat-dns

Refering to dats

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.

Examples

Note that dat-link-resolve also supports other methods, such as detection of dat keys in paths and http headers.

Simplest

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9
  • DNS: pfrazee.hashbase.io

With version

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5
  • DNS: pfrazee.hashbase.io+5

With scheme

With path

  • https: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/path1
  • dat: pfrazee.hashbase.io/path2

Combinations

Notes

  1. browsers expect http and https schemes with traditional hostname, not a dat key
  2. browsers expect http and https schemes with traditional hostname, no +5 (version) support

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

MIT

dat-link-resolve's People

Contributors

joehand avatar millette avatar martinheidegger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.