npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bitmessage

v0.6.6

Published

JavaScript Bitmessage library

Downloads

312

Readme

bitmessage Build Status

NPM

JavaScript Bitmessage library for both browserify and node. The goal of this project is to implement Bitmessage protocol v3 for both platforms at the maximum possible level (we still can't create TCP connections or listen for incoming connections in the Browser but the Proof of work and crypto is fully doable).

Public library API is currently in alpha stage, breaking changes are very likely to happen.

API documentation is available here.

References

Feature matrix

  • [x] Crypto
    • [x] SHA-1
    • [x] SHA-256
    • [x] SHA-512
    • [x] RIPEMD-160
    • [x] PRNG
    • [x] ECC keys handling
    • [x] ECDSA
    • [x] ECIES
  • [x] Common structures
    • [x] message
    • [x] object
    • [x] var_int
    • [x] var_str
    • [x] var_int_list
    • [x] net_addr
    • [x] inv_vect
    • [x] encrypted
    • [x] service features
    • [x] pubkey features
  • [x] Message types
    • [x] version
    • [x] addr
    • [x] inv
    • [x] getdata
    • [x] error
  • [x] Object types
    • [x] getpubkey
    • [x] pubkey
    • [x] msg
    • [x] broadcast
  • [x] WIF
  • [x] POW
  • [x] High-level classes
    • [x] Address
    • [x] UserAgent
  • [ ] PyBitmessage configs parsing
    • [ ] keys.dat
    • [ ] knownnodes.dat
    • [ ] messages.dat

Usage

Address

var Address = require("bitmessage").Address;

// Generate a new random Bitmessage identity.
var addr1 = Address.fromRandom();
console.log("New random Bitmessage address:", addr1.encode());

// Or create it from passphrase.
var addr2 = Address.fromPassphrase("test");
console.log("Deterministic Bitmessage address:", addr2.encode());

Structures

var structs = require("bitmessage").structs;

var encoded = Buffer.concat([
  structs.var_int.encode(4),
  Buffer("test"),
  structs.var_str.encode("test2"),
  structs.var_int_list.encode([1, 2, 3]),
]);

var decoded1 = structs.var_str.decode(encoded);
console.log(decoded1.str);  // test
var decoded2 = structs.var_str.decode(decoded1.rest);
console.log(decoded2.str);  // test2
var decoded3 = structs.var_int.decode(decoded2.rest);
console.log(decoded3.value);  // 3
var decoded4 = structs.var_int_list.decode(decoded2.rest);
console.log(decoded4.list);  // [1, 2, 3]

Messages

var structs = require("bitmessage").structs;
var messages = require("bitmessage").messages;

// Simple encoding and decoding:
var vermsg = messages.version.encode({
  remoteHost: "1.1.1.1",
  remotePort: 8444,
});
console.log(messages.version.decode(vermsg).remoteHost);  // 1.1.1.1

// Low-level encoding and decoding:
var addrPayload = messages.addr.encodePayload([
  {host: "2.2.2.2", port: 28444},
]);
var addrmsg = structs.message.encode("addr", addrPayload);
var decoded = structs.message.decode(addrmsg);
console.log(decoded.command);  // addr
var addr = messages.addr.decodePayload(decoded.payload);
console.log(addr.addrs[0].host);  // 2.2.2.2

// Encode with empty payload:
var verackmsg = structs.message.encode("verack");
console.log(structs.message.decode(verackmsg).command);  // verack

Networking

You will need to install bitmessage-transports library.

var messages = require("bitmessage").messages;
var TcpTransport = require("bitmessage-transports").TcpTransport;

var tcp = new TcpTransport({
  dnsSeeds: [["bootstrap8444.bitmessage.org", 8444]],
});

tcp.bootstrap().then(function(nodes) {
  var remoteHost = nodes[0][0];
  var remotePort = nodes[0][1];
  console.log("Connecting to", nodes[0]);
  tcp.connect(remotePort, remoteHost);
});

tcp.on("established", function(version) {
  console.log("Connection established to", version.userAgent);

  tcp.on("message", function(command, payload) {
    console.log("Got new", command, "message");
    var decoded;
    if (command === "addr") {
      decoded = messages.addr.decodePayload(payload);
      console.log("Got", decoded.addrs.length, "node addresses");
    }
  });
});

License

bitmessage - JavaScript Bitmessage library

Written in 2014-2015 by Kagami Hiiragi [email protected]

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.