How to use the hypercore/lib/crypto.randomBytes function in hypercore

To help you get started, we’ve selected a few hypercore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inkandswitch / capstone / src / node_modules / discovery-cloud / test2.ts View on Github external
let hypercore = require("hypercore")
let crypto = require("hypercore/lib/crypto")
let ram = require("random-access-memory")

const log1 = Debug("discovery-cloud:test:client1")
const log2 = Debug("discovery-cloud:test:client2")

const url = "wss://discovery-cloud.herokuapp.com"
// const url = "ws://0.0.0.0:8080"
const keys = crypto.keyPair()

const feed1 = hypercore(ram, keys.publicKey, { secretKey: keys.secretKey })
const feed2 = hypercore(ram, keys.publicKey)

const client1 = new DiscoveryCloudClient({
  id: crypto.randomBytes(32),
  url,
  stream: info => feed1.replicate(info),
})

feed1.on("ready", () => {
  client1.join(feed1.discoveryKey)
  log1("joining")
  feed1.append("foo")
  feed1.append("bar")
  feed1.append("baz")
})

const client2 = new DiscoveryCloudClient({
  id: crypto.randomBytes(32),
  url,
  stream: info => feed2.replicate(info),

hypercore

Hypercore is a secure, distributed append-only log

MIT
Latest version published 22 hours ago

Package Health Score

84 / 100
Full package analysis