sttp
v2.1.0
Published
STTP - new generation Secure TBM Transfer Protocol. STTP works over HTTP and it very similar to TLS. It is a kind of poor copy of HTTPS.
Downloads
6
Maintainers
Readme
STTP - new generation Secure TBM Transfer Protocol.
STTP works over HTTP and it very similar to TLS. It is a kind of poor copy of HTTPS. Picture taken from
Installation
npm install sttp
Tutorial
To use in nodejs backend call
var sttp = require("sttp")
.To use in browser attach
bundle.sttp.js
script from./node_modules/sttp/
directory. And usesttp
global variable.
<script src="path/to/bundle.sttp.js"></script>
<script type="text/javascript">
var AuthKeyPacker = sttp.AuthKeyPacker;
var rsaKeys = sttp.keys.generateRSAKey();
var packer = new AuthKeyPacker(rsaKeys.public)
// ...
</script>
AuthDataPacker
AuthDataPacker
uses on initializing handshake to share AES-key.
Usage:
var sttp = require("sttp");
// server:
// create and share somehow RSA public key with client
var keys = sttp.keys;
var rsaKeys = keys.generateRSAKey({bits: 512}); // by default 1024
// rsaKeys : { public, private }
// Share rsaKeys.public
// client:
// get RSA public key from server and
// send encrypted with rsaKeys.public generated aesKey
var aesKey = keys.generateAESKey(16); // 128 bit key
var AuthDataPacker = sttp.AuthDataPacker;
var packer = new AuthDataPacker(rsaKeys.public);
var authData = packer.pack(aesKey);
// transfer authData using some channel to server
// server:
// get authData from client, decrypt it and save somewhere
var packer = new AuthDataPacker(rsaKeys.private);
var data = packer.unpack(authData);
// save aesKey to correspoing user in database
// and start using DataPacker
DataPacker
DataPacker
uses for transfering main information it uses AES-128 for encryption(aesKey is transfering AuthDataPacker
).
Usage:
var DataPacker = sttp.DataPacker();
var data = { projectName : "sttp", contributors : ["Alik", "Kevin", "Sergey"] };
var packer = new DataPacker(aesKey);
var packedData = packer.pack(data);
// transfer packedData using some channel
// and on other end do the following:
// P.S. use the same aesKey
var packer = new DataPacker(aesKey);
var data = packer.unpack(packedData);
// use data...
Example
Also you can look at example of using sttp
in nodejs web application.
Contribution
Read git conventions before.
Make sure that you are using nodejs 6+
git clone https://github.com/alikhil/sttp
npm install
Run tests:
npm test