1.0.8 • Published 3 years ago

@carlostojal/chainify v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

chainify

Decentralized peer-to-peer networks represent a revolution in today's information systems. With that in mind, providing easy ways to implement this technologies is essential. Chainify appears as the solution to this problem, by providing a framework and a protocol specification for peer-to-peer networks creation. Each Chainify machine is a network node. A Chainify network is like a key-value storage distributed among all nodes.

Usage

Run npm install @carlostojal/chainify.

Get a RSA key pair that will be used for data encryption.

openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -outform PEM -pubout -out public.pem

Code example:

const { ChainifyNode } = require("@carlostojal/chainify");

// create the object with the configurations
const node = new ChainifyNode({
	host: "127.0.0.1",
	port: 1235,
	alwaysActiveNodes: [{
		address: "127.0.0.1",
		port: 1234
	}],
	networkAuthentication: {
		name: "chainify_test_network",
		secret: "mysupersecret"
	},
	rsaKeyPair: {
		public: "my_public_key",
		private: "my_private_key"
	}
});

// initialize the node (get it working)
node.init();

// get an item
node.getItem("users", (users) => {
	console.log(JSON.parse(users));
});

There is a complete REST API example using "chainify" as database available here.

Configuration Explanation

  • alwaysActiveNodes

    	You must have at least one node that you know that is always active. This node is the gateway into the network. From here your presence will be announced to the known nodes of all your active nodes, and so on.
  • networkAuthentication

    	Each developer can create a network of nodes. The network is like your private distributed key-value storage.
    	Each network has an unique name. If you provided always active nodes, the node will use this configuration to connect to them. If you didn't, this value will still be used for authentication from other nodes.
  • rsaKeyPair

    	As the name says, this defines the RSA key pair to be used.
    	RSA encryption is used to encrypt calls between your nodes.
    	All your nodes must use the same key pair, so they can communicate but if an attacker or a node from another network gets the call can't do anything.

Disclaimer

This is a work under progress. This module is far from complete/working yet.

Contributions are welcome, go ahead and open issues/pull requests.

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago