Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperdrive

Package Overview
Dependencies
Maintainers
1
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperdrive - npm Package Compare versions

Comparing version 0.0.0-alpha to 1.0.1

example.js

62

package.json
{
"author": "Julien Biezemans <jb@jbpros.com>",
"name": "hyperdrive",
"version": "0.0.0-alpha",
"description": "A REST framework",
"main": "lib/main",
"scripts": {
"test": "echo \"No tests yet.\""
"version": "1.0.1",
"description": "A file sharing network based on rabin file chunking and append only feeds of data verified by merkle trees.",
"main": "index.js",
"dependencies": {
"bitfield": "^1.1.2",
"buffer-equals": "^1.0.3",
"bulk-write-stream": "^1.1.1",
"debug": "^2.2.0",
"duplexify": "^3.4.2",
"flat-tree": "^1.2.1",
"flush-write-stream": "^1.0.0",
"last-one-wins": "^1.0.0",
"length-prefixed-stream": "^1.4.0",
"merkle-tree-stream": "^1.0.2",
"numeric-id-map": "^1.1.0",
"octal": "^1.0.0",
"protocol-buffers": "^3.1.3",
"pump": "^1.0.1",
"pumpify": "^1.3.3",
"rabin": "^1.4.0",
"stream-collector": "^1.0.1",
"sublevel-prefixer": "^1.0.0",
"subleveldown": "^2.1.0",
"through2": "^2.0.0",
"thunky": "^0.1.0",
"uint64be": "^1.0.1"
},
"devDependencies": {
"discovery-channel": "^1.2.0",
"level": "^1.3.0",
"memdb": "^1.0.1",
"network-address": "^1.0.0"
},
"repository": {
"type": "git",
"url": "git://github.com/jbpros/hyperdrive.git"
"url": "https://github.com/mafintosh/hyperdrive.git"
},
"keywords": [
"rest",
"hypermedia",
"http",
"web",
"framework"
],
"dependencies": {
"coffee-script": "1.3.3",
"express-negotiate": "git://github.com/jbpros/express-negotiate.git#fix-header"
"author": "Mathias Buus (@mafintosh)",
"license": "MIT",
"bugs": {
"url": "https://github.com/mafintosh/hyperdrive/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/jbpros/hyperdrive/LICENSE"
}
],
"license": "MIT"
"homepage": "https://github.com/mafintosh/hyperdrive"
}

@@ -1,3 +0,96 @@

# Hyperdrive
# hyperdrive
A REST + Hypermedia framework for Node.js.
A file sharing network based on [rabin](https://github.com/maxogden/rabin) file chunking and
append only feeds of data verified by merkle trees.
```
npm install hyperdrive
```
# Status
## Almost ready for prime time :rocket:
## Feel free to open issues and ask questions
APIs/protocols might be still break.
Main things missing are:
- [ ] Storing downloaded files as actual files (not in leveldb doh)
- [ ] Full documention of the apis/protocols
- [ ] Tit-for-tat swarm logic
- [ ] Integrate peer discovery (currently has be handled externally)
- [ ] Tests for internal logic
- [ ] A bit of refactoring
## Usage
First create a new feed to share
``` js
var hyperdrive = require('hyperdrive')
var fs = require('fs')
var drive = hyperdrive(aLevelDB)
var pack = drive.add()
var stream = pack.entry({
name: 'my-file.txt',
mode: 0644
})
fs.createReadStream('my-file.txt').pipe(stream)
pack.finalize(function () {
var link = pack.id.toString('hex')
console.log(link, '<-- this is your hyperdrive link')
})
```
Then to share it
``` js
var disc = require('discovery-channel')()
var server = net.createServer(function (socket) {
socket.pipe(drive.createPeerStream()).pipe(socket)
})
server.listen(0, function () {
function ann () {
// discovery-channel currently only works with 20 bytes hashes
disc.announce(link.slice(0, 20), server.address().port)
}
ann()
setInterval(ann, 10000)
var lookup = disc.lookup(hash.slice(0, 20))
lookup.on('peer', function (ip, port) {
var socket = net.connect(port, ip)
socket.pipe(drive.createPeerStream()).pipe(socket)
})
})
```
If you run this code on multiple computers you should be able to access
the content in the feed by doing
``` js
var feed = drive.get(link) // the link identifies/verifies the content
feed.get(0, function (err, entry) { // get the first entry
console.log(entry) // prints {name: 'my-file.txt', ...}
var content = drive.get(entry.link)
content.get(0, function (err, data) {
console.log('first block of the file', data)
content.get(1, ...)
})
})
```
## License
MIT

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc