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

@detox/routing

v0.3.2

Published

Anonymous routing implementation for Detox project

Downloads

8

Readme

Detox routing Travis CI

Anonymous routing implementation for Detox project.

This is a domain-specific implementation of anonymous routing functionality with simple API. It is built on top of Ronion framework and uses @detox/crypto for cryptographic needs. Still agnostic to transport layer.

How to install

npm install @detox/routing

How to use

Node.js:

var detox_routing = require('@detox/routing')

detox_routing.ready(function () {
    // Do stuff
});

Browser:

requirejs(['@detox/routing'], function (detox_routing) {
    detox_routing.ready(function () {
        // Do stuff
    });
})

API

detox_routing.ready(callback)

  • callback - Callback function that is called when library is ready for use

detox_routing.Router(dht_private_key : Uint8Array, max_pending_segments = 10 : number, routing_path_segment_timeout = 10 : number) : detox_routing.Router

Constructor for Router object, offers anonymous routing functionality based on Ronion spec and reference implementation with just a few high-level APIs available for the user.

  • dht_private_key - X25519 private key that corresponds to Ed25519 key used in DHT constructor (from @detox/dht package)
  • max_pending_segments - how many segments can be in pending state per one address
  • routing_path_segment_timeout - max time in seconds allowed for routing path segment creation after which creation is considered failed

detox_routing.Router.process_packet(node_id : Uint8Array, packet : Uint8Array)

Process routing packet coming from node with specified ID.

detox_routing.Router.construct_routing_path(nodes : Uint8Array[]) : Promise

Construct routing path through specified nodes.

  • nodes - IDs of the nodes through which routing path must be constructed, last node in the list is responder

Returned promise will resolve with ID of the route or will be rejected if path construction fails.

detox_routing.Router.destroy_routing_path(node_id : Uint8Array, route_id : Uint8Array)

Destroy routing path constructed earlier.

  • node_id - first node in routing path
  • route_id - identifier returned during routing path construction

detox_routing.Router.get_max_packet_data_size() : number

Max data size that will fit into single packet without fragmentation

detox_routing.Router.send_data(node_id : Uint8Array, route_id : Uint8Array, command : number, data : Uint8Array)

Send data to the responder on specified routing path.

  • node_id - first node in routing path
  • route_id - identifier returned during routing path construction
  • command - command for data, can be any number from the range 0..245
  • data - data being sent

detox_routing.Router.destroy()

Destroy all of the routing path constructed earlier.

detox_routing.Router.on(event: string, callback: Function) : detox_routing.Router

Register event handler.

detox_routing.Router.once(event: string, callback: Function) : detox_routing.Router

Register one-time event handler (just on() + off() under the hood).

detox_routing.Router.off(event: string[, callback: Function]) : detox_routing.Router

Unregister event handler.

Event: activity

Payload consists of two Uint8Array arguments: node_id and route_id. Event is fired when packet is sent/received from/to address with segment ID segment_id.

This event can be used to track when packets are flowing on certain address and segment_id and decide when to consider routing path as inactive and destroy it.

Event: send

Payload consists of two Uint8Array arguments: node_id and packet. Event is fired when packet needs to be sent to node_id node.

Event: data

Payload consists of four arguments, all of which except command are Uint8Array: node_id, route_id, command and data.

Event is fired when data were received from the responder with specified command on routing path with started at node_id with route_id.

detox_routing.MAX_DATA_SIZE : number

Constant that defines max data size supported for sending by Router as command data.

Contribution

Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!

When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.

License

Free Public License 1.0.0 / Zero Clause BSD License

https://opensource.org/licenses/FPL-1.0.0

https://tldrlegal.com/license/bsd-0-clause-license