Skip to content

DistributedWeb/dwebx-link-resolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dwebx-link-resolve

resolve urls, links to a dwebx key using common methods

npm travis standard

Supports

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

Install

npm install dwebx-link-resolve

Usage

var dwebxResolve = require('dwebx-link-resolve')

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

API

dwebxResolve(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 dwebx-encoding
  2. Check headers in http request
  3. Check JSON request response for key
  4. DWebX-DNS resolution via dwebx-dns

Refering to dvaults

Trying to tighten up a bit dwebx-link-resolve (and its dependencies dwebx-dns and dwebx-decode). I am noticing a few inconsistencies as I'm writing dwebx-shell.

Ideally, I'd like to launch dwebx-shell like this:

$ dwebx-shell dwebx://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5/path4

and have it open the dwebx at version 5 and change directory to /path4.

Currently dwebx-shell google-fonts-kewitz.hashbase.io/fonts/ fails somewhere in dwebx-link-resolve.

Examples

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

Simplest

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9
  • DNS: dwebx.org

With version

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5
  • DNS: dwebx.org+5

With scheme

With path

  • https: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/path1
  • dwebx: dwebx.org/path2

Combinations

Notes

  1. browsers expect http and https schemes with traditional hostname, not a dwebx 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

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •